blob: f55c6b5d34cb289bc5a53652a56e5d0f09229c92 [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",
44 "rx-internal-delay-ps", "1900"},
45 {"/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",
Yanhong Wang4e321fa2023-06-15 17:36:52 +080071 "rx-internal-delay-ps", "1900"},
72 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
73 "tx-internal-delay-ps", "1500"},
74
75 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
76 "motorcomm,tx-clk-adj-enabled", NULL},
77 { "/soc/ethernet@16040000/mdio/ethernet-phy@1",
78 "motorcomm,tx-clk-100-inverted", NULL},
79 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
Lukasz Tekielia99605d2024-01-28 20:22:48 +010080 "motorcomm,rx-clk-drv-microamp", "3970"},
81 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
82 "motorcomm,rx-data-drv-microamp", "2910"},
83 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
Yanhong Wang4e321fa2023-06-15 17:36:52 +080084 "rx-internal-delay-ps", "0"},
85 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
86 "tx-internal-delay-ps", "0"},
87};
88
H Bell25ce7c92024-05-22 19:12:48 +000089static const struct starfive_vf2_pro star64_pine64[] = {
90 {"/soc/ethernet@16030000", "starfive,tx-use-rgmii-clk", NULL},
91 {"/soc/ethernet@16040000", "starfive,tx-use-rgmii-clk", NULL},
92
93 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
94 "motorcomm,tx-clk-adj-enabled", NULL},
95 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
96 "motorcomm,tx-clk-10-inverted", NULL},
97 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
98 "motorcomm,tx-clk-100-inverted", NULL},
99 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
100 "motorcomm,tx-clk-1000-inverted", NULL},
101 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
102 "motorcomm,rx-clk-drv-microamp", "2910"},
103 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
104 "motorcomm,rx-data-drv-microamp", "2910"},
105 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
106 "rx-internal-delay-ps", "1900"},
107 {"/soc/ethernet@16030000/mdio/ethernet-phy@0",
108 "tx-internal-delay-ps", "1500"},
109
110 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
111 "motorcomm,tx-clk-adj-enabled", NULL},
112 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
113 "motorcomm,tx-clk-10-inverted", NULL},
114 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
115 "motorcomm,tx-clk-100-inverted", NULL},
116 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
117 "motorcomm,rx-clk-drv-microamp", "2910"},
118 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
119 "motorcomm,rx-data-drv-microamp", "2910"},
120 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
121 "rx-internal-delay-ps", "0"},
122 {"/soc/ethernet@16040000/mdio/ethernet-phy@1",
123 "tx-internal-delay-ps", "300"},
124};
125
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200126void spl_fdt_fixup_mars(void *fdt)
127{
128 static const char compat[] = "milkv,mars\0starfive,jh7110";
129 u32 phandle;
130 u8 i;
131 int offset;
132 int ret;
133
134 fdt_setprop(fdt, fdt_path_offset(fdt, "/"), "compatible", compat, sizeof(compat));
135 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model",
136 "Milk-V Mars");
137
138 /* gmac0 */
139 offset = fdt_path_offset(fdt, "/soc/clock-controller@17000000");
140 phandle = fdt_get_phandle(fdt, offset);
141 offset = fdt_path_offset(fdt, "/soc/ethernet@16030000");
142
143 fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
144 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_AONCLK_GMAC0_TX);
145 fdt_setprop_u32(fdt, offset, "assigned-clock-parents", phandle);
146 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
147 JH7110_AONCLK_GMAC0_RMII_RTX);
148
149 /* gmac1 */
150 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/soc/ethernet@16040000"),
151 "status", "disabled");
152
153 for (i = 0; i < ARRAY_SIZE(milk_v_mars); i++) {
154 offset = fdt_path_offset(fdt, milk_v_mars[i].path);
155
156 if (milk_v_mars[i].value)
157 ret = fdt_setprop_u32(fdt, offset, milk_v_mars[i].name,
158 dectoul(milk_v_mars[i].value, NULL));
159 else
160 ret = fdt_setprop_empty(fdt, offset, milk_v_mars[i].name);
161
162 if (ret) {
163 pr_err("%s set prop %s fail.\n", __func__, milk_v_mars[i].name);
164 break;
165 }
166 }
167}
168
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200169void spl_fdt_fixup_mars_cm(void *fdt)
170{
171 const char *compat;
172 const char *model;
Heinrich Schuchardt4487d632024-07-20 01:11:58 +0200173 int compat_size;
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200174
175 spl_fdt_fixup_mars(fdt);
176
177 if (!get_mmc_size_from_eeprom()) {
178 int offset;
Heinrich Schuchardt4487d632024-07-20 01:11:58 +0200179 static const char
180 compat_cm_lite[] = "milkv,mars-cm-lite\0starfive,jh7110";
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200181
182 model = "Milk-V Mars CM Lite";
Heinrich Schuchardt4487d632024-07-20 01:11:58 +0200183 compat = compat_cm_lite;
184 compat_size = sizeof(compat_cm_lite);
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200185
186 offset = fdt_path_offset(fdt, "/soc/pinctrl/mmc0-pins/mmc0-pins-rest");
187 /* GPIOMUX(22, GPOUT_SYS_SDIO0_RST, GPOEN_ENABLE, GPI_NONE) */
188 fdt_setprop_u32(fdt, offset, "pinmux", 0xff130016);
189 } else {
Heinrich Schuchardt4487d632024-07-20 01:11:58 +0200190 static const char
191 compat_cm[] = "milkv,mars-cm\0starfive,jh7110";
192
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200193 model = "Milk-V Mars CM";
Heinrich Schuchardt4487d632024-07-20 01:11:58 +0200194 compat = compat_cm;
195 compat_size = sizeof(compat_cm);
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200196 }
Heinrich Schuchardt4487d632024-07-20 01:11:58 +0200197 fdt_setprop(fdt, fdt_path_offset(fdt, "/"),
198 "compatible", compat, compat_size);
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200199 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model", model);
200}
201
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800202void spl_fdt_fixup_version_a(void *fdt)
203{
Aurelien Jarno5acb7c12024-01-10 21:17:44 +0100204 static const char compat[] = "starfive,visionfive-2-v1.2a\0starfive,jh7110";
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800205 u32 phandle;
206 u8 i;
207 int offset;
208 int ret;
209
Aurelien Jarno5acb7c12024-01-10 21:17:44 +0100210 fdt_setprop(fdt, fdt_path_offset(fdt, "/"), "compatible", compat, sizeof(compat));
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800211 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model",
212 "StarFive VisionFive 2 v1.2A");
213
214 offset = fdt_path_offset(fdt, "/soc/clock-controller@13020000");
215 phandle = fdt_get_phandle(fdt, offset);
216 offset = fdt_path_offset(fdt, "/soc/ethernet@16040000");
217
218 fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
219 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_SYSCLK_GMAC1_TX);
220 fdt_appendprop_u32(fdt, offset, "assigned-clocks", phandle);
221 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_SYSCLK_GMAC1_RX);
222
223 fdt_setprop_u32(fdt, offset, "assigned-clock-parents", phandle);
224 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
225 JH7110_SYSCLK_GMAC1_RMII_RTX);
226 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents", phandle);
227 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
228 JH7110_SYSCLK_GMAC1_RMII_RTX);
229
230 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/soc/ethernet@16040000"),
231 "phy-mode", "rmii");
232
233 for (i = 0; i < ARRAY_SIZE(starfive_vera); i++) {
234 offset = fdt_path_offset(fdt, starfive_vera[i].path);
235
236 if (starfive_vera[i].value)
237 ret = fdt_setprop_u32(fdt, offset, starfive_vera[i].name,
238 dectoul(starfive_vera[i].value, NULL));
239 else
240 ret = fdt_setprop_empty(fdt, offset, starfive_vera[i].name);
241
242 if (ret) {
243 pr_err("%s set prop %s fail.\n", __func__, starfive_vera[i].name);
244 break;
245 }
246 }
247}
248
249void spl_fdt_fixup_version_b(void *fdt)
250{
Aurelien Jarno5acb7c12024-01-10 21:17:44 +0100251 static const char compat[] = "starfive,visionfive-2-v1.3b\0starfive,jh7110";
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800252 u32 phandle;
253 u8 i;
254 int offset;
255 int ret;
256
Aurelien Jarno5acb7c12024-01-10 21:17:44 +0100257 fdt_setprop(fdt, fdt_path_offset(fdt, "/"), "compatible", compat, sizeof(compat));
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800258 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model",
259 "StarFive VisionFive 2 v1.3B");
260
261 /* gmac0 */
262 offset = fdt_path_offset(fdt, "/soc/clock-controller@17000000");
263 phandle = fdt_get_phandle(fdt, offset);
264 offset = fdt_path_offset(fdt, "/soc/ethernet@16030000");
265
266 fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
267 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_AONCLK_GMAC0_TX);
268 fdt_setprop_u32(fdt, offset, "assigned-clock-parents", phandle);
269 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
270 JH7110_AONCLK_GMAC0_RMII_RTX);
271
272 /* gmac1 */
273 offset = fdt_path_offset(fdt, "/soc/clock-controller@13020000");
274 phandle = fdt_get_phandle(fdt, offset);
275 offset = fdt_path_offset(fdt, "/soc/ethernet@16040000");
276
277 fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
278 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_SYSCLK_GMAC1_TX);
279 fdt_setprop_u32(fdt, offset, "assigned-clock-parents", phandle);
280 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
281 JH7110_SYSCLK_GMAC1_RMII_RTX);
282
283 for (i = 0; i < ARRAY_SIZE(starfive_verb); i++) {
284 offset = fdt_path_offset(fdt, starfive_verb[i].path);
285
286 if (starfive_verb[i].value)
287 ret = fdt_setprop_u32(fdt, offset, starfive_verb[i].name,
288 dectoul(starfive_verb[i].value, NULL));
289 else
290 ret = fdt_setprop_empty(fdt, offset, starfive_verb[i].name);
291
292 if (ret) {
293 pr_err("%s set prop %s fail.\n", __func__, starfive_verb[i].name);
294 break;
295 }
296 }
297}
298
H Bell25ce7c92024-05-22 19:12:48 +0000299void spl_fdt_fixup_star64(void *fdt)
300{
301 static const char compat[] = "pine64,star64\0starfive,jh7110";
302 u32 phandle;
303 u8 i;
304 int offset;
305 int ret;
306
307 fdt_setprop(fdt, fdt_path_offset(fdt, "/"), "compatible", compat, sizeof(compat));
308 fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model",
309 "Pine64 Star64");
310
311 /* gmac0 */
312 offset = fdt_path_offset(fdt, "/soc/clock-controller@17000000");
313 phandle = fdt_get_phandle(fdt, offset);
314 offset = fdt_path_offset(fdt, "/soc/ethernet@16030000");
315
316 fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
317 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_AONCLK_GMAC0_TX);
318 fdt_setprop_u32(fdt, offset, "assigned-clock-parents", phandle);
319 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
320 JH7110_AONCLK_GMAC0_RMII_RTX);
321
322 /* gmac1 */
323 offset = fdt_path_offset(fdt, "/soc/clock-controller@13020000");
324 phandle = fdt_get_phandle(fdt, offset);
325 offset = fdt_path_offset(fdt, "/soc/ethernet@16040000");
326
327 fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
328 fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_SYSCLK_GMAC1_TX);
329 fdt_setprop_u32(fdt, offset, "assigned-clock-parents", phandle);
330 fdt_appendprop_u32(fdt, offset, "assigned-clock-parents",
331 JH7110_SYSCLK_GMAC1_RMII_RTX);
332
333 for (i = 0; i < ARRAY_SIZE(star64_pine64); i++) {
334 offset = fdt_path_offset(fdt, star64_pine64[i].path);
335
336 if (star64_pine64[i].value)
337 ret = fdt_setprop_u32(fdt, offset, star64_pine64[i].name,
338 dectoul(star64_pine64[i].value, NULL));
339 else
340 ret = fdt_setprop_empty(fdt, offset, star64_pine64[i].name);
341
342 if (ret) {
343 pr_err("%s set prop %s fail.\n", __func__, star64_pine64[i].name);
344 break;
345 }
346 }
347}
348
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800349void spl_perform_fixups(struct spl_image_info *spl_image)
350{
351 u8 version;
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200352 const char *product_id;
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800353
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200354 product_id = get_product_id_from_eeprom();
355 if (!product_id) {
356 pr_err("Can't read EEPROM\n");
357 return;
358 }
Heinrich Schuchardtadaa12d2024-05-12 06:25:23 +0200359 if (!strncmp(product_id, "MARC", 4)) {
360 spl_fdt_fixup_mars_cm(spl_image->fdt_addr);
361 } else if (!strncmp(product_id, "MARS", 4)) {
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200362 spl_fdt_fixup_mars(spl_image->fdt_addr);
363 } else if (!strncmp(product_id, "VF7110", 6)) {
364 version = get_pcb_revision_from_eeprom();
365 switch (version) {
366 case 'a':
367 case 'A':
368 spl_fdt_fixup_version_a(spl_image->fdt_addr);
369 break;
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800370
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200371 case 'b':
372 case 'B':
373 default:
374 spl_fdt_fixup_version_b(spl_image->fdt_addr);
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800375 break;
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200376 };
H Bell25ce7c92024-05-22 19:12:48 +0000377 } else if (!strncmp(product_id, "STAR64", 6)) {
378 spl_fdt_fixup_star64(spl_image->fdt_addr);
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200379 } else {
380 pr_err("Unknown product %s\n", product_id);
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800381 };
382
Heinrich Schuchardtf8841732024-04-02 10:49:10 +0200383 /* Update the memory size which read from eeprom or DT */
Yanhong Wang4e321fa2023-06-15 17:36:52 +0800384 fdt_fixup_memory(spl_image->fdt_addr, 0x40000000, gd->ram_size);
385}
Chanho Park9ca68c92023-10-31 17:56:00 +0900386
387static void jh7110_jtag_init(void)
388{
389 /* nTRST: GPIO36 */
390 SYS_IOMUX_DOEN(36, HIGH);
391 SYS_IOMUX_DIN(36, 4);
392 /* TDI: GPIO61 */
393 SYS_IOMUX_DOEN(61, HIGH);
394 SYS_IOMUX_DIN(61, 19);
395 /* TMS: GPIO63 */
396 SYS_IOMUX_DOEN(63, HIGH);
397 SYS_IOMUX_DIN(63, 20);
398 /* TCK: GPIO60 */
399 SYS_IOMUX_DOEN(60, HIGH);
400 SYS_IOMUX_DIN(60, 29);
401 /* TDO: GPIO44 */
402 SYS_IOMUX_DOEN(44, 8);
403 SYS_IOMUX_DOUT(44, 22);
404}
405
Yanhong Wang6a5a45d2023-03-29 11:42:17 +0800406int spl_board_init_f(void)
407{
408 int ret;
409
Chanho Park9ca68c92023-10-31 17:56:00 +0900410 jh7110_jtag_init();
411
Lukas Funke2b62dd62024-04-24 09:43:39 +0200412 ret = spl_dram_init();
Yanhong Wang6a5a45d2023-03-29 11:42:17 +0800413 if (ret) {
Lukas Funke2b62dd62024-04-24 09:43:39 +0200414 debug("JH7110 DRAM init failed: %d\n", ret);
Yanhong Wang6a5a45d2023-03-29 11:42:17 +0800415 return ret;
416 }
417
418 return 0;
419}
420
421u32 spl_boot_device(void)
422{
423 u32 mode;
424
425 mode = in_le32(JH7110_BOOT_MODE_SELECT_REG)
426 & JH7110_BOOT_MODE_SELECT_MASK;
427 switch (mode) {
428 case 0:
429 return BOOT_DEVICE_SPI;
430
431 case 1:
432 return BOOT_DEVICE_MMC2;
433
434 case 2:
435 return BOOT_DEVICE_MMC1;
436
437 case 3:
438 return BOOT_DEVICE_UART;
439
440 default:
441 debug("Unsupported boot device 0x%x.\n", mode);
442 return BOOT_DEVICE_NONE;
443 }
444}
445
446void board_init_f(ulong dummy)
447{
448 int ret;
449
450 ret = spl_early_init();
451 if (ret)
452 panic("spl_early_init() failed: %d\n", ret);
453
Simon Glassb8357c12023-08-21 21:16:56 -0600454 riscv_cpu_setup();
Yanhong Wang6a5a45d2023-03-29 11:42:17 +0800455 preloader_console_init();
456
457 /* Set the parent clock of cpu_root clock to pll0,
458 * it must be initialized here
459 */
460 clrsetbits_le32(JH7110_SYS_CRG + JH7110_CLK_CPU_ROOT_OFFSET,
461 JH7110_CLK_CPU_ROOT_MASK,
462 BIT(JH7110_CLK_CPU_ROOT_SHIFT));
463
464 ret = spl_board_init_f();
465 if (ret) {
466 debug("spl_board_init_f init failed: %d\n", ret);
467 return;
468 }
469}
470
471#if CONFIG_IS_ENABLED(SPL_LOAD_FIT)
472int board_fit_config_name_match(const char *name)
473{
474 /* boot using first FIT config */
475 return 0;
476}
477#endif