4 * Common bootmode functions for omap based boards
6 * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
8 * SPDX-License-Identifier: GPL-2.0+
14 #include <asm/omap_common.h>
15 #include <asm/arch/omap.h>
16 #include <asm/arch/mmc_host_def.h>
17 #include <asm/arch/sys_proto.h>
22 DECLARE_GLOBAL_DATA_PTR;
24 __weak u32 omap_sys_boot_device(void)
26 return BOOT_DEVICE_NONE;
29 void save_omap_boot_params(void)
31 u32 boot_params = *((u32 *)OMAP_SRAM_SCRATCH_BOOT_PARAMS);
32 struct omap_boot_parameters *omap_boot_params;
36 if ((boot_params < NON_SECURE_SRAM_START) ||
37 (boot_params > NON_SECURE_SRAM_END))
40 omap_boot_params = (struct omap_boot_parameters *)boot_params;
42 boot_device = omap_boot_params->boot_device;
43 boot_mode = MMCSD_MODE_UNDEFINED;
47 #ifdef BOOT_DEVICE_NAND_I2C
49 * Re-map NAND&I2C boot-device to the "normal" NAND boot-device.
50 * Otherwise the SPL boot IF can't handle this device correctly.
51 * Somehow booting with Hynix 4GBit NAND H27U4G8 on Siemens
52 * Draco leads to this boot-device passed to SPL from the BootROM.
54 if (boot_device == BOOT_DEVICE_NAND_I2C)
55 boot_device = BOOT_DEVICE_NAND;
57 #ifdef BOOT_DEVICE_QSPI_4
59 * We get different values for QSPI_1 and QSPI_4 being used, but
60 * don't actually care about this difference. Rather than
61 * mangle the later code, if we're coming in as QSPI_4 just
62 * change to the QSPI_1 value.
64 if (boot_device == BOOT_DEVICE_QSPI_4)
65 boot_device = BOOT_DEVICE_SPI;
67 #if (defined(BOOT_DEVICE_UART) && !defined(CONFIG_SPL_YMODEM_SUPPORT)) || \
68 (defined(BOOT_DEVICE_USB) && !defined(CONFIG_SPL_USB_SUPPORT)) || \
69 (defined(BOOT_DEVICE_USBETH) && !defined(CONFIG_SPL_USBETH_SUPPORT))
71 * When booting from peripheral booting, the boot device is not usable
72 * as-is (unless there is support for it), so the boot device is instead
73 * figured out using the SYS_BOOT pins.
75 switch (boot_device) {
76 #ifdef BOOT_DEVICE_UART
77 case BOOT_DEVICE_UART:
79 #ifdef BOOT_DEVICE_USB
82 boot_device = omap_sys_boot_device();
84 /* MMC raw mode will fallback to FS mode. */
85 if ((boot_device >= MMC_BOOT_DEVICES_START) &&
86 (boot_device <= MMC_BOOT_DEVICES_END))
87 boot_mode = MMCSD_MODE_RAW;
93 gd->arch.omap_boot_device = boot_device;
97 #ifdef CONFIG_OMAP34XX
98 if ((boot_device >= MMC_BOOT_DEVICES_START) &&
99 (boot_device <= MMC_BOOT_DEVICES_END)) {
100 switch (boot_device) {
101 case BOOT_DEVICE_MMC1:
102 boot_mode = MMCSD_MODE_FS;
104 case BOOT_DEVICE_MMC2:
105 boot_mode = MMCSD_MODE_RAW;
111 * If the boot device was dynamically changed and doesn't match what
112 * the bootrom initially booted, we cannot use the boot device
113 * descriptor to figure out the boot mode.
115 if ((boot_device == omap_boot_params->boot_device) &&
116 (boot_device >= MMC_BOOT_DEVICES_START) &&
117 (boot_device <= MMC_BOOT_DEVICES_END)) {
118 boot_params = omap_boot_params->boot_device_descriptor;
119 if ((boot_params < NON_SECURE_SRAM_START) ||
120 (boot_params > NON_SECURE_SRAM_END))
123 boot_params = *((u32 *)(boot_params + DEVICE_DATA_OFFSET));
124 if ((boot_params < NON_SECURE_SRAM_START) ||
125 (boot_params > NON_SECURE_SRAM_END))
128 boot_mode = *((u32 *)(boot_params + BOOT_MODE_OFFSET));
130 if (boot_mode != MMCSD_MODE_FS &&
131 boot_mode != MMCSD_MODE_RAW)
132 #ifdef CONFIG_SUPPORT_EMMC_BOOT
133 boot_mode = MMCSD_MODE_EMMCBOOT;
135 boot_mode = MMCSD_MODE_UNDEFINED;
140 gd->arch.omap_boot_mode = boot_mode;
142 #if !defined(CONFIG_TI814X) && !defined(CONFIG_TI816X) && \
143 !defined(CONFIG_AM33XX) && !defined(CONFIG_AM43XX)
147 gd->arch.omap_ch_flags = omap_boot_params->ch_flags;
151 #ifdef CONFIG_SPL_BUILD
152 u32 spl_boot_device(void)
154 return gd->arch.omap_boot_device;
157 u32 spl_boot_mode(void)
159 return gd->arch.omap_boot_mode;
162 void spl_board_init(void)
165 * Save the boot parameters passed from romcode.
166 * We cannot delay the saving further than this,
167 * to prevent overwrites.
169 save_omap_boot_params();
171 /* Prepare console output */
172 preloader_console_init();
174 #if defined(CONFIG_SPL_NAND_SUPPORT) || defined(CONFIG_SPL_ONENAND_SUPPORT)
177 #ifdef CONFIG_SPL_I2C_SUPPORT
178 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
180 #if defined(CONFIG_AM33XX) && defined(CONFIG_SPL_MUSB_NEW_SUPPORT)
183 #if defined(CONFIG_HW_WATCHDOG)
187 am33xx_spl_board_init();
191 int board_mmc_init(bd_t *bis)
193 switch (spl_boot_device()) {
194 case BOOT_DEVICE_MMC1:
195 omap_mmc_init(0, 0, 0, -1, -1);
197 case BOOT_DEVICE_MMC2:
198 case BOOT_DEVICE_MMC2_2:
199 omap_mmc_init(1, 0, 0, -1, -1);
205 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
207 typedef void __noreturn (*image_entry_noargs_t)(u32 *);
208 image_entry_noargs_t image_entry =
209 (image_entry_noargs_t) spl_image->entry_point;
211 u32 boot_params = *((u32 *)OMAP_SRAM_SCRATCH_BOOT_PARAMS);
213 debug("image entry point: 0x%X\n", spl_image->entry_point);
214 /* Pass the saved boot_params from rom code */
215 image_entry((u32 *)boot_params);
219 #ifdef CONFIG_SCSI_AHCI_PLAT
220 void arch_preboot_os(void)
222 ahci_reset((void __iomem *)DWC_AHSATA_BASE);
226 #if defined(CONFIG_USB_FUNCTION_FASTBOOT) && !defined(CONFIG_ENV_IS_NOWHERE)
227 int fb_set_reboot_flag(void)
229 printf("Setting reboot to fastboot flag ...\n");
230 setenv("dofastboot", "1");