Tim Harvey | 887717d | 2014-06-02 16:13:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 Gateworks Corporation |
| 3 | * Copyright (C) 2011-2012 Freescale Semiconductor, Inc. |
| 4 | * |
| 5 | * Author: Tim Harvey <tharvey@gateworks.com> |
| 6 | * |
| 7 | * SPDX-License-Identifier: GPL-2.0+ |
| 8 | */ |
| 9 | |
| 10 | #include <common.h> |
| 11 | #include <asm/io.h> |
| 12 | #include <asm/arch/imx-regs.h> |
| 13 | #include <asm/spl.h> |
| 14 | #include <spl.h> |
| 15 | |
| 16 | #if defined(CONFIG_MX6) |
Nikita Kiryanov | f2863ff | 2014-10-29 19:28:33 +0200 | [diff] [blame] | 17 | /* determine boot device from SRC_SBMR1 (BOOT_CFG[4:1]) or SRC_GPR9 register */ |
Tim Harvey | 887717d | 2014-06-02 16:13:20 -0700 | [diff] [blame] | 18 | u32 spl_boot_device(void) |
| 19 | { |
| 20 | struct src *psrc = (struct src *)SRC_BASE_ADDR; |
Nikita Kiryanov | f2863ff | 2014-10-29 19:28:33 +0200 | [diff] [blame] | 21 | unsigned int gpr10_boot = readl(&psrc->gpr10) & (1 << 28); |
| 22 | unsigned reg = gpr10_boot ? readl(&psrc->gpr9) : readl(&psrc->sbmr1); |
Tim Harvey | 887717d | 2014-06-02 16:13:20 -0700 | [diff] [blame] | 23 | |
| 24 | /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */ |
| 25 | switch ((reg & 0x000000FF) >> 4) { |
| 26 | /* EIM: See 8.5.1, Table 8-9 */ |
| 27 | case 0x0: |
| 28 | /* BOOT_CFG1[3]: NOR/OneNAND Selection */ |
| 29 | if ((reg & 0x00000008) >> 3) |
| 30 | return BOOT_DEVICE_ONENAND; |
| 31 | else |
| 32 | return BOOT_DEVICE_NOR; |
| 33 | break; |
| 34 | /* SATA: See 8.5.4, Table 8-20 */ |
| 35 | case 0x2: |
| 36 | return BOOT_DEVICE_SATA; |
| 37 | /* Serial ROM: See 8.5.5.1, Table 8-22 */ |
| 38 | case 0x3: |
| 39 | /* BOOT_CFG4[2:0] */ |
| 40 | switch ((reg & 0x07000000) >> 24) { |
| 41 | case 0x0 ... 0x4: |
| 42 | return BOOT_DEVICE_SPI; |
| 43 | case 0x5 ... 0x7: |
| 44 | return BOOT_DEVICE_I2C; |
| 45 | } |
| 46 | break; |
| 47 | /* SD/eSD: 8.5.3, Table 8-15 */ |
| 48 | case 0x4: |
| 49 | case 0x5: |
| 50 | return BOOT_DEVICE_MMC1; |
| 51 | /* MMC/eMMC: 8.5.3 */ |
| 52 | case 0x6: |
| 53 | case 0x7: |
| 54 | return BOOT_DEVICE_MMC1; |
| 55 | /* NAND Flash: 8.5.2 */ |
| 56 | case 0x8 ... 0xf: |
| 57 | return BOOT_DEVICE_NAND; |
| 58 | } |
| 59 | return BOOT_DEVICE_NONE; |
| 60 | } |
| 61 | #endif |
| 62 | |
| 63 | #if defined(CONFIG_SPL_MMC_SUPPORT) |
| 64 | /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */ |
| 65 | u32 spl_boot_mode(void) |
| 66 | { |
| 67 | switch (spl_boot_device()) { |
| 68 | /* for MMC return either RAW or FAT mode */ |
| 69 | case BOOT_DEVICE_MMC1: |
| 70 | case BOOT_DEVICE_MMC2: |
| 71 | #ifdef CONFIG_SPL_FAT_SUPPORT |
Guillaume GARDET | 205b4f3 | 2014-10-15 17:53:11 +0200 | [diff] [blame] | 72 | return MMCSD_MODE_FS; |
Tim Harvey | 887717d | 2014-06-02 16:13:20 -0700 | [diff] [blame] | 73 | #else |
| 74 | return MMCSD_MODE_RAW; |
| 75 | #endif |
| 76 | break; |
| 77 | default: |
| 78 | puts("spl: ERROR: unsupported device\n"); |
| 79 | hang(); |
| 80 | } |
| 81 | } |
| 82 | #endif |