1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
6 #define LOG_CATEGORY LOGC_ARCH
15 #include <asm/cache.h>
16 #include <asm/global_data.h>
18 #include <asm/arch/sys_proto.h>
19 #include <linux/libfdt.h>
21 u32 spl_boot_device(void)
25 boot_mode = get_bootmode();
29 case BOOT_FLASH_EMMC_1:
30 return BOOT_DEVICE_MMC1;
32 case BOOT_FLASH_EMMC_2:
33 return BOOT_DEVICE_MMC2;
34 case BOOT_SERIAL_UART_1:
35 case BOOT_SERIAL_UART_2:
36 case BOOT_SERIAL_UART_3:
37 case BOOT_SERIAL_UART_4:
38 case BOOT_SERIAL_UART_5:
39 case BOOT_SERIAL_UART_6:
40 case BOOT_SERIAL_UART_7:
41 case BOOT_SERIAL_UART_8:
42 return BOOT_DEVICE_UART;
43 case BOOT_SERIAL_USB_OTG:
44 return BOOT_DEVICE_USB;
45 case BOOT_FLASH_NAND_FMC:
46 return BOOT_DEVICE_NAND;
47 case BOOT_FLASH_NOR_QSPI:
48 return BOOT_DEVICE_SPI;
49 case BOOT_FLASH_SPINAND_1:
50 return BOOT_DEVICE_NONE; /* SPINAND not supported in SPL */
53 return BOOT_DEVICE_MMC1;
56 u32 spl_mmc_boot_mode(const u32 boot_device)
58 return MMCSD_MODE_RAW;
61 #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
62 int spl_mmc_boot_partition(const u32 boot_device)
64 switch (boot_device) {
65 case BOOT_DEVICE_MMC1:
66 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
67 case BOOT_DEVICE_MMC2:
68 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2;
75 #ifdef CONFIG_SPL_DISPLAY_PRINT
76 void spl_display_print(void)
78 DECLARE_GLOBAL_DATA_PTR;
81 /* same code than show_board_info() but not compiled for SPL
82 * see CONFIG_DISPLAY_BOARDINFO & common/board_info.c
84 model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
86 log_info("Model: %s\n", model);
90 __weak int board_early_init_f(void)
95 void board_init_f(ulong dummy)
102 ret = spl_early_init();
104 log_debug("spl_early_init() failed: %d\n", ret);
108 ret = uclass_get_device(UCLASS_CLK, 0, &dev);
110 log_debug("Clock init failed: %d\n", ret);
114 ret = uclass_get_device(UCLASS_RESET, 0, &dev);
116 log_debug("Reset init failed: %d\n", ret);
120 ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev);
122 log_debug("%s: Cannot find pinctrl device\n", __func__);
126 /* enable console uart printing */
127 preloader_console_init();
129 ret = board_early_init_f();
131 log_debug("board_early_init_f() failed: %d\n", ret);
135 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
137 log_err("DRAM init failed: %d\n", ret);
142 * activate cache on DDR only when DDR is fully initialized
143 * to avoid speculative access and issue in get_ram_size()
145 if (!CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
146 mmu_set_region_dcache_behaviour(STM32_DDR_BASE,
147 CONFIG_DDR_CACHEABLE_SIZE,
148 DCACHE_DEFAULT_OPTION);
151 void spl_board_prepare_for_boot(void)
156 void spl_board_prepare_for_linux(void)