blob: f51992d2ee89ff2f0a8eaba63f5e5089046f543d [file] [log] [blame]
Biju Dasbf40dbb2020-11-09 09:40:04 +00001/*
2 * Copyright (c) 2020, Renesas Electronics Corporation. All rights reserved.
3 *
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
12#include "G2M/pfc_init_g2m.h"
13#endif /* RCAR_LSI == RCAR_AUTO */
14#if (RCAR_LSI == RZ_G2M)
15#include "G2M/pfc_init_g2m.h"
16#endif /* RCAR_LSI == RZ_G2M */
17#include "rcar_def.h"
18
19#define PRR_PRODUCT_ERR(reg) \
20 do { \
21 ERROR("LSI Product ID(PRR=0x%x) PFC init not supported.\n", \
22 reg); \
23 panic(); \
24 } while (0)
25
26#define PRR_CUT_ERR(reg) \
27 do { \
28 ERROR("LSI Cut ID(PRR=0x%x) PFC init not supported.\n", \
29 reg); \
30 panic();\
31 } while (0)
32
33void rzg_pfc_init(void)
34{
35 uint32_t reg;
36
37 reg = mmio_read_32(RCAR_PRR);
38#if RCAR_LSI == RCAR_AUTO
39 switch (reg & PRR_PRODUCT_MASK) {
40 case PRR_PRODUCT_M3:
41 pfc_init_g2m();
42 break;
43 default:
44 PRR_PRODUCT_ERR(reg);
45 break;
46 }
47
48#elif RCAR_LSI_CUT_COMPAT /* RCAR_LSI == RCAR_AUTO */
49 switch (reg & PRR_PRODUCT_MASK) {
50 case PRR_PRODUCT_M3:
51#if RCAR_LSI != RZ_G2M
52 PRR_PRODUCT_ERR(reg);
53#else /* RCAR_LSI != RZ_G2M */
54 pfc_init_g2m();
55#endif /* RCAR_LSI != RZ_G2M */
56 break;
57 default:
58 PRR_PRODUCT_ERR(reg);
59 break;
60 }
61
62#else /* RCAR_LSI == RCAR_AUTO */
63#if (RCAR_LSI == RZ_G2M)
64 if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_M3) {
65 PRR_PRODUCT_ERR(reg);
66 }
67 pfc_init_m3();
68#else /* RCAR_LSI == RZ_G2M */
69#error "Don't have PFC initialize routine(unknown)."
70#endif /* RCAR_LSI == RZ_G2M */
71#endif /* RCAR_LSI == RCAR_AUTO */
72}