]> Git Repo - J-u-boot.git/blame - board/sunxi/board.c
sunxi: move #ifdef guards around tzpc_init() to header file
[J-u-boot.git] / board / sunxi / board.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
cba69eee
IC
2/*
3 * (C) Copyright 2012-2013 Henrik Nordstrom <[email protected]>
4 * (C) Copyright 2013 Luke Kenneth Casson Leighton <[email protected]>
5 *
6 * (C) Copyright 2007-2011
7 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
8 * Tom Cubie <[email protected]>
9 *
10 * Some board init for the Allwinner A10-evb board.
cba69eee
IC
11 */
12
13#include <common.h>
2f8a6db5 14#include <clock_legacy.h>
237050fc 15#include <dm.h>
c7694dd4 16#include <env.h>
db41d65a 17#include <hang.h>
4d72caa5 18#include <image.h>
9b4a205f 19#include <init.h>
f7ae49fc 20#include <log.h>
e79c7c88 21#include <mmc.h>
6944aff1 22#include <axp_pmic.h>
237050fc
JT
23#include <generic-phy.h>
24#include <phy-sun4i-usb.h>
cba69eee 25#include <asm/arch/clock.h>
b41d7d05 26#include <asm/arch/cpu.h>
2d7a084b 27#include <asm/arch/display.h>
cba69eee 28#include <asm/arch/dram.h>
e24ea55c 29#include <asm/arch/mmc.h>
8a8b73b6 30#include <asm/arch/prcm.h>
52bcc4f0 31#include <asm/arch/pmic_bus.h>
4a8c7c1f 32#include <asm/arch/spl.h>
e943753d 33#include <asm/arch/sys_proto.h>
401d1c4f 34#include <asm/global_data.h>
c05ed00a 35#include <linux/delay.h>
1e94b46f 36#include <linux/printk.h>
f054f120 37#include <linux/types.h>
d96ebc46
SS
38#ifndef CONFIG_ARM64
39#include <asm/armv7.h>
40#endif
4f7e01c9 41#include <asm/gpio.h>
207ed0a3 42#include <sunxi_gpio.h>
b41d7d05 43#include <asm/io.h>
a740ee91 44#include <u-boot/crc.h>
f3998fdc 45#include <env_internal.h>
b08c8c48 46#include <linux/libfdt.h>
9267ff89 47#include <fdt_support.h>
f62bfa56 48#include <nand.h>
b41d7d05 49#include <net.h>
f4c3523c 50#include <spl.h>
0d8382ae 51#include <sy8106a.h>
5d982856 52#include <asm/setup.h>
8f872bb3 53#include <status_led.h>
cba69eee
IC
54
55DECLARE_GLOBAL_DATA_PTR;
56
acbc7e0a
JS
57void i2c_init_board(void)
58{
59#ifdef CONFIG_I2C0_ENABLE
60#if defined(CONFIG_MACH_SUN4I) || \
61 defined(CONFIG_MACH_SUN5I) || \
62 defined(CONFIG_MACH_SUN7I) || \
63 defined(CONFIG_MACH_SUN8I_R40)
64 sunxi_gpio_set_cfgpin(SUNXI_GPB(0), SUN4I_GPB_TWI0);
65 sunxi_gpio_set_cfgpin(SUNXI_GPB(1), SUN4I_GPB_TWI0);
66 clock_twi_onoff(0, 1);
67#elif defined(CONFIG_MACH_SUN6I)
68 sunxi_gpio_set_cfgpin(SUNXI_GPH(14), SUN6I_GPH_TWI0);
69 sunxi_gpio_set_cfgpin(SUNXI_GPH(15), SUN6I_GPH_TWI0);
70 clock_twi_onoff(0, 1);
8c51c652
IZ
71#elif defined(CONFIG_MACH_SUN8I_V3S)
72 sunxi_gpio_set_cfgpin(SUNXI_GPB(6), SUN8I_V3S_GPB_TWI0);
73 sunxi_gpio_set_cfgpin(SUNXI_GPB(7), SUN8I_V3S_GPB_TWI0);
74 clock_twi_onoff(0, 1);
acbc7e0a
JS
75#elif defined(CONFIG_MACH_SUN8I)
76 sunxi_gpio_set_cfgpin(SUNXI_GPH(2), SUN8I_GPH_TWI0);
77 sunxi_gpio_set_cfgpin(SUNXI_GPH(3), SUN8I_GPH_TWI0);
78 clock_twi_onoff(0, 1);
da1ae590
SM
79#elif defined(CONFIG_MACH_SUN50I)
80 sunxi_gpio_set_cfgpin(SUNXI_GPH(0), SUN50I_GPH_TWI0);
81 sunxi_gpio_set_cfgpin(SUNXI_GPH(1), SUN50I_GPH_TWI0);
82 clock_twi_onoff(0, 1);
acbc7e0a
JS
83#endif
84#endif
85
86#ifdef CONFIG_I2C1_ENABLE
87#if defined(CONFIG_MACH_SUN4I) || \
88 defined(CONFIG_MACH_SUN7I) || \
89 defined(CONFIG_MACH_SUN8I_R40)
90 sunxi_gpio_set_cfgpin(SUNXI_GPB(18), SUN4I_GPB_TWI1);
91 sunxi_gpio_set_cfgpin(SUNXI_GPB(19), SUN4I_GPB_TWI1);
92 clock_twi_onoff(1, 1);
93#elif defined(CONFIG_MACH_SUN5I)
94 sunxi_gpio_set_cfgpin(SUNXI_GPB(15), SUN5I_GPB_TWI1);
95 sunxi_gpio_set_cfgpin(SUNXI_GPB(16), SUN5I_GPB_TWI1);
96 clock_twi_onoff(1, 1);
97#elif defined(CONFIG_MACH_SUN6I)
98 sunxi_gpio_set_cfgpin(SUNXI_GPH(16), SUN6I_GPH_TWI1);
99 sunxi_gpio_set_cfgpin(SUNXI_GPH(17), SUN6I_GPH_TWI1);
100 clock_twi_onoff(1, 1);
101#elif defined(CONFIG_MACH_SUN8I)
102 sunxi_gpio_set_cfgpin(SUNXI_GPH(4), SUN8I_GPH_TWI1);
103 sunxi_gpio_set_cfgpin(SUNXI_GPH(5), SUN8I_GPH_TWI1);
104 clock_twi_onoff(1, 1);
da1ae590
SM
105#elif defined(CONFIG_MACH_SUN50I)
106 sunxi_gpio_set_cfgpin(SUNXI_GPH(2), SUN50I_GPH_TWI1);
107 sunxi_gpio_set_cfgpin(SUNXI_GPH(3), SUN50I_GPH_TWI1);
108 clock_twi_onoff(1, 1);
acbc7e0a
JS
109#endif
110#endif
111
acbc7e0a 112#ifdef CONFIG_R_I2C_ENABLE
31a4ac4d
VK
113#ifdef CONFIG_MACH_SUN50I
114 clock_twi_onoff(5, 1);
115 sunxi_gpio_set_cfgpin(SUNXI_GPL(8), SUN50I_GPL_R_TWI);
116 sunxi_gpio_set_cfgpin(SUNXI_GPL(9), SUN50I_GPL_R_TWI);
d0b07c15
JS
117#elif CONFIG_MACH_SUN50I_H616
118 clock_twi_onoff(5, 1);
119 sunxi_gpio_set_cfgpin(SUNXI_GPL(0), SUN50I_H616_GPL_R_TWI);
120 sunxi_gpio_set_cfgpin(SUNXI_GPL(1), SUN50I_H616_GPL_R_TWI);
31a4ac4d 121#else
acbc7e0a
JS
122 clock_twi_onoff(5, 1);
123 sunxi_gpio_set_cfgpin(SUNXI_GPL(0), SUN8I_H3_GPL_R_TWI);
124 sunxi_gpio_set_cfgpin(SUNXI_GPL(1), SUN8I_H3_GPL_R_TWI);
125#endif
31a4ac4d 126#endif
acbc7e0a
JS
127}
128
e42dad41
AP
129/*
130 * Try to use the environment from the boot source first.
131 * For MMC, this means a FAT partition on the boot device (SD or eMMC).
132 * If the raw MMC environment is also enabled, this is tried next.
e008e513 133 * When booting from NAND we try UBI first, then NAND directly.
e42dad41
AP
134 * SPI flash falls back to FAT (on SD card).
135 */
b39117ca
MR
136enum env_location env_get_location(enum env_operation op, int prio)
137{
e008e513
SH
138 if (prio > 1)
139 return ENVL_UNKNOWN;
e42dad41 140
e008e513
SH
141 /* NOWHERE is exclusive, no other option can be defined. */
142 if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
143 return ENVL_NOWHERE;
e42dad41
AP
144
145 switch (sunxi_get_boot_device()) {
146 case BOOT_DEVICE_MMC1:
147 case BOOT_DEVICE_MMC2:
e008e513
SH
148 if (prio == 0 && IS_ENABLED(CONFIG_ENV_IS_IN_FAT))
149 return ENVL_FAT;
150 if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
151 return ENVL_MMC;
e42dad41
AP
152 break;
153 case BOOT_DEVICE_NAND:
e008e513
SH
154 if (prio == 0 && IS_ENABLED(CONFIG_ENV_IS_IN_UBI))
155 return ENVL_UBI;
e42dad41 156 if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND))
e008e513 157 return ENVL_NAND;
e42dad41
AP
158 break;
159 case BOOT_DEVICE_SPI:
e008e513
SH
160 if (prio == 0 && IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
161 return ENVL_SPI_FLASH;
162 if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT))
163 return ENVL_FAT;
e42dad41
AP
164 break;
165 case BOOT_DEVICE_BOARD:
166 break;
b39117ca 167 default:
e42dad41 168 break;
b39117ca 169 }
e42dad41 170
e008e513
SH
171 /*
172 * If we come here for the first time, we *must* return a valid
173 * environment location other than ENVL_UNKNOWN, or the setup sequence
174 * in board_f() will silently hang. This is arguably a bug in
175 * env_init(), but for now pick one environment for which we know for
176 * sure to have a driver for. For all defconfigs this is either FAT
177 * or UBI, or NOWHERE, which is already handled above.
178 */
179 if (prio == 0) {
180 if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT))
e42dad41 181 return ENVL_FAT;
e008e513
SH
182 if (IS_ENABLED(CONFIG_ENV_IS_IN_UBI))
183 return ENVL_UBI;
e42dad41
AP
184 }
185
186 return ENVL_UNKNOWN;
b39117ca 187}
b39117ca 188
cba69eee
IC
189/* add board specific code here */
190int board_init(void)
191{
5ad98c57 192 __maybe_unused int id_pfr1, ret;
cba69eee
IC
193
194 gd->bd->bi_boot_params = (PHYS_SDRAM_0 + 0x100);
195
116e1ed1 196#if !defined(CONFIG_ARM64) && !defined(CONFIG_MACH_SUNIV)
cba69eee
IC
197 asm volatile("mrc p15, 0, %0, c0, c1, 1" : "=r"(id_pfr1));
198 debug("id_pfr1: 0x%08x\n", id_pfr1);
199 /* Generic Timer Extension available? */
d96ebc46
SS
200 if ((id_pfr1 >> CPUID_ARM_GENTIMER_SHIFT) & 0xf) {
201 uint32_t freq;
202
cba69eee 203 debug("Setting CNTFRQ\n");
d96ebc46
SS
204
205 /*
206 * CNTFRQ is a secure register, so we will crash if we try to
207 * write this from the non-secure world (read is OK, though).
208 * In case some bootcode has already set the correct value,
209 * we avoid the risk of writing to it.
210 */
211 asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r"(freq));
151a0300 212 if (freq != CONFIG_COUNTER_FREQUENCY) {
d96ebc46 213 debug("arch timer frequency is %d Hz, should be %d, fixing ...\n",
151a0300 214 freq, CONFIG_COUNTER_FREQUENCY);
d96ebc46
SS
215#ifdef CONFIG_NON_SECURE
216 printf("arch timer frequency is wrong, but cannot adjust it\n");
217#else
218 asm volatile("mcr p15, 0, %0, c14, c0, 0"
151a0300 219 : : "r"(CONFIG_COUNTER_FREQUENCY));
d96ebc46
SS
220#endif
221 }
cba69eee 222 }
116e1ed1 223#endif /* !CONFIG_ARM64 && !CONFIG_MACH_SUNIV */
cba69eee 224
2fcf033d
HG
225 ret = axp_gpio_init();
226 if (ret)
227 return ret;
228
2147a169 229#if CONFIG_IS_ENABLED(DM_I2C)
a8f01ccf
JS
230 /*
231 * Temporary workaround for enabling I2C clocks until proper sunxi DM
232 * clk, reset and pinctrl drivers land.
233 */
234 i2c_init_board();
235#endif
e943753d
AP
236 eth_init_board();
237
2421497c 238 return 0;
cba69eee
IC
239}
240
cff5c138
AP
241/*
242 * On older SoCs the SPL is actually at address zero, so using NULL as
243 * an error value does not work.
244 */
245#define INVALID_SPL_HEADER ((void *)~0UL)
246
247static struct boot_file_head * get_spl_header(uint8_t req_version)
248{
249 struct boot_file_head *spl = (void *)(ulong)SPL_ADDR;
250 uint8_t spl_header_version = spl->spl_signature[3];
251
252 /* Is there really the SPL header (still) there? */
253 if (memcmp(spl->spl_signature, SPL_SIGNATURE, 3) != 0)
254 return INVALID_SPL_HEADER;
255
256 if (spl_header_version < req_version) {
257 printf("sunxi SPL version mismatch: expected %u, got %u\n",
258 req_version, spl_header_version);
259 return INVALID_SPL_HEADER;
260 }
261
262 return spl;
263}
264
467b7e52
SH
265static const char *get_spl_dt_name(void)
266{
267 struct boot_file_head *spl = get_spl_header(SPL_DT_HEADER_VERSION);
268
269 /* Check if there is a DT name stored in the SPL header. */
270 if (spl != INVALID_SPL_HEADER && spl->dt_name_offset)
271 return (char *)spl + spl->dt_name_offset;
272
273 return NULL;
274}
467b7e52 275
cba69eee
IC
276int dram_init(void)
277{
5776610e
AP
278 struct boot_file_head *spl = get_spl_header(SPL_DRAM_HEADER_VERSION);
279
280 if (spl == INVALID_SPL_HEADER)
281 gd->ram_size = get_ram_size((long *)PHYS_SDRAM_0,
282 PHYS_SDRAM_0_SIZE);
283 else
284 gd->ram_size = (phys_addr_t)spl->dram_size << 20;
285
286 if (gd->ram_size > CONFIG_SUNXI_DRAM_MAX_SIZE)
287 gd->ram_size = CONFIG_SUNXI_DRAM_MAX_SIZE;
cba69eee
IC
288
289 return 0;
290}
291
21b790fd 292#if defined(CONFIG_NAND_SUNXI) && defined(CONFIG_SPL_BUILD)
ad008299
KG
293static void nand_pinmux_setup(void)
294{
295 unsigned int pin;
ad008299 296
022a99d8 297 for (pin = SUNXI_GPC(0); pin <= SUNXI_GPC(19); pin++)
ad008299
KG
298 sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_NAND);
299
022a99d8
HG
300#if defined CONFIG_MACH_SUN4I || defined CONFIG_MACH_SUN7I
301 for (pin = SUNXI_GPC(20); pin <= SUNXI_GPC(22); pin++)
302 sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_NAND);
303#endif
304 /* sun4i / sun7i do have a PC23, but it is not used for nand,
305 * only sun7i has a PC24 */
306#ifdef CONFIG_MACH_SUN7I
ad008299 307 sunxi_gpio_set_cfgpin(SUNXI_GPC(24), SUNXI_GPC_NAND);
022a99d8 308#endif
ad008299
KG
309}
310
311static void nand_clock_setup(void)
312{
313 struct sunxi_ccm_reg *const ccm =
314 (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
31c21471 315
ad008299 316 setbits_le32(&ccm->ahb_gate0, (CLK_GATE_OPEN << AHB_GATE_OFFSET_NAND0));
ba1c98ba
MR
317#if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I || \
318 defined CONFIG_MACH_SUN9I || defined CONFIG_MACH_SUN50I
319 setbits_le32(&ccm->ahb_reset0_cfg, (1 << AHB_GATE_OFFSET_NAND0));
31c21471 320#endif
ad008299
KG
321 setbits_le32(&ccm->nand0_clk_cfg, CCM_NAND_CTRL_ENABLE | AHB_DIV_1);
322}
f62bfa56
HG
323
324void board_nand_init(void)
325{
326 nand_pinmux_setup();
327 nand_clock_setup();
328}
64531496 329#endif /* CONFIG_NAND_SUNXI */
ad008299 330
4aa2ba3a 331#ifdef CONFIG_MMC
e24ea55c
IC
332static void mmc_pinmux_setup(int sdc)
333{
334 unsigned int pin;
335
336 switch (sdc) {
337 case 0:
8deacca9 338 /* SDC0: PF0-PF5 */
e24ea55c 339 for (pin = SUNXI_GPF(0); pin <= SUNXI_GPF(5); pin++) {
487b3277 340 sunxi_gpio_set_cfgpin(pin, SUNXI_GPF_SDC0);
e24ea55c
IC
341 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
342 sunxi_gpio_set_drv(pin, 2);
343 }
344 break;
345
346 case 1:
8094a4a2
CYT
347#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I) || \
348 defined(CONFIG_MACH_SUN8I_R40)
dda9fa73 349 if (IS_ENABLED(CONFIG_MMC1_PINS_PH)) {
8deacca9
PK
350 /* SDC1: PH22-PH-27 */
351 for (pin = SUNXI_GPH(22); pin <= SUNXI_GPH(27); pin++) {
352 sunxi_gpio_set_cfgpin(pin, SUN4I_GPH_SDC1);
353 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
354 sunxi_gpio_set_drv(pin, 2);
355 }
356 } else {
357 /* SDC1: PG0-PG5 */
358 for (pin = SUNXI_GPG(0); pin <= SUNXI_GPG(5); pin++) {
359 sunxi_gpio_set_cfgpin(pin, SUN4I_GPG_SDC1);
360 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
361 sunxi_gpio_set_drv(pin, 2);
362 }
363 }
364#elif defined(CONFIG_MACH_SUN5I)
365 /* SDC1: PG3-PG8 */
bbff84b3 366 for (pin = SUNXI_GPG(3); pin <= SUNXI_GPG(8); pin++) {
487b3277 367 sunxi_gpio_set_cfgpin(pin, SUN5I_GPG_SDC1);
e24ea55c
IC
368 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
369 sunxi_gpio_set_drv(pin, 2);
370 }
8deacca9
PK
371#elif defined(CONFIG_MACH_SUN6I)
372 /* SDC1: PG0-PG5 */
373 for (pin = SUNXI_GPG(0); pin <= SUNXI_GPG(5); pin++) {
374 sunxi_gpio_set_cfgpin(pin, SUN6I_GPG_SDC1);
375 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
376 sunxi_gpio_set_drv(pin, 2);
377 }
378#elif defined(CONFIG_MACH_SUN8I)
dda9fa73
SH
379 /* SDC1: PG0-PG5 */
380 for (pin = SUNXI_GPG(0); pin <= SUNXI_GPG(5); pin++) {
381 sunxi_gpio_set_cfgpin(pin, SUN8I_GPG_SDC1);
382 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
383 sunxi_gpio_set_drv(pin, 2);
8deacca9
PK
384 }
385#endif
e24ea55c
IC
386 break;
387
388 case 2:
8deacca9
PK
389#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I)
390 /* SDC2: PC6-PC11 */
e24ea55c 391 for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(11); pin++) {
487b3277 392 sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
e24ea55c
IC
393 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
394 sunxi_gpio_set_drv(pin, 2);
395 }
8deacca9 396#elif defined(CONFIG_MACH_SUN5I)
dda9fa73
SH
397 /* SDC2: PC6-PC15 */
398 for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(15); pin++) {
399 sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
400 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
401 sunxi_gpio_set_drv(pin, 2);
8deacca9
PK
402 }
403#elif defined(CONFIG_MACH_SUN6I)
dda9fa73
SH
404 /* SDC2: PC6-PC15, PC24 */
405 for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(15); pin++) {
406 sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
407 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
408 sunxi_gpio_set_drv(pin, 2);
8deacca9 409 }
dda9fa73
SH
410
411 sunxi_gpio_set_cfgpin(SUNXI_GPC(24), SUNXI_GPC_SDC2);
412 sunxi_gpio_set_pull(SUNXI_GPC(24), SUNXI_GPIO_PULL_UP);
413 sunxi_gpio_set_drv(SUNXI_GPC(24), 2);
8094a4a2
CYT
414#elif defined(CONFIG_MACH_SUN8I_R40)
415 /* SDC2: PC6-PC15, PC24 */
416 for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(15); pin++) {
417 sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
418 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
419 sunxi_gpio_set_drv(pin, 2);
420 }
421
422 sunxi_gpio_set_cfgpin(SUNXI_GPC(24), SUNXI_GPC_SDC2);
423 sunxi_gpio_set_pull(SUNXI_GPC(24), SUNXI_GPIO_PULL_UP);
424 sunxi_gpio_set_drv(SUNXI_GPC(24), 2);
d96ebc46 425#elif defined(CONFIG_MACH_SUN8I) || defined(CONFIG_MACH_SUN50I)
8deacca9
PK
426 /* SDC2: PC5-PC6, PC8-PC16 */
427 for (pin = SUNXI_GPC(5); pin <= SUNXI_GPC(6); pin++) {
428 sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
429 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
430 sunxi_gpio_set_drv(pin, 2);
431 }
432
433 for (pin = SUNXI_GPC(8); pin <= SUNXI_GPC(16); pin++) {
434 sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
435 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
436 sunxi_gpio_set_drv(pin, 2);
42956f1b
IZ
437 }
438#elif defined(CONFIG_MACH_SUN50I_H6)
439 /* SDC2: PC4-PC14 */
440 for (pin = SUNXI_GPC(4); pin <= SUNXI_GPC(14); pin++) {
441 sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
442 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
443 sunxi_gpio_set_drv(pin, 2);
8deacca9 444 }
212224ed
AP
445#elif defined(CONFIG_MACH_SUN50I_H616)
446 /* SDC2: PC0-PC1, PC5-PC6, PC8-PC11, PC13-PC16 */
447 for (pin = SUNXI_GPC(0); pin <= SUNXI_GPC(16); pin++) {
448 if (pin > SUNXI_GPC(1) && pin < SUNXI_GPC(5))
449 continue;
450 if (pin == SUNXI_GPC(7) || pin == SUNXI_GPC(12))
451 continue;
452 sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
453 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
454 sunxi_gpio_set_drv(pin, 3);
455 }
3ebb4567
PT
456#elif defined(CONFIG_MACH_SUN9I)
457 /* SDC2: PC6-PC16 */
458 for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(16); pin++) {
459 sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
460 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
461 sunxi_gpio_set_drv(pin, 2);
462 }
5b7c58fb
OS
463#elif defined(CONFIG_MACH_SUN8I_R528)
464 /* SDC2: PC2-PC7 */
465 for (pin = SUNXI_GPC(2); pin <= SUNXI_GPC(7); pin++) {
466 sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
467 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
468 sunxi_gpio_set_drv(pin, 2);
469 }
212224ed
AP
470#else
471 puts("ERROR: No pinmux setup defined for MMC2!\n");
8deacca9 472#endif
e24ea55c
IC
473 break;
474
475 case 3:
8094a4a2
CYT
476#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I) || \
477 defined(CONFIG_MACH_SUN8I_R40)
8deacca9 478 /* SDC3: PI4-PI9 */
e24ea55c 479 for (pin = SUNXI_GPI(4); pin <= SUNXI_GPI(9); pin++) {
8deacca9 480 sunxi_gpio_set_cfgpin(pin, SUNXI_GPI_SDC3);
e24ea55c
IC
481 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
482 sunxi_gpio_set_drv(pin, 2);
483 }
8deacca9 484#elif defined(CONFIG_MACH_SUN6I)
dda9fa73
SH
485 /* SDC3: PC6-PC15, PC24 */
486 for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(15); pin++) {
487 sunxi_gpio_set_cfgpin(pin, SUN6I_GPC_SDC3);
488 sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
489 sunxi_gpio_set_drv(pin, 2);
8deacca9 490 }
dda9fa73
SH
491
492 sunxi_gpio_set_cfgpin(SUNXI_GPC(24), SUN6I_GPC_SDC3);
493 sunxi_gpio_set_pull(SUNXI_GPC(24), SUNXI_GPIO_PULL_UP);
494 sunxi_gpio_set_drv(SUNXI_GPC(24), 2);
8deacca9 495#endif
e24ea55c
IC
496 break;
497
498 default:
499 printf("sunxi: invalid MMC slot %d for pinmux setup\n", sdc);
500 break;
501 }
502}
503
b75d8dc5 504int board_mmc_init(struct bd_info *bis)
e24ea55c 505{
ed82586c
AP
506 /*
507 * The BROM always accesses MMC port 0 (typically an SD card), and
508 * most boards seem to have such a slot. The others haven't reported
509 * any problem with unconditionally enabling this in the SPL.
510 */
3ba0a25c 511 if (!IS_ENABLED(CONFIG_UART0_PORT_F)) {
ed82586c
AP
512 mmc_pinmux_setup(0);
513 if (!sunxi_mmc_init(0))
3ba0a25c
SH
514 return -1;
515 }
e79c7c88 516
3ba0a25c
SH
517 if (CONFIG_MMC_SUNXI_SLOT_EXTRA != -1) {
518 mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);
519 if (!sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA))
520 return -1;
521 }
e79c7c88 522
e24ea55c
IC
523 return 0;
524}
1011ebc7
SH
525
526#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
527int mmc_get_env_dev(void)
528{
529 switch (sunxi_get_boot_device()) {
530 case BOOT_DEVICE_MMC1:
531 return 0;
532 case BOOT_DEVICE_MMC2:
533 return 1;
534 default:
535 return CONFIG_SYS_MMC_ENV_DEV;
536 }
537}
538#endif
64531496 539#endif /* CONFIG_MMC */
e24ea55c 540
cba69eee 541#ifdef CONFIG_SPL_BUILD
5776610e
AP
542
543static void sunxi_spl_store_dram_size(phys_addr_t dram_size)
544{
545 struct boot_file_head *spl = get_spl_header(SPL_DT_HEADER_VERSION);
546
547 if (spl == INVALID_SPL_HEADER)
548 return;
549
550 /* Promote the header version for U-Boot proper, if needed. */
551 if (spl->spl_signature[3] < SPL_DRAM_HEADER_VERSION)
552 spl->spl_signature[3] = SPL_DRAM_HEADER_VERSION;
553
554 spl->dram_size = dram_size >> 20;
555}
556
cba69eee
IC
557void sunxi_board_init(void)
558{
14bc66bd 559 int power_failed = 0;
cba69eee 560
8f872bb3
AF
561#ifdef CONFIG_LED_STATUS
562 if (IS_ENABLED(CONFIG_SPL_DRIVERS_MISC))
563 status_led_init();
564#endif
565
0d8382ae
JW
566#ifdef CONFIG_SY8106A_POWER
567 power_failed = sy8106a_set_vout1(CONFIG_SY8106A_VOUT1_VOLT);
568#endif
569
95ab8fee 570#if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \
fbd37d8d 571 defined CONFIG_AXP221_POWER || defined CONFIG_AXP305_POWER || \
d17d051c
AP
572 defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER || \
573 defined CONFIG_AXP313_POWER
6944aff1
HG
574 power_failed = axp_init();
575
52bcc4f0
CM
576 if (IS_ENABLED(CONFIG_AXP_DISABLE_BOOT_ON_POWERON) && !power_failed) {
577 u8 boot_reason;
578
579 pmic_bus_read(AXP_POWER_STATUS, &boot_reason);
580 if (boot_reason & AXP_POWER_STATUS_ALDO_IN) {
581 printf("Power on by plug-in, shutting down.\n");
582 pmic_bus_write(0x32, BIT(7));
583 }
584 }
585
ffb02942 586#ifdef CONFIG_AXP_DCDC1_VOLT
6944aff1 587 power_failed |= axp_set_dcdc1(CONFIG_AXP_DCDC1_VOLT);
ffb02942 588 power_failed |= axp_set_dcdc5(CONFIG_AXP_DCDC5_VOLT);
24289208 589#endif
ffb02942 590#ifdef CONFIG_AXP_DCDC2_VOLT
6944aff1
HG
591 power_failed |= axp_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
592 power_failed |= axp_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
fbd37d8d 593#endif
ffb02942 594#ifdef CONFIG_AXP_DCDC4_VOLT
6944aff1 595 power_failed |= axp_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
5c7f10fd 596#endif
14bc66bd 597
ffb02942 598#ifdef CONFIG_AXP_ALDO1_VOLT
6944aff1
HG
599 power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
600#endif
ffb02942 601#ifdef CONFIG_AXP_ALDO2_VOLT
6944aff1 602 power_failed |= axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
fbd37d8d 603#endif
ffb02942 604#ifdef CONFIG_AXP_ALDO3_VOLT
6944aff1
HG
605 power_failed |= axp_set_aldo3(CONFIG_AXP_ALDO3_VOLT);
606#endif
ffb02942 607#ifdef CONFIG_AXP_ALDO4_VOLT
6944aff1
HG
608 power_failed |= axp_set_aldo4(CONFIG_AXP_ALDO4_VOLT);
609#endif
610
ffb02942 611#ifdef CONFIG_AXP_DLDO1_VOLT
3517a27d
CYT
612 power_failed |= axp_set_dldo(1, CONFIG_AXP_DLDO1_VOLT);
613 power_failed |= axp_set_dldo(2, CONFIG_AXP_DLDO2_VOLT);
ffb02942
AP
614#endif
615#ifdef CONFIG_AXP_DLDO3_VOLT
3517a27d
CYT
616 power_failed |= axp_set_dldo(3, CONFIG_AXP_DLDO3_VOLT);
617 power_failed |= axp_set_dldo(4, CONFIG_AXP_DLDO4_VOLT);
795857df 618#endif
ffb02942 619#ifdef CONFIG_AXP_ELDO1_VOLT
6944aff1
HG
620 power_failed |= axp_set_eldo(1, CONFIG_AXP_ELDO1_VOLT);
621 power_failed |= axp_set_eldo(2, CONFIG_AXP_ELDO2_VOLT);
622 power_failed |= axp_set_eldo(3, CONFIG_AXP_ELDO3_VOLT);
623#endif
38491d9c 624
ffb02942 625#ifdef CONFIG_AXP_FLDO1_VOLT
38491d9c
CYT
626 power_failed |= axp_set_fldo(1, CONFIG_AXP_FLDO1_VOLT);
627 power_failed |= axp_set_fldo(2, CONFIG_AXP_FLDO2_VOLT);
628 power_failed |= axp_set_fldo(3, CONFIG_AXP_FLDO3_VOLT);
795857df
CYT
629#endif
630
631#if defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
15278ccb 632 power_failed |= axp_set_sw(IS_ENABLED(CONFIG_AXP_SW_ON));
38491d9c 633#endif
ffb02942 634#endif /* CONFIG_AXPxxx_POWER */
44c214dc
FKP
635 printf("DRAM:");
636 gd->ram_size = sunxi_dram_init();
637 printf(" %d MiB\n", (int)(gd->ram_size >> 20));
638 if (!gd->ram_size)
639 hang();
640
641 sunxi_spl_store_dram_size(gd->ram_size);
5776610e 642
14bc66bd
HN
643 /*
644 * Only clock up the CPU to full speed if we are reasonably
645 * assured it's being powered with suitable core voltage
646 */
647 if (!power_failed)
2f8a6db5 648 clock_set_pll1(get_board_sys_clk());
14bc66bd 649 else
44c214dc 650 printf("Failed to set core voltage! Can't set CPU frequency\n");
cba69eee 651}
64531496 652#endif /* CONFIG_SPL_BUILD */
b41d7d05 653
f1df758d
PK
654#ifdef CONFIG_USB_GADGET
655int g_dnl_board_usb_cable_connected(void)
656{
237050fc
JT
657 struct udevice *dev;
658 struct phy phy;
659 int ret;
660
01311624 661 ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, 0, &dev);
237050fc
JT
662 if (ret) {
663 pr_err("%s: Cannot find USB device\n", __func__);
664 return ret;
665 }
666
667 ret = generic_phy_get_by_name(dev, "usb", &phy);
668 if (ret) {
669 pr_err("failed to get %s USB PHY\n", dev->name);
670 return ret;
671 }
672
673 ret = generic_phy_init(&phy);
674 if (ret) {
f286e37c 675 pr_debug("failed to init %s USB PHY\n", dev->name);
237050fc
JT
676 return ret;
677 }
678
fbd9207e 679 return sun4i_usb_phy_vbus_detect(&phy);
f1df758d 680}
64531496 681#endif /* CONFIG_USB_GADGET */
f1df758d 682
9f852211
PK
683#ifdef CONFIG_SERIAL_TAG
684void get_board_serial(struct tag_serialnr *serialnr)
685{
686 char *serial_string;
687 unsigned long long serial;
688
00caae6d 689 serial_string = env_get("serial#");
9f852211
PK
690
691 if (serial_string) {
692 serial = simple_strtoull(serial_string, NULL, 16);
693
694 serialnr->high = (unsigned int) (serial >> 32);
695 serialnr->low = (unsigned int) (serial & 0xffffffff);
696 } else {
697 serialnr->high = 0;
698 serialnr->low = 0;
699 }
700}
701#endif
702
af654d14
BN
703/*
704 * Check the SPL header for the "sunxi" variant. If found: parse values
705 * that might have been passed by the loader ("fel" utility), and update
706 * the environment accordingly.
707 */
708static void parse_spl_header(const uint32_t spl_addr)
709{
cff5c138 710 struct boot_file_head *spl = get_spl_header(SPL_ENV_HEADER_VERSION);
320e0570 711
cff5c138 712 if (spl == INVALID_SPL_HEADER)
320e0570 713 return;
cff5c138 714
320e0570
BN
715 if (!spl->fel_script_address)
716 return;
717
718 if (spl->fel_uEnv_length != 0) {
719 /*
720 * data is expected in uEnv.txt compatible format, so "env
721 * import -t" the string(s) at fel_script_address right away.
722 */
5a74a391 723 himport_r(&env_htab, (char *)(uintptr_t)spl->fel_script_address,
320e0570
BN
724 spl->fel_uEnv_length, '\n', H_NOCLEAR, 0, 0, NULL);
725 return;
af654d14 726 }
320e0570 727 /* otherwise assume .scr format (mkimage-type script) */
018f5303 728 env_set_hex("fel_scriptaddr", spl->fel_script_address);
af654d14 729}
af654d14 730
928f4f48
AH
731static bool get_unique_sid(unsigned int *sid)
732{
733 if (sunxi_get_sid(sid) != 0)
734 return false;
735
736 if (!sid[0])
737 return false;
738
739 /*
740 * The single words 1 - 3 of the SID have quite a few bits
741 * which are the same on many models, so we take a crc32
742 * of all 3 words, to get a more unique value.
743 *
744 * Note we only do this on newer SoCs as we cannot change
745 * the algorithm on older SoCs since those have been using
746 * fixed mac-addresses based on only using word 3 for a
747 * long time and changing a fixed mac-address with an
748 * u-boot update is not good.
749 */
750#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \
751 !defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \
752 !defined(CONFIG_MACH_SUN8I_A23) && !defined(CONFIG_MACH_SUN8I_A33)
753 sid[3] = crc32(0, (unsigned char *)&sid[1], 12);
754#endif
755
756 /* Ensure the NIC specific bytes of the mac are not all 0 */
757 if ((sid[3] & 0xffffff) == 0)
758 sid[3] |= 0x800000;
759
760 return true;
761}
762
f221961e
HG
763/*
764 * Note this function gets called multiple times.
765 * It must not make any changes to env variables which already exist.
766 */
767static void setup_environment(const void *fdt)
b41d7d05 768{
8c816573 769 char serial_string[17] = { 0 };
cac5b1cc 770 unsigned int sid[4];
8c816573 771 uint8_t mac_addr[6];
f221961e 772 char ethaddr[16];
928f4f48 773 int i;
3f8ea3b0 774
928f4f48
AH
775 if (!get_unique_sid(sid))
776 return;
97322c3e 777
928f4f48
AH
778 for (i = 0; i < 4; i++) {
779 sprintf(ethaddr, "ethernet%d", i);
780 if (!fdt_get_alias(fdt, ethaddr))
781 continue;
f221961e 782
928f4f48
AH
783 if (i == 0)
784 strcpy(ethaddr, "ethaddr");
785 else
786 sprintf(ethaddr, "eth%daddr", i);
f221961e 787
928f4f48
AH
788 if (env_get(ethaddr))
789 continue;
f221961e 790
928f4f48
AH
791 /* Non OUI / registered MAC address */
792 mac_addr[0] = (i << 4) | 0x02;
793 mac_addr[1] = (sid[0] >> 0) & 0xff;
794 mac_addr[2] = (sid[3] >> 24) & 0xff;
795 mac_addr[3] = (sid[3] >> 16) & 0xff;
796 mac_addr[4] = (sid[3] >> 8) & 0xff;
797 mac_addr[5] = (sid[3] >> 0) & 0xff;
8c816573 798
928f4f48
AH
799 eth_env_set_enetaddr(ethaddr, mac_addr);
800 }
b41d7d05 801
928f4f48
AH
802 if (!env_get("serial#")) {
803 snprintf(serial_string, sizeof(serial_string),
804 "%08x%08x", sid[0], sid[3]);
b41d7d05 805
928f4f48 806 env_set("serial#", serial_string);
b41d7d05 807 }
f221961e
HG
808}
809
f221961e
HG
810int misc_init_r(void)
811{
20f3ee31 812 const char *spl_dt_name;
f4c3523c 813 uint boot;
f221961e 814
382bee57
SG
815 env_set("fel_booted", NULL);
816 env_set("fel_scriptaddr", NULL);
de86fc38 817 env_set("mmc_bootdev", NULL);
f4c3523c
MR
818
819 boot = sunxi_get_boot_device();
f221961e 820 /* determine if we are running in FEL mode */
f4c3523c 821 if (boot == BOOT_DEVICE_BOARD) {
382bee57 822 env_set("fel_booted", "1");
f221961e 823 parse_spl_header(SPL_ADDR);
de86fc38
MR
824 /* or if we booted from MMC, and which one */
825 } else if (boot == BOOT_DEVICE_MMC1) {
826 env_set("mmc_bootdev", "0");
827 } else if (boot == BOOT_DEVICE_MMC2) {
828 env_set("mmc_bootdev", "1");
f221961e 829 }
f221961e 830
20f3ee31
SH
831 /* Set fdtfile to match the FIT configuration chosen in SPL. */
832 spl_dt_name = get_spl_dt_name();
833 if (spl_dt_name) {
834 char *prefix = IS_ENABLED(CONFIG_ARM64) ? "allwinner/" : "";
835 char str[64];
836
837 snprintf(str, sizeof(str), "%s%s.dtb", prefix, spl_dt_name);
838 env_set("fdtfile", str);
839 }
840
f221961e 841 setup_environment(gd->fdt_blob);
b41d7d05 842
92600edb
AS
843 return 0;
844}
845
846int board_late_init(void)
847{
e6ee85a6 848#ifdef CONFIG_USB_ETHER
90dd2f19 849 usb_ether_init();
e6ee85a6 850#endif
90dd2f19 851
b41d7d05
JL
852 return 0;
853}
2d7a084b 854
9267ff89
AH
855static void bluetooth_dt_fixup(void *blob)
856{
857 /* Some devices ship with a Bluetooth controller default address.
858 * Set a valid address through the device tree.
859 */
860 uchar tmp[ETH_ALEN], bdaddr[ETH_ALEN];
861 unsigned int sid[4];
862 int i;
863
864 if (!CONFIG_BLUETOOTH_DT_DEVICE_FIXUP[0])
865 return;
866
867 if (eth_env_get_enetaddr("bdaddr", tmp)) {
868 /* Convert between the binary formats of the corresponding stacks */
869 for (i = 0; i < ETH_ALEN; ++i)
870 bdaddr[i] = tmp[ETH_ALEN - i - 1];
871 } else {
872 if (!get_unique_sid(sid))
873 return;
874
875 bdaddr[0] = ((sid[3] >> 0) & 0xff) ^ 1;
876 bdaddr[1] = (sid[3] >> 8) & 0xff;
877 bdaddr[2] = (sid[3] >> 16) & 0xff;
878 bdaddr[3] = (sid[3] >> 24) & 0xff;
879 bdaddr[4] = (sid[0] >> 0) & 0xff;
880 bdaddr[5] = 0x02;
881 }
882
883 do_fixup_by_compat(blob, CONFIG_BLUETOOTH_DT_DEVICE_FIXUP,
884 "local-bd-address", bdaddr, ETH_ALEN, 1);
885}
886
b75d8dc5 887int ft_board_setup(void *blob, struct bd_info *bd)
2d7a084b 888{
d75111a7
HG
889 int __maybe_unused r;
890
f221961e 891 /*
2753b072
IZ
892 * Call setup_environment and fdt_fixup_ethernet again
893 * in case the boot fdt has ethernet aliases the u-boot
894 * copy does not have.
f221961e
HG
895 */
896 setup_environment(blob);
2753b072 897 fdt_fixup_ethernet(blob);
f221961e 898
9267ff89
AH
899 bluetooth_dt_fixup(blob);
900
2d7a084b 901#ifdef CONFIG_VIDEO_DT_SIMPLEFB
d75111a7
HG
902 r = sunxi_simplefb_setup(blob);
903 if (r)
904 return r;
2d7a084b 905#endif
d75111a7 906 return 0;
2d7a084b 907}
9ea3c35a
AP
908
909#ifdef CONFIG_SPL_LOAD_FIT
41530cf6
SH
910static void set_spl_dt_name(const char *name)
911{
912 struct boot_file_head *spl = get_spl_header(SPL_ENV_HEADER_VERSION);
913
914 if (spl == INVALID_SPL_HEADER)
915 return;
916
917 /* Promote the header version for U-Boot proper, if needed. */
918 if (spl->spl_signature[3] < SPL_DT_HEADER_VERSION)
919 spl->spl_signature[3] = SPL_DT_HEADER_VERSION;
920
921 strcpy((char *)&spl->string_pool, name);
922 spl->dt_name_offset = offsetof(struct boot_file_head, string_pool);
923}
924
9ea3c35a
AP
925int board_fit_config_name_match(const char *name)
926{
467b7e52 927 const char *best_dt_name = get_spl_dt_name();
41530cf6 928 int ret;
9ea3c35a
AP
929
930#ifdef CONFIG_DEFAULT_DEVICE_TREE
467b7e52 931 if (best_dt_name == NULL)
2fcd7489 932 best_dt_name = CONFIG_DEFAULT_DEVICE_TREE;
9ea3c35a
AP
933#endif
934
467b7e52
SH
935 if (best_dt_name == NULL) {
936 /* No DT name was provided, so accept the first config. */
937 return 0;
938 }
c6c2c85e 939#ifdef CONFIG_PINE64_DT_SELECTION
54ac5aa1
SH
940 if (strstr(best_dt_name, "-pine64-plus")) {
941 /* Differentiate the Pine A64 boards by their DRAM size. */
f054f120 942 if (gd->ram_size == SZ_512M)
54ac5aa1 943 best_dt_name = "sun50i-a64-pine64";
9ea3c35a 944 }
c6c2c85e 945#endif
8a8b73b6
SH
946#ifdef CONFIG_PINEPHONE_DT_SELECTION
947 if (strstr(best_dt_name, "-pinephone")) {
948 /* Differentiate the PinePhone revisions by GPIO inputs. */
949 prcm_apb0_enable(PRCM_APB0_GATE_PIO);
950 sunxi_gpio_set_pull(SUNXI_GPL(6), SUNXI_GPIO_PULL_UP);
951 sunxi_gpio_set_cfgpin(SUNXI_GPL(6), SUNXI_GPIO_INPUT);
952 udelay(100);
953
954 /* PL6 is pulled low by the modem on v1.2. */
955 if (gpio_get_value(SUNXI_GPL(6)) == 0)
956 best_dt_name = "sun50i-a64-pinephone-1.2";
957 else
958 best_dt_name = "sun50i-a64-pinephone-1.1";
959
960 sunxi_gpio_set_cfgpin(SUNXI_GPL(6), SUNXI_GPIO_DISABLE);
961 sunxi_gpio_set_pull(SUNXI_GPL(6), SUNXI_GPIO_PULL_DISABLE);
962 prcm_apb0_disable(PRCM_APB0_GATE_PIO);
963 }
964#endif
965
41530cf6
SH
966 ret = strcmp(name, best_dt_name);
967
968 /*
969 * If one of the FIT configurations matches the most accurate DT name,
970 * update the SPL header to provide that DT name to U-Boot proper.
971 */
972 if (ret == 0)
973 set_spl_dt_name(best_dt_name);
974
975 return ret;
9ea3c35a 976}
64531496 977#endif /* CONFIG_SPL_LOAD_FIT */
This page took 0.899196 seconds and 4 git commands to generate.