blob: 61ad6e6f6b754fe40de0b29d1b38d9d5f5ae0b57 [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"
Lad Prabhakarb7fc5e22020-12-29 13:39:31 +000014#include "G2N/pfc_init_g2n.h"
Biju Dasbf40dbb2020-11-09 09:40:04 +000015#endif /* RCAR_LSI == RCAR_AUTO */
Lad Prabhakarb3e77d82021-03-18 13:07:51 +000016#if (RCAR_LSI == RZ_G2H)
17#include "G2H/pfc_init_g2h.h"
18#endif /* RCAR_LSI == RZ_G2H */
Biju Dasbf40dbb2020-11-09 09:40:04 +000019#if (RCAR_LSI == RZ_G2M)
20#include "G2M/pfc_init_g2m.h"
21#endif /* RCAR_LSI == RZ_G2M */
Lad Prabhakarb7fc5e22020-12-29 13:39:31 +000022#if (RCAR_LSI == RZ_G2N)
23#include "G2N/pfc_init_g2n.h"
24#endif /* RCAR_LSI == RZ_G2N */
Biju Dasbf40dbb2020-11-09 09:40:04 +000025#include "rcar_def.h"
26
27#define PRR_PRODUCT_ERR(reg) \
28 do { \
29 ERROR("LSI Product ID(PRR=0x%x) PFC init not supported.\n", \
30 reg); \
31 panic(); \
32 } while (0)
33
34#define PRR_CUT_ERR(reg) \
35 do { \
36 ERROR("LSI Cut ID(PRR=0x%x) PFC init not supported.\n", \
37 reg); \
38 panic();\
39 } while (0)
40
41void rzg_pfc_init(void)
42{
43 uint32_t reg;
44
45 reg = mmio_read_32(RCAR_PRR);
46#if RCAR_LSI == RCAR_AUTO
47 switch (reg & PRR_PRODUCT_MASK) {
48 case PRR_PRODUCT_M3:
49 pfc_init_g2m();
50 break;
Lad Prabhakarb3e77d82021-03-18 13:07:51 +000051 case PRR_PRODUCT_H3:
52 pfc_init_g2h();
53 break;
Lad Prabhakarb7fc5e22020-12-29 13:39:31 +000054 case PRR_PRODUCT_M3N:
55 pfc_init_g2n();
56 break;
Biju Dasbf40dbb2020-11-09 09:40:04 +000057 default:
58 PRR_PRODUCT_ERR(reg);
59 break;
60 }
61
62#elif RCAR_LSI_CUT_COMPAT /* RCAR_LSI == RCAR_AUTO */
63 switch (reg & PRR_PRODUCT_MASK) {
64 case PRR_PRODUCT_M3:
65#if RCAR_LSI != RZ_G2M
66 PRR_PRODUCT_ERR(reg);
67#else /* RCAR_LSI != RZ_G2M */
68 pfc_init_g2m();
69#endif /* RCAR_LSI != RZ_G2M */
70 break;
Lad Prabhakarb3e77d82021-03-18 13:07:51 +000071 case PRR_PRODUCT_H3:
72#if (RCAR_LSI != RZ_G2H)
73 PRR_PRODUCT_ERR(reg);
74#else /* RCAR_LSI != RZ_G2H */
75 pfc_init_g2h();
76#endif /* RCAR_LSI != RZ_G2H */
77 break;
Lad Prabhakarb7fc5e22020-12-29 13:39:31 +000078 case PRR_PRODUCT_M3N:
79#if RCAR_LSI != RZ_G2N
80 PRR_PRODUCT_ERR(reg);
81#else
82 pfc_init_g2n();
83#endif /* RCAR_LSI != RZ_G2N */
84 break;
Biju Dasbf40dbb2020-11-09 09:40:04 +000085 default:
86 PRR_PRODUCT_ERR(reg);
87 break;
88 }
89
90#else /* RCAR_LSI == RCAR_AUTO */
91#if (RCAR_LSI == RZ_G2M)
92 if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_M3) {
93 PRR_PRODUCT_ERR(reg);
94 }
95 pfc_init_m3();
Lad Prabhakarb3e77d82021-03-18 13:07:51 +000096#elif (RCAR_LSI == RZ_G2H)
97 if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_H3) {
98 PRR_PRODUCT_ERR(reg);
99 }
100 pfc_init_g2h();
Lad Prabhakarb7fc5e22020-12-29 13:39:31 +0000101#elif (RCAR_LSI == RZ_G2N) /* G2N */
102 if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_M3N) {
103 PRR_PRODUCT_ERR(reg);
104 }
105 pfc_init_g2n();
Biju Dasbf40dbb2020-11-09 09:40:04 +0000106#else /* RCAR_LSI == RZ_G2M */
107#error "Don't have PFC initialize routine(unknown)."
108#endif /* RCAR_LSI == RZ_G2M */
109#endif /* RCAR_LSI == RCAR_AUTO */
110}