blob: 762450cd2b5983a39f939a365b5feeb63f5466d9 [file] [log] [blame]
Biju Dasbf40dbb2020-11-09 09:40:04 +00001/*
Lad Prabhakarb3e77d82021-03-18 13:07:51 +00002 * Copyright (c) 2020-2021, Renesas Electronics Corporation. All rights reserved.
Biju Dasbf40dbb2020-11-09 09:40:04 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6#include <stdint.h>
7
8#include <common/debug.h>
9#include <lib/mmio.h>
10
11#if RCAR_LSI == RCAR_AUTO
Lad Prabhakar7b19dff2020-12-29 13:46:48 +000012#include "G2E/pfc_init_g2e.h"
Lad Prabhakarb3e77d82021-03-18 13:07:51 +000013#include "G2H/pfc_init_g2h.h"
Biju Dasbf40dbb2020-11-09 09:40:04 +000014#include "G2M/pfc_init_g2m.h"
Lad Prabhakarb7fc5e22020-12-29 13:39:31 +000015#include "G2N/pfc_init_g2n.h"
Biju Dasbf40dbb2020-11-09 09:40:04 +000016#endif /* RCAR_LSI == RCAR_AUTO */
Lad Prabhakar7b19dff2020-12-29 13:46:48 +000017#if (RCAR_LSI == RZ_G2E)
18#include "G2E/pfc_init_g2e.h"
19#endif /* RCAR_LSI == RZ_G2N */
Lad Prabhakarb3e77d82021-03-18 13:07:51 +000020#if (RCAR_LSI == RZ_G2H)
21#include "G2H/pfc_init_g2h.h"
22#endif /* RCAR_LSI == RZ_G2H */
Biju Dasbf40dbb2020-11-09 09:40:04 +000023#if (RCAR_LSI == RZ_G2M)
24#include "G2M/pfc_init_g2m.h"
25#endif /* RCAR_LSI == RZ_G2M */
Lad Prabhakarb7fc5e22020-12-29 13:39:31 +000026#if (RCAR_LSI == RZ_G2N)
27#include "G2N/pfc_init_g2n.h"
28#endif /* RCAR_LSI == RZ_G2N */
Biju Dasbf40dbb2020-11-09 09:40:04 +000029#include "rcar_def.h"
30
31#define PRR_PRODUCT_ERR(reg) \
32 do { \
33 ERROR("LSI Product ID(PRR=0x%x) PFC init not supported.\n", \
34 reg); \
35 panic(); \
36 } while (0)
37
38#define PRR_CUT_ERR(reg) \
39 do { \
40 ERROR("LSI Cut ID(PRR=0x%x) PFC init not supported.\n", \
41 reg); \
42 panic();\
43 } while (0)
44
45void rzg_pfc_init(void)
46{
47 uint32_t reg;
48
49 reg = mmio_read_32(RCAR_PRR);
50#if RCAR_LSI == RCAR_AUTO
51 switch (reg & PRR_PRODUCT_MASK) {
52 case PRR_PRODUCT_M3:
53 pfc_init_g2m();
54 break;
Lad Prabhakarb3e77d82021-03-18 13:07:51 +000055 case PRR_PRODUCT_H3:
56 pfc_init_g2h();
57 break;
Lad Prabhakarb7fc5e22020-12-29 13:39:31 +000058 case PRR_PRODUCT_M3N:
59 pfc_init_g2n();
60 break;
Lad Prabhakar7b19dff2020-12-29 13:46:48 +000061 case PRR_PRODUCT_E3:
62 pfc_init_g2e();
63 break;
Biju Dasbf40dbb2020-11-09 09:40:04 +000064 default:
65 PRR_PRODUCT_ERR(reg);
66 break;
67 }
68
69#elif RCAR_LSI_CUT_COMPAT /* RCAR_LSI == RCAR_AUTO */
70 switch (reg & PRR_PRODUCT_MASK) {
71 case PRR_PRODUCT_M3:
72#if RCAR_LSI != RZ_G2M
73 PRR_PRODUCT_ERR(reg);
74#else /* RCAR_LSI != RZ_G2M */
75 pfc_init_g2m();
76#endif /* RCAR_LSI != RZ_G2M */
77 break;
Lad Prabhakarb3e77d82021-03-18 13:07:51 +000078 case PRR_PRODUCT_H3:
79#if (RCAR_LSI != RZ_G2H)
80 PRR_PRODUCT_ERR(reg);
81#else /* RCAR_LSI != RZ_G2H */
82 pfc_init_g2h();
83#endif /* RCAR_LSI != RZ_G2H */
84 break;
Lad Prabhakarb7fc5e22020-12-29 13:39:31 +000085 case PRR_PRODUCT_M3N:
86#if RCAR_LSI != RZ_G2N
87 PRR_PRODUCT_ERR(reg);
88#else
89 pfc_init_g2n();
90#endif /* RCAR_LSI != RZ_G2N */
91 break;
Lad Prabhakar7b19dff2020-12-29 13:46:48 +000092 case PRR_PRODUCT_E3:
93#if RCAR_LSI != RZ_G2E
94 PRR_PRODUCT_ERR(reg);
95#else
96 pfc_init_g2e();
97#endif
98 break;
Biju Dasbf40dbb2020-11-09 09:40:04 +000099 default:
100 PRR_PRODUCT_ERR(reg);
101 break;
102 }
103
104#else /* RCAR_LSI == RCAR_AUTO */
105#if (RCAR_LSI == RZ_G2M)
106 if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_M3) {
107 PRR_PRODUCT_ERR(reg);
108 }
109 pfc_init_m3();
Lad Prabhakarb3e77d82021-03-18 13:07:51 +0000110#elif (RCAR_LSI == RZ_G2H)
111 if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_H3) {
112 PRR_PRODUCT_ERR(reg);
113 }
114 pfc_init_g2h();
Lad Prabhakarb7fc5e22020-12-29 13:39:31 +0000115#elif (RCAR_LSI == RZ_G2N) /* G2N */
116 if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_M3N) {
117 PRR_PRODUCT_ERR(reg);
118 }
119 pfc_init_g2n();
Lad Prabhakar7b19dff2020-12-29 13:46:48 +0000120#elif (RCAR_LSI == RZ_G2E)
121 if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_E3) {
122 PRR_PRODUCT_ERR(reg);
123 }
124 pfc_init_g2e();
Biju Dasbf40dbb2020-11-09 09:40:04 +0000125#else /* RCAR_LSI == RZ_G2M */
126#error "Don't have PFC initialize routine(unknown)."
127#endif /* RCAR_LSI == RZ_G2M */
128#endif /* RCAR_LSI == RCAR_AUTO */
129}