1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
13 #include <asm/cache.h>
15 #include <asm/arch/sys_proto.h>
16 #include <linux/libfdt.h>
18 u32 spl_boot_device(void)
22 boot_mode = get_bootmode();
26 case BOOT_FLASH_EMMC_1:
27 return BOOT_DEVICE_MMC1;
29 case BOOT_FLASH_EMMC_2:
30 return BOOT_DEVICE_MMC2;
31 case BOOT_SERIAL_UART_1:
32 case BOOT_SERIAL_UART_2:
33 case BOOT_SERIAL_UART_3:
34 case BOOT_SERIAL_UART_4:
35 case BOOT_SERIAL_UART_5:
36 case BOOT_SERIAL_UART_6:
37 case BOOT_SERIAL_UART_7:
38 case BOOT_SERIAL_UART_8:
39 return BOOT_DEVICE_UART;
40 case BOOT_SERIAL_USB_OTG:
41 return BOOT_DEVICE_USB;
42 case BOOT_FLASH_NAND_FMC:
43 return BOOT_DEVICE_NAND;
44 case BOOT_FLASH_NOR_QSPI:
45 return BOOT_DEVICE_SPI;
46 case BOOT_FLASH_SPINAND_1:
47 return BOOT_DEVICE_NONE; /* SPINAND not supported in SPL */
50 return BOOT_DEVICE_MMC1;
53 u32 spl_mmc_boot_mode(const u32 boot_device)
55 return MMCSD_MODE_RAW;
58 #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
59 int spl_mmc_boot_partition(const u32 boot_device)
61 switch (boot_device) {
62 case BOOT_DEVICE_MMC1:
63 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
64 case BOOT_DEVICE_MMC2:
65 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2;
72 #ifdef CONFIG_SPL_DISPLAY_PRINT
73 void spl_display_print(void)
75 DECLARE_GLOBAL_DATA_PTR;
78 /* same code than show_board_info() but not compiled for SPL
79 * see CONFIG_DISPLAY_BOARDINFO & common/board_info.c
81 model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
83 printf("Model: %s\n", model);
87 __weak int board_early_init_f(void)
92 void board_init_f(ulong dummy)
99 ret = spl_early_init();
101 debug("spl_early_init() failed: %d\n", ret);
105 ret = uclass_get_device(UCLASS_CLK, 0, &dev);
107 debug("Clock init failed: %d\n", ret);
111 ret = uclass_get_device(UCLASS_RESET, 0, &dev);
113 debug("Reset init failed: %d\n", ret);
117 ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev);
119 debug("%s: Cannot find pinctrl device\n", __func__);
123 /* enable console uart printing */
124 preloader_console_init();
126 ret = board_early_init_f();
128 debug("board_early_init_f() failed: %d\n", ret);
132 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
134 printf("DRAM init failed: %d\n", ret);
139 * activate cache on DDR only when DDR is fully initialized
140 * to avoid speculative access and issue in get_ram_size()
142 if (!CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
143 mmu_set_region_dcache_behaviour(STM32_DDR_BASE,
144 CONFIG_DDR_CACHEABLE_SIZE,
145 DCACHE_DEFAULT_OPTION);
148 void spl_board_prepare_for_boot(void)
153 void spl_board_prepare_for_linux(void)