diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-09-25 12:30:58 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-09-27 16:13:19 +0200 |
commit | 5913b71943decdf18b431bd0e0f959855aeb01c7 (patch) | |
tree | 28f7cce4a2297d40d7dd4e9de0fc87c5e0c6236c /arch/arm/mach-omap/omap_generic.c | |
parent | 9d88abf95823761315acd05ea7db7a1f309d2519 (diff) | |
download | barebox-5913b71943decdf18b431bd0e0f959855aeb01c7.tar.gz barebox-5913b71943decdf18b431bd0e0f959855aeb01c7.tar.xz |
ARM: OMAP: register OMAP specific barebox bootm handler
The OMAP ROM code passes the boot information via r0 to the
bootloader. Add an OMAP specific barebox handler to pass this
information to the next stage. This allows us to chainload
bootloaders without loosing the information where we booted from.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-omap/omap_generic.c')
-rw-r--r-- | arch/arm/mach-omap/omap_generic.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/arch/arm/mach-omap/omap_generic.c b/arch/arm/mach-omap/omap_generic.c index f024de69c5..aabd5e09f0 100644 --- a/arch/arm/mach-omap/omap_generic.c +++ b/arch/arm/mach-omap/omap_generic.c @@ -15,12 +15,66 @@ #include <common.h> #include <bootsource.h> #include <envfs.h> +#include <boot.h> #include <init.h> #include <io.h> #include <fs.h> #include <malloc.h> #include <linux/stat.h> #include <mach/generic.h> +#include <mach/am33xx-silicon.h> +#include <mach/omap3-silicon.h> +#include <mach/omap4-silicon.h> + +static void *omap_sram_start(void) +{ + if (cpu_is_am33xx()) + return (void *)AM33XX_SRAM0_START; + if (cpu_is_omap34xx()) + return (void *)OMAP3_SRAM_BASE; + if (cpu_is_omap4xxx()) + return (void *)OMAP44XX_SRAM_BASE; +} + +void __noreturn omap_start_barebox(void *barebox) +{ + int (*func)(void *) = barebox; + uint32_t *arg; + void *sramadr = omap_sram_start(); + + arg = (uint32_t *)&omap_bootinfo; + + memcpy(sramadr, &omap_bootinfo, sizeof(uint32_t) * 3); + + shutdown_barebox(); + func(sramadr); + hang(); +} + +#ifdef CONFIG_BOOTM +static int do_bootm_omap_barebox(struct image_data *data) +{ + void (*barebox)(uint32_t); + + barebox = read_file(data->os_file, NULL); + if (!barebox) + return -EINVAL; + + omap_start_barebox(barebox); +} + +static struct image_handler omap_barebox_handler = { + .name = "OMAP barebox", + .bootm = do_bootm_omap_barebox, + .filetype = filetype_arm_barebox, +}; + +static int omap_bootm_barebox(void) +{ + return register_image_handler(&omap_barebox_handler); +} +device_initcall(omap_bootm_barebox); +#endif const static char *omap_bootmmc_dev; |