[U-Boot] [PATCH v2 20/22] omap: spl: add FAT support over MMC

Aneesh V
2011-05-15T15:21:38Z

Signed-off-by: Aneesh V <aneesh@ti.com>
---
V2:
* Changes for make file changes
---
include/configs/omap4_sdp4430.h | 1 +
spl/board/ti/omap4.mk | 7 +++++++
spl/board/ti/spl-omap.c | 22 ++++++++++++++++++++++
3 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/include/configs/omap4_sdp4430.h b/include/configs/omap4_sdp4430.h
index 0b67345..cc64671 100644
--- a/include/configs/omap4_sdp4430.h
+++ b/include/configs/omap4_sdp4430.h
@@ -263,6 +263,7 @@

#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 /* address 0x60000 */
#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x200 /* 256 KB */
+#define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION 1

#define CONFIG_SYS_SPL_BSS_START_ADDR 0x80000000
#define CONFIG_SYS_SPL_BSS_MAX_SIZE 0x80000 /* 512 KB */
diff --git a/spl/board/ti/omap4.mk b/spl/board/ti/omap4.mk
index ecf605e..e66a532 100644
--- a/spl/board/ti/omap4.mk
+++ b/spl/board/ti/omap4.mk
@@ -107,6 +107,13 @@ $(obj)part_dos.h:

COBJS += omap_hsmmc.o omap24xx_i2c.o mmc.o time.o part.o part_dos.o

+# fat
+$(obj)fat.c:
+ @rm -f $@
+ @ln -s $(TOPDIR)/fs/fat/fat.c $@
+
+COBJS += fat.o
+
# armv7
$(obj)start.S:
@rm -f $@
diff --git a/spl/board/ti/spl-omap.c b/spl/board/ti/spl-omap.c
index 2174c55..81ca0d3 100644
--- a/spl/board/ti/spl-omap.c
+++ b/spl/board/ti/spl-omap.c
@@ -29,6 +29,7 @@
#include <asm/u-boot.h>
#include <asm/arch/sys_proto.h>
#include <mmc.h>
+#include <fat.h>
#include <timestamp_autogenerated.h>
#include <version_autogenerated.h>
#include <asm/omap_common.h>
@@ -104,6 +105,25 @@ end:
}
}

+static void mmc_load_uboot_fat(struct mmc *mmc)
+{
+ s32 err;
+
+ err = fat_register_device(&mmc->block_dev,
+ CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION);
+ if (err) {
+ printf("spl: fat register err - %d\n", err);
+ hang();
+ }
+
+ err = file_fat_read("u-boot.bin", (u8 *)CONFIG_SYS_TEXT_BASE, 0);
+
+ if (err <= 0) {
+ printf("spl: error reading u-boot.bin - %d\n", err);
+ hang();
+ }
+}
+
static void mmc_load_uboot(u32 mmc_dev)
{
struct mmc *mmc;
@@ -127,6 +147,8 @@ static void mmc_load_uboot(u32 mmc_dev)
boot_mode = omap_boot_mode();
if (boot_mode == MMCSD_MODE_RAW)
mmc_load_uboot_raw(mmc, mmc_dev);
+ else if (boot_mode == MMCSD_MODE_FAT)
+ mmc_load_uboot_fat(mmc);
else {
puts("spl: wrong MMC boot mode\n");
hang();
--
1.7.0.4