From b39c264364fdf7e22582fa01c24eaff6857448ff Mon Sep 17 00:00:00 2001 From: Vagrant Cascadian Date: Tue, 7 Apr 2015 20:42:30 +0000 Subject: [PATCH] imx6-spl-support Gbp-Pq: Topic cubox-i Gbp-Pq: Name imx6-spl-support.diff --- arch/arm/cpu/armv7/mx6/u-boot-spl.lds | 47 ++++++++++++++++++++++++ arch/arm/imx-common/spl.c | 14 ++++--- common/spl/spl_mmc.c | 53 +++++++++++++++++---------- drivers/mtd/nand/mxs_nand.c | 5 ++- drivers/mtd/nand/mxs_nand_spl.c | 23 +++++++++++- include/configs/imx6_spl.h | 2 +- include/spl.h | 1 + 7 files changed, 116 insertions(+), 29 deletions(-) create mode 100644 arch/arm/cpu/armv7/mx6/u-boot-spl.lds diff --git a/arch/arm/cpu/armv7/mx6/u-boot-spl.lds b/arch/arm/cpu/armv7/mx6/u-boot-spl.lds new file mode 100644 index 000000000..5e93b343e --- /dev/null +++ b/arch/arm/cpu/armv7/mx6/u-boot-spl.lds @@ -0,0 +1,47 @@ +/* + * (C) Copyright 2002 + * Gary Jennejohn, DENX Software Engineering, + * + * (C) Copyright 2010 + * Texas Instruments, + * Aneesh V + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\ + LENGTH = CONFIG_SPL_MAX_SIZE } +MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \ + LENGTH = CONFIG_SPL_BSS_MAX_SIZE } + +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_start) +SECTIONS +{ + .text : + { + __start = .; + arch/arm/cpu/armv7/start.o (.text*) + *(.text*) + } >.sram + + . = ALIGN(4); + .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram + + . = ALIGN(4); + .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram + + . = ALIGN(4); + __image_copy_end = .; + _end = .; + + .bss : + { + . = ALIGN(4); + __bss_start = .; + *(.bss*) + . = ALIGN(4); + __bss_end = .; + } >.sdram +} diff --git a/arch/arm/imx-common/spl.c b/arch/arm/imx-common/spl.c index 9a02a644b..30ca9fab9 100644 --- a/arch/arm/imx-common/spl.c +++ b/arch/arm/imx-common/spl.c @@ -46,7 +46,10 @@ u32 spl_boot_device(void) /* SD/eSD: 8.5.3, Table 8-15 */ case 0x4: case 0x5: - return BOOT_DEVICE_MMC1; + if ((reg & 0x00001000) >> 12) + return BOOT_DEVICE_MMC1; + else + return BOOT_DEVICE_MMC2; /* MMC/eMMC: 8.5.3 */ case 0x6: case 0x7: @@ -67,11 +70,10 @@ u32 spl_boot_mode(void) /* for MMC return either RAW or FAT mode */ case BOOT_DEVICE_MMC1: case BOOT_DEVICE_MMC2: -#ifdef CONFIG_SPL_FAT_SUPPORT - return MMCSD_MODE_FAT; -#else - return MMCSD_MODE_RAW; -#endif + return MMCSD_MODE_ANY; + break; + case BOOT_DEVICE_SATA: + return MMCSD_MODE_UNDEFINED; break; default: puts("spl: ERROR: unsupported device\n"); diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index fa6f891bc..847d84093 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -93,26 +93,26 @@ void spl_mmc_load_image(void) } boot_mode = spl_boot_mode(); - if (boot_mode == MMCSD_MODE_RAW) { - debug("boot mode - RAW\n"); -#ifdef CONFIG_SPL_OS_BOOT - if (spl_start_uboot() || mmc_load_image_raw_os(mmc)) + switch (boot_mode) { + case MMCSD_MODE_RAW: + case MMCSD_MODE_ANY: +#ifdef CONFIG_SUPPORT_EMMC_BOOT + case MMCSD_MODE_EMMCBOOT: #endif - err = mmc_load_image_raw(mmc, - CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); #ifdef CONFIG_SPL_FAT_SUPPORT - } else if (boot_mode == MMCSD_MODE_FAT) { - debug("boot mode - FAT\n"); -#ifdef CONFIG_SPL_OS_BOOT - if (spl_start_uboot() || spl_load_image_fat_os(&mmc->block_dev, - CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION)) + case MMCSD_MODE_FAT: #endif - err = spl_load_image_fat(&mmc->block_dev, - CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION, - CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME); + break; + default: +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT + puts("spl: wrong MMC boot mode\n"); #endif + hang(); + break; + } + #ifdef CONFIG_SUPPORT_EMMC_BOOT - } else if (boot_mode == MMCSD_MODE_EMMCBOOT) { + if (boot_mode == MMCSD_MODE_EMMCBOOT) { /* * We need to check what the partition is configured to. * 1 and 2 match up to boot0 / boot1 and 7 is user data @@ -129,18 +129,31 @@ void spl_mmc_load_image(void) #endif hang(); } + } +#endif + if (boot_mode == MMCSD_MODE_RAW || boot_mode == MMCSD_MODE_ANY + || boot_mode == MMCSD_MODE_EMMCBOOT) + { + debug("boot mode - RAW\n"); #ifdef CONFIG_SPL_OS_BOOT if (spl_start_uboot() || mmc_load_image_raw_os(mmc)) #endif err = mmc_load_image_raw(mmc, CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); + } +#ifdef CONFIG_SPL_FAT_SUPPORT + if (boot_mode == MMCSD_MODE_FAT || (boot_mode == MMCSD_MODE_ANY && err)) + { + debug("boot mode - FAT\n"); +#ifdef CONFIG_SPL_OS_BOOT + if (spl_start_uboot() || spl_load_image_fat_os(&mmc->block_dev, + CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION)) #endif - } else { -#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT - puts("spl: wrong MMC boot mode\n"); -#endif - hang(); + err = spl_load_image_fat(&mmc->block_dev, + CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION, + CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME); } +#endif if (err) hang(); diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c index 036c113ad..36cfc18b0 100644 --- a/drivers/mtd/nand/mxs_nand.c +++ b/drivers/mtd/nand/mxs_nand.c @@ -1014,9 +1014,12 @@ static int mxs_nand_scan_bbt(struct mtd_info *mtd) nand_info->hooked_block_markbad = mtd->_block_markbad; mtd->_block_markbad = mxs_nand_hook_block_markbad; } - + #ifdef CONFIG_SPL_BUILD + return 0; + #else /* We use the reference implementation for bad block management. */ return nand_default_bbt(mtd); + #endif } /* diff --git a/drivers/mtd/nand/mxs_nand_spl.c b/drivers/mtd/nand/mxs_nand_spl.c index 0e7c364a2..8bc71477b 100644 --- a/drivers/mtd/nand/mxs_nand_spl.c +++ b/drivers/mtd/nand/mxs_nand_spl.c @@ -223,9 +223,30 @@ int nand_default_bbt(struct mtd_info *mtd) void nand_init(void) { + /* + * Init board specific nand support + */ + mtd.priv = &nand_chip; + + board_nand_init(&nand_chip); + mtd.priv = &nand_chip; + + if (nand_chip.select_chip) + nand_chip.select_chip(&mtd, 0); + + mtd.writesize = CONFIG_SYS_NAND_PAGE_SIZE; + mtd.oobsize = CONFIG_SYS_NAND_OOBSIZE; + + //Actually, not scan and create bbt, just for setting flash memory geometry to BCH + nand_chip.scan_bbt(&mtd); + + nand_chip.buffers = memalign(ARCH_DMA_MINALIGN, sizeof(*nand_chip.buffers)); + nand_chip.oob_poi = nand_chip.buffers->databuf + mtd.writesize; } +/* Unselect after operation */ void nand_deselect(void) { + if (nand_chip.select_chip) + nand_chip.select_chip(&mtd, -1); } - diff --git a/include/configs/imx6_spl.h b/include/configs/imx6_spl.h index 970460d5f..d8247058b 100644 --- a/include/configs/imx6_spl.h +++ b/include/configs/imx6_spl.h @@ -25,7 +25,7 @@ * or 64KB */ #define CONFIG_SYS_THUMB_BUILD -#define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/omap-common/u-boot-spl.lds" +#define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/mx6/u-boot-spl.lds" #define CONFIG_SPL_TEXT_BASE 0x00908000 #define CONFIG_SPL_MAX_SIZE (64 * 1024) #define CONFIG_SPL_START_S_PATH "arch/arm/cpu/armv7" diff --git a/include/spl.h b/include/spl.h index a7e41da7f..dd80a8146 100644 --- a/include/spl.h +++ b/include/spl.h @@ -17,6 +17,7 @@ #define MMCSD_MODE_RAW 1 #define MMCSD_MODE_FAT 2 #define MMCSD_MODE_EMMCBOOT 3 +#define MMCSD_MODE_ANY 4 struct spl_image_info { const char *name; -- 2.30.2