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 return BOOT_DEVICE_UART;
32 /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
33 switch ((reg & 0x000000FF) >> 4) {
34 /* EIM: See 8.5.1, Table 8-9 */
36 /* BOOT_CFG1[3]: NOR/OneNAND Selection */
37 if ((reg & 0x00000008) >> 3)
38 return BOOT_DEVICE_ONENAND;
40 return BOOT_DEVICE_NOR;
42 /* Reserved: Used to force Serial Downloader */
44 return BOOT_DEVICE_UART;
45 /* SATA: See 8.5.4, Table 8-20 */
47 return BOOT_DEVICE_SATA;
48 /* Serial ROM: See 8.5.5.1, Table 8-22 */
51 switch ((reg & 0x07000000) >> 24) {
53 return BOOT_DEVICE_SPI;
55 return BOOT_DEVICE_I2C;
58 /* SD/eSD: 8.5.3, Table 8-15 */
61 return BOOT_DEVICE_MMC1;
65 return BOOT_DEVICE_MMC1;
66 /* NAND Flash: 8.5.2 */
68 return BOOT_DEVICE_NAND;
70 return BOOT_DEVICE_NONE;
74 #if defined(CONFIG_SPL_MMC_SUPPORT)
75 /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */
76 u32 spl_boot_mode(const u32 boot_device)
78 switch (spl_boot_device()) {
79 /* for MMC return either RAW or FAT mode */
80 case BOOT_DEVICE_MMC1:
81 case BOOT_DEVICE_MMC2:
82 #if defined(CONFIG_SPL_FAT_SUPPORT)
84 #elif defined(CONFIG_SUPPORT_EMMC_BOOT)
85 return MMCSD_MODE_EMMCBOOT;
87 return MMCSD_MODE_RAW;
91 puts("spl: ERROR: unsupported device\n");
97 #if defined(CONFIG_SECURE_BOOT)
99 __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
101 typedef void __noreturn (*image_entry_noargs_t)(void);
103 image_entry_noargs_t image_entry =
104 (image_entry_noargs_t)(unsigned long)spl_image->entry_point;
106 debug("image entry point: 0x%lX\n", spl_image->entry_point);
108 /* HAB looks for the CSF at the end of the authenticated data therefore,
109 * we need to subtract the size of the CSF from the actual filesize */
110 if (authenticate_image(spl_image->load_addr,
111 spl_image->size - CONFIG_CSF_SIZE)) {
114 puts("spl: ERROR: image authentication unsuccessful\n");