2 * Copyright (C) 2014 Gateworks Corporation
3 * Copyright (C) 2011-2012 Freescale Semiconductor, Inc.
5 * Author: Tim Harvey <tharvey@gateworks.com>
7 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/arch/imx-regs.h>
15 #include <asm/imx-common/hab.h>
17 #if defined(CONFIG_MX6)
18 /* determine boot device from SRC_SBMR1 (BOOT_CFG[4:1]) or SRC_GPR9 register */
19 u32 spl_boot_device(void)
21 struct src *psrc = (struct src *)SRC_BASE_ADDR;
22 unsigned int gpr10_boot = readl(&psrc->gpr10) & (1 << 28);
23 unsigned reg = gpr10_boot ? readl(&psrc->gpr9) : readl(&psrc->sbmr1);
24 unsigned int bmode = readl(&psrc->sbmr2);
27 * Check for BMODE if serial downloader is enabled
28 * BOOT_MODE - see IMX6DQRM Table 8-1
30 if ((((bmode >> 24) & 0x03) == 0x01) || /* Serial Downloader */
31 (gpr10_boot && (reg == 1)))
32 return BOOT_DEVICE_UART;
33 /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
34 switch ((reg & 0x000000FF) >> 4) {
35 /* EIM: See 8.5.1, Table 8-9 */
37 /* BOOT_CFG1[3]: NOR/OneNAND Selection */
38 if ((reg & 0x00000008) >> 3)
39 return BOOT_DEVICE_ONENAND;
41 return BOOT_DEVICE_NOR;
43 /* SATA: See 8.5.4, Table 8-20 */
45 return BOOT_DEVICE_SATA;
46 /* Serial ROM: See 8.5.5.1, Table 8-22 */
49 switch ((reg & 0x07000000) >> 24) {
51 return BOOT_DEVICE_SPI;
53 return BOOT_DEVICE_I2C;
56 /* SD/eSD: 8.5.3, Table 8-15 */
59 return BOOT_DEVICE_MMC1;
63 return BOOT_DEVICE_MMC1;
64 /* NAND Flash: 8.5.2 */
66 return BOOT_DEVICE_NAND;
68 return BOOT_DEVICE_NONE;
72 #if defined(CONFIG_SPL_MMC_SUPPORT)
73 /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */
74 u32 spl_boot_mode(const u32 boot_device)
76 switch (spl_boot_device()) {
77 /* for MMC return either RAW or FAT mode */
78 case BOOT_DEVICE_MMC1:
79 case BOOT_DEVICE_MMC2:
80 #if defined(CONFIG_SPL_FAT_SUPPORT)
82 #elif defined(CONFIG_SUPPORT_EMMC_BOOT)
83 return MMCSD_MODE_EMMCBOOT;
85 return MMCSD_MODE_RAW;
89 puts("spl: ERROR: unsupported device\n");
95 #if defined(CONFIG_SECURE_BOOT)
97 __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
99 typedef void __noreturn (*image_entry_noargs_t)(void);
101 image_entry_noargs_t image_entry =
102 (image_entry_noargs_t)(unsigned long)spl_image->entry_point;
104 debug("image entry point: 0x%X\n", spl_image->entry_point);
106 /* HAB looks for the CSF at the end of the authenticated data therefore,
107 * we need to subtract the size of the CSF from the actual filesize */
108 if (authenticate_image(spl_image->load_addr,
109 spl_image->size - CONFIG_CSF_SIZE)) {
112 puts("spl: ERROR: image authentication unsuccessful\n");