summaryrefslogtreecommitdiffstats
path: root/drivers/renesas/rzg/pfc/pfc_init.c
blob: 762450cd2b5983a39f939a365b5feeb63f5466d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 * Copyright (c) 2020-2021, Renesas Electronics Corporation. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */
#include <stdint.h>

#include <common/debug.h>
#include <lib/mmio.h>

#if RCAR_LSI == RCAR_AUTO
#include "G2E/pfc_init_g2e.h"
#include "G2H/pfc_init_g2h.h"
#include "G2M/pfc_init_g2m.h"
#include "G2N/pfc_init_g2n.h"
#endif /* RCAR_LSI == RCAR_AUTO */
#if (RCAR_LSI == RZ_G2E)
#include "G2E/pfc_init_g2e.h"
#endif /* RCAR_LSI == RZ_G2N */
#if (RCAR_LSI == RZ_G2H)
#include "G2H/pfc_init_g2h.h"
#endif /* RCAR_LSI == RZ_G2H */
#if (RCAR_LSI == RZ_G2M)
#include "G2M/pfc_init_g2m.h"
#endif /* RCAR_LSI == RZ_G2M */
#if (RCAR_LSI == RZ_G2N)
#include "G2N/pfc_init_g2n.h"
#endif /* RCAR_LSI == RZ_G2N */
#include "rcar_def.h"

#define PRR_PRODUCT_ERR(reg)				\
	do {						\
		ERROR("LSI Product ID(PRR=0x%x) PFC init not supported.\n", \
			reg);				\
		panic();				\
	} while (0)

#define PRR_CUT_ERR(reg)				\
	do {						\
		ERROR("LSI Cut ID(PRR=0x%x) PFC init not supported.\n", \
			reg);				\
		panic();\
	} while (0)

void rzg_pfc_init(void)
{
	uint32_t reg;

	reg = mmio_read_32(RCAR_PRR);
#if RCAR_LSI == RCAR_AUTO
	switch (reg & PRR_PRODUCT_MASK) {
	case PRR_PRODUCT_M3:
		pfc_init_g2m();
		break;
	case PRR_PRODUCT_H3:
		pfc_init_g2h();
		break;
	case PRR_PRODUCT_M3N:
		pfc_init_g2n();
		break;
	case PRR_PRODUCT_E3:
		pfc_init_g2e();
		break;
	default:
		PRR_PRODUCT_ERR(reg);
		break;
	}

#elif RCAR_LSI_CUT_COMPAT /* RCAR_LSI == RCAR_AUTO */
	switch (reg & PRR_PRODUCT_MASK) {
	case PRR_PRODUCT_M3:
#if RCAR_LSI != RZ_G2M
		PRR_PRODUCT_ERR(reg);
#else /* RCAR_LSI != RZ_G2M */
		pfc_init_g2m();
#endif /* RCAR_LSI != RZ_G2M */
		break;
	case PRR_PRODUCT_H3:
#if (RCAR_LSI != RZ_G2H)
		PRR_PRODUCT_ERR(reg);
#else /* RCAR_LSI != RZ_G2H */
		pfc_init_g2h();
#endif /* RCAR_LSI != RZ_G2H */
		break;
	case PRR_PRODUCT_M3N:
#if RCAR_LSI != RZ_G2N
		PRR_PRODUCT_ERR(reg);
#else
		pfc_init_g2n();
#endif /* RCAR_LSI != RZ_G2N */
		break;
	case PRR_PRODUCT_E3:
#if RCAR_LSI != RZ_G2E
		PRR_PRODUCT_ERR(reg);
#else
		pfc_init_g2e();
#endif
		break;
	default:
		PRR_PRODUCT_ERR(reg);
		break;
	}

#else /* RCAR_LSI == RCAR_AUTO */
#if (RCAR_LSI == RZ_G2M)
	if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_M3) {
		PRR_PRODUCT_ERR(reg);
	}
	pfc_init_m3();
#elif (RCAR_LSI == RZ_G2H)
	if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_H3) {
		PRR_PRODUCT_ERR(reg);
	}
	pfc_init_g2h();
#elif (RCAR_LSI == RZ_G2N)	/* G2N */
	if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_M3N) {
		PRR_PRODUCT_ERR(reg);
	}
	pfc_init_g2n();
#elif (RCAR_LSI == RZ_G2E)
	if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_E3) {
		PRR_PRODUCT_ERR(reg);
	}
	pfc_init_g2e();
#else /* RCAR_LSI == RZ_G2M */
#error "Don't have PFC initialize routine(unknown)."
#endif /* RCAR_LSI == RZ_G2M */
#endif /* RCAR_LSI == RCAR_AUTO */
}