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
;
33 int sys_boot_device
= 0;
37 if ((boot_params
< NON_SECURE_SRAM_START
) ||
38 (boot_params
> NON_SECURE_SRAM_END
))
41 omap_boot_params
= (struct omap_boot_parameters
*)boot_params
;
43 boot_device
= omap_boot_params
->boot_device
;
44 boot_mode
= MMCSD_MODE_UNDEFINED
;
48 #ifdef BOOT_DEVICE_NAND_I2C
50 * Re-map NAND&I2C boot-device to the "normal" NAND boot-device.
51 * Otherwise the SPL boot IF can't handle this device correctly.
52 * Somehow booting with Hynix 4GBit NAND H27U4G8 on Siemens
53 * Draco leads to this boot-device passed to SPL from the BootROM.
55 if (boot_device
== BOOT_DEVICE_NAND_I2C
)
56 boot_device
= BOOT_DEVICE_NAND
;
58 #ifdef BOOT_DEVICE_QSPI_4
60 * We get different values for QSPI_1 and QSPI_4 being used, but
61 * don't actually care about this difference. Rather than
62 * mangle the later code, if we're coming in as QSPI_4 just
63 * change to the QSPI_1 value.
65 if (boot_device
== BOOT_DEVICE_QSPI_4
)
66 boot_device
= BOOT_DEVICE_SPI
;
69 * When booting from peripheral booting, the boot device is not usable
70 * as-is (unless there is support for it), so the boot device is instead
71 * figured out using the SYS_BOOT pins.
73 switch (boot_device
) {
74 #if defined(BOOT_DEVICE_UART) && !defined(CONFIG_SPL_YMODEM_SUPPORT)
75 case BOOT_DEVICE_UART
:
79 #if defined(BOOT_DEVICE_USB) && !defined(CONFIG_SPL_USB_SUPPORT)
84 #if defined(BOOT_DEVICE_USBETH) && !defined(CONFIG_SPL_USBETH_SUPPORT)
85 case BOOT_DEVICE_USBETH
:
89 #if defined(BOOT_DEVICE_CPGMAC) && !defined(CONFIG_SPL_ETH_SUPPORT)
90 case BOOT_DEVICE_CPGMAC
:
94 #if defined(BOOT_DEVICE_DFU) && !defined(CONFIG_SPL_DFU_SUPPORT)
101 if (sys_boot_device
) {
102 boot_device
= omap_sys_boot_device();
104 /* MMC raw mode will fallback to FS mode. */
105 if ((boot_device
>= MMC_BOOT_DEVICES_START
) &&
106 (boot_device
<= MMC_BOOT_DEVICES_END
))
107 boot_mode
= MMCSD_MODE_RAW
;
110 gd
->arch
.omap_boot_device
= boot_device
;
114 #ifdef CONFIG_OMAP34XX
115 if ((boot_device
>= MMC_BOOT_DEVICES_START
) &&
116 (boot_device
<= MMC_BOOT_DEVICES_END
)) {
117 switch (boot_device
) {
118 case BOOT_DEVICE_MMC1
:
119 boot_mode
= MMCSD_MODE_FS
;
121 case BOOT_DEVICE_MMC2
:
122 boot_mode
= MMCSD_MODE_RAW
;
128 * If the boot device was dynamically changed and doesn't match what
129 * the bootrom initially booted, we cannot use the boot device
130 * descriptor to figure out the boot mode.
132 if ((boot_device
== omap_boot_params
->boot_device
) &&
133 (boot_device
>= MMC_BOOT_DEVICES_START
) &&
134 (boot_device
<= MMC_BOOT_DEVICES_END
)) {
135 boot_params
= omap_boot_params
->boot_device_descriptor
;
136 if ((boot_params
< NON_SECURE_SRAM_START
) ||
137 (boot_params
> NON_SECURE_SRAM_END
))
140 boot_params
= *((u32
*)(boot_params
+ DEVICE_DATA_OFFSET
));
141 if ((boot_params
< NON_SECURE_SRAM_START
) ||
142 (boot_params
> NON_SECURE_SRAM_END
))
145 boot_mode
= *((u32
*)(boot_params
+ BOOT_MODE_OFFSET
));
147 if (boot_mode
!= MMCSD_MODE_FS
&&
148 boot_mode
!= MMCSD_MODE_RAW
)
149 #ifdef CONFIG_SUPPORT_EMMC_BOOT
150 boot_mode
= MMCSD_MODE_EMMCBOOT
;
152 boot_mode
= MMCSD_MODE_UNDEFINED
;
157 gd
->arch
.omap_boot_mode
= boot_mode
;
159 #if !defined(CONFIG_TI814X) && !defined(CONFIG_TI816X) && \
160 !defined(CONFIG_AM33XX) && !defined(CONFIG_AM43XX)
164 gd
->arch
.omap_ch_flags
= omap_boot_params
->ch_flags
;
168 #ifdef CONFIG_SPL_BUILD
169 u32
spl_boot_device(void)
171 return gd
->arch
.omap_boot_device
;
174 u32
spl_boot_mode(const u32 boot_device
)
176 return gd
->arch
.omap_boot_mode
;
179 void spl_board_init(void)
182 * Save the boot parameters passed from romcode.
183 * We cannot delay the saving further than this,
184 * to prevent overwrites.
186 save_omap_boot_params();
188 /* Prepare console output */
189 preloader_console_init();
191 #if defined(CONFIG_SPL_NAND_SUPPORT) || defined(CONFIG_SPL_ONENAND_SUPPORT)
194 #ifdef CONFIG_SPL_I2C_SUPPORT
195 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED
, CONFIG_SYS_OMAP24_I2C_SLAVE
);
197 #if defined(CONFIG_AM33XX) && defined(CONFIG_SPL_MUSB_NEW_SUPPORT)
200 #if defined(CONFIG_HW_WATCHDOG)
204 am33xx_spl_board_init();
208 void __noreturn
jump_to_image_no_args(struct spl_image_info
*spl_image
)
210 typedef void __noreturn (*image_entry_noargs_t
)(u32
*);
211 image_entry_noargs_t image_entry
=
212 (image_entry_noargs_t
) spl_image
->entry_point
;
214 u32 boot_params
= *((u32
*)OMAP_SRAM_SCRATCH_BOOT_PARAMS
);
216 debug("image entry point: 0x%lX\n", spl_image
->entry_point
);
217 /* Pass the saved boot_params from rom code */
218 image_entry((u32
*)boot_params
);
222 #ifdef CONFIG_SCSI_AHCI_PLAT
223 void arch_preboot_os(void)
225 ahci_reset((void __iomem
*)DWC_AHSATA_BASE
);
229 #if defined(CONFIG_USB_FUNCTION_FASTBOOT) && !defined(CONFIG_ENV_IS_NOWHERE)
230 int fb_set_reboot_flag(void)
232 printf("Setting reboot to fastboot flag ...\n");
233 setenv("dofastboot", "1");