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>
16 #if defined(CONFIG_MX6)
17 /* determine boot device from SRC_SBMR1 register (BOOT_CFG[4:1]) */
18 u32 spl_boot_device(void)
20 struct src *psrc = (struct src *)SRC_BASE_ADDR;
21 unsigned reg = readl(&psrc->sbmr1);
23 /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
24 switch ((reg & 0x000000FF) >> 4) {
25 /* EIM: See 8.5.1, Table 8-9 */
27 /* BOOT_CFG1[3]: NOR/OneNAND Selection */
28 if ((reg & 0x00000008) >> 3)
29 return BOOT_DEVICE_ONENAND;
31 return BOOT_DEVICE_NOR;
33 /* SATA: See 8.5.4, Table 8-20 */
35 return BOOT_DEVICE_SATA;
36 /* Serial ROM: See 8.5.5.1, Table 8-22 */
39 switch ((reg & 0x07000000) >> 24) {
41 return BOOT_DEVICE_SPI;
43 return BOOT_DEVICE_I2C;
46 /* SD/eSD: 8.5.3, Table 8-15 */
49 return BOOT_DEVICE_MMC1;
53 return BOOT_DEVICE_MMC1;
54 /* NAND Flash: 8.5.2 */
56 return BOOT_DEVICE_NAND;
58 return BOOT_DEVICE_NONE;
62 #if defined(CONFIG_SPL_MMC_SUPPORT)
63 /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */
64 u32 spl_boot_mode(void)
66 switch (spl_boot_device()) {
67 /* for MMC return either RAW or FAT mode */
68 case BOOT_DEVICE_MMC1:
69 case BOOT_DEVICE_MMC2:
70 #ifdef CONFIG_SPL_FAT_SUPPORT
71 return MMCSD_MODE_FAT;
73 return MMCSD_MODE_RAW;
77 puts("spl: ERROR: unsupported device\n");