From 59284580e2e0b377071af479bc153a23fee6b8d8 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 10 Jul 2015 00:04:23 +0200 Subject: [PATCH] arm: socfpga: spl: Add support for booting from SD/MMC Add code and configuration options to support booting from RAW SD/MMC card as well as for ext4/vfat filesystems. Enable support for booting from SD/MMC card, but don't enable the filesystem support just yet to retain compatibility with old SoCFPGA card format. Signed-off-by: Marek Vasut --- arch/arm/mach-socfpga/spl.c | 17 +++++++++++++++++ configs/socfpga_arria5_defconfig | 2 ++ configs/socfpga_cyclone5_defconfig | 2 ++ configs/socfpga_socrates_defconfig | 3 ++- include/configs/socfpga_common.h | 14 ++++++++++++++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-socfpga/spl.c b/arch/arm/mach-socfpga/spl.c index ea0ed1a24d..bacc845cd4 100644 --- a/arch/arm/mach-socfpga/spl.c +++ b/arch/arm/mach-socfpga/spl.c @@ -31,8 +31,25 @@ static struct nic301_registers *nic301_regs = u32 spl_boot_device(void) { +#ifdef CONFIG_SPL_MMC_SUPPORT + socfpga_per_reset(SOCFPGA_RESET(SDMMC), 0); + socfpga_per_reset(SOCFPGA_RESET(DMA), 0); + return BOOT_DEVICE_MMC1; +#else return BOOT_DEVICE_RAM; +#endif +} + +#ifdef CONFIG_SPL_MMC_SUPPORT +u32 spl_boot_mode(void) +{ +#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT) + return MMCSD_MODE_FS; +#else + return MMCSD_MODE_RAW; +#endif } +#endif static void socfpga_nic301_slave_ns(void) { diff --git a/configs/socfpga_arria5_defconfig b/configs/socfpga_arria5_defconfig index 4ba4b8c5f2..245d53c17c 100644 --- a/configs/socfpga_arria5_defconfig +++ b/configs/socfpga_arria5_defconfig @@ -7,3 +7,5 @@ CONFIG_SPL=y # CONFIG_CMD_FLASH is not set CONFIG_OF_CONTROL=y CONFIG_SPI_FLASH=y +CONFIG_SPL_DM=y +CONFIG_SPL_MMC_SUPPORT=y diff --git a/configs/socfpga_cyclone5_defconfig b/configs/socfpga_cyclone5_defconfig index e101f76712..00536ffc77 100644 --- a/configs/socfpga_cyclone5_defconfig +++ b/configs/socfpga_cyclone5_defconfig @@ -9,3 +9,5 @@ CONFIG_OF_CONTROL=y CONFIG_SPI_FLASH=y CONFIG_NETDEVICES=y CONFIG_ETH_DESIGNWARE=y +CONFIG_SPL_DM=y +CONFIG_SPL_MMC_SUPPORT=y diff --git a/configs/socfpga_socrates_defconfig b/configs/socfpga_socrates_defconfig index 63dda73dd2..11bbff1db4 100644 --- a/configs/socfpga_socrates_defconfig +++ b/configs/socfpga_socrates_defconfig @@ -6,7 +6,8 @@ CONFIG_SPL=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set CONFIG_OF_CONTROL=y -CONFIG_SPL_DISABLE_OF_CONTROL=y CONFIG_SPI_FLASH=y CONFIG_NETDEVICES=y CONFIG_ETH_DESIGNWARE=y +CONFIG_SPL_DM=y +CONFIG_SPL_MMC_SUPPORT=y diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h index 1235aaafde..c1380807ec 100644 --- a/include/configs/socfpga_common.h +++ b/include/configs/socfpga_common.h @@ -300,6 +300,20 @@ unsigned int cm_get_qspi_controller_clk_hz(void); #define CONFIG_SPL_LIBGENERIC_SUPPORT #define CONFIG_SPL_WATCHDOG_SUPPORT #define CONFIG_SPL_SERIAL_SUPPORT +#define CONFIG_SPL_MMC_SUPPORT + +/* SPL SDMMC boot support */ +#ifdef CONFIG_SPL_MMC_SUPPORT +#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT) +#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 2 +#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot-dtb.img" +#define CONFIG_SPL_LIBDISK_SUPPORT +#else +#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 3 +#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0xa00 /* offset 2560 sect (1M+256k) */ +#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 800 /* 400 KB */ +#endif +#endif /* * Stack setup -- 2.39.2