blob: 3fd535e7cfcc28fd90cfac1e15451ec99f558d50 [file] [log] [blame]
Yanhong Wang6a5a45d2023-03-29 11:42:17 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2022 StarFive Technology Co., Ltd.
4 * Author: Yanhong Wang<yanhong.wang@starfivetech.com>
5 */
6
Yanhong Wang4e321fa2023-06-15 17:36:52 +08007#include <asm/arch/eeprom.h>
Chanho Park9ca68c92023-10-31 17:56:00 +09008#include <asm/arch/gpio.h>
Yanhong Wang6a5a45d2023-03-29 11:42:17 +08009#include <asm/arch/regs.h>
10#include <asm/arch/spl.h>
11#include <asm/io.h>
Yanhong Wang4e321fa2023-06-15 17:36:52 +080012#include <dt-bindings/clock/starfive,jh7110-crg.h>
13#include <fdt_support.h>
14#include <linux/libfdt.h>
Yanhong Wang6a5a45d2023-03-29 11:42:17 +080015#include <log.h>
16#include <spl.h>
17
Yanhong Wang4e321fa2023-06-15 17:36:52 +080018DECLARE_GLOBAL_DATA_PTR;
Yanhong Wang6a5a45d2023-03-29 11:42:17 +080019#define JH7110_CLK_CPU_ROOT_OFFSET 0x0U
20#define JH7110_CLK_CPU_ROOT_SHIFT 24
21#define JH7110_CLK_CPU_ROOT_MASK GENMASK(29, 24)
22
Yanhong Wang4e321fa2023-06-15 17:36:52 +080023struct starfive_vf2_pro {
24 const char *path;
25 const char *name;
26 const char *value;
27};
28
Heinrich Schuchardtf8841732024-04-02 10:49:10 +020029static const struct starfive_vf2_pro milk_v_mars[] = {
30 {"/soc/ethernet@16030000", "starfive,tx-use-rgmii-clk", NULL},
31 {"/soc/ethernet@16040000", "starfive,tx-use-rgmii-clk", NULL},
32
33 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
34 "motorcomm,tx-clk-adj-enabled", NULL},
35 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
36 "motorcomm,tx-clk-100-inverted", NULL},
37 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
38 "motorcomm,tx-clk-1000-inverted", NULL},
39 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
40 "motorcomm,rx-clk-drv-microamp", "3970"},
41 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
42 "motorcomm,rx-data-drv-microamp", "2910"},
43 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
E Shattow86f723a2024-10-26 05:40:15 -070044 "rx-internal-delay-ps", "1500"},
Heinrich Schuchardtf8841732024-04-02 10:49:10 +020045 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
46 "tx-internal-delay-ps", "1500"},
47};
48
Yanhong Wang4e321fa2023-06-15 17:36:52 +080049static const struct starfive_vf2_pro starfive_vera[] = {
50 {"/soc/ethernet@16030000/mdio/ethernet-phy@0", "rx-internal-delay-ps",
51 "1900"},
52 {"/soc/ethernet@16030000/mdio/ethernet-phy@0", "tx-internal-delay-ps",
53 "1350"}
54};
55
56static const struct starfive_vf2_pro starfive_verb[] = {
57 {"/soc/ethernet@16030000", "starfive,tx-use-rgmii-clk", NULL},
58 {"/soc/ethernet@16040000", "starfive,tx-use-rgmii-clk", NULL},
59
60 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
61 "motorcomm,tx-clk-adj-enabled", NULL},
62 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
63 "motorcomm,tx-clk-100-inverted", NULL},
64 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
65 "motorcomm,tx-clk-1000-inverted", NULL},
66 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
Lukasz Tekielia99605d2024-01-28 20:22:48 +010067 "motorcomm,rx-clk-drv-microamp", "3970"},
68 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
69 "motorcomm,rx-data-drv-microamp", "2910"},
70 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
E Shattow28ff2062024-10-26 04:35:28 -070071 "rx-internal-delay-ps", "1500"},
Yanhong Wang4e321fa2023-06-15 17:36:52 +080072
73 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
74 "motorcomm,tx-clk-adj-enabled", NULL},
75 { "/soc/ethernet@16040000/mdio/ethernet-phy@1",
76 "motorcomm,tx-clk-100-inverted", NULL},
77 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
Lukasz Tekielia99605d2024-01-28 20:22:48 +010078 "motorcomm,rx-clk-drv-microamp", "3970"},
79 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
80 "motorcomm,rx-data-drv-microamp", "2910"},
81 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
Yanhong Wang4e321fa2023-06-15 17:36:52 +080082 "rx-internal-delay-ps", "0"},
83 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
84 "tx-internal-delay-ps", "0"},
85};
86
H Bell25ce7c92024-05-22 19:12:48 +000087static const struct starfive_vf2_pro star64_pine64[] = {
88 {"/soc/ethernet@16030000", "starfive,tx-use-rgmii-clk", NULL},
89 {"/soc/ethernet@16040000", "starfive,tx-use-rgmii-clk", NULL},
90
91 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
92 "motorcomm,tx-clk-adj-enabled", NULL},
93 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
94 "motorcomm,tx-clk-10-inverted", NULL},
95 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
96 "motorcomm,tx-clk-100-inverted", NULL},
97 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
98 "motorcomm,tx-clk-1000-inverted", NULL},
99 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
100 "motorcomm,rx-clk-drv-microamp", "2910"},
101 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
102 "motorcomm,rx-data-drv-microamp", "2910"},
103 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
104 "rx-internal-delay-ps", "1900"},
105 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
106 "tx-internal-delay-ps", "1500"},
107
108 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
109 "motorcomm,tx-clk-adj-enabled", NULL},
110 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
111 "motorcomm,tx-clk-10-inverted", NULL},
112 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
113 "motorcomm,tx-clk-100-inverted", NULL},
114 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
115 "motorcomm,rx-clk-drv-microamp", "2910"},
116 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
117 "motorcomm,rx-data-drv-microamp", "2910"},
118 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
119 "rx-internal-delay-ps", "0"},
120 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
121 "tx-internal-delay-ps", "300"},
122};
123
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200124void spl_fdt_fixup_mars(void *fdt)
125{
126 static const char compat[] = "milkv,mars\0starfive,jh7110";
127 u32 phandle;
128 u8 i;
129 int offset;
130 int ret;
131
132 fdt_setprop(fdt, fdt_path_offset(fdt, "/"), "compatible", compat, sizeof(compat));
133 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model",
134 "Milk-V Mars");
135
136 /* gmac0 */
137 offset = fdt_path_offset(fdt, "/soc/clock-controller@17000000");
138 phandle = fdt_get_phandle(fdt, offset);
139 offset = fdt_path_offset(fdt, "/soc/ethernet@16030000");
140
141 fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
142 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_AONCLK_GMAC0_TX);
143 fdt_setprop_u32(fdt, offset, "assigned-clock-parents", phandle);
144 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
145 JH7110_AONCLK_GMAC0_RMII_RTX);
146
147 /* gmac1 */
148 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/soc/ethernet@16040000"),
149 "status", "disabled");
150
151 for (i = 0; i < ARRAY_SIZE(milk_v_mars); i++) {
152 offset = fdt_path_offset(fdt, milk_v_mars[i].path);
153
154 if (milk_v_mars[i].value)
155 ret = fdt_setprop_u32(fdt, offset, milk_v_mars[i].name,
156 dectoul(milk_v_mars[i].value, NULL));
157 else
158 ret = fdt_setprop_empty(fdt, offset, milk_v_mars[i].name);
159
160 if (ret) {
161 pr_err("%s set prop %s fail.\n", __func__, milk_v_mars[i].name);
162 break;
163 }
164 }
165}
166
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200167void spl_fdt_fixup_mars_cm(void *fdt)
168{
169 const char *compat;
170 const char *model;
Heinrich Schuchardt4487d632024-07-20 01:11:58 +0200171 int compat_size;
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200172
173 spl_fdt_fixup_mars(fdt);
174
175 if (!get_mmc_size_from_eeprom()) {
176 int offset;
Heinrich Schuchardt4487d632024-07-20 01:11:58 +0200177 static const char
178 compat_cm_lite[] = "milkv,mars-cm-lite\0starfive,jh7110";
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200179
180 model = "Milk-V Mars CM Lite";
Heinrich Schuchardt4487d632024-07-20 01:11:58 +0200181 compat = compat_cm_lite;
182 compat_size = sizeof(compat_cm_lite);
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200183
184 offset = fdt_path_offset(fdt, "/soc/pinctrl/mmc0-pins/mmc0-pins-rest");
185 /* GPIOMUX(22, GPOUT_SYS_SDIO0_RST, GPOEN_ENABLE, GPI_NONE) */
186 fdt_setprop_u32(fdt, offset, "pinmux", 0xff130016);
187 } else {
Heinrich Schuchardt4487d632024-07-20 01:11:58 +0200188 static const char
189 compat_cm[] = "milkv,mars-cm\0starfive,jh7110";
190
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200191 model = "Milk-V Mars CM";
Heinrich Schuchardt4487d632024-07-20 01:11:58 +0200192 compat = compat_cm;
193 compat_size = sizeof(compat_cm);
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200194 }
Heinrich Schuchardt4487d632024-07-20 01:11:58 +0200195 fdt_setprop(fdt, fdt_path_offset(fdt, "/"),
196 "compatible", compat, compat_size);
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200197 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model", model);
198}
199
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800200void spl_fdt_fixup_version_a(void *fdt)
201{
Aurelien Jarno5acb7c12024-01-10 21:17:44 +0100202 static const char compat[] = "starfive,visionfive-2-v1.2a\0starfive,jh7110";
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800203 u32 phandle;
204 u8 i;
205 int offset;
206 int ret;
207
Aurelien Jarno5acb7c12024-01-10 21:17:44 +0100208 fdt_setprop(fdt, fdt_path_offset(fdt, "/"), "compatible", compat, sizeof(compat));
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800209 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model",
210 "StarFive VisionFive 2 v1.2A");
211
212 offset = fdt_path_offset(fdt, "/soc/clock-controller@13020000");
213 phandle = fdt_get_phandle(fdt, offset);
214 offset = fdt_path_offset(fdt, "/soc/ethernet@16040000");
215
216 fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
217 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_SYSCLK_GMAC1_TX);
218 fdt_appendprop_u32(fdt, offset, "assigned-clocks", phandle);
219 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_SYSCLK_GMAC1_RX);
220
221 fdt_setprop_u32(fdt, offset, "assigned-clock-parents", phandle);
222 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
223 JH7110_SYSCLK_GMAC1_RMII_RTX);
224 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents", phandle);
225 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
226 JH7110_SYSCLK_GMAC1_RMII_RTX);
227
228 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/soc/ethernet@16040000"),
229 "phy-mode", "rmii");
230
231 for (i = 0; i < ARRAY_SIZE(starfive_vera); i++) {
232 offset = fdt_path_offset(fdt, starfive_vera[i].path);
233
234 if (starfive_vera[i].value)
235 ret = fdt_setprop_u32(fdt, offset, starfive_vera[i].name,
236 dectoul(starfive_vera[i].value, NULL));
237 else
238 ret = fdt_setprop_empty(fdt, offset, starfive_vera[i].name);
239
240 if (ret) {
241 pr_err("%s set prop %s fail.\n", __func__, starfive_vera[i].name);
242 break;
243 }
244 }
245}
246
247void spl_fdt_fixup_version_b(void *fdt)
248{
Aurelien Jarno5acb7c12024-01-10 21:17:44 +0100249 static const char compat[] = "starfive,visionfive-2-v1.3b\0starfive,jh7110";
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800250 u32 phandle;
251 u8 i;
252 int offset;
253 int ret;
254
Aurelien Jarno5acb7c12024-01-10 21:17:44 +0100255 fdt_setprop(fdt, fdt_path_offset(fdt, "/"), "compatible", compat, sizeof(compat));
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800256 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model",
257 "StarFive VisionFive 2 v1.3B");
258
259 /* gmac0 */
260 offset = fdt_path_offset(fdt, "/soc/clock-controller@17000000");
261 phandle = fdt_get_phandle(fdt, offset);
262 offset = fdt_path_offset(fdt, "/soc/ethernet@16030000");
263
264 fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
265 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_AONCLK_GMAC0_TX);
266 fdt_setprop_u32(fdt, offset, "assigned-clock-parents", phandle);
267 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
268 JH7110_AONCLK_GMAC0_RMII_RTX);
269
270 /* gmac1 */
271 offset = fdt_path_offset(fdt, "/soc/clock-controller@13020000");
272 phandle = fdt_get_phandle(fdt, offset);
273 offset = fdt_path_offset(fdt, "/soc/ethernet@16040000");
274
275 fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
276 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_SYSCLK_GMAC1_TX);
277 fdt_setprop_u32(fdt, offset, "assigned-clock-parents", phandle);
278 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
279 JH7110_SYSCLK_GMAC1_RMII_RTX);
280
281 for (i = 0; i < ARRAY_SIZE(starfive_verb); i++) {
282 offset = fdt_path_offset(fdt, starfive_verb[i].path);
283
284 if (starfive_verb[i].value)
285 ret = fdt_setprop_u32(fdt, offset, starfive_verb[i].name,
286 dectoul(starfive_verb[i].value, NULL));
287 else
288 ret = fdt_setprop_empty(fdt, offset, starfive_verb[i].name);
289
290 if (ret) {
291 pr_err("%s set prop %s fail.\n", __func__, starfive_verb[i].name);
292 break;
293 }
294 }
295}
296
H Bell25ce7c92024-05-22 19:12:48 +0000297void spl_fdt_fixup_star64(void *fdt)
298{
299 static const char compat[] = "pine64,star64\0starfive,jh7110";
300 u32 phandle;
301 u8 i;
302 int offset;
303 int ret;
304
305 fdt_setprop(fdt, fdt_path_offset(fdt, "/"), "compatible", compat, sizeof(compat));
306 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model",
307 "Pine64 Star64");
308
309 /* gmac0 */
310 offset = fdt_path_offset(fdt, "/soc/clock-controller@17000000");
311 phandle = fdt_get_phandle(fdt, offset);
312 offset = fdt_path_offset(fdt, "/soc/ethernet@16030000");
313
314 fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
315 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_AONCLK_GMAC0_TX);
316 fdt_setprop_u32(fdt, offset, "assigned-clock-parents", phandle);
317 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
318 JH7110_AONCLK_GMAC0_RMII_RTX);
319
320 /* gmac1 */
321 offset = fdt_path_offset(fdt, "/soc/clock-controller@13020000");
322 phandle = fdt_get_phandle(fdt, offset);
323 offset = fdt_path_offset(fdt, "/soc/ethernet@16040000");
324
325 fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
326 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_SYSCLK_GMAC1_TX);
327 fdt_setprop_u32(fdt, offset, "assigned-clock-parents", phandle);
328 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
329 JH7110_SYSCLK_GMAC1_RMII_RTX);
330
331 for (i = 0; i < ARRAY_SIZE(star64_pine64); i++) {
332 offset = fdt_path_offset(fdt, star64_pine64[i].path);
333
334 if (star64_pine64[i].value)
335 ret = fdt_setprop_u32(fdt, offset, star64_pine64[i].name,
336 dectoul(star64_pine64[i].value, NULL));
337 else
338 ret = fdt_setprop_empty(fdt, offset, star64_pine64[i].name);
339
340 if (ret) {
341 pr_err("%s set prop %s fail.\n", __func__, star64_pine64[i].name);
342 break;
343 }
344 }
345}
346
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800347void spl_perform_fixups(struct spl_image_info *spl_image)
348{
349 u8 version;
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200350 const char *product_id;
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800351
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200352 product_id = get_product_id_from_eeprom();
353 if (!product_id) {
354 pr_err("Can't read EEPROM\n");
355 return;
356 }
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200357 if (!strncmp(product_id, "MARC", 4)) {
358 spl_fdt_fixup_mars_cm(spl_image->fdt_addr);
359 } else if (!strncmp(product_id, "MARS", 4)) {
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200360 spl_fdt_fixup_mars(spl_image->fdt_addr);
361 } else if (!strncmp(product_id, "VF7110", 6)) {
362 version = get_pcb_revision_from_eeprom();
363 switch (version) {
364 case 'a':
365 case 'A':
366 spl_fdt_fixup_version_a(spl_image->fdt_addr);
367 break;
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800368
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200369 case 'b':
370 case 'B':
371 default:
372 spl_fdt_fixup_version_b(spl_image->fdt_addr);
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800373 break;
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200374 };
H Bell25ce7c92024-05-22 19:12:48 +0000375 } else if (!strncmp(product_id, "STAR64", 6)) {
376 spl_fdt_fixup_star64(spl_image->fdt_addr);
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200377 } else {
378 pr_err("Unknown product %s\n", product_id);
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800379 };
380
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200381 /* Update the memory size which read from eeprom or DT */
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800382 fdt_fixup_memory(spl_image->fdt_addr, 0x40000000, gd->ram_size);
383}
Chanho Park9ca68c92023-10-31 17:56:00 +0900384
385static void jh7110_jtag_init(void)
386{
387 /* nTRST: GPIO36 */
388 SYS_IOMUX_DOEN(36, HIGH);
389 SYS_IOMUX_DIN(36, 4);
390 /* TDI: GPIO61 */
391 SYS_IOMUX_DOEN(61, HIGH);
392 SYS_IOMUX_DIN(61, 19);
393 /* TMS: GPIO63 */
394 SYS_IOMUX_DOEN(63, HIGH);
395 SYS_IOMUX_DIN(63, 20);
396 /* TCK: GPIO60 */
397 SYS_IOMUX_DOEN(60, HIGH);
398 SYS_IOMUX_DIN(60, 29);
399 /* TDO: GPIO44 */
400 SYS_IOMUX_DOEN(44, 8);
401 SYS_IOMUX_DOUT(44, 22);
402}
403
Yanhong Wang6a5a45d2023-03-29 11:42:17 +0800404int spl_board_init_f(void)
405{
406 int ret;
407
Chanho Park9ca68c92023-10-31 17:56:00 +0900408 jh7110_jtag_init();
409
Lukas Funke2b62dd62024-04-24 09:43:39 +0200410 ret = spl_dram_init();
Yanhong Wang6a5a45d2023-03-29 11:42:17 +0800411 if (ret) {
Lukas Funke2b62dd62024-04-24 09:43:39 +0200412 debug("JH7110 DRAM init failed: %d\n", ret);
Yanhong Wang6a5a45d2023-03-29 11:42:17 +0800413 return ret;
414 }
415
416 return 0;
417}
418
419u32 spl_boot_device(void)
420{
421 u32 mode;
422
423 mode = in_le32(JH7110_BOOT_MODE_SELECT_REG)
424 & JH7110_BOOT_MODE_SELECT_MASK;
425 switch (mode) {
426 case 0:
427 return BOOT_DEVICE_SPI;
428
429 case 1:
430 return BOOT_DEVICE_MMC2;
431
432 case 2:
433 return BOOT_DEVICE_MMC1;
434
435 case 3:
436 return BOOT_DEVICE_UART;
437
438 default:
439 debug("Unsupported boot device 0x%x.\n", mode);
440 return BOOT_DEVICE_NONE;
441 }
442}
443
444void board_init_f(ulong dummy)
445{
446 int ret;
447
448 ret = spl_early_init();
449 if (ret)
450 panic("spl_early_init() failed: %d\n", ret);
451
Simon Glassb8357c12023-08-21 21:16:56 -0600452 riscv_cpu_setup();
Yanhong Wang6a5a45d2023-03-29 11:42:17 +0800453 preloader_console_init();
454
455 /* Set the parent clock of cpu_root clock to pll0,
456 * it must be initialized here
457 */
458 clrsetbits_le32(JH7110_SYS_CRG + JH7110_CLK_CPU_ROOT_OFFSET,
459 JH7110_CLK_CPU_ROOT_MASK,
460 BIT(JH7110_CLK_CPU_ROOT_SHIFT));
461
462 ret = spl_board_init_f();
463 if (ret) {
464 debug("spl_board_init_f init failed: %d\n", ret);
465 return;
466 }
467}
468
469#if CONFIG_IS_ENABLED(SPL_LOAD_FIT)
470int board_fit_config_name_match(const char *name)
471{
472 /* boot using first FIT config */
473 return 0;
474}
475#endif