blob: 871edfb2064a1ba998db1c1b7ef4d8dded7bda6d [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 Prabhakarb3e77d82021-03-18 13:07:51 +000012#include "G2H/pfc_init_g2h.h"
Biju Dasbf40dbb2020-11-09 09:40:04 +000013#include "G2M/pfc_init_g2m.h"
14#endif /* RCAR_LSI == RCAR_AUTO */
Lad Prabhakarb3e77d82021-03-18 13:07:51 +000015#if (RCAR_LSI == RZ_G2H)
16#include "G2H/pfc_init_g2h.h"
17#endif /* RCAR_LSI == RZ_G2H */
Biju Dasbf40dbb2020-11-09 09:40:04 +000018#if (RCAR_LSI == RZ_G2M)
19#include "G2M/pfc_init_g2m.h"
20#endif /* RCAR_LSI == RZ_G2M */
21#include "rcar_def.h"
22
23#define PRR_PRODUCT_ERR(reg) \
24 do { \
25 ERROR("LSI Product ID(PRR=0x%x) PFC init not supported.\n", \
26 reg); \
27 panic(); \
28 } while (0)
29
30#define PRR_CUT_ERR(reg) \
31 do { \
32 ERROR("LSI Cut ID(PRR=0x%x) PFC init not supported.\n", \
33 reg); \
34 panic();\
35 } while (0)
36
37void rzg_pfc_init(void)
38{
39 uint32_t reg;
40
41 reg = mmio_read_32(RCAR_PRR);
42#if RCAR_LSI == RCAR_AUTO
43 switch (reg & PRR_PRODUCT_MASK) {
44 case PRR_PRODUCT_M3:
45 pfc_init_g2m();
46 break;
Lad Prabhakarb3e77d82021-03-18 13:07:51 +000047 case PRR_PRODUCT_H3:
48 pfc_init_g2h();
49 break;
Biju Dasbf40dbb2020-11-09 09:40:04 +000050 default:
51 PRR_PRODUCT_ERR(reg);
52 break;
53 }
54
55#elif RCAR_LSI_CUT_COMPAT /* RCAR_LSI == RCAR_AUTO */
56 switch (reg & PRR_PRODUCT_MASK) {
57 case PRR_PRODUCT_M3:
58#if RCAR_LSI != RZ_G2M
59 PRR_PRODUCT_ERR(reg);
60#else /* RCAR_LSI != RZ_G2M */
61 pfc_init_g2m();
62#endif /* RCAR_LSI != RZ_G2M */
63 break;
Lad Prabhakarb3e77d82021-03-18 13:07:51 +000064 case PRR_PRODUCT_H3:
65#if (RCAR_LSI != RZ_G2H)
66 PRR_PRODUCT_ERR(reg);
67#else /* RCAR_LSI != RZ_G2H */
68 pfc_init_g2h();
69#endif /* RCAR_LSI != RZ_G2H */
70 break;
Biju Dasbf40dbb2020-11-09 09:40:04 +000071 default:
72 PRR_PRODUCT_ERR(reg);
73 break;
74 }
75
76#else /* RCAR_LSI == RCAR_AUTO */
77#if (RCAR_LSI == RZ_G2M)
78 if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_M3) {
79 PRR_PRODUCT_ERR(reg);
80 }
81 pfc_init_m3();
Lad Prabhakarb3e77d82021-03-18 13:07:51 +000082#elif (RCAR_LSI == RZ_G2H)
83 if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_H3) {
84 PRR_PRODUCT_ERR(reg);
85 }
86 pfc_init_g2h();
Biju Dasbf40dbb2020-11-09 09:40:04 +000087#else /* RCAR_LSI == RZ_G2M */
88#error "Don't have PFC initialize routine(unknown)."
89#endif /* RCAR_LSI == RZ_G2M */
90#endif /* RCAR_LSI == RCAR_AUTO */
91}