blob: e9455af51cd154c792fcee1581f0885ae4d465c2 [file] [log] [blame]
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +02001/*
2 * Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <stdint.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <common/debug.h>
10#include <lib/mmio.h>
11
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020012#include "rcar_def.h"
13#if RCAR_LSI == RCAR_AUTO
14#include "H3/pfc_init_h3_v1.h"
15#include "H3/pfc_init_h3_v2.h"
16#include "M3/pfc_init_m3.h"
17#include "M3N/pfc_init_m3n.h"
Valentine Barshakf2184142018-10-30 02:06:17 +030018#include "V3M/pfc_init_v3m.h"
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020019#endif
20#if (RCAR_LSI == RCAR_H3) || (RCAR_LSI == RCAR_H3N) /* H3 */
21#include "H3/pfc_init_h3_v1.h"
22#include "H3/pfc_init_h3_v2.h"
23#endif
24#if RCAR_LSI == RCAR_M3 /* M3 */
25#include "M3/pfc_init_m3.h"
26#endif
27#if RCAR_LSI == RCAR_M3N /* M3N */
28#include "M3N/pfc_init_m3n.h"
29#endif
Valentine Barshakf2184142018-10-30 02:06:17 +030030#if RCAR_LSI == RCAR_V3M /* V3M */
31#include "V3M/pfc_init_v3m.h"
32#endif
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020033#if RCAR_LSI == RCAR_E3 /* E3 */
34#include "E3/pfc_init_e3.h"
35#endif
Marek Vasut6f4984c2018-06-14 06:26:45 +020036#if RCAR_LSI == RCAR_D3 /* D3 */
37#include "D3/pfc_init_d3.h"
38#endif
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020039
40 /* Product Register */
41#define PRR (0xFFF00044U)
42#define PRR_PRODUCT_MASK (0x00007F00U)
43#define PRR_CUT_MASK (0x000000FFU)
44#define PRR_PRODUCT_H3 (0x00004F00U) /* R-Car H3 */
45#define PRR_PRODUCT_M3 (0x00005200U) /* R-Car M3 */
Valentine Barshakf2184142018-10-30 02:06:17 +030046#define PRR_PRODUCT_V3M (0x00005400U) /* R-Car V3M */
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020047#define PRR_PRODUCT_M3N (0x00005500U) /* R-Car M3N */
48#define PRR_PRODUCT_E3 (0x00005700U) /* R-Car E3 */
Marek Vasut6f4984c2018-06-14 06:26:45 +020049#define PRR_PRODUCT_D3 (0x00005800U) /* R-Car D3 */
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020050#define PRR_PRODUCT_10 (0x00U)
51#define PRR_PRODUCT_11 (0x01U)
52#define PRR_PRODUCT_20 (0x10U)
53
Marek Vasutdc9a7df2019-06-17 19:28:12 +020054#define PRR_PRODUCT_ERR(reg) \
55 do { \
56 ERROR("LSI Product ID(PRR=0x%x) PFC initialize not supported.\n", \
57 reg); \
58 panic(); \
59 } while (0)
60
61#define PRR_CUT_ERR(reg) \
62 do { \
63 ERROR("LSI Cut ID(PRR=0x%x) PFC initialize not supported.\n", \
64 reg); \
65 panic();\
66 } while (0)
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020067
68void rcar_pfc_init(void)
69{
70 uint32_t reg;
71
72 reg = mmio_read_32(RCAR_PRR);
73#if RCAR_LSI == RCAR_AUTO
74 switch (reg & RCAR_PRODUCT_MASK) {
75 case RCAR_PRODUCT_H3:
76 switch (reg & PRR_CUT_MASK) {
77 case PRR_PRODUCT_10: /* H3 Ver.1.0 */
78 pfc_init_h3_v1();
79 break;
80 case PRR_PRODUCT_11: /* H3 Ver.1.1 */
81 pfc_init_h3_v1();
82 break;
83 default: /* H3 Ver.2.0 or later */
84 pfc_init_h3_v2();
85 break;
86 }
87 break;
88 case RCAR_PRODUCT_M3:
89 pfc_init_m3();
90 break;
91 case RCAR_PRODUCT_M3N:
92 pfc_init_m3n();
93 break;
Valentine Barshakf2184142018-10-30 02:06:17 +030094 case RCAR_PRODUCT_V3M:
95 pfc_init_v3m();
96 break;
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020097 default:
98 PRR_PRODUCT_ERR(reg);
99 break;
100 }
101
102#elif RCAR_LSI_CUT_COMPAT
103 switch (reg & PRR_PRODUCT_MASK) {
104 case PRR_PRODUCT_H3:
105#if (RCAR_LSI != RCAR_H3) && (RCAR_LSI != RCAR_H3N)
106 PRR_PRODUCT_ERR(reg);
107#else
108 switch (reg & PRR_CUT_MASK) {
109 case PRR_PRODUCT_10: /* H3 Ver.1.0 */
110 pfc_init_h3_v1();
111 break;
112 case PRR_PRODUCT_11: /* H3 Ver.1.1 */
113 pfc_init_h3_v1();
114 break;
115 default: /* H3 Ver.2.0 or later */
116 pfc_init_h3_v2();
117 break;
118 }
119#endif
120 break;
121 case PRR_PRODUCT_M3:
122#if RCAR_LSI != RCAR_M3
123 PRR_PRODUCT_ERR(reg);
124#else
125 pfc_init_m3();
126#endif
127 break;
128 case PRR_PRODUCT_M3N:
129#if RCAR_LSI != RCAR_M3N
130 PRR_PRODUCT_ERR(reg);
131#else
132 pfc_init_m3n();
133#endif
134 break;
Valentine Barshakf2184142018-10-30 02:06:17 +0300135 case PRR_PRODUCT_V3M:
136#if RCAR_LSI != RCAR_V3M
137 PRR_PRODUCT_ERR(reg);
138#else
139 pfc_init_v3m();
140#endif
141 break;
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +0200142 case PRR_PRODUCT_E3:
143#if RCAR_LSI != RCAR_E3
144 PRR_PRODUCT_ERR(reg);
145#else
146 pfc_init_e3();
147#endif
148 break;
Marek Vasut6f4984c2018-06-14 06:26:45 +0200149 case PRR_PRODUCT_D3:
150#if RCAR_LSI != RCAR_D3
151 PRR_PRODUCT_ERR(reg);
152#else
153 pfc_init_d3();
154#endif
155 break;
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +0200156 default:
157 PRR_PRODUCT_ERR(reg);
158 break;
159 }
160
161#else
162#if (RCAR_LSI == RCAR_H3) || (RCAR_LSI == RCAR_H3N) /* H3 */
163#if RCAR_LSI_CUT == RCAR_CUT_10
164 /* H3 Ver.1.0 */
165 if ((PRR_PRODUCT_H3 | PRR_PRODUCT_10)
166 != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
167 PRR_PRODUCT_ERR(reg);
168 }
169 pfc_init_h3_v1();
170#elif RCAR_LSI_CUT == RCAR_CUT_11
171 /* H3 Ver.1.1 */
172 if ((PRR_PRODUCT_H3 | PRR_PRODUCT_11)
173 != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
174 PRR_PRODUCT_ERR(reg);
175 }
176 pfc_init_h3_v1();
177#else
178 /* H3 Ver.2.0 or later */
179 if (PRR_PRODUCT_H3 != (reg & PRR_PRODUCT_MASK)) {
180 PRR_PRODUCT_ERR(reg);
181 }
182 pfc_init_h3_v2();
183#endif
184#elif RCAR_LSI == RCAR_M3 /* M3 */
185 if ((PRR_PRODUCT_M3) != (reg & PRR_PRODUCT_MASK)) {
186 PRR_PRODUCT_ERR(reg);
187 }
188 pfc_init_m3();
189#elif RCAR_LSI == RCAR_M3N /* M3N */
190 if ((PRR_PRODUCT_M3N) != (reg & PRR_PRODUCT_MASK)) {
191 PRR_PRODUCT_ERR(reg);
192 }
193 pfc_init_m3n();
Valentine Barshakf2184142018-10-30 02:06:17 +0300194#elif RCAR_LSI == RCAR_V3M /* V3M */
195 if ((PRR_PRODUCT_V3M) != (reg & PRR_PRODUCT_MASK)) {
196 PRR_PRODUCT_ERR(reg);
197 }
198 pfc_init_v3m();
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +0200199#elif RCAR_LSI == RCAR_E3 /* E3 */
200 if ((PRR_PRODUCT_E3) != (reg & PRR_PRODUCT_MASK)) {
201 PRR_PRODUCT_ERR(reg);
202 }
203 pfc_init_e3();
Marek Vasut6f4984c2018-06-14 06:26:45 +0200204#elif RCAR_LSI == RCAR_D3 /* D3 */
205 if ((PRR_PRODUCT_D3) != (reg & PRR_PRODUCT_MASK)) {
206 PRR_PRODUCT_ERR(reg);
207 }
208 pfc_init_d3();
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +0200209#else
210#error "Don't have PFC initialize routine(unknown)."
211#endif
212#endif
213}