[U-Boot] [PATCH v7 0/29] ARM: SPL: Make more generic, merge DaVinci and OMAP

Hey all,
The following patch series merges the davinci and omap-common SPL frameworks into a single framework, CONFIG_SPL_FRAMEWORK along with a few small cleanups to the code to make it a little smaller and more flexible. The end result is that davinci can now opt in on SPL-boots-Linux by just setting the right defines and other platforms would just need to adapt to this framework. In my testing, davinci gains between 300 and 700 bytes for this (not enabling the SPL OS feature) and omap4/5/etc lose just a little bit (from the printf->puts changes). I've tested this on omap3_beagle (xM and classic) and omap4_panda. I don't have any davinci platforms that were previously using SPL so I can't boot-test those changes but since everyone sets CONFIG_SPL_MAX_SIZE, we're OK in that department.
To make this series easier to test I've placed it on http://github.com/trini/u-boot WIP/spl-improvements
I've looked a little into re-reducing the size and the biggest problem I see is that SPI a lot of informational prints that we don't need, strictly speaking, but are nice in a normal U-Boot context. I'm unsure of the best way to quiet these as I don't like the idea of sprinkling http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303 and I'm sending another email to discuss that.
v6 is tested on: - AM335x EVM, Beaglebone, Beagleboard rev C (NAND and MMC), Beagleboard xM, OMAP3EVM (MMC) Devkit8000 (MMC + SPL OS goto U-Boot instead, no kernel so no SPL Linux test), Pandaboard, Pandaboard ES, LogicPD AM1808 EVM
v7 is tested on: - Beaglebone, Beagleboard rev C (NAND and MMC), Beagleboard xM.
I did more limited testing this time due to the scope of the changes.
'reset' and cold power-on tested in various combinations.
-- Tom
Changes in v2: - Fix checkpatch warning (u32* boot_params_ptr -> u32 *boot_params_ptr) - Reorder all of the patches that used to follow this to precede. - Place files into common/spl (due to gcc bug #54303) and include/spl.h - Add CONFIG_SYS_SPL_MALLOC_START / SIZE defines from Christian Riesch - Add arch/arm/cpu/arm926ejs/davinci/config.mk to build u-boot.ais - Add README.da850_am18xxevm
Changes in v3: - Fix checkpatch.pl warning - Make use of board_init_f being a weak function now so that we can perform early init. Fixes the cannot reset problem. - Make u-boot.ais use u-boot.img not u-boot.bin, now that it uses CONFIG_SPL_FRAMEWORK - Fix thinko, Nand -> SPI (spotted by Prabhakar Lad) - Rename to README.da850, add more direct recovery method (Christian Riesch)
Changes in v4: - Document what board_init_f must do - Based on PowerPC, use memset to clear BSS rather than relocate_code - Move board_init_f / jump_to_image_linux to arch/arm/lib/spl.c - Make board_init_f setup the global data pointer, after clearing BSS. - Add Stefano's patch for CONFIG_SYS_MONITOR_LEN - Leave nand_spl_load.c alone, move the new load into nand_spl_simple.c - Adapt davinci to new board_init_f requirements - Further re-word README.da850 based on feedback from Christian Riesch
Changes in v5: - Drop <asm/utils.h> from spl.c (noticed by Stefan) - After seeing Stefan's PowerPC series, move gdata to arch/arm/lib/spl.c - Add Stefan's patch to use image_get_xxx() functions - Move the file to common/spl/ rather than integrate with another file, after talking with Scott Wood - Update davinci conversion for NAND change - Add Stefan's patch for NOR loading in SPL - Drop mpc5xxx-specific memcpy changes, these should be handled by the Makefile logic (noticed by Daniel Schwierzeck, changed by me)
Changes in v6: - Add Pavel's whitespace fix to omap-common/u-boot-spl.lds - Move __bss* extern's to <asm/spl.h> - Document that preloader_console_init requires the gd pointer to be setup. - Have omap*/am33xx set gd prior to calling preloader_console_init - Make common/spl/spl_nand.o build for CONFIG_SPL_NAND_SUPPORT (noticed by Scott Wood) - Add Sughosh's patch to update hawkboard - Fix typo (L137 -> L138) noticed by Christian Riesch - Add Stefan's patch for custom U-Boot entry point - Add Pavel's spl_ram_load_image for when we've already got next image residing in DDR. - Fix multiline comment in spl_ram_load_image.
Changes in v7: - Make spl_mmc use mmc->read_bl_len rather than a define. - Fix igep* board building - Drop drivers/mmc/spl_mmc_load.c - Update davinci MMC loading options / code for new framework - Update hawkboard size based on new upstream values
Pavel Machek (2): omap-common: SPL: Fix whitespace in omap-common/u-boot-spl.lds. SPL: Add support for loading image from ram in SPL.
Stefan Roese (4): SPL: Use image_get_xxx() functions to access header values SPL: Add NOR flash booting support SPL: Add option to skip copying of the mkimage header SPL: Enable use of custom defined U-Boot entry point
Stefano Babic (1): SPL: do not use fix value for u-boot size
Sughosh Ganu (1): hawkboard: Update config file to work with common spl framework
Tom Rini (21): Makefile: Move SPL files to clobber, remove from clean spl_mmc: Make FAT checks / calls guarded with CONFIG_SPL_FAT_SUPPORT omap-common: SPL: Add CONFIG_SPL_DISPLAY_PRINT / spl_display_print() omap-common: Fix typo in save_boot_params() in lowlevel_init.S ARM: SPL: Rename omap_boot_device to spl_boot_device ARM: SPL: Rename omap_boot_mode to spl_boot_mode() ARM: SPL: Remove NAND_MODE_HW_ECC from spl_nand.c ARM: SPL: Only call mem_malloc_init if configured ARM: SPL: Add <asm/spl.h> and <asm/arch/spl.h> ARM: SPL: Make spl_mmc.c more generic ARM: SPL: Clean up spl.c / spl_nand.c slightly ARM: SPL: Start hooking in the current SPI SPL support ARM: SPL: Move gpmc_init() to spl_board_init() SPL: Move the omap SPL framework to common/spl SPL: Create arch/arm/lib/spl.c for board_init_f and jump_to_image_linux SPL: NAND: Move arch/arm/cpu/armv7/omap-common/spl_nand.c to common/spl ARM: SPL: Convert davinci to CONFIG_SPL_FRAMEWORK da850: Add README.da850 SPL: SPI: Enhance spi_spl_load to match the other load functions SPL: Make un-supported boot device puts a debug instead SPL: Rework how we inform about un-headered images
Makefile | 11 +- README | 12 ++ arch/arm/cpu/arm926ejs/davinci/Makefile | 2 +- arch/arm/cpu/arm926ejs/davinci/config.mk | 16 ++ arch/arm/cpu/arm926ejs/davinci/spl.c | 72 ++++----- arch/arm/cpu/arm926ejs/start.S | 20 +-- arch/arm/cpu/armv7/am33xx/board.c | 4 +- arch/arm/cpu/armv7/omap-common/Makefile | 13 -- arch/arm/cpu/armv7/omap-common/boot-common.c | 27 +++- arch/arm/cpu/armv7/omap-common/hwinit-common.c | 10 +- arch/arm/cpu/armv7/omap-common/lowlevel_init.S | 6 +- arch/arm/cpu/armv7/omap-common/u-boot-spl.lds | 6 +- arch/arm/cpu/armv7/omap3/board.c | 32 +++- arch/arm/cpu/armv7/start.S | 13 +- arch/arm/include/asm/arch-am33xx/spl.h | 31 ++++ arch/arm/include/asm/arch-davinci/spl.h | 32 ++++ arch/arm/include/asm/arch-omap3/spl.h | 34 +++++ arch/arm/include/asm/arch-omap4/spl.h | 35 +++++ arch/arm/include/asm/arch-omap4/sys_proto.h | 1 - arch/arm/include/asm/arch-omap5/spl.h | 35 +++++ arch/arm/include/asm/arch-omap5/sys_proto.h | 1 - arch/arm/include/asm/omap_common.h | 77 ---------- arch/arm/include/asm/spl.h | 34 +++++ arch/arm/lib/Makefile | 2 + arch/arm/lib/spl.c | 72 +++++++++ board/davinci/da8xxevm/README.da850 | 68 +++++++++ board/overo/overo.c | 10 -- common/spl/Makefile | 39 +++++ .../arm/cpu/armv7/omap-common => common/spl}/spl.c | 157 +++++++++++--------- .../armv7/omap-common => common/spl}/spl_nand.c | 25 +--- common/spl/spl_nor.c | 62 ++++++++ .../armv7/omap-common => common/spl}/spl_ymodem.c | 3 +- doc/README.SPL | 1 + drivers/mmc/Makefile | 4 +- .../armv7/omap-common => drivers/mmc}/spl_mmc.c | 30 +--- drivers/mmc/spl_mmc_load.c | 62 -------- drivers/mtd/spi/spi_spl_load.c | 23 +-- include/configs/am335x_evm.h | 1 + include/configs/am3517_crane.h | 2 + include/configs/am3517_evm.h | 2 + include/configs/cam_enc_4xx.h | 3 +- include/configs/da850evm.h | 15 +- include/configs/devkit8000.h | 1 + include/configs/hawkboard.h | 5 +- include/configs/igep00x0.h | 1 + include/configs/mcx.h | 2 + include/configs/omap3_beagle.h | 1 + include/configs/omap3_evm_common.h | 1 + include/configs/omap3_overo.h | 1 + include/configs/omap4_common.h | 2 + include/configs/omap5_evm.h | 2 + include/configs/tam3517-common.h | 2 + include/configs/tricorder.h | 1 + include/spl.h | 77 ++++++++++ spl/Makefile | 1 + 55 files changed, 811 insertions(+), 391 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/davinci/config.mk create mode 100644 arch/arm/include/asm/arch-am33xx/spl.h create mode 100644 arch/arm/include/asm/arch-davinci/spl.h create mode 100644 arch/arm/include/asm/arch-omap3/spl.h create mode 100644 arch/arm/include/asm/arch-omap4/spl.h create mode 100644 arch/arm/include/asm/arch-omap5/spl.h create mode 100644 arch/arm/include/asm/spl.h create mode 100644 arch/arm/lib/spl.c create mode 100644 board/davinci/da8xxevm/README.da850 create mode 100644 common/spl/Makefile rename {arch/arm/cpu/armv7/omap-common => common/spl}/spl.c (60%) rename {arch/arm/cpu/armv7/omap-common => common/spl}/spl_nand.c (86%) create mode 100644 common/spl/spl_nor.c rename {arch/arm/cpu/armv7/omap-common => common/spl}/spl_ymodem.c (96%) rename {arch/arm/cpu/armv7/omap-common => drivers/mmc}/spl_mmc.c (87%) delete mode 100644 drivers/mmc/spl_mmc_load.c create mode 100644 include/spl.h

The 'clean' target has been removing all of spl but not u-boot itself. For consistency and ease of testing, only remove SPL binaries / maps in the clobber target, just like for full U-Boot
Signed-off-by: Tom Rini trini@ti.com ---
Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile index e3a27c6..5b7a850 100644 --- a/Makefile +++ b/Makefile @@ -786,10 +786,6 @@ clean: @rm -f $(obj)lib/asm-offsets.s @rm -f $(obj)include/generated/asm-offsets.h @rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s - @rm -f $(obj)nand_spl/{u-boot.lds,u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map,System.map} - @rm -f $(ONENAND_BIN) - @rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.lds,u-boot-spl.map} - @rm -f $(obj)MLO @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE) @find $(OBJTREE) -type f \ ( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \ @@ -814,6 +810,9 @@ clobber: tidy @rm -f $(obj)u-boot.dtb @rm -f $(obj)u-boot.sb @rm -f $(obj)u-boot.spr + @rm -f $(obj)nand_spl/{u-boot.lds,u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map,System.map} + @rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.lds,u-boot-spl.map} + @rm -f $(obj)MLO @rm -f $(obj)tools/xway-swap-bytes @rm -f $(obj)arch/powerpc/cpu/mpc824x/bedbug_603e.c @rm -f $(obj)arch/powerpc/cpu/mpc83xx/ddr-gen?.c

Signed-off-by: Tom Rini trini@ti.com ---
arch/arm/cpu/armv7/omap-common/spl_mmc.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/arm/cpu/armv7/omap-common/spl_mmc.c b/arch/arm/cpu/armv7/omap-common/spl_mmc.c index 2f921bb..7552f6c 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_mmc.c +++ b/arch/arm/cpu/armv7/omap-common/spl_mmc.c @@ -84,6 +84,7 @@ end: } }
+#ifdef CONFIG_SPL_FAT_SUPPORT static void mmc_load_image_fat(struct mmc *mmc) { s32 err; @@ -116,6 +117,7 @@ end: hang(); } } +#endif
void spl_mmc_load_image(void) { @@ -140,9 +142,11 @@ void spl_mmc_load_image(void) if (boot_mode == MMCSD_MODE_RAW) { debug("boot mode - RAW\n"); mmc_load_image_raw(mmc); +#ifdef CONFIG_SPL_FAT_SUPPORT } else if (boot_mode == MMCSD_MODE_FAT) { debug("boot mode - FAT\n"); mmc_load_image_fat(mmc); +#endif } else { puts("spl: wrong MMC boot mode\n"); hang();

Only omap4/5 currently have a meaningful set of display text and overo had been adding a function to display nothing. Change how this works to be opt-in and only turned on for omap4/5 now.
Signed-off-by: Tom Rini trini@ti.com ---
README | 4 ++++ arch/arm/cpu/armv7/omap-common/hwinit-common.c | 5 +++++ arch/arm/cpu/armv7/omap-common/spl.c | 9 +++------ arch/arm/include/asm/arch-omap4/sys_proto.h | 1 - arch/arm/include/asm/arch-omap5/sys_proto.h | 1 - arch/arm/include/asm/omap_common.h | 2 +- board/overo/overo.c | 10 ---------- include/configs/omap4_common.h | 1 + include/configs/omap5_evm.h | 1 + 9 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/README b/README index 4428205..3acfe80 100644 --- a/README +++ b/README @@ -2572,6 +2572,10 @@ FIT uImage format: CONFIG_SYS_SPL_MALLOC_SIZE The size of the malloc pool used in SPL.
+ CONFIG_SPL_DISPLAY_PRINT + For ARM, enable an optional function to print more information + about the running system. + CONFIG_SPL_LIBCOMMON_SUPPORT Support for common/libcommon.o in SPL binary
diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c index 459ebb5..4d7ef5c 100644 --- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c +++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c @@ -92,6 +92,11 @@ static void init_boot_params(void) { boot_params_ptr = (u32 *) &boot_params; } + +void spl_display_print(void) +{ + omap_rev_string(); +} #endif
/* diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index 4d1ac85..b10832a 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -219,10 +219,7 @@ void preloader_console_init(void)
printf("\nU-Boot SPL %s (%s - %s)\n", u_boot_rev, U_BOOT_DATE, U_BOOT_TIME); - omap_rev_string(); -} - -void __weak omap_rev_string() -{ - printf("Texas Instruments Revision detection unimplemented\n"); +#ifdef CONFIG_SPL_DISPLAY_PRINT + spl_display_print(); +#endif } diff --git a/arch/arm/include/asm/arch-omap4/sys_proto.h b/arch/arm/include/asm/arch-omap4/sys_proto.h index d633573..b48f81d 100644 --- a/arch/arm/include/asm/arch-omap4/sys_proto.h +++ b/arch/arm/include/asm/arch-omap4/sys_proto.h @@ -42,7 +42,6 @@ void sr32(void *, u32, u32, u32); u32 wait_on_value(u32, u32, void *, u32); void sdelay(unsigned long); void set_pl310_ctrl_reg(u32 val); -void omap_rev_string(void); void setup_clocks_for_console(void); void prcm_init(void); void bypass_dpll(u32 *const base); diff --git a/arch/arm/include/asm/arch-omap5/sys_proto.h b/arch/arm/include/asm/arch-omap5/sys_proto.h index 74feb90..72e9df7 100644 --- a/arch/arm/include/asm/arch-omap5/sys_proto.h +++ b/arch/arm/include/asm/arch-omap5/sys_proto.h @@ -42,7 +42,6 @@ void set_muxconf_regs_non_essential(void); void sr32(void *, u32, u32, u32); u32 wait_on_value(u32, u32, void *, u32); void sdelay(unsigned long); -void omap_rev_string(void); void setup_clocks_for_console(void); void prcm_init(void); void bypass_dpll(u32 *const base); diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index 71ef9b0..65b566c 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -94,9 +94,9 @@ u32 omap_boot_mode(void);
/* SPL common function s*/ void spl_parse_image_header(const struct image_header *header); -void omap_rev_string(void); void spl_board_prepare_for_linux(void); int spl_start_uboot(void); +void spl_display_print(void);
/* NAND SPL functions */ void spl_nand_load_image(void); diff --git a/board/overo/overo.c b/board/overo/overo.c index f973870..c6d50a0 100644 --- a/board/overo/overo.c +++ b/board/overo/overo.c @@ -101,16 +101,6 @@ int board_init(void) }
/* - * Routine: omap_rev_string - * Description: For SPL builds output board rev - */ -#ifdef CONFIG_SPL_BUILD -void omap_rev_string(void) -{ -} -#endif - -/* * Routine: get_board_revision * Description: Returns the board revision */ diff --git a/include/configs/omap4_common.h b/include/configs/omap4_common.h index ee0c4b9..c1c2fa9 100644 --- a/include/configs/omap4_common.h +++ b/include/configs/omap4_common.h @@ -235,6 +235,7 @@ #define CONFIG_SPL_TEXT_BASE 0x40304350 #define CONFIG_SPL_MAX_SIZE (38 * 1024) #define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR +#define CONFIG_SPL_DISPLAY_PRINT
/* * 64 bytes before this address should be set aside for u-boot.img's diff --git a/include/configs/omap5_evm.h b/include/configs/omap5_evm.h index 4f0a6c1..b4a237a 100644 --- a/include/configs/omap5_evm.h +++ b/include/configs/omap5_evm.h @@ -232,6 +232,7 @@ #define CONFIG_SPL_TEXT_BASE 0x40300350 #define CONFIG_SPL_MAX_SIZE 0x19000 /* 100K */ #define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR +#define CONFIG_SPL_DISPLAY_PRINT
#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 /* address 0x60000 */ #define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x200 /* 256 KB */

Signed-off-by: Tom Rini trini@ti.com ---
arch/arm/cpu/armv7/omap-common/lowlevel_init.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/cpu/armv7/omap-common/lowlevel_init.S b/arch/arm/cpu/armv7/omap-common/lowlevel_init.S index 1ece073..024dda1 100644 --- a/arch/arm/cpu/armv7/omap-common/lowlevel_init.S +++ b/arch/arm/cpu/armv7/omap-common/lowlevel_init.S @@ -63,7 +63,7 @@ ENTRY(save_boot_params) blt 2f cmp r2, #7 bgt 2f - /* Store the boot mode (raw/FAT) in omap_boot_mode */ + /* Store the boot mode (raw/FAT) in omap_bootmode */ ldr r2, [r0, #DEV_DESC_PTR_OFFSET] @ get the device descriptor ptr ldr r2, [r2, #DEV_DATA_PTR_OFFSET] @ get the pDeviceData ptr ldr r2, [r2, #BOOT_MODE_OFFSET] @ get the boot mode

From: Pavel Machek pavel@denx.de
Signed-off-by: Pavel Machek pavel@denx.de Signed-off-by: Tom Rini trini@ti.com --- Changes in v6: - Add Pavel's whitespace fix to omap-common/u-boot-spl.lds
arch/arm/cpu/armv7/omap-common/u-boot-spl.lds | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/u-boot-spl.lds b/arch/arm/cpu/armv7/omap-common/u-boot-spl.lds index 8867e06..1d8efb2 100644 --- a/arch/arm/cpu/armv7/omap-common/u-boot-spl.lds +++ b/arch/arm/cpu/armv7/omap-common/u-boot-spl.lds @@ -37,9 +37,9 @@ SECTIONS { .text : { - __start = .; - arch/arm/cpu/armv7/start.o (.text) - *(.text*) + __start = .; + arch/arm/cpu/armv7/start.o (.text) + *(.text*) } >.sram
. = ALIGN(4);

Signed-off-by: Tom Rini trini@ti.com ---
arch/arm/cpu/armv7/omap-common/boot-common.c | 2 +- arch/arm/cpu/armv7/omap-common/lowlevel_init.S | 4 ++-- arch/arm/cpu/armv7/omap-common/spl.c | 2 +- arch/arm/cpu/armv7/omap-common/spl_mmc.c | 2 +- arch/arm/cpu/armv7/omap3/board.c | 4 ++-- arch/arm/include/asm/omap_common.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c index f211f76..102a381 100644 --- a/arch/arm/cpu/armv7/omap-common/boot-common.c +++ b/arch/arm/cpu/armv7/omap-common/boot-common.c @@ -37,7 +37,7 @@ struct omap_boot_parameters boot_params __attribute__ ((section(".data"))); */ u32 omap_bootmode = MMCSD_MODE_FAT;
-u32 omap_boot_device(void) +u32 spl_boot_device(void) { return (u32) (boot_params.omap_bootdevice); } diff --git a/arch/arm/cpu/armv7/omap-common/lowlevel_init.S b/arch/arm/cpu/armv7/omap-common/lowlevel_init.S index 024dda1..9766563 100644 --- a/arch/arm/cpu/armv7/omap-common/lowlevel_init.S +++ b/arch/arm/cpu/armv7/omap-common/lowlevel_init.S @@ -52,11 +52,11 @@ ENTRY(save_boot_params) ldr r1, =boot_params str r0, [r1] #ifdef CONFIG_SPL_BUILD - /* Store the boot device in omap_boot_device */ + /* Store the boot device in spl_boot_device */ ldrb r2, [r0, #BOOT_DEVICE_OFFSET] @ r1 <- value of boot device and r2, #BOOT_DEVICE_MASK ldr r3, =boot_params - strb r2, [r3, #BOOT_DEVICE_OFFSET] @ omap_boot_device <- r1 + strb r2, [r3, #BOOT_DEVICE_OFFSET] @ spl_boot_device <- r1
/* boot mode is passed only for devices that can raw/fat mode */ cmp r2, #2 diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index b10832a..4d33f99 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -156,7 +156,7 @@ void board_init_r(gd_t *id, ulong dummy) spl_board_init(); #endif
- boot_device = omap_boot_device(); + boot_device = spl_boot_device(); debug("boot device - %d\n", boot_device); switch (boot_device) { #ifdef CONFIG_SPL_MMC_SUPPORT diff --git a/arch/arm/cpu/armv7/omap-common/spl_mmc.c b/arch/arm/cpu/armv7/omap-common/spl_mmc.c index 7552f6c..3ad382b 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_mmc.c +++ b/arch/arm/cpu/armv7/omap-common/spl_mmc.c @@ -37,7 +37,7 @@ DECLARE_GLOBAL_DATA_PTR; #ifdef CONFIG_GENERIC_MMC int board_mmc_init(bd_t *bis) { - switch (omap_boot_device()) { + switch (spl_boot_device()) { case BOOT_DEVICE_MMC1: omap_mmc_init(0, 0, 0); break; diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index f2e52e9..b4f4fee 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -71,7 +71,7 @@ u32 omap3_boot_device = BOOT_DEVICE_NAND; /* auto boot mode detection is not possible for OMAP3 - hard code */ u32 omap_boot_mode(void) { - switch (omap_boot_device()) { + switch (spl_boot_device()) { case BOOT_DEVICE_MMC2: return MMCSD_MODE_RAW; case BOOT_DEVICE_MMC1: @@ -86,7 +86,7 @@ u32 omap_boot_mode(void) } }
-u32 omap_boot_device(void) +u32 spl_boot_device(void) { return omap3_boot_device; } diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index 65b566c..336ac39 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -89,7 +89,7 @@ struct spl_image_info { extern struct spl_image_info spl_image;
extern u32* boot_params_ptr; -u32 omap_boot_device(void); +u32 spl_boot_device(void); u32 omap_boot_mode(void);
/* SPL common function s*/

Signed-off-by: Tom Rini trini@ti.com ---
arch/arm/cpu/armv7/omap-common/boot-common.c | 2 +- arch/arm/cpu/armv7/omap-common/spl_mmc.c | 2 +- arch/arm/cpu/armv7/omap-common/spl_nand.c | 2 +- arch/arm/cpu/armv7/omap3/board.c | 2 +- arch/arm/include/asm/omap_common.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c index 102a381..53568ac 100644 --- a/arch/arm/cpu/armv7/omap-common/boot-common.c +++ b/arch/arm/cpu/armv7/omap-common/boot-common.c @@ -42,7 +42,7 @@ u32 spl_boot_device(void) return (u32) (boot_params.omap_bootdevice); }
-u32 omap_boot_mode(void) +u32 spl_boot_mode(void) { return omap_bootmode; } diff --git a/arch/arm/cpu/armv7/omap-common/spl_mmc.c b/arch/arm/cpu/armv7/omap-common/spl_mmc.c index 3ad382b..62b308b 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_mmc.c +++ b/arch/arm/cpu/armv7/omap-common/spl_mmc.c @@ -138,7 +138,7 @@ void spl_mmc_load_image(void) printf("spl: mmc init failed: err - %d\n", err); hang(); } - boot_mode = omap_boot_mode(); + boot_mode = spl_boot_mode(); if (boot_mode == MMCSD_MODE_RAW) { debug("boot mode - RAW\n"); mmc_load_image_raw(mmc); diff --git a/arch/arm/cpu/armv7/omap-common/spl_nand.c b/arch/arm/cpu/armv7/omap-common/spl_nand.c index 8cf55c9..ea7cc8a 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_nand.c +++ b/arch/arm/cpu/armv7/omap-common/spl_nand.c @@ -35,7 +35,7 @@ void spl_nand_load_image(void) int *src __attribute__((unused)); int *dst __attribute__((unused));
- switch (omap_boot_mode()) { + switch (spl_boot_mode()) { case NAND_MODE_HW_ECC: debug("spl: nand - using hw ecc\n"); gpmc_init(); diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index b4f4fee..1640696 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -69,7 +69,7 @@ const struct gpio_bank *const omap_gpio_bank = gpio_bank_34xx; u32 omap3_boot_device = BOOT_DEVICE_NAND;
/* auto boot mode detection is not possible for OMAP3 - hard code */ -u32 omap_boot_mode(void) +u32 spl_boot_mode(void) { switch (spl_boot_device()) { case BOOT_DEVICE_MMC2: diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index 336ac39..f5b9dfe 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -90,7 +90,7 @@ extern struct spl_image_info spl_image;
extern u32* boot_params_ptr; u32 spl_boot_device(void); -u32 omap_boot_mode(void); +u32 spl_boot_mode(void);
/* SPL common function s*/ void spl_parse_image_header(const struct image_header *header);

This detection code doesn't (and can't) do anything currently, so remove.
Signed-off-by: Tom Rini trini@ti.com ---
arch/arm/cpu/armv7/omap-common/spl_nand.c | 13 +++---------- arch/arm/cpu/armv7/omap3/board.c | 3 --- arch/arm/include/asm/omap_common.h | 1 - 3 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/spl_nand.c b/arch/arm/cpu/armv7/omap-common/spl_nand.c index ea7cc8a..39221d5 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_nand.c +++ b/arch/arm/cpu/armv7/omap-common/spl_nand.c @@ -35,16 +35,9 @@ void spl_nand_load_image(void) int *src __attribute__((unused)); int *dst __attribute__((unused));
- switch (spl_boot_mode()) { - case NAND_MODE_HW_ECC: - debug("spl: nand - using hw ecc\n"); - gpmc_init(); - nand_init(); - break; - default: - puts("spl: ERROR: This bootmode is not implemented - hanging"); - hang(); - } + debug("spl: nand - using hw ecc\n"); + gpmc_init(); + nand_init();
/*use CONFIG_SYS_TEXT_BASE as temporary storage area */ header = (struct image_header *)(CONFIG_SYS_TEXT_BASE); diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index 1640696..a487374 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -77,9 +77,6 @@ u32 spl_boot_mode(void) case BOOT_DEVICE_MMC1: return MMCSD_MODE_FAT; break; - case BOOT_DEVICE_NAND: - return NAND_MODE_HW_ECC; - break; default: puts("spl: ERROR: unknown device - can't select boot mode\n"); hang(); diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index f5b9dfe..4d331fc 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -76,7 +76,6 @@ void preloader_console_init(void); #define MMCSD_MODE_UNDEFINED 0 #define MMCSD_MODE_RAW 1 #define MMCSD_MODE_FAT 2 -#define NAND_MODE_HW_ECC 3
struct spl_image_info { const char *name;

We can only attempt to setup a malloc pool if CONFIG_SYS_SPL_MALLOC_START is defined, and not all boards require it. Make the call depend on the define.
Signed-off-by: Tom Rini trini@ti.com ---
arch/arm/cpu/armv7/omap-common/spl.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index 4d33f99..71a467e 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -149,8 +149,10 @@ void board_init_r(gd_t *id, ulong dummy) u32 boot_device; debug(">>spl:board_init_r()\n");
+#ifdef CONFIG_SYS_SPL_MALLOC_START mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE); +#endif
#ifdef CONFIG_SPL_BOARD_INIT spl_board_init();

Move the SPL prototypes from <asm/omap_common.h> into <asm/spl.h> and add <asm/arch/spl.h> for arch specific portions of CONFIG_SPL_FRAMEWORK.
Signed-off-by: Tom Rini trini@ti.com --- Changes in v2: - Fix checkpatch warning (u32* boot_params_ptr -> u32 *boot_params_ptr)
arch/arm/cpu/armv7/am33xx/board.c | 2 +- arch/arm/cpu/armv7/omap-common/hwinit-common.c | 2 +- arch/arm/cpu/armv7/omap-common/spl.c | 2 +- arch/arm/cpu/armv7/omap-common/spl_mmc.c | 1 + arch/arm/cpu/armv7/omap-common/spl_nand.c | 2 +- arch/arm/cpu/armv7/omap-common/spl_ymodem.c | 2 +- arch/arm/cpu/armv7/omap3/board.c | 1 + arch/arm/include/asm/arch-am33xx/spl.h | 31 +++++++++++ arch/arm/include/asm/arch-omap3/spl.h | 34 ++++++++++++ arch/arm/include/asm/arch-omap4/spl.h | 35 ++++++++++++ arch/arm/include/asm/arch-omap5/spl.h | 35 ++++++++++++ arch/arm/include/asm/omap_common.h | 71 ------------------------ arch/arm/include/asm/spl.h | 61 ++++++++++++++++++++ 13 files changed, 203 insertions(+), 76 deletions(-) create mode 100644 arch/arm/include/asm/arch-am33xx/spl.h create mode 100644 arch/arm/include/asm/arch-omap3/spl.h create mode 100644 arch/arm/include/asm/arch-omap4/spl.h create mode 100644 arch/arm/include/asm/arch-omap5/spl.h create mode 100644 arch/arm/include/asm/spl.h
diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index ecc2671..e89df8e 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -27,9 +27,9 @@ #include <asm/arch/mmc_host_def.h> #include <asm/arch/sys_proto.h> #include <asm/io.h> -#include <asm/omap_common.h> #include <asm/emif.h> #include <asm/gpio.h> +#include <asm/spl.h> #include <i2c.h> #include <miiphy.h> #include <cpsw.h> diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c index 4d7ef5c..d5fde38 100644 --- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c +++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c @@ -31,7 +31,7 @@ #include <asm/arch/sys_proto.h> #include <asm/sizes.h> #include <asm/emif.h> -#include <asm/omap_common.h> +#include <asm/spl.h>
DECLARE_GLOBAL_DATA_PTR;
diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index 71a467e..81991b2 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -23,6 +23,7 @@ * MA 02111-1307 USA */ #include <common.h> +#include <asm/spl.h> #include <asm/u-boot.h> #include <asm/utils.h> #include <asm/arch/sys_proto.h> @@ -30,7 +31,6 @@ #include <mmc.h> #include <fat.h> #include <version.h> -#include <asm/omap_common.h> #include <asm/arch/mmc_host_def.h> #include <i2c.h> #include <image.h> diff --git a/arch/arm/cpu/armv7/omap-common/spl_mmc.c b/arch/arm/cpu/armv7/omap-common/spl_mmc.c index 62b308b..fe44538 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_mmc.c +++ b/arch/arm/cpu/armv7/omap-common/spl_mmc.c @@ -23,6 +23,7 @@ * MA 02111-1307 USA */ #include <common.h> +#include <asm/spl.h> #include <asm/u-boot.h> #include <asm/utils.h> #include <asm/arch/sys_proto.h> diff --git a/arch/arm/cpu/armv7/omap-common/spl_nand.c b/arch/arm/cpu/armv7/omap-common/spl_nand.c index 39221d5..6552a5d 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_nand.c +++ b/arch/arm/cpu/armv7/omap-common/spl_nand.c @@ -21,13 +21,13 @@ * MA 02111-1307 USA */ #include <common.h> +#include <asm/spl.h> #include <asm/u-boot.h> #include <asm/utils.h> #include <asm/arch/sys_proto.h> #include <asm/io.h> #include <nand.h> #include <version.h> -#include <asm/omap_common.h>
void spl_nand_load_image(void) { diff --git a/arch/arm/cpu/armv7/omap-common/spl_ymodem.c b/arch/arm/cpu/armv7/omap-common/spl_ymodem.c index 47663f7..65565e3 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_ymodem.c +++ b/arch/arm/cpu/armv7/omap-common/spl_ymodem.c @@ -26,11 +26,11 @@ * MA 02111-1307 USA */ #include <common.h> +#include <asm/spl.h> #include <xyzModem.h> #include <asm/u-boot.h> #include <asm/utils.h> #include <asm/arch/sys_proto.h> -#include <asm/omap_common.h>
#define BUF_SIZE 1024
diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index a487374..45976f9 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -39,6 +39,7 @@ #include <asm/cache.h> #include <asm/armv7.h> #include <asm/arch/gpio.h> +#include <asm/spl.h> #include <asm/omap_common.h> #include <i2c.h> #include <linux/compiler.h> diff --git a/arch/arm/include/asm/arch-am33xx/spl.h b/arch/arm/include/asm/arch-am33xx/spl.h new file mode 100644 index 0000000..70f521d --- /dev/null +++ b/arch/arm/include/asm/arch-am33xx/spl.h @@ -0,0 +1,31 @@ +/* + * (C) Copyright 2012 + * Texas Instruments, <www.ti.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +#ifndef _ASM_ARCH_SPL_H_ +#define _ASM_SPL_H_ + +#define BOOT_DEVICE_NAND 5 +#define BOOT_DEVICE_MMC1 8 +#define BOOT_DEVICE_MMC2 9 /* eMMC or daughter card */ +#define BOOT_DEVICE_UART 65 +#define BOOT_DEVICE_MMC2_2 0xFF +#endif diff --git a/arch/arm/include/asm/arch-omap3/spl.h b/arch/arm/include/asm/arch-omap3/spl.h new file mode 100644 index 0000000..404e16a --- /dev/null +++ b/arch/arm/include/asm/arch-omap3/spl.h @@ -0,0 +1,34 @@ +/* + * (C) Copyright 2012 + * Texas Instruments, <www.ti.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +#ifndef _ASM_ARCH_SPL_H_ +#define _ASM_SPL_H_ + +#define BOOT_DEVICE_NONE 0 +#define BOOT_DEVICE_XIP 1 +#define BOOT_DEVICE_NAND 2 +#define BOOT_DEVICE_ONE_NAND 3 +#define BOOT_DEVICE_MMC2 5 /*emmc*/ +#define BOOT_DEVICE_MMC1 6 +#define BOOT_DEVICE_XIPWAIT 7 +#define BOOT_DEVICE_MMC2_2 0xFF +#endif diff --git a/arch/arm/include/asm/arch-omap4/spl.h b/arch/arm/include/asm/arch-omap4/spl.h new file mode 100644 index 0000000..cec84dc --- /dev/null +++ b/arch/arm/include/asm/arch-omap4/spl.h @@ -0,0 +1,35 @@ +/* + * (C) Copyright 2012 + * Texas Instruments, <www.ti.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +#ifndef _ASM_ARCH_SPL_H_ +#define _ASM_SPL_H_ + +#define BOOT_DEVICE_NONE 0 +#define BOOT_DEVICE_XIP 1 +#define BOOT_DEVICE_XIPWAIT 2 +#define BOOT_DEVICE_NAND 3 +#define BOOT_DEVICE_ONE_NAND 4 +#define BOOT_DEVICE_MMC1 5 +#define BOOT_DEVICE_MMC2 6 +#define BOOT_DEVICE_MMC2_2 0xFF + +#endif diff --git a/arch/arm/include/asm/arch-omap5/spl.h b/arch/arm/include/asm/arch-omap5/spl.h new file mode 100644 index 0000000..d125c61 --- /dev/null +++ b/arch/arm/include/asm/arch-omap5/spl.h @@ -0,0 +1,35 @@ +/* + * (C) Copyright 2012 + * Texas Instruments, <www.ti.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +#ifndef _ASM_ARCH_SPL_H_ +#define _ASM_SPL_H_ + +#define BOOT_DEVICE_NONE 0 +#define BOOT_DEVICE_XIP 1 +#define BOOT_DEVICE_XIPWAIT 2 +#define BOOT_DEVICE_NAND 3 +#define BOOT_DEVICE_ONE_NAND 4 +#define BOOT_DEVICE_MMC1 5 +#define BOOT_DEVICE_MMC2 6 +#define BOOT_DEVICE_MMC2_2 7 + +#endif diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index 4d331fc..775ab6c 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -34,82 +34,11 @@ #define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL 2 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH 3
-void preloader_console_init(void); - -/* Boot device */ -#ifdef CONFIG_OMAP54XX -#define BOOT_DEVICE_NONE 0 -#define BOOT_DEVICE_XIP 1 -#define BOOT_DEVICE_XIPWAIT 2 -#define BOOT_DEVICE_NAND 3 -#define BOOT_DEVICE_ONE_NAND 4 -#define BOOT_DEVICE_MMC1 5 -#define BOOT_DEVICE_MMC2 6 -#define BOOT_DEVICE_MMC2_2 7 -#elif defined(CONFIG_OMAP44XX) /* OMAP4 */ -#define BOOT_DEVICE_NONE 0 -#define BOOT_DEVICE_XIP 1 -#define BOOT_DEVICE_XIPWAIT 2 -#define BOOT_DEVICE_NAND 3 -#define BOOT_DEVICE_ONE_NAND 4 -#define BOOT_DEVICE_MMC1 5 -#define BOOT_DEVICE_MMC2 6 -#define BOOT_DEVICE_MMC2_2 0xFF -#elif defined(CONFIG_OMAP34XX) /* OMAP3 */ -#define BOOT_DEVICE_NONE 0 -#define BOOT_DEVICE_XIP 1 -#define BOOT_DEVICE_NAND 2 -#define BOOT_DEVICE_ONE_NAND 3 -#define BOOT_DEVICE_MMC2 5 /*emmc*/ -#define BOOT_DEVICE_MMC1 6 -#define BOOT_DEVICE_XIPWAIT 7 -#define BOOT_DEVICE_MMC2_2 0xFF -#elif defined(CONFIG_AM33XX) /* AM33XX */ -#define BOOT_DEVICE_NAND 5 -#define BOOT_DEVICE_MMC1 8 -#define BOOT_DEVICE_MMC2 9 /* eMMC or daughter card */ -#define BOOT_DEVICE_UART 65 -#define BOOT_DEVICE_MMC2_2 0xFF -#endif - /* Boot type */ #define MMCSD_MODE_UNDEFINED 0 #define MMCSD_MODE_RAW 1 #define MMCSD_MODE_FAT 2
-struct spl_image_info { - const char *name; - u8 os; - u32 load_addr; - u32 entry_point; - u32 size; -}; - -extern struct spl_image_info spl_image; - -extern u32* boot_params_ptr; -u32 spl_boot_device(void); -u32 spl_boot_mode(void); - -/* SPL common function s*/ -void spl_parse_image_header(const struct image_header *header); -void spl_board_prepare_for_linux(void); -int spl_start_uboot(void); -void spl_display_print(void); - -/* NAND SPL functions */ -void spl_nand_load_image(void); - -/* MMC SPL functions */ -void spl_mmc_load_image(void); - -/* YMODEM SPL functions */ -void spl_ymodem_load_image(void); - -#ifdef CONFIG_SPL_BOARD_INIT -void spl_board_init(void); -#endif - static inline u32 omap_revision(void) { extern u32 *const omap_si_rev; diff --git a/arch/arm/include/asm/spl.h b/arch/arm/include/asm/spl.h new file mode 100644 index 0000000..19e6c50 --- /dev/null +++ b/arch/arm/include/asm/spl.h @@ -0,0 +1,61 @@ +/* + * (C) Copyright 2012 + * Texas Instruments, <www.ti.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +#ifndef _ASM_SPL_H_ +#define _ASM_SPL_H_ + +/* Platform-specific defines */ +#include <asm/arch/spl.h> + +struct spl_image_info { + const char *name; + u8 os; + u32 load_addr; + u32 entry_point; + u32 size; +}; + +extern struct spl_image_info spl_image; +extern u32 *boot_params_ptr; + +/* SPL common functions */ +void preloader_console_init(void); +u32 spl_boot_device(void); +u32 spl_boot_mode(void); +void spl_parse_image_header(const struct image_header *header); +void spl_board_prepare_for_linux(void); +int spl_start_uboot(void); +void spl_display_print(void); + +/* NAND SPL functions */ +void spl_nand_load_image(void); + +/* MMC SPL functions */ +void spl_mmc_load_image(void); + +/* YMODEM SPL functions */ +void spl_ymodem_load_image(void); + +#ifdef CONFIG_SPL_BOARD_INIT +void spl_board_init(void); +#endif +#endif

Move the default omap/related-centric board_mmc_init to arch/arm/cpu/armv7/omap-common/boot-common.c and move the type defines to <asm/spl.h>. Also use mmc->read_bl_len rather than MMCSD_SECTOR_SIZE
Signed-off-by: Tom Rini trini@ti.com --- Changes in v7: - Make spl_mmc use mmc->read_bl_len rather than a define.
arch/arm/cpu/armv7/omap-common/boot-common.c | 16 ++++++++++++++++ arch/arm/cpu/armv7/omap-common/spl_mmc.c | 23 ++--------------------- arch/arm/cpu/armv7/omap3/board.c | 15 +++++++++++++++ arch/arm/include/asm/omap_common.h | 5 ----- arch/arm/include/asm/spl.h | 5 +++++ 5 files changed, 38 insertions(+), 26 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c index 53568ac..3406cfb 100644 --- a/arch/arm/cpu/armv7/omap-common/boot-common.c +++ b/arch/arm/cpu/armv7/omap-common/boot-common.c @@ -17,8 +17,10 @@ */
#include <common.h> +#include <asm/spl.h> #include <asm/omap_common.h> #include <asm/arch/omap.h> +#include <asm/arch/mmc_host_def.h>
/* * This is used to verify if the configuration header @@ -46,4 +48,18 @@ u32 spl_boot_mode(void) { return omap_bootmode; } + +int board_mmc_init(bd_t *bis) +{ + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC1: + omap_mmc_init(0, 0, 0); + break; + case BOOT_DEVICE_MMC2: + case BOOT_DEVICE_MMC2_2: + omap_mmc_init(1, 0, 0); + break; + } + return 0; +} #endif diff --git a/arch/arm/cpu/armv7/omap-common/spl_mmc.c b/arch/arm/cpu/armv7/omap-common/spl_mmc.c index fe44538..fdecf94 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_mmc.c +++ b/arch/arm/cpu/armv7/omap-common/spl_mmc.c @@ -26,31 +26,12 @@ #include <asm/spl.h> #include <asm/u-boot.h> #include <asm/utils.h> -#include <asm/arch/sys_proto.h> #include <mmc.h> #include <fat.h> #include <version.h> -#include <asm/omap_common.h> -#include <asm/arch/mmc_host_def.h>
DECLARE_GLOBAL_DATA_PTR;
-#ifdef CONFIG_GENERIC_MMC -int board_mmc_init(bd_t *bis) -{ - switch (spl_boot_device()) { - case BOOT_DEVICE_MMC1: - omap_mmc_init(0, 0, 0); - break; - case BOOT_DEVICE_MMC2: - case BOOT_DEVICE_MMC2_2: - omap_mmc_init(1, 0, 0); - break; - } - return 0; -} -#endif - static void mmc_load_image_raw(struct mmc *mmc) { u32 image_size_sectors, err; @@ -70,8 +51,8 @@ static void mmc_load_image_raw(struct mmc *mmc) spl_parse_image_header(header);
/* convert size to sectors - round up */ - image_size_sectors = (spl_image.size + MMCSD_SECTOR_SIZE - 1) / - MMCSD_SECTOR_SIZE; + image_size_sectors = (spl_image.size + mmc->read_bl_len - 1) / + mmc->read_bl_len;
/* Read the header too to avoid extra memcpy */ err = mmc->block_dev.block_read(0, diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index 45976f9..3d74f09 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -41,6 +41,7 @@ #include <asm/arch/gpio.h> #include <asm/spl.h> #include <asm/omap_common.h> +#include <asm/arch/mmc_host_def.h> #include <i2c.h> #include <linux/compiler.h>
@@ -89,6 +90,20 @@ u32 spl_boot_device(void) return omap3_boot_device; }
+int board_mmc_init(bd_t *bis) +{ + switch (spl_boot_device()) { + case BOOT_DEVICE_MMC1: + omap_mmc_init(0, 0, 0); + break; + case BOOT_DEVICE_MMC2: + case BOOT_DEVICE_MMC2_2: + omap_mmc_init(1, 0, 0); + break; + } + return 0; +} + void spl_board_init(void) { #ifdef CONFIG_SPL_I2C_SUPPORT diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index 775ab6c..2a40b89 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -34,11 +34,6 @@ #define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL 2 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH 3
-/* Boot type */ -#define MMCSD_MODE_UNDEFINED 0 -#define MMCSD_MODE_RAW 1 -#define MMCSD_MODE_FAT 2 - static inline u32 omap_revision(void) { extern u32 *const omap_si_rev; diff --git a/arch/arm/include/asm/spl.h b/arch/arm/include/asm/spl.h index 19e6c50..fdb78b5 100644 --- a/arch/arm/include/asm/spl.h +++ b/arch/arm/include/asm/spl.h @@ -26,6 +26,11 @@ /* Platform-specific defines */ #include <asm/arch/spl.h>
+/* Boot type */ +#define MMCSD_MODE_UNDEFINED 0 +#define MMCSD_MODE_RAW 1 +#define MMCSD_MODE_FAT 2 + struct spl_image_info { const char *name; u8 os;

- Remove includes we don't need - Switch some printf statements to puts - Convert some printf statements to debug, introduce new puts statements - In most cases saying just "No mkimage signature, assuming u-boot.bin" or similar is sufficient. This also means the non-DEBUG case doesn't need printf, in the core of SPL. - The other case here is that PLAIN_VERSION provided what we wanted already, so just use it.
Signed-off-by: Tom Rini trini@ti.com ---
arch/arm/cpu/armv7/omap-common/spl.c | 23 ++++++++--------------- arch/arm/cpu/armv7/omap-common/spl_nand.c | 1 - 2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index 81991b2..3a1029f 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -26,12 +26,9 @@ #include <asm/spl.h> #include <asm/u-boot.h> #include <asm/utils.h> -#include <asm/arch/sys_proto.h> #include <nand.h> -#include <mmc.h> #include <fat.h> #include <version.h> -#include <asm/arch/mmc_host_def.h> #include <i2c.h> #include <image.h> #include <malloc.h> @@ -78,8 +75,8 @@ void board_init_f(ulong dummy) #ifdef CONFIG_SPL_OS_BOOT __weak int spl_start_uboot(void) { - printf("SPL: Please implement spl_start_uboot() for your board\n"); - printf("SPL: Direct Linux boot not active!\n"); + puts("SPL: Please implement spl_start_uboot() for your board\n"); + puts("SPL: Direct Linux boot not active!\n"); return 1; } #endif @@ -99,9 +96,9 @@ void spl_parse_image_header(const struct image_header *header) spl_image.name, spl_image.load_addr, spl_image.size); } else { /* Signature not found - assume u-boot.bin */ - printf("mkimage signature not found - ih_magic = %x\n", + puts("mkimage signature not found, assuming u-boot.bin ..\n"); + debug("mkimage signature not found - ih_magic = %x\n", header->ih_magic); - debug("Assuming u-boot.bin ..\n"); /* Let's assume U-Boot will not be more than 200 KB */ spl_image.size = 200 * 1024; spl_image.entry_point = CONFIG_SYS_TEXT_BASE; @@ -179,7 +176,8 @@ void board_init_r(gd_t *id, ulong dummy) break; #endif default: - printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device); + puts("SPL: Un-supported Boot Device\n"); + debug("Found: %d\n", boot_device); hang(); break; } @@ -205,8 +203,6 @@ void board_init_r(gd_t *id, ulong dummy) /* This requires UART clocks to be enabled */ void preloader_console_init(void) { - const char *u_boot_rev = U_BOOT_VERSION; - gd = &gdata; gd->bd = &bdata; gd->flags |= GD_FLG_RELOC; @@ -216,11 +212,8 @@ void preloader_console_init(void)
gd->have_console = 1;
- /* Avoid a second "U-Boot" coming from this string */ - u_boot_rev = &u_boot_rev[7]; - - printf("\nU-Boot SPL %s (%s - %s)\n", u_boot_rev, U_BOOT_DATE, - U_BOOT_TIME); + puts("\nU-Boot SPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \ + U_BOOT_TIME ")\n"); #ifdef CONFIG_SPL_DISPLAY_PRINT spl_display_print(); #endif diff --git a/arch/arm/cpu/armv7/omap-common/spl_nand.c b/arch/arm/cpu/armv7/omap-common/spl_nand.c index 6552a5d..3e2f359 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_nand.c +++ b/arch/arm/cpu/armv7/omap-common/spl_nand.c @@ -24,7 +24,6 @@ #include <asm/spl.h> #include <asm/u-boot.h> #include <asm/utils.h> -#include <asm/arch/sys_proto.h> #include <asm/io.h> #include <nand.h> #include <version.h>

Signed-off-by: Tom Rini trini@ti.com ---
arch/arm/cpu/armv7/omap-common/spl.c | 5 +++++ arch/arm/include/asm/spl.h | 3 +++ 2 files changed, 8 insertions(+)
diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index 3a1029f..dc26750 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -175,6 +175,11 @@ void board_init_r(gd_t *id, ulong dummy) spl_ymodem_load_image(); break; #endif +#ifdef CONFIG_SPL_SPI_SUPPORT + case BOOT_DEVICE_SPI: + spi_boot(); + break; +#endif default: puts("SPL: Un-supported Boot Device\n"); debug("Found: %d\n", boot_device); diff --git a/arch/arm/include/asm/spl.h b/arch/arm/include/asm/spl.h index fdb78b5..47ca1b6 100644 --- a/arch/arm/include/asm/spl.h +++ b/arch/arm/include/asm/spl.h @@ -60,6 +60,9 @@ void spl_mmc_load_image(void); /* YMODEM SPL functions */ void spl_ymodem_load_image(void);
+/* SPI SPL functions */ +void spi_boot(void); + #ifdef CONFIG_SPL_BOARD_INIT void spl_board_init(void); #endif

This is an OMAP/related-specific function, move calling it to spl_board_init() and turn on CONFIG_SPL_BOARD_INIT on the boards that enabled NAND and didn't enable this already.
Signed-off-by: Tom Rini trini@ti.com ---
arch/arm/cpu/armv7/omap-common/boot-common.c | 7 +++++++ arch/arm/cpu/armv7/omap-common/spl_nand.c | 1 - arch/arm/cpu/armv7/omap3/board.c | 3 +++ include/configs/am3517_crane.h | 1 + include/configs/am3517_evm.h | 1 + include/configs/mcx.h | 1 + include/configs/tam3517-common.h | 1 + 7 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c index 3406cfb..ed398fd 100644 --- a/arch/arm/cpu/armv7/omap-common/boot-common.c +++ b/arch/arm/cpu/armv7/omap-common/boot-common.c @@ -49,6 +49,13 @@ u32 spl_boot_mode(void) return omap_bootmode; }
+void spl_board_init(void) +{ +#ifdef CONFIG_SPL_NAND_SUPPORT + gpmc_init(); +#endif +} + int board_mmc_init(bd_t *bis) { switch (spl_boot_device()) { diff --git a/arch/arm/cpu/armv7/omap-common/spl_nand.c b/arch/arm/cpu/armv7/omap-common/spl_nand.c index 3e2f359..1e6b5f0 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_nand.c +++ b/arch/arm/cpu/armv7/omap-common/spl_nand.c @@ -35,7 +35,6 @@ void spl_nand_load_image(void) int *dst __attribute__((unused));
debug("spl: nand - using hw ecc\n"); - gpmc_init(); nand_init();
/*use CONFIG_SYS_TEXT_BASE as temporary storage area */ diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index 3d74f09..52196c8 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -106,6 +106,9 @@ int board_mmc_init(bd_t *bis)
void spl_board_init(void) { +#ifdef CONFIG_SPL_NAND_SUPPORT + gpmc_init(); +#endif #ifdef CONFIG_SPL_I2C_SUPPORT i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); #endif diff --git a/include/configs/am3517_crane.h b/include/configs/am3517_crane.h index f24b44d..254ed57 100644 --- a/include/configs/am3517_crane.h +++ b/include/configs/am3517_crane.h @@ -314,6 +314,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_NAND_SIMPLE #define CONFIG_SPL_TEXT_BASE 0x40200800 #define CONFIG_SPL_MAX_SIZE (54 * 1024) /* 8 KB for stack */ diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h index 95f8d78..ca39c72 100644 --- a/include/configs/am3517_evm.h +++ b/include/configs/am3517_evm.h @@ -313,6 +313,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_NAND_SIMPLE #define CONFIG_SPL_TEXT_BASE 0x40200800 #define CONFIG_SPL_MAX_SIZE (54 * 1024) /* 8 KB for stack */ diff --git a/include/configs/mcx.h b/include/configs/mcx.h index 733022e..a841c70 100644 --- a/include/configs/mcx.h +++ b/include/configs/mcx.h @@ -359,6 +359,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_NAND_SIMPLE #define CONFIG_SPL_NAND_SOFTECC
diff --git a/include/configs/tam3517-common.h b/include/configs/tam3517-common.h index a13fd93..b34cb78 100644 --- a/include/configs/tam3517-common.h +++ b/include/configs/tam3517-common.h @@ -239,6 +239,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_CONSOLE #define CONFIG_SPL_NAND_SIMPLE #define CONFIG_SPL_NAND_SOFTECC

Add a new flag, CONFIG_SPL_FRAMEWORK to opt into the common/spl SPL framework, enable on all of the previously using boards. We move the spl_ymodem.c portion to common/ and spl_mmc.c to drivers/mmc/. We leave the NAND one in-place as we plan to replace it later in this series.
We use common/spl to avoid linker problems with respect to merging constant strings in objects. Otherwise all strings in common/ will be linked in and kept which grows SPL in size too much.
Signed-off-by: Tom Rini trini@ti.com --- Changes in v2: - Reorder all of the patches that used to follow this to precede. - Place files into common/spl (due to gcc bug #54303) and include/spl.h
Changes in v3: - Fix checkpatch.pl warning
Changes in v5: - Drop <asm/utils.h> from spl.c (noticed by Stefan)
Changes in v7: - Fix igep* board building
README | 5 ++ arch/arm/cpu/armv7/am33xx/board.c | 2 +- arch/arm/cpu/armv7/omap-common/Makefile | 7 -- arch/arm/cpu/armv7/omap-common/boot-common.c | 2 +- arch/arm/cpu/armv7/omap-common/hwinit-common.c | 2 +- arch/arm/cpu/armv7/omap-common/spl_nand.c | 2 +- arch/arm/cpu/armv7/omap3/board.c | 2 +- arch/arm/include/asm/spl.h | 40 ------------ common/spl/Makefile | 37 +++++++++++ .../arm/cpu/armv7/omap-common => common/spl}/spl.c | 5 +- .../armv7/omap-common => common/spl}/spl_ymodem.c | 3 +- drivers/mmc/Makefile | 5 +- .../armv7/omap-common => drivers/mmc}/spl_mmc.c | 2 +- include/configs/am335x_evm.h | 1 + include/configs/am3517_crane.h | 1 + include/configs/am3517_evm.h | 1 + include/configs/devkit8000.h | 1 + include/configs/igep00x0.h | 1 + include/configs/mcx.h | 1 + include/configs/omap3_beagle.h | 1 + include/configs/omap3_evm_common.h | 1 + include/configs/omap3_overo.h | 1 + include/configs/omap4_common.h | 1 + include/configs/omap5_evm.h | 1 + include/configs/tam3517-common.h | 1 + include/configs/tricorder.h | 1 + include/spl.h | 69 ++++++++++++++++++++ spl/Makefile | 1 + 28 files changed, 138 insertions(+), 59 deletions(-) create mode 100644 common/spl/Makefile rename {arch/arm/cpu/armv7/omap-common => common/spl}/spl.c (98%) rename {arch/arm/cpu/armv7/omap-common => common/spl}/spl_ymodem.c (97%) rename {arch/arm/cpu/armv7/omap-common => drivers/mmc}/spl_mmc.c (99%) create mode 100644 include/spl.h
diff --git a/README b/README index 3acfe80..9bcfe7a 100644 --- a/README +++ b/README @@ -2572,6 +2572,11 @@ FIT uImage format: CONFIG_SYS_SPL_MALLOC_SIZE The size of the malloc pool used in SPL.
+ CONFIG_SPL_FRAMEWORK + Enable the SPL framework under common/. This framework + supports MMC, NAND and YMODEM loading of U-Boot and NAND + NAND loading of the Linux Kernel. + CONFIG_SPL_DISPLAY_PRINT For ARM, enable an optional function to print more information about the running system. diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index e89df8e..c45b19b 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -18,6 +18,7 @@
#include <common.h> #include <errno.h> +#include <spl.h> #include <asm/arch/cpu.h> #include <asm/arch/hardware.h> #include <asm/arch/omap.h> @@ -29,7 +30,6 @@ #include <asm/io.h> #include <asm/emif.h> #include <asm/gpio.h> -#include <asm/spl.h> #include <i2c.h> #include <miiphy.h> #include <cpsw.h> diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile index d37b22d..6e815c6 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -43,16 +43,9 @@ SOBJS += lowlevel_init.o endif
ifdef CONFIG_SPL_BUILD -COBJS += spl.o ifdef CONFIG_SPL_NAND_SUPPORT COBJS += spl_nand.o endif -ifdef CONFIG_SPL_MMC_SUPPORT -COBJS += spl_mmc.o -endif -ifdef CONFIG_SPL_YMODEM_SUPPORT -COBJS += spl_ymodem.o -endif endif
ifndef CONFIG_SPL_BUILD diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c index ed398fd..0f19141 100644 --- a/arch/arm/cpu/armv7/omap-common/boot-common.c +++ b/arch/arm/cpu/armv7/omap-common/boot-common.c @@ -17,7 +17,7 @@ */
#include <common.h> -#include <asm/spl.h> +#include <spl.h> #include <asm/omap_common.h> #include <asm/arch/omap.h> #include <asm/arch/mmc_host_def.h> diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c index d5fde38..ad8b5ac 100644 --- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c +++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c @@ -28,10 +28,10 @@ * MA 02111-1307 USA */ #include <common.h> +#include <spl.h> #include <asm/arch/sys_proto.h> #include <asm/sizes.h> #include <asm/emif.h> -#include <asm/spl.h>
DECLARE_GLOBAL_DATA_PTR;
diff --git a/arch/arm/cpu/armv7/omap-common/spl_nand.c b/arch/arm/cpu/armv7/omap-common/spl_nand.c index 1e6b5f0..9e9206c 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_nand.c +++ b/arch/arm/cpu/armv7/omap-common/spl_nand.c @@ -21,7 +21,7 @@ * MA 02111-1307 USA */ #include <common.h> -#include <asm/spl.h> +#include <spl.h> #include <asm/u-boot.h> #include <asm/utils.h> #include <asm/io.h> diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index 52196c8..42e2fd9 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -33,13 +33,13 @@ * MA 02111-1307 USA */ #include <common.h> +#include <spl.h> #include <asm/io.h> #include <asm/arch/sys_proto.h> #include <asm/arch/mem.h> #include <asm/cache.h> #include <asm/armv7.h> #include <asm/arch/gpio.h> -#include <asm/spl.h> #include <asm/omap_common.h> #include <asm/arch/mmc_host_def.h> #include <i2c.h> diff --git a/arch/arm/include/asm/spl.h b/arch/arm/include/asm/spl.h index 47ca1b6..ad61990 100644 --- a/arch/arm/include/asm/spl.h +++ b/arch/arm/include/asm/spl.h @@ -26,44 +26,4 @@ /* Platform-specific defines */ #include <asm/arch/spl.h>
-/* Boot type */ -#define MMCSD_MODE_UNDEFINED 0 -#define MMCSD_MODE_RAW 1 -#define MMCSD_MODE_FAT 2 - -struct spl_image_info { - const char *name; - u8 os; - u32 load_addr; - u32 entry_point; - u32 size; -}; - -extern struct spl_image_info spl_image; -extern u32 *boot_params_ptr; - -/* SPL common functions */ -void preloader_console_init(void); -u32 spl_boot_device(void); -u32 spl_boot_mode(void); -void spl_parse_image_header(const struct image_header *header); -void spl_board_prepare_for_linux(void); -int spl_start_uboot(void); -void spl_display_print(void); - -/* NAND SPL functions */ -void spl_nand_load_image(void); - -/* MMC SPL functions */ -void spl_mmc_load_image(void); - -/* YMODEM SPL functions */ -void spl_ymodem_load_image(void); - -/* SPI SPL functions */ -void spi_boot(void); - -#ifdef CONFIG_SPL_BOARD_INIT -void spl_board_init(void); -#endif #endif diff --git a/common/spl/Makefile b/common/spl/Makefile new file mode 100644 index 0000000..b61b438 --- /dev/null +++ b/common/spl/Makefile @@ -0,0 +1,37 @@ +# +# (C) Copyright 2012 +# Texas Instruments Incorporated - http://www.ti.com/ +# Aneesh V aneesh@ti.com +# +# This file is released under the terms of GPL v2 and any later version. +# See the file COPYING in the root directory of the source tree for details. +# +# Based on common/Makefile. +# + +include $(TOPDIR)/config.mk + +LIB = $(obj)libspl.o + +ifdef CONFIG_SPL_BUILD +COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o +COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o +endif + +COBJS := $(sort $(COBJS-y)) +SRCS := $(COBJS:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS-y)) + +all: $(obj).depend $(LIB) + +$(LIB): $(OBJS) + $(call cmd_link_o_target, $(OBJS)) + +######################################################################### + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +######################################################################### diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/common/spl/spl.c similarity index 98% rename from arch/arm/cpu/armv7/omap-common/spl.c rename to common/spl/spl.c index dc26750..1562f2a 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/common/spl/spl.c @@ -23,9 +23,8 @@ * MA 02111-1307 USA */ #include <common.h> -#include <asm/spl.h> +#include <spl.h> #include <asm/u-boot.h> -#include <asm/utils.h> #include <nand.h> #include <fat.h> #include <version.h> @@ -36,7 +35,7 @@
DECLARE_GLOBAL_DATA_PTR;
-u32* boot_params_ptr = NULL; +u32 *boot_params_ptr = NULL; struct spl_image_info spl_image;
/* Define global data structure pointer to it*/ diff --git a/arch/arm/cpu/armv7/omap-common/spl_ymodem.c b/common/spl/spl_ymodem.c similarity index 97% rename from arch/arm/cpu/armv7/omap-common/spl_ymodem.c rename to common/spl/spl_ymodem.c index 65565e3..40e5035 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_ymodem.c +++ b/common/spl/spl_ymodem.c @@ -26,11 +26,10 @@ * MA 02111-1307 USA */ #include <common.h> -#include <asm/spl.h> +#include <spl.h> #include <xyzModem.h> #include <asm/u-boot.h> #include <asm/utils.h> -#include <asm/arch/sys_proto.h>
#define BUF_SIZE 1024
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index 2b96cdc..941a909 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -25,8 +25,11 @@ include $(TOPDIR)/config.mk
LIB := $(obj)libmmc.o
-ifdef CONFIG_SPL_MMC_LOAD +ifdef CONFIG_SPL_BUILD COBJS-$(CONFIG_SPL_MMC_LOAD) += spl_mmc_load.o +ifdef CONFIG_SPL_FRAMEWORK +COBJS-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o +endif endif
COBJS-$(CONFIG_BFIN_SDH) += bfin_sdh.o diff --git a/arch/arm/cpu/armv7/omap-common/spl_mmc.c b/drivers/mmc/spl_mmc.c similarity index 99% rename from arch/arm/cpu/armv7/omap-common/spl_mmc.c rename to drivers/mmc/spl_mmc.c index fdecf94..753c6a0 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_mmc.c +++ b/drivers/mmc/spl_mmc.c @@ -23,7 +23,7 @@ * MA 02111-1307 USA */ #include <common.h> -#include <asm/spl.h> +#include <spl.h> #include <asm/u-boot.h> #include <asm/utils.h> #include <mmc.h> diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index a3752bc..263a5ad 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -193,6 +193,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_TEXT_BASE 0x402F0400 #define CONFIG_SPL_MAX_SIZE (46 * 1024) #define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR diff --git a/include/configs/am3517_crane.h b/include/configs/am3517_crane.h index 254ed57..8ddeff4 100644 --- a/include/configs/am3517_crane.h +++ b/include/configs/am3517_crane.h @@ -314,6 +314,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_NAND_SIMPLE #define CONFIG_SPL_TEXT_BASE 0x40200800 diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h index ca39c72..6980811 100644 --- a/include/configs/am3517_evm.h +++ b/include/configs/am3517_evm.h @@ -313,6 +313,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_NAND_SIMPLE #define CONFIG_SPL_TEXT_BASE 0x40200800 diff --git a/include/configs/devkit8000.h b/include/configs/devkit8000.h index de75daf..2d2ee5f 100644 --- a/include/configs/devkit8000.h +++ b/include/configs/devkit8000.h @@ -303,6 +303,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_NAND_SIMPLE
#define CONFIG_SPL_LIBCOMMON_SUPPORT diff --git a/include/configs/igep00x0.h b/include/configs/igep00x0.h index 5468a1a..b1071e8 100644 --- a/include/configs/igep00x0.h +++ b/include/configs/igep00x0.h @@ -295,6 +295,7 @@
/* SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_NAND_SIMPLE #define CONFIG_SPL_TEXT_BASE 0x40200800 #define CONFIG_SPL_MAX_SIZE (54 * 1024) diff --git a/include/configs/mcx.h b/include/configs/mcx.h index a841c70..359522a 100644 --- a/include/configs/mcx.h +++ b/include/configs/mcx.h @@ -359,6 +359,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_NAND_SIMPLE #define CONFIG_SPL_NAND_SOFTECC diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h index 782a4c5..f79f996 100644 --- a/include/configs/omap3_beagle.h +++ b/include/configs/omap3_beagle.h @@ -391,6 +391,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_NAND_SIMPLE #define CONFIG_SPL_TEXT_BASE 0x40200800 #define CONFIG_SPL_MAX_SIZE (54 * 1024) /* 8 KB for stack */ diff --git a/include/configs/omap3_evm_common.h b/include/configs/omap3_evm_common.h index d9578f4..2ef3aaa 100644 --- a/include/configs/omap3_evm_common.h +++ b/include/configs/omap3_evm_common.h @@ -273,6 +273,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_TEXT_BASE 0x40200800 #define CONFIG_SPL_MAX_SIZE (54 * 1024) /* 8 KB for stack */ #define CONFIG_SPL_STACK LOW_LEVEL_SRAM_STACK diff --git a/include/configs/omap3_overo.h b/include/configs/omap3_overo.h index dd4b2c0..f6d6f75 100644 --- a/include/configs/omap3_overo.h +++ b/include/configs/omap3_overo.h @@ -293,6 +293,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_NAND_SIMPLE #define CONFIG_SPL_TEXT_BASE 0x40200800 #define CONFIG_SPL_MAX_SIZE (54 * 1024) /* 8 KB for stack */ diff --git a/include/configs/omap4_common.h b/include/configs/omap4_common.h index c1c2fa9..cbc9bdb 100644 --- a/include/configs/omap4_common.h +++ b/include/configs/omap4_common.h @@ -232,6 +232,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_TEXT_BASE 0x40304350 #define CONFIG_SPL_MAX_SIZE (38 * 1024) #define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR diff --git a/include/configs/omap5_evm.h b/include/configs/omap5_evm.h index b4a237a..743edfd 100644 --- a/include/configs/omap5_evm.h +++ b/include/configs/omap5_evm.h @@ -229,6 +229,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_TEXT_BASE 0x40300350 #define CONFIG_SPL_MAX_SIZE 0x19000 /* 100K */ #define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR diff --git a/include/configs/tam3517-common.h b/include/configs/tam3517-common.h index b34cb78..cbb6c7e 100644 --- a/include/configs/tam3517-common.h +++ b/include/configs/tam3517-common.h @@ -239,6 +239,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_CONSOLE #define CONFIG_SPL_NAND_SIMPLE diff --git a/include/configs/tricorder.h b/include/configs/tricorder.h index 63c98dc..00d02e8 100644 --- a/include/configs/tricorder.h +++ b/include/configs/tricorder.h @@ -271,6 +271,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_NAND_SIMPLE
#define CONFIG_SPL_BOARD_INIT diff --git a/include/spl.h b/include/spl.h new file mode 100644 index 0000000..af9ef71 --- /dev/null +++ b/include/spl.h @@ -0,0 +1,69 @@ +/* + * (C) Copyright 2012 + * Texas Instruments, <www.ti.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +#ifndef _SPL_H_ +#define _SPL_H_ + +/* Platform-specific defines */ +#include <asm/spl.h> + +/* Boot type */ +#define MMCSD_MODE_UNDEFINED 0 +#define MMCSD_MODE_RAW 1 +#define MMCSD_MODE_FAT 2 + +struct spl_image_info { + const char *name; + u8 os; + u32 load_addr; + u32 entry_point; + u32 size; +}; + +extern struct spl_image_info spl_image; +extern u32 *boot_params_ptr; + +/* SPL common functions */ +void preloader_console_init(void); +u32 spl_boot_device(void); +u32 spl_boot_mode(void); +void spl_parse_image_header(const struct image_header *header); +void spl_board_prepare_for_linux(void); +int spl_start_uboot(void); +void spl_display_print(void); + +/* NAND SPL functions */ +void spl_nand_load_image(void); + +/* MMC SPL functions */ +void spl_mmc_load_image(void); + +/* YMODEM SPL functions */ +void spl_ymodem_load_image(void); + +/* SPI SPL functions */ +void spi_boot(void); + +#ifdef CONFIG_SPL_BOARD_INIT +void spl_board_init(void); +#endif +#endif diff --git a/spl/Makefile b/spl/Makefile index d4cb668..d9b1c2f 100644 --- a/spl/Makefile +++ b/spl/Makefile @@ -41,6 +41,7 @@ endif LIBS-y += board/$(BOARDDIR)/lib$(BOARD).o LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o
+LIBS-$(CONFIG_SPL_FRAMEWORK) += common/spl/libspl.o LIBS-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/libcommon.o LIBS-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/libdisk.o LIBS-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/libi2c.o

In SPL (CONFIG_SPL_FRAMEWORK) board_init_f must setup the stack pointer, clear the BSS and call board_init_r. We mark this as weak as some platforms may need to perform additional initalization at this point. We provide a gd that we know will be in a usable location, once the BSS has been cleared to help with this as well. Finally, we no longer call relocate_code so remove that from the armv7 version.
Next, both board_init_f and jump_to_image_linux are going to be inherently arch-specific, so move these versions to arch/arm/lib/spl.c
Signed-off-by: Tom Rini trini@ti.com --- Changes in v4: - Document what board_init_f must do - Based on PowerPC, use memset to clear BSS rather than relocate_code - Move board_init_f / jump_to_image_linux to arch/arm/lib/spl.c - Make board_init_f setup the global data pointer, after clearing BSS.
Changes in v5: - After seeing Stefan's PowerPC series, move gdata to arch/arm/lib/spl.c
Changes in v6: - Move __bss* extern's to <asm/spl.h> - Document that preloader_console_init requires the gd pointer to be setup. - Have omap*/am33xx set gd prior to calling preloader_console_init
arch/arm/cpu/armv7/am33xx/board.c | 2 + arch/arm/cpu/armv7/omap-common/hwinit-common.c | 3 + arch/arm/cpu/armv7/omap3/board.c | 4 ++ arch/arm/cpu/armv7/start.S | 13 +---- arch/arm/include/asm/spl.h | 5 ++ arch/arm/lib/Makefile | 2 + arch/arm/lib/spl.c | 72 ++++++++++++++++++++++++ common/spl/spl.c | 41 ++------------ include/spl.h | 2 + 9 files changed, 98 insertions(+), 46 deletions(-) create mode 100644 arch/arm/lib/spl.c
diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index c45b19b..978b184 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -166,6 +166,8 @@ void s_init(void) regVal |= UART_SMART_IDLE_EN; writel(regVal, &uart_base->uartsyscfg);
+ gd = &gdata; + preloader_console_init();
/* Initalize the board header */ diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c index ad8b5ac..9ef10bd 100644 --- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c +++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c @@ -124,6 +124,9 @@ void s_init(void) set_mux_conf_regs(); #ifdef CONFIG_SPL_BUILD setup_clocks_for_console(); + + gd = &gdata; + preloader_console_init(); do_io_settings(); #endif diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index 42e2fd9..9cee1d9 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -45,6 +45,8 @@ #include <i2c.h> #include <linux/compiler.h>
+DECLARE_GLOBAL_DATA_PTR; + /* Declarations */ extern omap3_sysinfo sysinfo; static void omap3_setup_aux_cr(void); @@ -252,6 +254,8 @@ void s_init(void) #endif
#ifdef CONFIG_SPL_BUILD + gd = &gdata; + preloader_console_init();
timer_init(); diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 32658eb..f26308d 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -164,6 +164,7 @@ call_board_init_f:
/*------------------------------------------------------------------------------*/
+#ifndef CONFIG_SPL_BUILD /* * void relocate_code (addr_sp, gd, addr_moni) * @@ -194,7 +195,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop
-#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */ @@ -241,20 +241,12 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start
-#endif /* #ifndef CONFIG_SPL_BUILD */ - clear_bss: -#ifdef CONFIG_SPL_BUILD - /* No relocation for SPL */ - ldr r0, =__bss_start - ldr r1, =__bss_end__ -#else ldr r0, _bss_start_ofs ldr r1, _bss_end_ofs mov r4, r6 /* reloc addr */ add r0, r0, r4 add r1, r1, r4 -#endif mov r2, #0x00000000 /* clear */
clbss_l:cmp r0, r1 /* clear loop... */ @@ -281,12 +273,10 @@ jump_2_ram: * Move vector table */ #if !defined(CONFIG_TEGRA20) -#if !(defined(CONFIG_OMAP44XX) && defined(CONFIG_SPL_BUILD)) /* Set vector address in CP15 VBAR register */ ldr r0, =_start add r0, r0, r9 mcr p15, 0, r0, c12, c0, 0 @Set VBAR -#endif #endif /* !Tegra20 */
ldr r0, _board_init_r_ofs @@ -302,6 +292,7 @@ jump_2_ram: _board_init_r_ofs: .word board_init_r - _start ENDPROC(relocate_code) +#endif
/************************************************************************* * diff --git a/arch/arm/include/asm/spl.h b/arch/arm/include/asm/spl.h index ad61990..62011aa 100644 --- a/arch/arm/include/asm/spl.h +++ b/arch/arm/include/asm/spl.h @@ -26,4 +26,9 @@ /* Platform-specific defines */ #include <asm/arch/spl.h>
+/* Linker symbols. */ +extern char __bss_start[], __bss_end__[]; + +extern gd_t gdata; + #endif diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index bd3b77f..3422ac1 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -44,6 +44,8 @@ COBJS-y += interrupts.o COBJS-y += reset.o SOBJS-$(CONFIG_USE_ARCH_MEMSET) += memset.o SOBJS-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o +else +COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o endif
COBJS-y += cache.o diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c new file mode 100644 index 0000000..f568f61 --- /dev/null +++ b/arch/arm/lib/spl.c @@ -0,0 +1,72 @@ +/* + * (C) Copyright 2010-2012 + * Texas Instruments, <www.ti.com> + * + * Aneesh V aneesh@ti.com + * Tom Rini trini@ti.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +#include <common.h> +#include <config.h> +#include <spl.h> +#include <image.h> +#include <linux/compiler.h> + +/* Pointer to as well as the global data structure for SPL */ +DECLARE_GLOBAL_DATA_PTR; +gd_t gdata __attribute__ ((section(".data"))); + +/* + * In the context of SPL, board_init_f must ensure that any clocks/etc for + * DDR are enabled, ensure that the stack pointer is valid, clear the BSS + * and call board_init_f. We provide this version by default but mark it + * as __weak to allow for platforms to do this in their own way if needed. + */ +void __weak board_init_f(ulong dummy) +{ + /* Set the stack pointer. */ + asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK)); + + /* Clear the BSS. */ + memset(__bss_start, 0, __bss_end__ - __bss_start); + + /* Set global data pointer. */ + gd = &gdata; + + board_init_r(NULL, 0); +} + +/* + * This function jumps to an image with argument. Normally an FDT or ATAGS + * image. + * arg: Pointer to paramter image in RAM + */ +#ifdef CONFIG_SPL_OS_BOOT +void __noreturn jump_to_image_linux(void *arg) +{ + debug("Entering kernel arg pointer: 0x%p\n", arg); + typedef void (*image_entry_arg_t)(int, int, void *) + __attribute__ ((noreturn)); + image_entry_arg_t image_entry = + (image_entry_arg_t) spl_image.entry_point; + cleanup_before_linux(); + image_entry(0, CONFIG_MACH_TYPE, arg); +} +#endif diff --git a/common/spl/spl.c b/common/spl/spl.c index 1562f2a..3f41014 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -38,8 +38,7 @@ DECLARE_GLOBAL_DATA_PTR; u32 *boot_params_ptr = NULL; struct spl_image_info spl_image;
-/* Define global data structure pointer to it*/ -static gd_t gdata __attribute__ ((section(".data"))); +/* Define board data structure */ static bd_t bdata __attribute__ ((section(".data")));
inline void hang(void) @@ -49,18 +48,6 @@ inline void hang(void) ; }
-void board_init_f(ulong dummy) -{ - /* - * We call relocate_code() with relocation target same as the - * CONFIG_SYS_SPL_TEXT_BASE. This will result in relocation getting - * skipped. Instead, only .bss initialization will happen. That's - * all we need - */ - debug(">>board_init_f()\n"); - relocate_code(CONFIG_SPL_STACK, &gdata, CONFIG_SPL_TEXT_BASE); -} - /* * Default function to determine if u-boot or the OS should * be started. This implementation always returns 1. @@ -107,24 +94,6 @@ void spl_parse_image_header(const struct image_header *header) } }
-/* - * This function jumps to an image with argument. Normally an FDT or ATAGS - * image. - * arg: Pointer to paramter image in RAM - */ -#ifdef CONFIG_SPL_OS_BOOT -static void __noreturn jump_to_image_linux(void *arg) -{ - debug("Entering kernel arg pointer: 0x%p\n", arg); - typedef void (*image_entry_arg_t)(int, int, void *) - __attribute__ ((noreturn)); - image_entry_arg_t image_entry = - (image_entry_arg_t) spl_image.entry_point; - cleanup_before_linux(); - image_entry(0, CONFIG_MACH_TYPE, arg); -} -#endif - static void __noreturn jump_to_image_no_args(void) { typedef void __noreturn (*image_entry_noargs_t)(u32 *); @@ -140,7 +109,7 @@ static void __noreturn jump_to_image_no_args(void) image_entry((u32 *)boot_params_ptr_addr); }
-void board_init_r(gd_t *id, ulong dummy) +void board_init_r(gd_t *dummy1, ulong dummy2) { u32 boot_device; debug(">>spl:board_init_r()\n"); @@ -204,10 +173,12 @@ void board_init_r(gd_t *id, ulong dummy) } }
-/* This requires UART clocks to be enabled */ +/* + * This requires UART clocks to be enabled. In order for this to work the + * caller must ensure that the gd pointer is valid. + */ void preloader_console_init(void) { - gd = &gdata; gd->bd = &bdata; gd->flags |= GD_FLG_RELOC; gd->baudrate = CONFIG_BAUDRATE; diff --git a/include/spl.h b/include/spl.h index af9ef71..2923cd2 100644 --- a/include/spl.h +++ b/include/spl.h @@ -24,6 +24,7 @@ #define _SPL_H_
/* Platform-specific defines */ +#include <linux/compiler.h> #include <asm/spl.h>
/* Boot type */ @@ -48,6 +49,7 @@ u32 spl_boot_device(void); u32 spl_boot_mode(void); void spl_parse_image_header(const struct image_header *header); void spl_board_prepare_for_linux(void); +void __noreturn jump_to_image_linux(void *arg); int spl_start_uboot(void); void spl_display_print(void);

From: Stefano Babic sbabic@denx.de
If an u-boot image is not found, SPL thinks to load a bare u-boot.bin image with a maximum size of 200KB. Use CONFIG_SYS_MONITOR_LEN instead.
Signed-off-by: Stefan Roese stefan.roese@gmail.com Signed-off-by: Stefano Babic sbabic@denx.de Signed-off-by: Tom Rini trini@ti.com --- Changes in v4: - Add Stefano's patch for CONFIG_SYS_MONITOR_LEN
common/spl/spl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/common/spl/spl.c b/common/spl/spl.c index 3f41014..70c374a 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -35,6 +35,10 @@
DECLARE_GLOBAL_DATA_PTR;
+#ifndef CONFIG_SYS_MONITOR_LEN +#define CONFIG_SYS_MONITOR_LEN (200 * 1024) +#endif + u32 *boot_params_ptr = NULL; struct spl_image_info spl_image;
@@ -86,7 +90,7 @@ void spl_parse_image_header(const struct image_header *header) debug("mkimage signature not found - ih_magic = %x\n", header->ih_magic); /* Let's assume U-Boot will not be more than 200 KB */ - spl_image.size = 200 * 1024; + spl_image.size = CONFIG_SYS_MONITOR_LEN; spl_image.entry_point = CONFIG_SYS_TEXT_BASE; spl_image.load_addr = CONFIG_SYS_TEXT_BASE; spl_image.os = IH_OS_U_BOOT;

From: Stefan Roese sr@denx.de
Signed-off-by: Stefan Roese sr@denx.de Signed-off-by: Tom Rini trini@ti.com --- Changes in v5: - Add Stefan's patch to use image_get_xxx() functions
common/spl/spl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/common/spl/spl.c b/common/spl/spl.c index 70c374a..3b4fcba 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -75,13 +75,13 @@ void spl_parse_image_header(const struct image_header *header) { u32 header_size = sizeof(struct image_header);
- if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) { - spl_image.size = __be32_to_cpu(header->ih_size) + header_size; - spl_image.entry_point = __be32_to_cpu(header->ih_load); + if (image_get_magic(header) == IH_MAGIC) { + spl_image.size = image_get_data_size(header) + header_size; + spl_image.entry_point = image_get_load(header); /* Load including the header */ spl_image.load_addr = spl_image.entry_point - header_size; - spl_image.os = header->ih_os; - spl_image.name = (const char *)&header->ih_name; + spl_image.os = image_get_os(header); + spl_image.name = image_get_name(header); debug("spl: payload image: %s load addr: 0x%x size: %d\n", spl_image.name, spl_image.load_addr, spl_image.size); } else {

We move the spl_nand_load_image function to common/spl. This will allow for easier integration of SPL-boots-Linux code on other arches.
Signed-off-by: Tom Rini trini@ti.com --- Changes in v4: - Leave nand_spl_load.c alone, move the new load into nand_spl_simple.c
Changes in v5: - Move the file to common/spl/ rather than integrate with another file, after talking with Scott Wood
Changes in v6: - Make common/spl/spl_nand.o build for CONFIG_SPL_NAND_SUPPORT (noticed by Scott Wood)
arch/arm/cpu/armv7/omap-common/Makefile | 6 ------ common/spl/Makefile | 1 + .../armv7/omap-common => common/spl}/spl_nand.c | 10 ++++------ 3 files changed, 5 insertions(+), 12 deletions(-) rename {arch/arm/cpu/armv7/omap-common => common/spl}/spl_nand.c (94%)
diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile index 6e815c6..1f2fa02 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -42,12 +42,6 @@ COBJS += boot-common.o SOBJS += lowlevel_init.o endif
-ifdef CONFIG_SPL_BUILD -ifdef CONFIG_SPL_NAND_SUPPORT -COBJS += spl_nand.o -endif -endif - ifndef CONFIG_SPL_BUILD ifneq ($(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) COBJS += mem-common.o diff --git a/common/spl/Makefile b/common/spl/Makefile index b61b438..b9c9fd8 100644 --- a/common/spl/Makefile +++ b/common/spl/Makefile @@ -16,6 +16,7 @@ LIB = $(obj)libspl.o ifdef CONFIG_SPL_BUILD COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o +COBJS-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o endif
COBJS := $(sort $(COBJS-y)) diff --git a/arch/arm/cpu/armv7/omap-common/spl_nand.c b/common/spl/spl_nand.c similarity index 94% rename from arch/arm/cpu/armv7/omap-common/spl_nand.c rename to common/spl/spl_nand.c index 9e9206c..61de5a4 100644 --- a/arch/arm/cpu/armv7/omap-common/spl_nand.c +++ b/common/spl/spl_nand.c @@ -21,12 +21,10 @@ * MA 02111-1307 USA */ #include <common.h> +#include <config.h> #include <spl.h> -#include <asm/u-boot.h> -#include <asm/utils.h> #include <asm/io.h> #include <nand.h> -#include <version.h>
void spl_nand_load_image(void) { @@ -71,10 +69,10 @@ void spl_nand_load_image(void) nand_deselect(); return; } else { - printf("The Expected Linux image was not" - "found. Please check your NAND" + puts("The Expected Linux image was not " + "found. Please check your NAND " "configuration.\n"); - printf("Trying to start u-boot now...\n"); + puts("Trying to start u-boot now...\n"); } } #endif

- Convert the non-relocation part of board_init_f to spl_board_init, turn on CONFIG_SPL_BOARD_INIT in the configs. - Remove duplicated code. - Add spl_boot_device() that returns the statically chosen boot device.
Signed-off-by: Tom Rini trini@ti.com --- Changes in v2: - Add CONFIG_SYS_SPL_MALLOC_START / SIZE defines from Christian Riesch - Add arch/arm/cpu/arm926ejs/davinci/config.mk to build u-boot.ais
Changes in v3: - Make use of board_init_f being a weak function now so that we can perform early init. Fixes the cannot reset problem. - Make u-boot.ais use u-boot.img not u-boot.bin, now that it uses CONFIG_SPL_FRAMEWORK
Changes in v4: - Adapt davinci to new board_init_f requirements
Changes in v5: - Update davinci conversion for NAND change
Changes in v7: - Drop drivers/mmc/spl_mmc_load.c - Update davinci MMC loading options / code for new framework
Makefile | 4 +- arch/arm/cpu/arm926ejs/davinci/Makefile | 2 +- arch/arm/cpu/arm926ejs/davinci/config.mk | 16 +++++++ arch/arm/cpu/arm926ejs/davinci/spl.c | 72 +++++++++++++----------------- arch/arm/cpu/arm926ejs/start.S | 20 +-------- arch/arm/include/asm/arch-davinci/spl.h | 32 +++++++++++++ drivers/mmc/Makefile | 3 -- drivers/mmc/spl_mmc_load.c | 62 ------------------------- include/configs/cam_enc_4xx.h | 3 +- include/configs/da850evm.h | 15 +++++-- include/configs/hawkboard.h | 3 +- 11 files changed, 101 insertions(+), 131 deletions(-) create mode 100644 arch/arm/cpu/arm926ejs/davinci/config.mk create mode 100644 arch/arm/include/asm/arch-davinci/spl.h delete mode 100644 drivers/mmc/spl_mmc_load.c
diff --git a/Makefile b/Makefile index 5b7a850..958a158 100644 --- a/Makefile +++ b/Makefile @@ -452,7 +452,7 @@ $(obj)u-boot.ubl: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin rm $(obj)u-boot-ubl.bin rm $(obj)spl/u-boot-spl-pad.bin
-$(obj)u-boot.ais: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin +$(obj)u-boot.ais: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img $(obj)tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(CONFIG_AIS_CONFIG_FILE),"/dev/null") \ -T aisimage \ -e $(CONFIG_SPL_TEXT_BASE) \ @@ -461,7 +461,7 @@ $(obj)u-boot.ais: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin $(OBJCOPY) ${OBJCFLAGS} -I binary \ --pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \ $(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais - cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.bin > \ + cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.img > \ $(obj)u-boot.ais
# Specify the target for use in elftosb call diff --git a/arch/arm/cpu/arm926ejs/davinci/Makefile b/arch/arm/cpu/arm926ejs/davinci/Makefile index c91928e..dec7bfb 100644 --- a/arch/arm/cpu/arm926ejs/davinci/Makefile +++ b/arch/arm/cpu/arm926ejs/davinci/Makefile @@ -37,7 +37,7 @@ COBJS-$(CONFIG_SOC_DA850) += da850_pinmux.o COBJS-$(CONFIG_DRIVER_TI_EMAC) += lxt972.o dp83848.o et1011c.o ksz8873.o
ifdef CONFIG_SPL_BUILD -COBJS-y += spl.o +COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o COBJS-$(CONFIG_SOC_DM365) += dm365_lowlevel.o COBJS-$(CONFIG_SOC_DA8XX) += da850_lowlevel.o endif diff --git a/arch/arm/cpu/arm926ejs/davinci/config.mk b/arch/arm/cpu/arm926ejs/davinci/config.mk new file mode 100644 index 0000000..7452315 --- /dev/null +++ b/arch/arm/cpu/arm926ejs/davinci/config.mk @@ -0,0 +1,16 @@ +# +# Copyright (C) 2012, Texas Instruments, Incorporated - http://www.ti.com/ +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed "as is" WITHOUT ANY WARRANTY of any +# kind, whether express or implied; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +ifndef CONFIG_SPL_BUILD +ALL-$(CONFIG_SPL_FRAMEWORK) += $(obj)u-boot.ais +endif diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c index 03c85c8..714fa92 100644 --- a/arch/arm/cpu/arm926ejs/davinci/spl.c +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c @@ -21,6 +21,8 @@ * MA 02111-1307 USA */ #include <common.h> +#include <config.h> +#include <spl.h> #include <asm/u-boot.h> #include <asm/utils.h> #include <nand.h> @@ -30,15 +32,9 @@ #include <spi_flash.h> #include <mmc.h>
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT - DECLARE_GLOBAL_DATA_PTR; -/* Define global data structure pointer to it*/ -static gd_t gdata __attribute__ ((section(".data"))); -static bd_t bdata __attribute__ ((section(".data"))); - -#else
+#ifndef CONFIG_SPL_LIBCOMMON_SUPPORT void puts(const char *str) { while (*str) @@ -52,53 +48,49 @@ void putc(char c)
NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c); } - #endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
-inline void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); - for (;;) - ; -} - void board_init_f(ulong dummy) { + /* First, setup our stack pointer. */ + asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK)); + + /* Second, perform our low-level init. */ #ifdef CONFIG_SOC_DM365 dm36x_lowlevel_init(0); #endif #ifdef CONFIG_SOC_DA8XX arch_cpu_init(); #endif - relocate_code(CONFIG_SPL_STACK, NULL, CONFIG_SPL_TEXT_BASE); -}
-void board_init_r(gd_t *id, ulong dummy) -{ -#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT - mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, - CONFIG_SYS_MALLOC_LEN); + /* Third, we clear the BSS. */ + memset(__bss_start, 0, __bss_end__ - __bss_start);
+ /* Finally, setup gd and move to the next step. */ gd = &gdata; - gd->bd = &bdata; - gd->flags |= GD_FLG_RELOC; - gd->baudrate = CONFIG_BAUDRATE; - serial_init(); /* serial communications setup */ - gd->have_console = 1; + board_init_r(NULL, 0); +}
-#endif +void spl_board_init(void) +{ + preloader_console_init(); +}
-#ifdef CONFIG_SPL_NAND_LOAD - nand_init(); - puts("Nand boot...\n"); - nand_boot(); -#endif -#ifdef CONFIG_SPL_SPI_LOAD - puts("SPI boot...\n"); - spi_boot(); -#endif -#ifdef CONFIG_SPL_MMC_LOAD - puts("MMC boot...\n"); - spl_mmc_load(); +u32 spl_boot_mode(void) +{ + return MMCSD_MODE_RAW; +} + +u32 spl_boot_device(void) +{ +#ifdef CONFIG_SPL_NAND_SIMPLE + return BOOT_DEVICE_NAND; +#elif defined(CONFIG_SPL_SPI_LOAD) + return BOOT_DEVICE_SPI; +#elif defined(CONFIG_SPL_MMC_LOAD) + return BOOT_DEVICE_MMC1; +#else + puts("Unknown boot device\n"); + hang(); #endif } diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S index 6f05f1a..7889d13 100644 --- a/arch/arm/cpu/arm926ejs/start.S +++ b/arch/arm/cpu/arm926ejs/start.S @@ -215,6 +215,7 @@ call_board_init_f:
/*------------------------------------------------------------------------------*/
+#ifndef CONFIG_SPL_BUILD /* * void relocate_code (addr_sp, gd, addr_moni) * @@ -246,7 +247,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop
-#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */ @@ -285,20 +285,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif
clear_bss: -#ifdef CONFIG_SPL_BUILD - /* No relocation for SPL */ - ldr r0, =__bss_start - ldr r1, =__bss_end__ -#else ldr r0, _bss_start_ofs ldr r1, _bss_end_ofs mov r4, r6 /* reloc addr */ add r0, r0, r4 add r1, r1, r4 -#endif mov r2, #0x00000000 /* clear */
clbss_l:cmp r0, r1 /* clear loop... */ @@ -308,22 +301,13 @@ clbss_l:cmp r0, r1 /* clear loop... */ b clbss_l clbss_e:
-#ifndef CONFIG_SPL_BUILD bl coloured_LED_init bl red_led_on -#endif
/* * We are done. Do not return, instead branch to second part of board * initialization, now running from RAM. */ -#ifdef CONFIG_NAND_SPL - ldr r0, _nand_boot_ofs - mov pc, r0 - -_nand_boot_ofs: - .word nand_boot -#else ldr r0, _board_init_r_ofs ldr r1, _TEXT_BASE add lr, r0, r1 @@ -336,7 +320,6 @@ _nand_boot_ofs:
_board_init_r_ofs: .word board_init_r - _start -#endif
_rel_dyn_start_ofs: .word __rel_dyn_start - _start @@ -344,6 +327,7 @@ _rel_dyn_end_ofs: .word __rel_dyn_end - _start _dynsym_start_ofs: .word __dynsym_start - _start +#endif
/* ************************************************************************* diff --git a/arch/arm/include/asm/arch-davinci/spl.h b/arch/arm/include/asm/arch-davinci/spl.h new file mode 100644 index 0000000..fb01db0 --- /dev/null +++ b/arch/arm/include/asm/arch-davinci/spl.h @@ -0,0 +1,32 @@ +/* + * (C) Copyright 2012 + * Texas Instruments, <www.ti.com> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +#ifndef _ASM_ARCH_SPL_H_ +#define _ASM_SPL_H_ + +#define BOOT_DEVICE_NAND 1 +#define BOOT_DEVICE_SPI 2 +#define BOOT_DEVICE_MMC1 3 +#define BOOT_DEVICE_MMC2 4 /* dummy */ +#define BOOT_DEVICE_MMC2_2 5 /* dummy */ + +#endif diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index 941a909..565ba6a 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -26,11 +26,8 @@ include $(TOPDIR)/config.mk LIB := $(obj)libmmc.o
ifdef CONFIG_SPL_BUILD -COBJS-$(CONFIG_SPL_MMC_LOAD) += spl_mmc_load.o -ifdef CONFIG_SPL_FRAMEWORK COBJS-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o endif -endif
COBJS-$(CONFIG_BFIN_SDH) += bfin_sdh.o COBJS-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o diff --git a/drivers/mmc/spl_mmc_load.c b/drivers/mmc/spl_mmc_load.c deleted file mode 100644 index 79a68fb..0000000 --- a/drivers/mmc/spl_mmc_load.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <common.h> -#include <mmc.h> - -DECLARE_GLOBAL_DATA_PTR; - -static void mmc_load_image(struct mmc *mmc) -{ - s32 err; - void (*uboot)(void) __noreturn; - - err = mmc->block_dev.block_read(0, CONFIG_SYS_MMC_U_BOOT_OFFS, - CONFIG_SYS_MMC_U_BOOT_SIZE/512, - (u32 *)CONFIG_SYS_TEXT_BASE); - - if (err <= 0) { - printf("spl: error reading image %s, err - %d\n", - "u-boot.img", err); - hang(); - } - uboot = (void *) CONFIG_SYS_TEXT_BASE; - (*uboot)(); -} - -void spl_mmc_load(void) -{ - struct mmc *mmc; - int err; - void (mmc_load_image)(struct mmc *mmc) __noreturn; - - mmc_initialize(gd->bd); - mmc = find_mmc_device(0); - if (!mmc) { - puts("spl: mmc device not found!!\n"); - hang(); - } else { - puts("spl: mmc device found\n"); - } - err = mmc_init(mmc); - if (err) { - printf("spl: mmc init failed: err - %d\n", err); - hang(); - } - mmc_load_image(mmc); -} diff --git a/include/configs/cam_enc_4xx.h b/include/configs/cam_enc_4xx.h index 91ab812..9b56e02 100644 --- a/include/configs/cam_enc_4xx.h +++ b/include/configs/cam_enc_4xx.h @@ -215,10 +215,11 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK +#define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_LIBGENERIC_SUPPORT #define CONFIG_SPL_NAND_SUPPORT #define CONFIG_SPL_NAND_SIMPLE -#define CONFIG_SPL_NAND_LOAD #define CONFIG_SYS_NAND_HW_ECC_OOBFIRST #define CONFIG_SPL_SERIAL_SUPPORT #define CONFIG_SPL_POST_MEM_SUPPORT diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index 09a9660..ddd6155 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -380,6 +380,16 @@ #ifndef CONFIG_DIRECT_NOR_BOOT /* defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK +#define CONFIG_SPL_BOARD_INIT +#define CONFIG_SYS_SPL_MALLOC_START (CONFIG_SYS_TEXT_BASE - \ + CONFIG_SYS_MALLOC_LEN) +#define CONFIG_SYS_SPL_MALLOC_SIZE CONFIG_SYS_MALLOC_LEN +#define CONFIG_SPL_SPI_SUPPORT +#define CONFIG_SPL_SPI_FLASH_SUPPORT +#define CONFIG_SPL_SPI_LOAD +#define CONFIG_SPL_SPI_BUS 0 +#define CONFIG_SPL_SPI_CS 0 #define CONFIG_SPL_SERIAL_SUPPORT #define CONFIG_SPL_LIBCOMMON_SUPPORT #define CONFIG_SPL_LIBGENERIC_SUPPORT @@ -392,10 +402,9 @@ /* Load U-Boot Image From MMC */ #ifdef CONFIG_SPL_MMC_LOAD #define CONFIG_SPL_MMC_SUPPORT -#define CONFIG_SPL_FAT_SUPPORT #define CONFIG_SPL_LIBDISK_SUPPORT -#define CONFIG_SYS_MMC_U_BOOT_OFFS 0x75 -#define CONFIG_SYS_MMC_U_BOOT_SIZE 0x30000 +#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x75 +#undef CONFIG_SPL_SPI_SUPPORT #undef CONFIG_SPL_SPI_LOAD #endif
diff --git a/include/configs/hawkboard.h b/include/configs/hawkboard.h index 73ab4c8..9ea200a 100644 --- a/include/configs/hawkboard.h +++ b/include/configs/hawkboard.h @@ -60,9 +60,10 @@
/* Spl */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK +#define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_NAND_SUPPORT #define CONFIG_SPL_NAND_SIMPLE -#define CONFIG_SPL_NAND_LOAD #define CONFIG_SPL_LIBGENERIC_SUPPORT /* for udelay and __div64_32 for NAND */ #define CONFIG_SPL_SERIAL_SUPPORT #define CONFIG_SPL_LDSCRIPT "board/$(BOARDDIR)/u-boot-spl-hawk.lds"

On Mon, Sep 24, 2012 at 05:30:58PM -0700, Tom Rini wrote:
- Convert the non-relocation part of board_init_f to spl_board_init, turn on CONFIG_SPL_BOARD_INIT in the configs.
- Remove duplicated code.
- Add spl_boot_device() that returns the statically chosen boot device.
Signed-off-by: Tom Rini trini@ti.com
[snip]
diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S index 6f05f1a..7889d13 100644 --- a/arch/arm/cpu/arm926ejs/start.S +++ b/arch/arm/cpu/arm926ejs/start.S @@ -215,6 +215,7 @@ call_board_init_f:
/*------------------------------------------------------------------------------*/
+#ifndef CONFIG_SPL_BUILD /*
- void relocate_code (addr_sp, gd, addr_moni)
In testing this for merge I found it breaks tx25 which uses the old nand_spl framework. I've change this to be: #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_NAND_SPL)
and dropped the rest of the hunks from this file other than the final endif for this function.

From: Sughosh Ganu urwithsughosh@gmail.com
The common spl framework expects the u-boot payload size through CONFIG_SYS_MONITOR_LEN. Define the macro with the u-boot's size. With this change, CONFIG_SYS_NAND_U_BOOT_SIZE is no longer required. Delete the same.
Signed-off-by: Tom Rini trini@ti.com Signed-off-by: Sughosh Ganu urwithsughosh@gmail.com --- Changes in v6: - Add Sughosh's patch to update hawkboard
Changes in v7: - Update hawkboard size based on new upstream values
include/configs/hawkboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/configs/hawkboard.h b/include/configs/hawkboard.h index 9ea200a..c0e3ed3 100644 --- a/include/configs/hawkboard.h +++ b/include/configs/hawkboard.h @@ -80,6 +80,7 @@ #define CONFIG_MAX_RAM_BANK_SIZE (512 << 20) #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x1000 -\ GENERATED_GBL_DATA_SIZE) +#define CONFIG_SYS_MONITOR_LEN 0x60000
/* memtest start addr */ #define CONFIG_SYS_MEMTEST_START (PHYS_SDRAM_1) @@ -137,7 +138,6 @@ #define CONFIG_SYS_NAND_PAGE_SIZE (2 << 10) #define CONFIG_SYS_NAND_BLOCK_SIZE (128 << 10) #define CONFIG_SYS_NAND_U_BOOT_OFFS 0xe0000 -#define CONFIG_SYS_NAND_U_BOOT_SIZE 0x60000 #define CONFIG_SYS_NAND_U_BOOT_DST 0xc1180000 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_NAND_U_BOOT_DST #define CONFIG_SYS_NAND_U_BOOT_RELOC_SP (CONFIG_SYS_NAND_U_BOOT_DST - \

This file documents when to build for da850evm and when to build for da850_am18xxevm. It also documents how to write the u-boot.ais file to persistent storage (such as SPI), in some cases as well as how to write a recovery image.
Signed-off-by: Tom Rini trini@ti.com Acked-by: Christian Riesch christian.riesch@omicron.at Acked-by: Prabhakar Lad prabhakar.lad@ti.com --- Changes in v2: - Add README.da850_am18xxevm
Changes in v3: - Fix thinko, Nand -> SPI (spotted by Prabhakar Lad) - Rename to README.da850, add more direct recovery method (Christian Riesch)
Changes in v4: - Further re-word README.da850 based on feedback from Christian Riesch
Changes in v6: - Fix typo (L137 -> L138) noticed by Christian Riesch
board/davinci/da8xxevm/README.da850 | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 board/davinci/da8xxevm/README.da850
diff --git a/board/davinci/da8xxevm/README.da850 b/board/davinci/da8xxevm/README.da850 new file mode 100644 index 0000000..313a1ef --- /dev/null +++ b/board/davinci/da8xxevm/README.da850 @@ -0,0 +1,68 @@ +Summary +======= +The README is for the boot procedure used for various DA850 (or compatible +parts such as the AM1808) based boards. + +In the context of U-Boot, the board is booted in three stages. The initial +bootloader which executes upon reset is the ROM Boot Loader (RBL) and sits +in the internal ROM. The RBL initializes the internal memory and then +depending on the exact board and pin configurations will initialize another +controller (such as SPI or NAND) to continue the boot process by loading +the secondary program loader (SPL). The SPL will initialize the system +further (some clocks, SDRAM) and then load the full u-boot from a +predefined location in persistent storage to DDR and jumps to the u-boot +entry point. + +AIS is an image format defined by TI for the images that are to be loaded +to memory by the RBL. The image is divided into a series of sections and +the image's entry point is specified. Each section comes with meta data +like the target address the section is to be copied to and the size of the +section, which is used by the RBL to load the image. At the end of the +image the RBL jumps to the image entry point. The AIS format allows for +other things such as programming the clocks and SDRAM if the header is +programmed for it. We do not take advantage of this and instead use SPL as +it allows for additional flexibility (run-time detect of board revision, +loading the next image from a different media, etc). + + +Compilation +=========== +The exact build target you need will depend on the board you have. For +Logic PD boards, or other boards which store the ethernet MAC address at +the end of SPI flash, run 'make da850evm'. For boards which store the +ethernet MAC address in the i2c EEPROM located at 0x50, run +'make da850_am18xxevm'. Once this build completes you will have a +u-boot.ais file that needs to be written to the correct persistent +storage. + + +Flashing the images to SPI +========================== +The AIS image can be written to SPI flash using the following commands. +Assuming that the network is configured and enabled and the u-boot.ais file +is tftp'able. + +U-Boot > sf probe 0 +U-Boot > sf erase 0 +320000 +U-Boot > tftp u-boot.ais +U-Boot > sf write c0700000 0 $filesize + + +Recovery +======== + +In the case of a "bricked" board, you need to use the TI tools found +here[1] to write the u-boot.ais file. An example of recovering to the SPI +flash of an AM1808 would be: + +$ mono sfh_OMAP-L138.exe -targetType AM1808 -p /dev/ttyUSB0 \ + -flash_noubl /path/to/u-boot.ais + +For other target types and flash locations: + +$ mono sfh_OMAP-L138.exe -h + +Links +===== +[1] + http://processors.wiki.ti.com/index.php/Serial_Boot_and_Flash_Loading_Utilit...

From: Stefan Roese sr@denx.de
SPL NOR flash booting support is quite simple. Only copying of the images is needed.
On MPC5xxx we need to make sure to only use the standard memcpy() implementation and not the MPC5xxx specific one. As the MPC5xxx version has some complexity which is not needed for this SPL booting.
Signed-off-by: Stefan Roese sr@denx.de Signed-off-by: Tom Rini trini@ti.com --- Changes in v5: - Add Stefan's patch for NOR loading in SPL - Drop mpc5xxx-specific memcpy changes, these should be handled by the Makefile logic (noticed by Daniel Schwierzeck, changed by me)
common/spl/Makefile | 1 + common/spl/spl.c | 5 ++++ common/spl/spl_nor.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/spl.h | 3 +++ 4 files changed, 71 insertions(+) create mode 100644 common/spl/spl_nor.c
diff --git a/common/spl/Makefile b/common/spl/Makefile index b9c9fd8..7cf01ad 100644 --- a/common/spl/Makefile +++ b/common/spl/Makefile @@ -15,6 +15,7 @@ LIB = $(obj)libspl.o
ifdef CONFIG_SPL_BUILD COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o +COBJS-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o COBJS-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o endif diff --git a/common/spl/spl.c b/common/spl/spl.c index 3b4fcba..3156401 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -142,6 +142,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2) spl_nand_load_image(); break; #endif +#ifdef CONFIG_SPL_NOR_SUPPORT + case BOOT_DEVICE_NOR: + spl_nor_load_image(); + break; +#endif #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART: spl_ymodem_load_image(); diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c new file mode 100644 index 0000000..976e865 --- /dev/null +++ b/common/spl/spl_nor.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2012 Stefan Roese sr@denx.de + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <common.h> +#include <spl.h> + +void spl_nor_load_image(void) +{ + /* + * Loading of the payload to SDRAM is done with skipping of + * the mkimage header in this SPL NOR driver + */ + spl_image.flags |= SPL_COPY_PAYLOAD_ONLY; + + if (spl_start_uboot()) { + /* + * Load real U-Boot from its location in NOR flash to its + * defined location in SDRAM + */ + spl_parse_image_header( + (const struct image_header *)CONFIG_SYS_UBOOT_BASE); + + memcpy((void *)spl_image.load_addr, + (void *)(CONFIG_SYS_UBOOT_BASE + + sizeof(struct image_header)), + spl_image.size); + } else { + /* + * Load Linux from its location in NOR flash to its defined + * location in SDRAM + */ + spl_parse_image_header( + (const struct image_header *)CONFIG_SYS_OS_BASE); + + memcpy((void *)spl_image.load_addr, + (void *)(CONFIG_SYS_OS_BASE + + sizeof(struct image_header)), + spl_image.size); + + /* + * Copy DT blob (fdt) to SDRAM. Passing pointer to flash + * doesn't work (16 KiB should be enough for DT) + */ + memcpy((void *)CONFIG_SYS_SPL_ARGS_ADDR, + (void *)(CONFIG_SYS_FDT_BASE), + (16 << 10)); + } +} diff --git a/include/spl.h b/include/spl.h index 2923cd2..e405386 100644 --- a/include/spl.h +++ b/include/spl.h @@ -56,6 +56,9 @@ void spl_display_print(void); /* NAND SPL functions */ void spl_nand_load_image(void);
+/* NOR SPL functions */ +void spl_nor_load_image(void); + /* MMC SPL functions */ void spl_mmc_load_image(void);

From: Stefan Roese sr@denx.de
On some system (e.g. powerpc), the load-address and entry-point is located at address 0. So the current approach to load the image (payload) including the header to the address "load-address - 64" can't work here.
This patch adds an flag to skip this copying including header to the SPL framework. By setting SPL_COPY_PAYLOAD_ONLY, only the playload will be copied. This will be used by the SPL NOR flash driver on powerpc.
Signed-off-by: Stefan Roese sr@denx.de Signed-off-by: Tom Rini trini@ti.com ---
common/spl/spl.c | 21 +++++++++++++++++---- include/spl.h | 3 +++ 2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/common/spl/spl.c b/common/spl/spl.c index 3156401..95dd9d5 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -76,10 +76,23 @@ void spl_parse_image_header(const struct image_header *header) u32 header_size = sizeof(struct image_header);
if (image_get_magic(header) == IH_MAGIC) { - spl_image.size = image_get_data_size(header) + header_size; - spl_image.entry_point = image_get_load(header); - /* Load including the header */ - spl_image.load_addr = spl_image.entry_point - header_size; + if (spl_image.flags & SPL_COPY_PAYLOAD_ONLY) { + /* + * On some system (e.g. powerpc), the load-address and + * entry-point is located at address 0. We can't load + * to 0-0x40. So skip header in this case. + */ + spl_image.load_addr = image_get_load(header); + spl_image.entry_point = image_get_ep(header); + spl_image.size = image_get_data_size(header); + } else { + spl_image.entry_point = image_get_load(header); + /* Load including the header */ + spl_image.load_addr = spl_image.entry_point - + header_size; + spl_image.size = image_get_data_size(header) + + header_size; + } spl_image.os = image_get_os(header); spl_image.name = image_get_name(header); debug("spl: payload image: %s load addr: 0x%x size: %d\n", diff --git a/include/spl.h b/include/spl.h index e405386..cf441a1 100644 --- a/include/spl.h +++ b/include/spl.h @@ -38,8 +38,11 @@ struct spl_image_info { u32 load_addr; u32 entry_point; u32 size; + u32 flags; };
+#define SPL_COPY_PAYLOAD_ONLY 1 + extern struct spl_image_info spl_image; extern u32 *boot_params_ptr;

Signed-off-by: Tom Rini trini@ti.com
---
common/spl/spl.c | 4 ++-- drivers/mtd/spi/spi_spl_load.c | 23 ++++++++++++----------- include/spl.h | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/common/spl/spl.c b/common/spl/spl.c index 95dd9d5..40de454 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -167,8 +167,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2) #endif #ifdef CONFIG_SPL_SPI_SUPPORT case BOOT_DEVICE_SPI: - spi_boot(); - break; + spl_spi_load_image(); + break; #endif default: puts("SPL: Un-supported Boot Device\n"); diff --git a/drivers/mtd/spi/spi_spl_load.c b/drivers/mtd/spi/spi_spl_load.c index 1aa30ac..d4f81f2 100644 --- a/drivers/mtd/spi/spi_spl_load.c +++ b/drivers/mtd/spi/spi_spl_load.c @@ -24,16 +24,17 @@
#include <common.h> #include <spi_flash.h> +#include <spl.h>
/* * The main entry for SPI booting. It's necessary that SDRAM is already * configured and available since this code loads the main U-Boot image * from SPI into SDRAM and starts it from there. */ -void spi_boot(void) +void spl_spi_load_image(void) { struct spi_flash *flash; - void (*uboot)(void) __noreturn; + struct image_header *header;
/* * Load U-Boot image from SPI flash into RAM @@ -42,17 +43,17 @@ void spi_boot(void) flash = spi_flash_probe(CONFIG_SPL_SPI_BUS, CONFIG_SPL_SPI_CS, CONFIG_SF_DEFAULT_SPEED, SPI_MODE_3); if (!flash) { - puts("failed.\n"); + puts("SPI probe failed.\n"); hang(); }
- spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, - CONFIG_SYS_SPI_U_BOOT_SIZE, - (void *) CONFIG_SYS_TEXT_BASE); + /* use CONFIG_SYS_TEXT_BASE as temporary storage area */ + header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
- /* - * Jump to U-Boot image - */ - uboot = (void *) CONFIG_SYS_TEXT_BASE; - (*uboot)(); + /* Load u-boot, mkimage header is 64 bytes. */ + spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40, + (void *) header); + spl_parse_image_header(header); + spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, + spl_image.size, (void *)spl_image.load_addr); } diff --git a/include/spl.h b/include/spl.h index cf441a1..af94a82 100644 --- a/include/spl.h +++ b/include/spl.h @@ -69,7 +69,7 @@ void spl_mmc_load_image(void); void spl_ymodem_load_image(void);
/* SPI SPL functions */ -void spi_boot(void); +void spl_spi_load_image(void);
#ifdef CONFIG_SPL_BOARD_INIT void spl_board_init(void);

From: Stefan Roese sr@denx.de
By setting CONFIG_SYS_UBOOT_START boards can now use a different entry point for their U-Boot image. So the U-Boot entry point is not fixed to CONFIG_SYS_TEXT_BASE any more.
Signed-off-by: Stefan Roese sr@denx.de Signed-off-by: Tom Rini trini@ti.com --- Changes in v6: - Add Stefan's patch for custom U-Boot entry point
common/spl/spl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/common/spl/spl.c b/common/spl/spl.c index 40de454..14f7bdb 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -35,6 +35,9 @@
DECLARE_GLOBAL_DATA_PTR;
+#ifndef CONFIG_SYS_UBOOT_START +#define CONFIG_SYS_UBOOT_START CONFIG_SYS_TEXT_BASE +#endif #ifndef CONFIG_SYS_MONITOR_LEN #define CONFIG_SYS_MONITOR_LEN (200 * 1024) #endif @@ -104,7 +107,7 @@ void spl_parse_image_header(const struct image_header *header) header->ih_magic); /* Let's assume U-Boot will not be more than 200 KB */ spl_image.size = CONFIG_SYS_MONITOR_LEN; - spl_image.entry_point = CONFIG_SYS_TEXT_BASE; + spl_image.entry_point = CONFIG_SYS_UBOOT_START; spl_image.load_addr = CONFIG_SYS_TEXT_BASE; spl_image.os = IH_OS_U_BOOT; spl_image.name = "U-Boot";

Signed-off-by: Tom Rini trini@ti.com ---
common/spl/spl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/common/spl/spl.c b/common/spl/spl.c index 14f7bdb..3aa0703 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -174,10 +174,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2) break; #endif default: - puts("SPL: Un-supported Boot Device\n"); - debug("Found: %d\n", boot_device); + debug("SPL: Un-supported Boot Device\n"); hang(); - break; }
switch (spl_image.os) {

First, remove the puts from the case where we don't have an mkimage header as this is somewhat common and intentional for no-arg target images. Second, rework the final switch statement in board_init_r to, in the case of !CONFIG_SPL_OS_BOOT be only about doing debug prints about if we know what the magic is or not (the CONFIG_SPL_OS_BOOT case is unchanged). Then we call jump_to_image_no_args(). This gives us the same behavior as before but with slightly smaller code.
Signed-off-by: Tom Rini trini@ti.com ---
common/spl/spl.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/common/spl/spl.c b/common/spl/spl.c index 3aa0703..f2f6de7 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -102,7 +102,6 @@ void spl_parse_image_header(const struct image_header *header) spl_image.name, spl_image.load_addr, spl_image.size); } else { /* Signature not found - assume u-boot.bin */ - puts("mkimage signature not found, assuming u-boot.bin ..\n"); debug("mkimage signature not found - ih_magic = %x\n", header->ih_magic); /* Let's assume U-Boot will not be more than 200 KB */ @@ -181,19 +180,17 @@ void board_init_r(gd_t *dummy1, ulong dummy2) switch (spl_image.os) { case IH_OS_U_BOOT: debug("Jumping to U-Boot\n"); - jump_to_image_no_args(); break; #ifdef CONFIG_SPL_OS_BOOT case IH_OS_LINUX: debug("Jumping to Linux\n"); spl_board_prepare_for_linux(); jump_to_image_linux((void *)CONFIG_SYS_SPL_ARGS_ADDR); - break; #endif default: - puts("Unsupported OS image.. Jumping nevertheless..\n"); - jump_to_image_no_args(); + debug("Unsupported OS image.. Jumping nevertheless..\n"); } + jump_to_image_no_args(); }
/*

From: Pavel Machek pavel@denx.de
Signed-off-by: Pavel Machek pavel@denx.de Signed-off-by: Tom Rini trini@ti.com --- Changes in v6: - Add Pavel's spl_ram_load_image for when we've already got next image residing in DDR. - Fix multiline comment in spl_ram_load_image.
README | 3 +++ common/spl/spl.c | 22 ++++++++++++++++++++++ doc/README.SPL | 1 + 3 files changed, 26 insertions(+)
diff --git a/README b/README index 9bcfe7a..9ca3c85 100644 --- a/README +++ b/README @@ -2644,6 +2644,9 @@ FIT uImage format: CONFIG_SPL_SPI_SUPPORT Support for drivers/spi/libspi.o in SPL binary
+ CONFIG_SPL_RAM_DEVICE + Support for running image already present in ram, in SPL binary + CONFIG_SPL_LIBGENERIC_SUPPORT Support for lib/libgeneric.o in SPL binary
diff --git a/common/spl/spl.c b/common/spl/spl.c index f2f6de7..c640f87 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -128,6 +128,23 @@ static void __noreturn jump_to_image_no_args(void) image_entry((u32 *)boot_params_ptr_addr); }
+#ifdef CONFIG_SPL_RAM_DEVICE +static void spl_ram_load_image(void) +{ + const struct image_header *header; + + /* + * Get the header. It will point to an address defined by handoff + * which will tell where the image located inside the flash. For + * now, it will temporary fixed to address pointed by U-Boot. + */ + header = (struct image_header *) + (CONFIG_SYS_TEXT_BASE - sizeof(struct image_header)); + + spl_parse_image_header(header); +} +#endif + void board_init_r(gd_t *dummy1, ulong dummy2) { u32 boot_device; @@ -145,6 +162,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2) boot_device = spl_boot_device(); debug("boot device - %d\n", boot_device); switch (boot_device) { +#ifdef CONFIG_SPL_RAM_DEVICE + case BOOT_DEVICE_RAM: + spl_ram_load_image(); + break; +#endif #ifdef CONFIG_SPL_MMC_SUPPORT case BOOT_DEVICE_MMC1: case BOOT_DEVICE_MMC2: diff --git a/doc/README.SPL b/doc/README.SPL index 5368586..4e1cb28 100644 --- a/doc/README.SPL +++ b/doc/README.SPL @@ -66,6 +66,7 @@ CONFIG_SPL_DMA_SUPPORT (drivers/dma/libdma.o) CONFIG_SPL_POST_MEM_SUPPORT (post/drivers/memory.o) CONFIG_SPL_NAND_LOAD (drivers/mtd/nand/nand_spl_load.o) CONFIG_SPL_SPI_LOAD (drivers/mtd/spi/spi_spl_load.o) +CONFIG_SPL_RAM_DEVICE (common/spl/spl.c)
Normally CPU is assumed to be the same between the SPL and normal

On Mon, Sep 24, 2012 at 05:30:38PM -0700, Tom Rini wrote:
Hey all,
The following patch series merges the davinci and omap-common SPL frameworks into a single framework, CONFIG_SPL_FRAMEWORK along with a few small cleanups to the code to make it a little smaller and more flexible. The end result is that davinci can now opt in on SPL-boots-Linux by just setting the right defines and other platforms would just need to adapt to this framework. In my testing, davinci gains between 300 and 700 bytes for this (not enabling the SPL OS feature) and omap4/5/etc lose just a little bit (from the printf->puts changes). I've tested this on omap3_beagle (xM and classic) and omap4_panda. I don't have any davinci platforms that were previously using SPL so I can't boot-test those changes but since everyone sets CONFIG_SPL_MAX_SIZE, we're OK in that department.
To make this series easier to test I've placed it on http://github.com/trini/u-boot WIP/spl-improvements
I've looked a little into re-reducing the size and the biggest problem I see is that SPI a lot of informational prints that we don't need, strictly speaking, but are nice in a normal U-Boot context. I'm unsure of the best way to quiet these as I don't like the idea of sprinkling http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303 and I'm sending another email to discuss that.
v6 is tested on:
- AM335x EVM, Beaglebone, Beagleboard rev C (NAND and MMC), Beagleboard xM, OMAP3EVM (MMC) Devkit8000 (MMC + SPL OS goto U-Boot instead, no kernel so no SPL Linux test), Pandaboard, Pandaboard ES, LogicPD AM1808 EVM
v7 is tested on:
- Beaglebone, Beagleboard rev C (NAND and MMC), Beagleboard xM.
I did more limited testing this time due to the scope of the changes.
'reset' and cold power-on tested in various combinations.
With the one change I have mentioned already, I have now pushed this. I figure going this direcion will hopefully make the merging for Albert and others simpiler.
participants (1)
-
Tom Rini