]> git.ipfire.org Git - people/ms/u-boot.git/blame - arch/arm/imx-common/spl.c
mx6: add boot device support for SPL
[people/ms/u-boot.git] / arch / arm / imx-common / spl.c
CommitLineData
887717db
TH
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)
17/* determine boot device from SRC_SBMR1 register (BOOT_CFG[4:1]) */
18u32 spl_boot_device(void)
19{
20 struct src *psrc = (struct src *)SRC_BASE_ADDR;
21 unsigned reg = readl(&psrc->sbmr1);
22
23 /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
24 switch ((reg & 0x000000FF) >> 4) {
25 /* EIM: See 8.5.1, Table 8-9 */
26 case 0x0:
27 /* BOOT_CFG1[3]: NOR/OneNAND Selection */
28 if ((reg & 0x00000008) >> 3)
29 return BOOT_DEVICE_ONENAND;
30 else
31 return BOOT_DEVICE_NOR;
32 break;
33 /* SATA: See 8.5.4, Table 8-20 */
34 case 0x2:
35 return BOOT_DEVICE_SATA;
36 /* Serial ROM: See 8.5.5.1, Table 8-22 */
37 case 0x3:
38 /* BOOT_CFG4[2:0] */
39 switch ((reg & 0x07000000) >> 24) {
40 case 0x0 ... 0x4:
41 return BOOT_DEVICE_SPI;
42 case 0x5 ... 0x7:
43 return BOOT_DEVICE_I2C;
44 }
45 break;
46 /* SD/eSD: 8.5.3, Table 8-15 */
47 case 0x4:
48 case 0x5:
49 return BOOT_DEVICE_MMC1;
50 /* MMC/eMMC: 8.5.3 */
51 case 0x6:
52 case 0x7:
53 return BOOT_DEVICE_MMC1;
54 /* NAND Flash: 8.5.2 */
55 case 0x8 ... 0xf:
56 return BOOT_DEVICE_NAND;
57 }
58 return BOOT_DEVICE_NONE;
59}
60#endif
61
62#if defined(CONFIG_SPL_MMC_SUPPORT)
63/* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */
64u32 spl_boot_mode(void)
65{
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;
72#else
73 return MMCSD_MODE_RAW;
74#endif
75 break;
76 default:
77 puts("spl: ERROR: unsupported device\n");
78 hang();
79 }
80}
81#endif