diff options
author | Jan Luebbe <jlu@pengutronix.de> | 2012-09-11 13:43:28 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-09-11 15:54:49 +0200 |
commit | 379ab6ee990ffbcbb7e3039a9ca249b50a6682ad (patch) | |
tree | 59adf87bfa30503dea16d3ca9560ffa493ac5789 /arch/arm/mach-omap/xload.c | |
parent | f1be4350b0f6489835080509e58c7481b047cb3f (diff) | |
download | barebox-379ab6ee990ffbcbb7e3039a9ca249b50a6682ad.tar.gz barebox-379ab6ee990ffbcbb7e3039a9ca249b50a6682ad.tar.xz |
xload: add SPI as a boot mode
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-omap/xload.c')
-rw-r--r-- | arch/arm/mach-omap/xload.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c index 18a90c9f22..9fa8221ec9 100644 --- a/arch/arm/mach-omap/xload.c +++ b/arch/arm/mach-omap/xload.c @@ -103,6 +103,42 @@ static void *omap_xload_boot_mmc(void) return buf; } +static void *omap_xload_boot_spi(int offset) +{ + int ret; + int size; + void *to, *header; + struct cdev *cdev; + + devfs_add_partition("m25p0", offset, SZ_1M, DEVFS_PARTITION_FIXED, "x"); + + header = read_image_head("x"); + if (header == NULL) + return NULL; + + size = get_image_size(header); + if (!size) { + printf("failed to get image size\n"); + return NULL; + } + + to = xmalloc(size); + + cdev = cdev_open("x", O_RDONLY); + if (!cdev) { + printf("failed to open spi flash\n"); + return NULL; + } + + ret = cdev_read(cdev, to, size, 0, 0); + if (ret != size) { + printf("failed to read from spi flash\n"); + return NULL; + } + + return to; +} + enum omap_boot_src omap_bootsrc(void) { #if defined(CONFIG_ARCH_OMAP3) @@ -131,6 +167,10 @@ int run_shell(void) printf("booting from NAND\n"); func = omap_xload_boot_nand(SZ_128K); break; + case OMAP_BOOTSRC_SPI1: + printf("booting from SPI1\n"); + func = omap_xload_boot_spi(SZ_128K); + break; } if (!func) { |