pfc_init.c 4.59 KB
Newer Older
1
2
3
4
5
6
7
/*
 * Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <stdint.h>
8
9
10
11

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

12
13
14
15
16
17
#include "rcar_def.h"
#if RCAR_LSI == RCAR_AUTO
#include "H3/pfc_init_h3_v1.h"
#include "H3/pfc_init_h3_v2.h"
#include "M3/pfc_init_m3.h"
#include "M3N/pfc_init_m3n.h"
18
#include "V3M/pfc_init_v3m.h"
19
20
21
22
23
24
25
26
27
28
29
#endif
#if (RCAR_LSI == RCAR_H3) || (RCAR_LSI == RCAR_H3N)	/* H3 */
#include "H3/pfc_init_h3_v1.h"
#include "H3/pfc_init_h3_v2.h"
#endif
#if RCAR_LSI == RCAR_M3		/* M3 */
#include "M3/pfc_init_m3.h"
#endif
#if RCAR_LSI == RCAR_M3N	/* M3N */
#include "M3N/pfc_init_m3n.h"
#endif
30
31
32
#if RCAR_LSI == RCAR_V3M	/* V3M */
#include "V3M/pfc_init_v3m.h"
#endif
33
34
#if RCAR_LSI == RCAR_E3		/* E3 */
#include "E3/pfc_init_e3.h"
35
36
37
#endif
#if RCAR_LSI == RCAR_D3		/* D3 */
#include "D3/pfc_init_d3.h"
38
39
40
41
42
43
44
45
#endif

 /* Product Register */
#define PRR			(0xFFF00044U)
#define PRR_PRODUCT_MASK	(0x00007F00U)
#define PRR_CUT_MASK		(0x000000FFU)
#define PRR_PRODUCT_H3		(0x00004F00U)	/* R-Car H3 */
#define PRR_PRODUCT_M3		(0x00005200U)	/* R-Car M3 */
46
#define PRR_PRODUCT_V3M		(0x00005400U)	/* R-Car V3M */
47
48
#define PRR_PRODUCT_M3N		(0x00005500U)	/* R-Car M3N */
#define PRR_PRODUCT_E3		(0x00005700U)	/* R-Car E3 */
49
#define PRR_PRODUCT_D3		(0x00005800U)	/* R-Car D3 */
50
51
52
53
#define PRR_PRODUCT_10		(0x00U)
#define PRR_PRODUCT_11		(0x01U)
#define PRR_PRODUCT_20		(0x10U)

54
55
56
57
58
59
60
61
62
63
64
65
66
#define PRR_PRODUCT_ERR(reg)				\
	do {						\
		ERROR("LSI Product ID(PRR=0x%x) PFC initialize not supported.\n", \
			reg);				\
		panic();				\
	} while (0)

#define PRR_CUT_ERR(reg)				\
	do {						\
		ERROR("LSI Cut ID(PRR=0x%x) PFC initialize not supported.\n", \
			reg);				\
		panic();\
	} while (0)
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

void rcar_pfc_init(void)
{
	uint32_t reg;

	reg = mmio_read_32(RCAR_PRR);
#if RCAR_LSI == RCAR_AUTO
	switch (reg & RCAR_PRODUCT_MASK) {
	case RCAR_PRODUCT_H3:
		switch (reg & PRR_CUT_MASK) {
		case PRR_PRODUCT_10:	/* H3 Ver.1.0 */
			pfc_init_h3_v1();
			break;
		case PRR_PRODUCT_11:	/* H3 Ver.1.1 */
			pfc_init_h3_v1();
			break;
		default:	/* H3 Ver.2.0 or later */
			pfc_init_h3_v2();
			break;
		}
		break;
	case RCAR_PRODUCT_M3:
		pfc_init_m3();
		break;
	case RCAR_PRODUCT_M3N:
		pfc_init_m3n();
		break;
94
95
96
	case RCAR_PRODUCT_V3M:
		pfc_init_v3m();
		break;
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
130
131
132
	default:
		PRR_PRODUCT_ERR(reg);
		break;
	}

#elif RCAR_LSI_CUT_COMPAT
	switch (reg & PRR_PRODUCT_MASK) {
	case PRR_PRODUCT_H3:
#if (RCAR_LSI != RCAR_H3) && (RCAR_LSI != RCAR_H3N)
		PRR_PRODUCT_ERR(reg);
#else
		switch (reg & PRR_CUT_MASK) {
		case PRR_PRODUCT_10:	/* H3 Ver.1.0 */
			pfc_init_h3_v1();
			break;
		case PRR_PRODUCT_11:	/* H3 Ver.1.1 */
			pfc_init_h3_v1();
			break;
		default:	/* H3 Ver.2.0 or later */
			pfc_init_h3_v2();
			break;
		}
#endif
		break;
	case PRR_PRODUCT_M3:
#if RCAR_LSI != RCAR_M3
		PRR_PRODUCT_ERR(reg);
#else
		pfc_init_m3();
#endif
		break;
	case PRR_PRODUCT_M3N:
#if RCAR_LSI != RCAR_M3N
		PRR_PRODUCT_ERR(reg);
#else
		pfc_init_m3n();
133
134
135
136
137
138
139
#endif
		break;
	case PRR_PRODUCT_V3M:
#if RCAR_LSI != RCAR_V3M
		PRR_PRODUCT_ERR(reg);
#else
		pfc_init_v3m();
140
141
142
143
144
145
146
#endif
		break;
	case PRR_PRODUCT_E3:
#if RCAR_LSI != RCAR_E3
		PRR_PRODUCT_ERR(reg);
#else
		pfc_init_e3();
147
148
149
150
151
152
153
#endif
		break;
	case PRR_PRODUCT_D3:
#if RCAR_LSI != RCAR_D3
		PRR_PRODUCT_ERR(reg);
#else
		pfc_init_d3();
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#endif
		break;
	default:
		PRR_PRODUCT_ERR(reg);
		break;
	}

#else
#if (RCAR_LSI == RCAR_H3) || (RCAR_LSI == RCAR_H3N)	/* H3 */
#if RCAR_LSI_CUT == RCAR_CUT_10
	/* H3 Ver.1.0 */
	if ((PRR_PRODUCT_H3 | PRR_PRODUCT_10)
	    != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
		PRR_PRODUCT_ERR(reg);
	}
	pfc_init_h3_v1();
#elif RCAR_LSI_CUT == RCAR_CUT_11
	/* H3 Ver.1.1 */
	if ((PRR_PRODUCT_H3 | PRR_PRODUCT_11)
	    != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
		PRR_PRODUCT_ERR(reg);
	}
	pfc_init_h3_v1();
#else
	/* H3 Ver.2.0 or later */
	if (PRR_PRODUCT_H3 != (reg & PRR_PRODUCT_MASK)) {
		PRR_PRODUCT_ERR(reg);
	}
	pfc_init_h3_v2();
#endif
#elif RCAR_LSI == RCAR_M3	/* M3 */
	if ((PRR_PRODUCT_M3) != (reg & PRR_PRODUCT_MASK)) {
		PRR_PRODUCT_ERR(reg);
	}
	pfc_init_m3();
#elif RCAR_LSI == RCAR_M3N	/* M3N */
	if ((PRR_PRODUCT_M3N) != (reg & PRR_PRODUCT_MASK)) {
		PRR_PRODUCT_ERR(reg);
	}
	pfc_init_m3n();
194
195
196
197
198
#elif RCAR_LSI == RCAR_V3M	/* V3M */
	if ((PRR_PRODUCT_V3M) != (reg & PRR_PRODUCT_MASK)) {
		PRR_PRODUCT_ERR(reg);
	}
	pfc_init_v3m();
199
200
201
202
203
#elif RCAR_LSI == RCAR_E3	/* E3 */
	if ((PRR_PRODUCT_E3) != (reg & PRR_PRODUCT_MASK)) {
		PRR_PRODUCT_ERR(reg);
	}
	pfc_init_e3();
204
205
206
207
208
#elif RCAR_LSI == RCAR_D3	/* D3 */
	if ((PRR_PRODUCT_D3) != (reg & PRR_PRODUCT_MASK)) {
		PRR_PRODUCT_ERR(reg);
	}
	pfc_init_d3();
209
210
211
212
213
#else
#error "Don't have PFC initialize routine(unknown)."
#endif
#endif
}