blob: 88106676a3e3c9f798fce09c41488a98cc0e70a9 [file] [log] [blame]
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +02001/*
Marek Vasutd97f6ee2019-08-06 18:58:38 +02002 * Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved.
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +02003 *
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
Marek Vasutdc9a7df2019-06-17 19:28:12 +020040#define PRR_PRODUCT_ERR(reg) \
41 do { \
42 ERROR("LSI Product ID(PRR=0x%x) PFC initialize not supported.\n", \
43 reg); \
44 panic(); \
45 } while (0)
46
47#define PRR_CUT_ERR(reg) \
48 do { \
49 ERROR("LSI Cut ID(PRR=0x%x) PFC initialize not supported.\n", \
50 reg); \
51 panic();\
52 } while (0)
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020053
54void rcar_pfc_init(void)
55{
56 uint32_t reg;
57
58 reg = mmio_read_32(RCAR_PRR);
59#if RCAR_LSI == RCAR_AUTO
Marek Vasut9cadc782019-08-06 19:13:22 +020060 switch (reg & PRR_PRODUCT_MASK) {
61 case PRR_PRODUCT_H3:
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020062 switch (reg & PRR_CUT_MASK) {
63 case PRR_PRODUCT_10: /* H3 Ver.1.0 */
64 pfc_init_h3_v1();
65 break;
66 case PRR_PRODUCT_11: /* H3 Ver.1.1 */
67 pfc_init_h3_v1();
68 break;
69 default: /* H3 Ver.2.0 or later */
70 pfc_init_h3_v2();
71 break;
72 }
73 break;
Marek Vasut9cadc782019-08-06 19:13:22 +020074 case PRR_PRODUCT_M3:
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020075 pfc_init_m3();
76 break;
Marek Vasut9cadc782019-08-06 19:13:22 +020077 case PRR_PRODUCT_M3N:
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020078 pfc_init_m3n();
79 break;
Marek Vasut9cadc782019-08-06 19:13:22 +020080 case PRR_PRODUCT_V3M:
Valentine Barshakf2184142018-10-30 02:06:17 +030081 pfc_init_v3m();
82 break;
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +020083 default:
84 PRR_PRODUCT_ERR(reg);
85 break;
86 }
87
88#elif RCAR_LSI_CUT_COMPAT
89 switch (reg & PRR_PRODUCT_MASK) {
90 case PRR_PRODUCT_H3:
91#if (RCAR_LSI != RCAR_H3) && (RCAR_LSI != RCAR_H3N)
92 PRR_PRODUCT_ERR(reg);
93#else
94 switch (reg & PRR_CUT_MASK) {
95 case PRR_PRODUCT_10: /* H3 Ver.1.0 */
96 pfc_init_h3_v1();
97 break;
98 case PRR_PRODUCT_11: /* H3 Ver.1.1 */
99 pfc_init_h3_v1();
100 break;
101 default: /* H3 Ver.2.0 or later */
102 pfc_init_h3_v2();
103 break;
104 }
105#endif
106 break;
107 case PRR_PRODUCT_M3:
108#if RCAR_LSI != RCAR_M3
109 PRR_PRODUCT_ERR(reg);
110#else
111 pfc_init_m3();
112#endif
113 break;
114 case PRR_PRODUCT_M3N:
115#if RCAR_LSI != RCAR_M3N
116 PRR_PRODUCT_ERR(reg);
117#else
118 pfc_init_m3n();
119#endif
120 break;
Valentine Barshakf2184142018-10-30 02:06:17 +0300121 case PRR_PRODUCT_V3M:
122#if RCAR_LSI != RCAR_V3M
123 PRR_PRODUCT_ERR(reg);
124#else
125 pfc_init_v3m();
126#endif
127 break;
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +0200128 case PRR_PRODUCT_E3:
129#if RCAR_LSI != RCAR_E3
130 PRR_PRODUCT_ERR(reg);
131#else
132 pfc_init_e3();
133#endif
134 break;
Marek Vasut6f4984c2018-06-14 06:26:45 +0200135 case PRR_PRODUCT_D3:
136#if RCAR_LSI != RCAR_D3
137 PRR_PRODUCT_ERR(reg);
138#else
139 pfc_init_d3();
140#endif
141 break;
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +0200142 default:
143 PRR_PRODUCT_ERR(reg);
144 break;
145 }
146
147#else
148#if (RCAR_LSI == RCAR_H3) || (RCAR_LSI == RCAR_H3N) /* H3 */
149#if RCAR_LSI_CUT == RCAR_CUT_10
150 /* H3 Ver.1.0 */
151 if ((PRR_PRODUCT_H3 | PRR_PRODUCT_10)
152 != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
153 PRR_PRODUCT_ERR(reg);
154 }
155 pfc_init_h3_v1();
156#elif RCAR_LSI_CUT == RCAR_CUT_11
157 /* H3 Ver.1.1 */
158 if ((PRR_PRODUCT_H3 | PRR_PRODUCT_11)
159 != (reg & (PRR_PRODUCT_MASK | PRR_CUT_MASK))) {
160 PRR_PRODUCT_ERR(reg);
161 }
162 pfc_init_h3_v1();
163#else
164 /* H3 Ver.2.0 or later */
165 if (PRR_PRODUCT_H3 != (reg & PRR_PRODUCT_MASK)) {
166 PRR_PRODUCT_ERR(reg);
167 }
168 pfc_init_h3_v2();
169#endif
170#elif RCAR_LSI == RCAR_M3 /* M3 */
171 if ((PRR_PRODUCT_M3) != (reg & PRR_PRODUCT_MASK)) {
172 PRR_PRODUCT_ERR(reg);
173 }
174 pfc_init_m3();
175#elif RCAR_LSI == RCAR_M3N /* M3N */
176 if ((PRR_PRODUCT_M3N) != (reg & PRR_PRODUCT_MASK)) {
177 PRR_PRODUCT_ERR(reg);
178 }
179 pfc_init_m3n();
Valentine Barshakf2184142018-10-30 02:06:17 +0300180#elif RCAR_LSI == RCAR_V3M /* V3M */
181 if ((PRR_PRODUCT_V3M) != (reg & PRR_PRODUCT_MASK)) {
182 PRR_PRODUCT_ERR(reg);
183 }
184 pfc_init_v3m();
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +0200185#elif RCAR_LSI == RCAR_E3 /* E3 */
186 if ((PRR_PRODUCT_E3) != (reg & PRR_PRODUCT_MASK)) {
187 PRR_PRODUCT_ERR(reg);
188 }
189 pfc_init_e3();
Marek Vasut6f4984c2018-06-14 06:26:45 +0200190#elif RCAR_LSI == RCAR_D3 /* D3 */
191 if ((PRR_PRODUCT_D3) != (reg & PRR_PRODUCT_MASK)) {
192 PRR_PRODUCT_ERR(reg);
193 }
194 pfc_init_d3();
Jorge Ramirez-Ortiz47503d22018-09-23 09:36:52 +0200195#else
196#error "Don't have PFC initialize routine(unknown)."
197#endif
198#endif
199}