[U-Boot] [PATCH 00/17]: 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 #ifndef CONFIG_SPL_BUILD in random places.
-- Tom

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();

On 15/08/2012 23:30, Tom Rini wrote:
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();
Right, this should be done !
Acked-by: Stefano Babic sbabic@denx.de
Regards, Stefano

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 fb9d904..f1a12a5 100644 --- a/README +++ b/README @@ -2564,6 +2564,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 4e95eee..19df5ea 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 2192c2b..685fde9 100644 --- a/include/configs/omap4_common.h +++ b/include/configs/omap4_common.h @@ -249,6 +249,7 @@ #define CONFIG_SPL_TEXT_BASE 0x40304350 #define CONFIG_SPL_MAX_SIZE (38 * 1024) #define CONFIG_SPL_STACK LOW_LEVEL_SRAM_STACK +#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 c5874bb..ef4034c 100644 --- a/include/configs/omap5_evm.h +++ b/include/configs/omap5_evm.h @@ -246,6 +246,7 @@ #define CONFIG_SPL_TEXT_BASE 0x40300350 #define CONFIG_SPL_MAX_SIZE 0x19000 /* 100K */ #define CONFIG_SPL_STACK LOW_LEVEL_SRAM_STACK +#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 */

Add a new flag, CONFIG_SPL_FRAMEWORK to opt into the arch/arm/lib SPL framework, enable on all of the previously using boards.
Signed-off-by: Tom Rini trini@ti.com --- README | 5 + arch/arm/cpu/armv7/omap-common/Makefile | 13 -- arch/arm/cpu/armv7/omap-common/spl.c | 225 --------------------------- arch/arm/cpu/armv7/omap-common/spl_mmc.c | 154 ------------------ arch/arm/cpu/armv7/omap-common/spl_nand.c | 111 ------------- arch/arm/cpu/armv7/omap-common/spl_ymodem.c | 76 --------- arch/arm/lib/Makefile | 9 +- arch/arm/lib/spl.c | 225 +++++++++++++++++++++++++++ arch/arm/lib/spl_mmc.c | 154 ++++++++++++++++++ arch/arm/lib/spl_nand.c | 111 +++++++++++++ arch/arm/lib/spl_ymodem.c | 76 +++++++++ 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/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 + 23 files changed, 591 insertions(+), 580 deletions(-) delete mode 100644 arch/arm/cpu/armv7/omap-common/spl.c delete mode 100644 arch/arm/cpu/armv7/omap-common/spl_mmc.c delete mode 100644 arch/arm/cpu/armv7/omap-common/spl_nand.c delete mode 100644 arch/arm/cpu/armv7/omap-common/spl_ymodem.c create mode 100644 arch/arm/lib/spl.c create mode 100644 arch/arm/lib/spl_mmc.c create mode 100644 arch/arm/lib/spl_nand.c create mode 100644 arch/arm/lib/spl_ymodem.c
diff --git a/README b/README index f1a12a5..de6b6c5 100644 --- a/README +++ b/README @@ -2564,6 +2564,11 @@ FIT uImage format: CONFIG_SYS_SPL_MALLOC_SIZE The size of the malloc pool used in SPL.
+ CONFIG_SPL_FRAMEWORK + For ARM, enable the SPL framework under arch/arm/lib, which + 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/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile index 2a6625f..0e0b641 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -45,19 +45,6 @@ COBJS += boot-common.o 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 ifneq ($(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) COBJS += mem-common.o diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c deleted file mode 100644 index b10832a..0000000 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - * (C) Copyright 2010 - * Texas Instruments, <www.ti.com> - * - * Aneesh V aneesh@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 <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/omap_common.h> -#include <asm/arch/mmc_host_def.h> -#include <i2c.h> -#include <image.h> -#include <malloc.h> -#include <linux/compiler.h> - -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"))); -static bd_t bdata __attribute__ ((section(".data"))); - -inline void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); - for (;;) - ; -} - -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. - * - * Please implement your own board specific funcion to do this. - * - * RETURN - * 0 to not start u-boot - * positive if u-boot should start - */ -#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"); - return 1; -} -#endif - -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); - /* 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; - debug("spl: payload image: %s load addr: 0x%x size: %d\n", - 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", - 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; - spl_image.load_addr = CONFIG_SYS_TEXT_BASE; - spl_image.os = IH_OS_U_BOOT; - spl_image.name = "U-Boot"; - } -} - -/* - * 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 *); - image_entry_noargs_t image_entry = - (image_entry_noargs_t) spl_image.entry_point; - - debug("image entry point: 0x%X\n", spl_image.entry_point); - /* Pass the saved boot_params from rom code */ -#if defined(CONFIG_VIRTIO) || defined(CONFIG_ZEBU) - image_entry = (image_entry_noargs_t)0x80100000; -#endif - u32 boot_params_ptr_addr = (u32)&boot_params_ptr; - image_entry((u32 *)boot_params_ptr_addr); -} - -void board_init_r(gd_t *id, ulong dummy) -{ - u32 boot_device; - debug(">>spl:board_init_r()\n"); - - mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, - CONFIG_SYS_SPL_MALLOC_SIZE); - -#ifdef CONFIG_SPL_BOARD_INIT - spl_board_init(); -#endif - - boot_device = omap_boot_device(); - debug("boot device - %d\n", boot_device); - switch (boot_device) { -#ifdef CONFIG_SPL_MMC_SUPPORT - case BOOT_DEVICE_MMC1: - case BOOT_DEVICE_MMC2: - case BOOT_DEVICE_MMC2_2: - spl_mmc_load_image(); - break; -#endif -#ifdef CONFIG_SPL_NAND_SUPPORT - case BOOT_DEVICE_NAND: - spl_nand_load_image(); - break; -#endif -#ifdef CONFIG_SPL_YMODEM_SUPPORT - case BOOT_DEVICE_UART: - spl_ymodem_load_image(); - break; -#endif - default: - printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device); - hang(); - break; - } - - 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(); - } -} - -/* 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; - gd->baudrate = CONFIG_BAUDRATE; - - serial_init(); /* serial communications setup */ - - 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); -#ifdef CONFIG_SPL_DISPLAY_PRINT - spl_display_print(); -#endif -} diff --git a/arch/arm/cpu/armv7/omap-common/spl_mmc.c b/arch/arm/cpu/armv7/omap-common/spl_mmc.c deleted file mode 100644 index 7552f6c..0000000 --- a/arch/arm/cpu/armv7/omap-common/spl_mmc.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * (C) Copyright 2010 - * Texas Instruments, <www.ti.com> - * - * Aneesh V aneesh@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 <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 (omap_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; - const struct image_header *header; - - header = (struct image_header *)(CONFIG_SYS_TEXT_BASE - - sizeof(struct image_header)); - - /* read image header to find the image size & load address */ - err = mmc->block_dev.block_read(0, - CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, 1, - (void *)header); - - if (err <= 0) - goto end; - - spl_parse_image_header(header); - - /* convert size to sectors - round up */ - image_size_sectors = (spl_image.size + MMCSD_SECTOR_SIZE - 1) / - MMCSD_SECTOR_SIZE; - - /* Read the header too to avoid extra memcpy */ - err = mmc->block_dev.block_read(0, - CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, - image_size_sectors, (void *)spl_image.load_addr); - -end: - if (err <= 0) { - printf("spl: mmc blk read err - %d\n", err); - hang(); - } -} - -#ifdef CONFIG_SPL_FAT_SUPPORT -static void mmc_load_image_fat(struct mmc *mmc) -{ - s32 err; - struct image_header *header; - - header = (struct image_header *)(CONFIG_SYS_TEXT_BASE - - sizeof(struct image_header)); - - err = fat_register_device(&mmc->block_dev, - CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION); - if (err) { - printf("spl: fat register err - %d\n", err); - hang(); - } - - err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, - (u8 *)header, sizeof(struct image_header)); - if (err <= 0) - goto end; - - spl_parse_image_header(header); - - err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, - (u8 *)spl_image.load_addr, 0); - -end: - if (err <= 0) { - printf("spl: error reading image %s, err - %d\n", - CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, err); - hang(); - } -} -#endif - -void spl_mmc_load_image(void) -{ - struct mmc *mmc; - int err; - u32 boot_mode; - - mmc_initialize(gd->bd); - /* We register only one device. So, the dev id is always 0 */ - mmc = find_mmc_device(0); - if (!mmc) { - puts("spl: mmc device not found!!\n"); - hang(); - } - - err = mmc_init(mmc); - if (err) { - printf("spl: mmc init failed: err - %d\n", err); - hang(); - } - boot_mode = omap_boot_mode(); - 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(); - } -} diff --git a/arch/arm/cpu/armv7/omap-common/spl_nand.c b/arch/arm/cpu/armv7/omap-common/spl_nand.c deleted file mode 100644 index 8cf55c9..0000000 --- a/arch/arm/cpu/armv7/omap-common/spl_nand.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2011 - * Corscience GmbH & Co. KG - Simon Schwarz schwarz@corscience.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. - * - * 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 <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) -{ - struct image_header *header; - int *src __attribute__((unused)); - int *dst __attribute__((unused)); - - switch (omap_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(); - } - - /*use CONFIG_SYS_TEXT_BASE as temporary storage area */ - header = (struct image_header *)(CONFIG_SYS_TEXT_BASE); -#ifdef CONFIG_SPL_OS_BOOT - if (!spl_start_uboot()) { - /* - * load parameter image - * load to temp position since nand_spl_load_image reads - * a whole block which is typically larger than - * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite - * following sections like BSS - */ - nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS, - CONFIG_CMD_SPL_WRITE_SIZE, - (void *)CONFIG_SYS_TEXT_BASE); - /* copy to destintion */ - for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR, - src = (int *)CONFIG_SYS_TEXT_BASE; - src < (int *)(CONFIG_SYS_TEXT_BASE + - CONFIG_CMD_SPL_WRITE_SIZE); - src++, dst++) { - writel(readl(src), dst); - } - - /* load linux */ - nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS, - CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); - spl_parse_image_header(header); - if (header->ih_os == IH_OS_LINUX) { - /* happy - was a linux */ - nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS, - spl_image.size, (void *)spl_image.load_addr); - nand_deselect(); - return; - } else { - printf("The Expected Linux image was not" - "found. Please check your NAND" - "configuration.\n"); - printf("Trying to start u-boot now...\n"); - } - } -#endif -#ifdef CONFIG_NAND_ENV_DST - nand_spl_load_image(CONFIG_ENV_OFFSET, - CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); - spl_parse_image_header(header); - nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size, - (void *)spl_image.load_addr); -#ifdef CONFIG_ENV_OFFSET_REDUND - nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, - CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); - spl_parse_image_header(header); - nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size, - (void *)spl_image.load_addr); -#endif -#endif - /* Load u-boot */ - nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, - CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); - spl_parse_image_header(header); - nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, - spl_image.size, (void *)spl_image.load_addr); - nand_deselect(); -} diff --git a/arch/arm/cpu/armv7/omap-common/spl_ymodem.c b/arch/arm/cpu/armv7/omap-common/spl_ymodem.c deleted file mode 100644 index 47663f7..0000000 --- a/arch/arm/cpu/armv7/omap-common/spl_ymodem.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * (C) Copyright 2000-2004 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * (C) Copyright 2011 - * Texas Instruments, <www.ti.com> - * - * Matt Porter mporter@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 <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 - -static int getcymodem(void) { - if (tstc()) - return (getc()); - return -1; -} - -void spl_ymodem_load_image(void) -{ - int size = 0; - int err; - int res; - int ret; - connection_info_t info; - char buf[BUF_SIZE]; - ulong store_addr = ~0; - ulong addr = 0; - - info.mode = xyzModem_ymodem; - ret = xyzModem_stream_open(&info, &err); - - if (!ret) { - while ((res = - xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0) { - if (addr == 0) - spl_parse_image_header((struct image_header *)buf); - store_addr = addr + spl_image.load_addr; - size += res; - addr += res; - memcpy((char *)(store_addr), buf, res); - } - } else { - printf("spl: ymodem err - %s\n", xyzModem_error(err)); - hang(); - } - - xyzModem_stream_close(&err); - xyzModem_stream_terminate(false, &getcymodem); - - printf("Loaded %d bytes\n", size); -} diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 39a9550..abf550a 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -26,7 +26,14 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(ARCH).o LIBGCC = $(obj)libgcc.o
-ifndef CONFIG_SPL_BUILD +ifdef CONFIG_SPL_BUILD +ifdef CONFIG_SPL_FRAMEWORK +COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o +COBJS-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o +COBJS-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o +COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o +endif +else GLSOBJS += _ashldi3.o GLSOBJS += _ashrdi3.o GLSOBJS += _divsi3.o diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c new file mode 100644 index 0000000..b10832a --- /dev/null +++ b/arch/arm/lib/spl.c @@ -0,0 +1,225 @@ +/* + * (C) Copyright 2010 + * Texas Instruments, <www.ti.com> + * + * Aneesh V aneesh@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 <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/omap_common.h> +#include <asm/arch/mmc_host_def.h> +#include <i2c.h> +#include <image.h> +#include <malloc.h> +#include <linux/compiler.h> + +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"))); +static bd_t bdata __attribute__ ((section(".data"))); + +inline void hang(void) +{ + puts("### ERROR ### Please RESET the board ###\n"); + for (;;) + ; +} + +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. + * + * Please implement your own board specific funcion to do this. + * + * RETURN + * 0 to not start u-boot + * positive if u-boot should start + */ +#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"); + return 1; +} +#endif + +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); + /* 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; + debug("spl: payload image: %s load addr: 0x%x size: %d\n", + 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", + 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; + spl_image.load_addr = CONFIG_SYS_TEXT_BASE; + spl_image.os = IH_OS_U_BOOT; + spl_image.name = "U-Boot"; + } +} + +/* + * 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 *); + image_entry_noargs_t image_entry = + (image_entry_noargs_t) spl_image.entry_point; + + debug("image entry point: 0x%X\n", spl_image.entry_point); + /* Pass the saved boot_params from rom code */ +#if defined(CONFIG_VIRTIO) || defined(CONFIG_ZEBU) + image_entry = (image_entry_noargs_t)0x80100000; +#endif + u32 boot_params_ptr_addr = (u32)&boot_params_ptr; + image_entry((u32 *)boot_params_ptr_addr); +} + +void board_init_r(gd_t *id, ulong dummy) +{ + u32 boot_device; + debug(">>spl:board_init_r()\n"); + + mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, + CONFIG_SYS_SPL_MALLOC_SIZE); + +#ifdef CONFIG_SPL_BOARD_INIT + spl_board_init(); +#endif + + boot_device = omap_boot_device(); + debug("boot device - %d\n", boot_device); + switch (boot_device) { +#ifdef CONFIG_SPL_MMC_SUPPORT + case BOOT_DEVICE_MMC1: + case BOOT_DEVICE_MMC2: + case BOOT_DEVICE_MMC2_2: + spl_mmc_load_image(); + break; +#endif +#ifdef CONFIG_SPL_NAND_SUPPORT + case BOOT_DEVICE_NAND: + spl_nand_load_image(); + break; +#endif +#ifdef CONFIG_SPL_YMODEM_SUPPORT + case BOOT_DEVICE_UART: + spl_ymodem_load_image(); + break; +#endif + default: + printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device); + hang(); + break; + } + + 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(); + } +} + +/* 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; + gd->baudrate = CONFIG_BAUDRATE; + + serial_init(); /* serial communications setup */ + + 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); +#ifdef CONFIG_SPL_DISPLAY_PRINT + spl_display_print(); +#endif +} diff --git a/arch/arm/lib/spl_mmc.c b/arch/arm/lib/spl_mmc.c new file mode 100644 index 0000000..7552f6c --- /dev/null +++ b/arch/arm/lib/spl_mmc.c @@ -0,0 +1,154 @@ +/* + * (C) Copyright 2010 + * Texas Instruments, <www.ti.com> + * + * Aneesh V aneesh@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 <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 (omap_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; + const struct image_header *header; + + header = (struct image_header *)(CONFIG_SYS_TEXT_BASE - + sizeof(struct image_header)); + + /* read image header to find the image size & load address */ + err = mmc->block_dev.block_read(0, + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, 1, + (void *)header); + + if (err <= 0) + goto end; + + spl_parse_image_header(header); + + /* convert size to sectors - round up */ + image_size_sectors = (spl_image.size + MMCSD_SECTOR_SIZE - 1) / + MMCSD_SECTOR_SIZE; + + /* Read the header too to avoid extra memcpy */ + err = mmc->block_dev.block_read(0, + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, + image_size_sectors, (void *)spl_image.load_addr); + +end: + if (err <= 0) { + printf("spl: mmc blk read err - %d\n", err); + hang(); + } +} + +#ifdef CONFIG_SPL_FAT_SUPPORT +static void mmc_load_image_fat(struct mmc *mmc) +{ + s32 err; + struct image_header *header; + + header = (struct image_header *)(CONFIG_SYS_TEXT_BASE - + sizeof(struct image_header)); + + err = fat_register_device(&mmc->block_dev, + CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION); + if (err) { + printf("spl: fat register err - %d\n", err); + hang(); + } + + err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, + (u8 *)header, sizeof(struct image_header)); + if (err <= 0) + goto end; + + spl_parse_image_header(header); + + err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, + (u8 *)spl_image.load_addr, 0); + +end: + if (err <= 0) { + printf("spl: error reading image %s, err - %d\n", + CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, err); + hang(); + } +} +#endif + +void spl_mmc_load_image(void) +{ + struct mmc *mmc; + int err; + u32 boot_mode; + + mmc_initialize(gd->bd); + /* We register only one device. So, the dev id is always 0 */ + mmc = find_mmc_device(0); + if (!mmc) { + puts("spl: mmc device not found!!\n"); + hang(); + } + + err = mmc_init(mmc); + if (err) { + printf("spl: mmc init failed: err - %d\n", err); + hang(); + } + boot_mode = omap_boot_mode(); + 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(); + } +} diff --git a/arch/arm/lib/spl_nand.c b/arch/arm/lib/spl_nand.c new file mode 100644 index 0000000..8cf55c9 --- /dev/null +++ b/arch/arm/lib/spl_nand.c @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2011 + * Corscience GmbH & Co. KG - Simon Schwarz schwarz@corscience.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. + * + * 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 <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) +{ + struct image_header *header; + int *src __attribute__((unused)); + int *dst __attribute__((unused)); + + switch (omap_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(); + } + + /*use CONFIG_SYS_TEXT_BASE as temporary storage area */ + header = (struct image_header *)(CONFIG_SYS_TEXT_BASE); +#ifdef CONFIG_SPL_OS_BOOT + if (!spl_start_uboot()) { + /* + * load parameter image + * load to temp position since nand_spl_load_image reads + * a whole block which is typically larger than + * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite + * following sections like BSS + */ + nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS, + CONFIG_CMD_SPL_WRITE_SIZE, + (void *)CONFIG_SYS_TEXT_BASE); + /* copy to destintion */ + for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR, + src = (int *)CONFIG_SYS_TEXT_BASE; + src < (int *)(CONFIG_SYS_TEXT_BASE + + CONFIG_CMD_SPL_WRITE_SIZE); + src++, dst++) { + writel(readl(src), dst); + } + + /* load linux */ + nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS, + CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); + spl_parse_image_header(header); + if (header->ih_os == IH_OS_LINUX) { + /* happy - was a linux */ + nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS, + spl_image.size, (void *)spl_image.load_addr); + nand_deselect(); + return; + } else { + printf("The Expected Linux image was not" + "found. Please check your NAND" + "configuration.\n"); + printf("Trying to start u-boot now...\n"); + } + } +#endif +#ifdef CONFIG_NAND_ENV_DST + nand_spl_load_image(CONFIG_ENV_OFFSET, + CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); + spl_parse_image_header(header); + nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size, + (void *)spl_image.load_addr); +#ifdef CONFIG_ENV_OFFSET_REDUND + nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, + CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); + spl_parse_image_header(header); + nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size, + (void *)spl_image.load_addr); +#endif +#endif + /* Load u-boot */ + nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, + CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); + spl_parse_image_header(header); + nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, + spl_image.size, (void *)spl_image.load_addr); + nand_deselect(); +} diff --git a/arch/arm/lib/spl_ymodem.c b/arch/arm/lib/spl_ymodem.c new file mode 100644 index 0000000..47663f7 --- /dev/null +++ b/arch/arm/lib/spl_ymodem.c @@ -0,0 +1,76 @@ +/* + * (C) Copyright 2000-2004 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * (C) Copyright 2011 + * Texas Instruments, <www.ti.com> + * + * Matt Porter mporter@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 <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 + +static int getcymodem(void) { + if (tstc()) + return (getc()); + return -1; +} + +void spl_ymodem_load_image(void) +{ + int size = 0; + int err; + int res; + int ret; + connection_info_t info; + char buf[BUF_SIZE]; + ulong store_addr = ~0; + ulong addr = 0; + + info.mode = xyzModem_ymodem; + ret = xyzModem_stream_open(&info, &err); + + if (!ret) { + while ((res = + xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0) { + if (addr == 0) + spl_parse_image_header((struct image_header *)buf); + store_addr = addr + spl_image.load_addr; + size += res; + addr += res; + memcpy((char *)(store_addr), buf, res); + } + } else { + printf("spl: ymodem err - %s\n", xyzModem_error(err)); + hang(); + } + + xyzModem_stream_close(&err); + xyzModem_stream_terminate(false, &getcymodem); + + printf("Loaded %d bytes\n", size); +} diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index d0fbc88..cda2c4f 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -126,6 +126,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 LOW_LEVEL_SRAM_STACK diff --git a/include/configs/am3517_crane.h b/include/configs/am3517_crane.h index 54ab3eb..a5799d9 100644 --- a/include/configs/am3517_crane.h +++ b/include/configs/am3517_crane.h @@ -322,6 +322,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/am3517_evm.h b/include/configs/am3517_evm.h index ed0a601..62da56e 100644 --- a/include/configs/am3517_evm.h +++ b/include/configs/am3517_evm.h @@ -321,6 +321,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/devkit8000.h b/include/configs/devkit8000.h index 037a5bb..47187cf 100644 --- a/include/configs/devkit8000.h +++ b/include/configs/devkit8000.h @@ -305,6 +305,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/mcx.h b/include/configs/mcx.h index 970c882..d91258a 100644 --- a/include/configs/mcx.h +++ b/include/configs/mcx.h @@ -309,6 +309,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #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 657780e..1b4e2ee 100644 --- a/include/configs/omap3_beagle.h +++ b/include/configs/omap3_beagle.h @@ -398,6 +398,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 20192a9..22f30f4 100644 --- a/include/configs/omap3_evm_common.h +++ b/include/configs/omap3_evm_common.h @@ -280,6 +280,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 d29b326..8e63802 100644 --- a/include/configs/omap3_overo.h +++ b/include/configs/omap3_overo.h @@ -300,6 +300,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 685fde9..1384522 100644 --- a/include/configs/omap4_common.h +++ b/include/configs/omap4_common.h @@ -246,6 +246,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 LOW_LEVEL_SRAM_STACK diff --git a/include/configs/omap5_evm.h b/include/configs/omap5_evm.h index ef4034c..65a34fa 100644 --- a/include/configs/omap5_evm.h +++ b/include/configs/omap5_evm.h @@ -243,6 +243,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 LOW_LEVEL_SRAM_STACK diff --git a/include/configs/tam3517-common.h b/include/configs/tam3517-common.h index 777f77c..8646d94 100644 --- a/include/configs/tam3517-common.h +++ b/include/configs/tam3517-common.h @@ -241,6 +241,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_CONSOLE #define CONFIG_SPL_NAND_SIMPLE #define CONFIG_SPL_NAND_SOFTECC diff --git a/include/configs/tricorder.h b/include/configs/tricorder.h index 56336ae..0679f18 100644 --- a/include/configs/tricorder.h +++ b/include/configs/tricorder.h @@ -275,6 +275,7 @@
/* Defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_NAND_SIMPLE
#define CONFIG_SPL_BOARD_INIT

On 15/08/2012 23:30, Tom Rini wrote:
Add a new flag, CONFIG_SPL_FRAMEWORK to opt into the arch/arm/lib SPL framework, enable on all of the previously using boards.
Signed-off-by: Tom Rini trini@ti.com
Hi Tom,
README | 5 + arch/arm/cpu/armv7/omap-common/Makefile | 13 -- arch/arm/cpu/armv7/omap-common/spl.c | 225 --------------------------- arch/arm/cpu/armv7/omap-common/spl_mmc.c | 154 ------------------ arch/arm/cpu/armv7/omap-common/spl_nand.c | 111 ------------- arch/arm/cpu/armv7/omap-common/spl_ymodem.c | 76 --------- arch/arm/lib/Makefile | 9 +- arch/arm/lib/spl.c | 225 +++++++++++++++++++++++++++ arch/arm/lib/spl_mmc.c | 154 ++++++++++++++++++ arch/arm/lib/spl_nand.c | 111 +++++++++++++ arch/arm/lib/spl_ymodem.c | 76 +++++++++ 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/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 + 23 files changed, 591 insertions(+), 580 deletions(-) delete mode 100644 arch/arm/cpu/armv7/omap-common/spl.c delete mode 100644 arch/arm/cpu/armv7/omap-common/spl_mmc.c delete mode 100644 arch/arm/cpu/armv7/omap-common/spl_nand.c delete mode 100644 arch/arm/cpu/armv7/omap-common/spl_ymodem.c create mode 100644 arch/arm/lib/spl.c create mode 100644 arch/arm/lib/spl_mmc.c create mode 100644 arch/arm/lib/spl_nand.c create mode 100644 arch/arm/lib/spl_ymodem.c
In my attempt I moved files from arch/arm/cpu/armv7/omap-common/ to common. This is because to make it available to all SOCs, not only armv7. What do you think about ? I would like to add an example with an arm1136 (MX35).
--- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -45,19 +45,6 @@ COBJS += boot-common.o 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 ifneq ($(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) COBJS += mem-common.o diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c deleted file mode 100644 index b10832a..0000000 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ /dev/null @@ -1,225 +0,0 @@ -/*
- (C) Copyright 2010
- Texas Instruments, <www.ti.com>
- Aneesh V aneesh@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 <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/omap_common.h> -#include <asm/arch/mmc_host_def.h> -#include <i2c.h> -#include <image.h> -#include <malloc.h> -#include <linux/compiler.h>
-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"))); -static bd_t bdata __attribute__ ((section(".data")));
-inline void hang(void) -{
- puts("### ERROR ### Please RESET the board ###\n");
- for (;;)
;
-}
-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.
- Please implement your own board specific funcion to do this.
- RETURN
- 0 to not start u-boot
- positive if u-boot should start
- */
-#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");
- return 1;
-} -#endif
-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);
/* 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;
debug("spl: payload image: %s load addr: 0x%x size: %d\n",
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",
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;
spl_image.load_addr = CONFIG_SYS_TEXT_BASE;
spl_image.os = IH_OS_U_BOOT;
spl_image.name = "U-Boot";
- }
-}
-/*
- 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 *);
- image_entry_noargs_t image_entry =
(image_entry_noargs_t) spl_image.entry_point;
- debug("image entry point: 0x%X\n", spl_image.entry_point);
- /* Pass the saved boot_params from rom code */
-#if defined(CONFIG_VIRTIO) || defined(CONFIG_ZEBU)
- image_entry = (image_entry_noargs_t)0x80100000;
-#endif
- u32 boot_params_ptr_addr = (u32)&boot_params_ptr;
- image_entry((u32 *)boot_params_ptr_addr);
-}
-void board_init_r(gd_t *id, ulong dummy) -{
- u32 boot_device;
- debug(">>spl:board_init_r()\n");
- mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
CONFIG_SYS_SPL_MALLOC_SIZE);
-#ifdef CONFIG_SPL_BOARD_INIT
- spl_board_init();
-#endif
- boot_device = omap_boot_device();
- debug("boot device - %d\n", boot_device);
- switch (boot_device) {
-#ifdef CONFIG_SPL_MMC_SUPPORT
- case BOOT_DEVICE_MMC1:
- case BOOT_DEVICE_MMC2:
- case BOOT_DEVICE_MMC2_2:
spl_mmc_load_image();
break;
-#endif -#ifdef CONFIG_SPL_NAND_SUPPORT
- case BOOT_DEVICE_NAND:
spl_nand_load_image();
break;
-#endif -#ifdef CONFIG_SPL_YMODEM_SUPPORT
- case BOOT_DEVICE_UART:
spl_ymodem_load_image();
break;
-#endif
- default:
printf("SPL: Un-supported Boot Device - %d!!!\n", boot_device);
hang();
break;
- }
- 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();
- }
-}
-/* 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;
- gd->baudrate = CONFIG_BAUDRATE;
- serial_init(); /* serial communications setup */
- 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);
-#ifdef CONFIG_SPL_DISPLAY_PRINT
- spl_display_print();
-#endif -}
diff --git a/arch/arm/cpu/armv7/omap-common/spl_mmc.c b/arch/arm/cpu/armv7/omap-common/spl_mmc.c deleted file mode 100644 index 7552f6c..0000000 --- a/arch/arm/cpu/armv7/omap-common/spl_mmc.c +++ /dev/null @@ -1,154 +0,0 @@ -/*
- (C) Copyright 2010
- Texas Instruments, <www.ti.com>
- Aneesh V aneesh@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 <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 (omap_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;
- const struct image_header *header;
- header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
sizeof(struct image_header));
- /* read image header to find the image size & load address */
- err = mmc->block_dev.block_read(0,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, 1,
(void *)header);
- if (err <= 0)
goto end;
- spl_parse_image_header(header);
- /* convert size to sectors - round up */
- image_size_sectors = (spl_image.size + MMCSD_SECTOR_SIZE - 1) /
MMCSD_SECTOR_SIZE;
- /* Read the header too to avoid extra memcpy */
- err = mmc->block_dev.block_read(0,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
image_size_sectors, (void *)spl_image.load_addr);
-end:
- if (err <= 0) {
printf("spl: mmc blk read err - %d\n", err);
hang();
- }
-}
-#ifdef CONFIG_SPL_FAT_SUPPORT -static void mmc_load_image_fat(struct mmc *mmc) -{
- s32 err;
- struct image_header *header;
- header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
sizeof(struct image_header));
- err = fat_register_device(&mmc->block_dev,
CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION);
- if (err) {
printf("spl: fat register err - %d\n", err);
hang();
- }
- err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME,
(u8 *)header, sizeof(struct image_header));
- if (err <= 0)
goto end;
- spl_parse_image_header(header);
- err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME,
(u8 *)spl_image.load_addr, 0);
-end:
- if (err <= 0) {
printf("spl: error reading image %s, err - %d\n",
CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, err);
hang();
- }
-} -#endif
-void spl_mmc_load_image(void) -{
- struct mmc *mmc;
- int err;
- u32 boot_mode;
- mmc_initialize(gd->bd);
- /* We register only one device. So, the dev id is always 0 */
- mmc = find_mmc_device(0);
- if (!mmc) {
puts("spl: mmc device not found!!\n");
hang();
- }
- err = mmc_init(mmc);
- if (err) {
printf("spl: mmc init failed: err - %d\n", err);
hang();
- }
- boot_mode = omap_boot_mode();
- 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();
- }
-} diff --git a/arch/arm/cpu/armv7/omap-common/spl_nand.c b/arch/arm/cpu/armv7/omap-common/spl_nand.c deleted file mode 100644 index 8cf55c9..0000000 --- a/arch/arm/cpu/armv7/omap-common/spl_nand.c +++ /dev/null @@ -1,111 +0,0 @@ -/*
- Copyright (C) 2011
- Corscience GmbH & Co. KG - Simon Schwarz schwarz@corscience.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.
- 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 <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) -{
- struct image_header *header;
- int *src __attribute__((unused));
- int *dst __attribute__((unused));
- switch (omap_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();
- }
- /*use CONFIG_SYS_TEXT_BASE as temporary storage area */
- header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
-#ifdef CONFIG_SPL_OS_BOOT
- if (!spl_start_uboot()) {
/*
* load parameter image
* load to temp position since nand_spl_load_image reads
* a whole block which is typically larger than
* CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite
* following sections like BSS
*/
nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS,
CONFIG_CMD_SPL_WRITE_SIZE,
(void *)CONFIG_SYS_TEXT_BASE);
/* copy to destintion */
for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR,
src = (int *)CONFIG_SYS_TEXT_BASE;
src < (int *)(CONFIG_SYS_TEXT_BASE +
CONFIG_CMD_SPL_WRITE_SIZE);
src++, dst++) {
writel(readl(src), dst);
}
/* load linux */
nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
spl_parse_image_header(header);
if (header->ih_os == IH_OS_LINUX) {
/* happy - was a linux */
nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
spl_image.size, (void *)spl_image.load_addr);
nand_deselect();
return;
} else {
printf("The Expected Linux image was not"
"found. Please check your NAND"
"configuration.\n");
printf("Trying to start u-boot now...\n");
}
- }
-#endif -#ifdef CONFIG_NAND_ENV_DST
- nand_spl_load_image(CONFIG_ENV_OFFSET,
CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
- spl_parse_image_header(header);
- nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
(void *)spl_image.load_addr);
-#ifdef CONFIG_ENV_OFFSET_REDUND
- nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
- spl_parse_image_header(header);
- nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
(void *)spl_image.load_addr);
-#endif -#endif
- /* Load u-boot */
- nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
- spl_parse_image_header(header);
- nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
spl_image.size, (void *)spl_image.load_addr);
- nand_deselect();
-} diff --git a/arch/arm/cpu/armv7/omap-common/spl_ymodem.c b/arch/arm/cpu/armv7/omap-common/spl_ymodem.c deleted file mode 100644 index 47663f7..0000000 --- a/arch/arm/cpu/armv7/omap-common/spl_ymodem.c +++ /dev/null @@ -1,76 +0,0 @@ -/*
- (C) Copyright 2000-2004
- Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- (C) Copyright 2011
- Texas Instruments, <www.ti.com>
- Matt Porter mporter@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 <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
-static int getcymodem(void) {
- if (tstc())
return (getc());
- return -1;
-}
-void spl_ymodem_load_image(void) -{
- int size = 0;
- int err;
- int res;
- int ret;
- connection_info_t info;
- char buf[BUF_SIZE];
- ulong store_addr = ~0;
- ulong addr = 0;
- info.mode = xyzModem_ymodem;
- ret = xyzModem_stream_open(&info, &err);
- if (!ret) {
while ((res =
xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0) {
if (addr == 0)
spl_parse_image_header((struct image_header *)buf);
store_addr = addr + spl_image.load_addr;
size += res;
addr += res;
memcpy((char *)(store_addr), buf, res);
}
- } else {
printf("spl: ymodem err - %s\n", xyzModem_error(err));
hang();
- }
- xyzModem_stream_close(&err);
- xyzModem_stream_terminate(false, &getcymodem);
- printf("Loaded %d bytes\n", size);
-} diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 39a9550..abf550a 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -26,7 +26,14 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(ARCH).o LIBGCC = $(obj)libgcc.o
-ifndef CONFIG_SPL_BUILD +ifdef CONFIG_SPL_BUILD +ifdef CONFIG_SPL_FRAMEWORK +COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o +COBJS-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o +COBJS-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o +COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o +endif +else GLSOBJS += _ashldi3.o GLSOBJS += _ashrdi3.o GLSOBJS += _divsi3.o diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c new file mode 100644 index 0000000..b10832a --- /dev/null +++ b/arch/arm/lib/spl.c @@ -0,0 +1,225 @@ +/*
- (C) Copyright 2010
- Texas Instruments, <www.ti.com>
- Aneesh V aneesh@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 <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/omap_common.h>
This is a conflict I got. This file should be generic code, and should not have reference to a specific SOC or SOC family, as omap here. So I have added a include/spl.h with only the SPL relevant part, dropping other OMAP specific from this file (I see you did the same with omap_boot_device and omap_boot_mode).
+#include <asm/arch/mmc_host_def.h>
As far as I have understood, this is only for MMCSD_SECTOR_SIZE, that can be moved into another header file. Not all SOCs have asm/arch/mmc_host_def.h
+#include <common.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>
Both files are OMAP specific
+DECLARE_GLOBAL_DATA_PTR;
+#ifdef CONFIG_GENERIC_MMC +int board_mmc_init(bd_t *bis) +{
- switch (omap_boot_device()) {
And this is also omap specific. Replaced by soc_boot_device ?
Cheers, Stefano

On 08/16/2012 12:45 AM, Stefano Babic wrote:
On 15/08/2012 23:30, Tom Rini wrote:
Add a new flag, CONFIG_SPL_FRAMEWORK to opt into the arch/arm/lib SPL framework, enable on all of the previously using boards.
Signed-off-by: Tom Rini trini@ti.com
Hi Tom,
README | 5 + arch/arm/cpu/armv7/omap-common/Makefile | 13 -- arch/arm/cpu/armv7/omap-common/spl.c | 225 --------------------------- arch/arm/cpu/armv7/omap-common/spl_mmc.c | 154 ------------------ arch/arm/cpu/armv7/omap-common/spl_nand.c | 111 ------------- arch/arm/cpu/armv7/omap-common/spl_ymodem.c | 76 --------- arch/arm/lib/Makefile | 9 +- arch/arm/lib/spl.c | 225 +++++++++++++++++++++++++++ arch/arm/lib/spl_mmc.c | 154 ++++++++++++++++++ arch/arm/lib/spl_nand.c | 111 +++++++++++++ arch/arm/lib/spl_ymodem.c | 76 +++++++++ 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/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 + 23 files changed, 591 insertions(+), 580 deletions(-) delete mode 100644 arch/arm/cpu/armv7/omap-common/spl.c delete mode 100644 arch/arm/cpu/armv7/omap-common/spl_mmc.c delete mode 100644 arch/arm/cpu/armv7/omap-common/spl_nand.c delete mode 100644 arch/arm/cpu/armv7/omap-common/spl_ymodem.c create mode 100644 arch/arm/lib/spl.c create mode 100644 arch/arm/lib/spl_mmc.c create mode 100644 arch/arm/lib/spl_nand.c create mode 100644 arch/arm/lib/spl_ymodem.c
In my attempt I moved files from arch/arm/cpu/armv7/omap-common/ to common. This is because to make it available to all SOCs, not only armv7. What do you think about ? I would like to add an example with an arm1136 (MX35).
Second request so yes, for v2 I'll move things to common/
[snip]
+#include <asm/omap_common.h>
This is a conflict I got. This file should be generic code, and should not have reference to a specific SOC or SOC family, as omap here. So I have added a include/spl.h with only the SPL relevant part, dropping other OMAP specific from this file (I see you did the same with omap_boot_device and omap_boot_mode).
+#include <asm/arch/mmc_host_def.h>
As far as I have understood, this is only for MMCSD_SECTOR_SIZE, that can be moved into another header file. Not all SOCs have asm/arch/mmc_host_def.h
Yes, mandating what the asm/ mmc header file names should be is something I've thought about but not had to step on, yet.
+#include <common.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>
Both files are OMAP specific
+DECLARE_GLOBAL_DATA_PTR;
+#ifdef CONFIG_GENERIC_MMC +int board_mmc_init(bd_t *bis) +{
- switch (omap_boot_device()) {
And this is also omap specific. Replaced by soc_boot_device ?
My goal with this series, and part of why I added CONFIG_SPL_FRAMEWORK was that indeed, there's a lot of omap-isms in the code at the start. I believe by the end of the series they're all removed and the code is common. If it's a concern I can re-work things so that the move is one of the last steps.

On 16/08/2012 16:38, Tom Rini wrote:
On 08/16/2012 12:45 AM, Stefano Babic wrote:
On 15/08/2012 23:30, Tom Rini wrote:
Add a new flag, CONFIG_SPL_FRAMEWORK to opt into the arch/arm/lib SPL framework, enable on all of the previously using boards.
Signed-off-by: Tom Rini trini@ti.com
Hi Tom,
My goal with this series, and part of why I added CONFIG_SPL_FRAMEWORK was that indeed, there's a lot of omap-isms in the code at the start. I believe by the end of the series they're all removed and the code is common. If it's a concern I can re-work things so that the move is one of the last steps.
No, it is not a problem. I am setting on top of your tree and it looks great.
Regards, Stefano

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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile index 73c8e39..57bb0b9 100644 --- a/Makefile +++ b/Makefile @@ -763,12 +763,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 $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl.map} - @rm -f $(ONENAND_BIN) - @rm -f $(obj)onenand_ipl/u-boot.lds - @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' \ @@ -793,6 +787,12 @@ 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)onenand_ipl/onenand-{ipl,ipl.bin,ipl.map} + @rm -f $(ONENAND_BIN) + @rm -f $(obj)onenand_ipl/u-boot.lds + @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/boot-common.c | 2 +- arch/arm/cpu/armv7/omap-common/lowlevel_init.S | 4 ++-- arch/arm/cpu/armv7/omap3/board.c | 4 ++-- arch/arm/include/asm/omap_common.h | 2 +- arch/arm/lib/spl.c | 2 +- arch/arm/lib/spl_mmc.c | 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 ccc6bb6..d4ce0af 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/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 19df5ea..a3853ce 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*/ diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c index b10832a..4d33f99 100644 --- a/arch/arm/lib/spl.c +++ b/arch/arm/lib/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/lib/spl_mmc.c b/arch/arm/lib/spl_mmc.c index 7552f6c..3ad382b 100644 --- a/arch/arm/lib/spl_mmc.c +++ b/arch/arm/lib/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;

Signed-off-by: Tom Rini trini@ti.com --- arch/arm/cpu/armv7/omap-common/boot-common.c | 2 +- arch/arm/cpu/armv7/omap3/board.c | 2 +- arch/arm/include/asm/omap_common.h | 2 +- arch/arm/lib/spl_mmc.c | 2 +- arch/arm/lib/spl_nand.c | 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/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 a3853ce..9ac0cc2 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); diff --git a/arch/arm/lib/spl_mmc.c b/arch/arm/lib/spl_mmc.c index 3ad382b..62b308b 100644 --- a/arch/arm/lib/spl_mmc.c +++ b/arch/arm/lib/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/lib/spl_nand.c b/arch/arm/lib/spl_nand.c index 8cf55c9..ea7cc8a 100644 --- a/arch/arm/lib/spl_nand.c +++ b/arch/arm/lib/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();

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 d4ce0af..dafe18b 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

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/omap3/board.c | 3 --- arch/arm/include/asm/omap_common.h | 1 - arch/arm/lib/spl_nand.c | 13 +++---------- 3 files changed, 3 insertions(+), 14 deletions(-)
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 9ac0cc2..1e8f59b 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; diff --git a/arch/arm/lib/spl_nand.c b/arch/arm/lib/spl_nand.c index ea7cc8a..39221d5 100644 --- a/arch/arm/lib/spl_nand.c +++ b/arch/arm/lib/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);

On 15/08/2012 23:30, Tom Rini wrote:
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/omap3/board.c | 3 --- arch/arm/include/asm/omap_common.h | 1 - arch/arm/lib/spl_nand.c | 13 +++---------- 3 files changed, 3 insertions(+), 14 deletions(-)
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;
default: puts("spl: ERROR: unknown device - can't select boot mode\n"); hang();break;
diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index 9ac0cc2..1e8f59b 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; diff --git a/arch/arm/lib/spl_nand.c b/arch/arm/lib/spl_nand.c index ea7cc8a..39221d5 100644 --- a/arch/arm/lib/spl_nand.c +++ b/arch/arm/lib/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();
This also does not work with other SOCs, where there is not a gpmc init. My idea was to add here a soc specific function, where gpmc_init and nand_init can be called.
Regards, Stefano

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/lib/spl.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c index 4d33f99..71a467e 100644 --- a/arch/arm/lib/spl.c +++ b/arch/arm/lib/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();

On 15/08/2012 23:30, Tom Rini wrote:
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/lib/spl.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c index 4d33f99..71a467e 100644 --- a/arch/arm/lib/spl.c +++ b/arch/arm/lib/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();
Agree, mem_malloc_init should be not always called. However, how are the dependencies with other SPL configuration ? I think (but I can be wrong) that we need it if CONFIG_SPL_LIBDISK_SUPPORT or CONFIG_SPL_FAT_SUPPORT are set. Should we add them to your #ifdef case ?
Regards, Stefano

On 08/16/2012 01:01 AM, Stefano Babic wrote:
On 15/08/2012 23:30, Tom Rini wrote:
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/lib/spl.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c index 4d33f99..71a467e 100644 --- a/arch/arm/lib/spl.c +++ b/arch/arm/lib/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();
Agree, mem_malloc_init should be not always called. However, how are the dependencies with other SPL configuration ? I think (but I can be wrong) that we need it if CONFIG_SPL_LIBDISK_SUPPORT or CONFIG_SPL_FAT_SUPPORT are set. Should we add them to your #ifdef case ?
I think until we have Kconfig-style dependencies available, there's going to be a certain amount of pain here. We should probably add to docs/README.SPL that SPL_FAT_SUPPORT depends on the malloc pool and the defines that calls for (since there's a few of them not referenced right were we call mem_malloc_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 --- arch/arm/cpu/armv7/am33xx/board.c | 2 +- arch/arm/cpu/armv7/omap-common/hwinit-common.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 ++++++++++++++++++++ arch/arm/lib/spl.c | 2 +- arch/arm/lib/spl_mmc.c | 1 + arch/arm/lib/spl_nand.c | 2 +- arch/arm/lib/spl_ymodem.c | 2 +- 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 71309a7..fadc6e7 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -25,7 +25,7 @@ #include <asm/arch/mmc_host_def.h> #include <asm/arch/common_def.h> #include <asm/io.h> -#include <asm/omap_common.h> +#include <asm/spl.h>
DECLARE_GLOBAL_DATA_PTR;
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/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..f25afe4 --- /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 0 +#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 1e8f59b..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 0 -#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..8aa4428 --- /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 diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c index 71a467e..81991b2 100644 --- a/arch/arm/lib/spl.c +++ b/arch/arm/lib/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/lib/spl_mmc.c b/arch/arm/lib/spl_mmc.c index 62b308b..fe44538 100644 --- a/arch/arm/lib/spl_mmc.c +++ b/arch/arm/lib/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/lib/spl_nand.c b/arch/arm/lib/spl_nand.c index 39221d5..6552a5d 100644 --- a/arch/arm/lib/spl_nand.c +++ b/arch/arm/lib/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/lib/spl_ymodem.c b/arch/arm/lib/spl_ymodem.c index 47663f7..65565e3 100644 --- a/arch/arm/lib/spl_ymodem.c +++ b/arch/arm/lib/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

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>
Signed-off-by: Tom Rini trini@ti.com --- arch/arm/cpu/armv7/omap-common/boot-common.c | 16 ++++++++++++++++ arch/arm/cpu/armv7/omap3/board.c | 15 +++++++++++++++ arch/arm/include/asm/omap_common.h | 5 ----- arch/arm/include/asm/spl.h | 5 +++++ arch/arm/lib/spl_mmc.c | 17 ----------------- 5 files changed, 36 insertions(+), 22 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/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 8aa4428..41036e9 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; diff --git a/arch/arm/lib/spl_mmc.c b/arch/arm/lib/spl_mmc.c index fe44538..5c65ba5 100644 --- a/arch/arm/lib/spl_mmc.c +++ b/arch/arm/lib/spl_mmc.c @@ -30,27 +30,10 @@ #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;

- 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/lib/spl.c | 23 ++++++++--------------- arch/arm/lib/spl_nand.c | 1 - 2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c index 81991b2..3a1029f 100644 --- a/arch/arm/lib/spl.c +++ b/arch/arm/lib/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/lib/spl_nand.c b/arch/arm/lib/spl_nand.c index 6552a5d..3e2f359 100644 --- a/arch/arm/lib/spl_nand.c +++ b/arch/arm/lib/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/include/asm/spl.h | 3 +++ arch/arm/lib/spl.c | 5 +++++ 2 files changed, 8 insertions(+)
diff --git a/arch/arm/include/asm/spl.h b/arch/arm/include/asm/spl.h index 41036e9..f0eb96f 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 diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c index 3a1029f..dc26750 100644 --- a/arch/arm/lib/spl.c +++ b/arch/arm/lib/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);

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/omap3/board.c | 3 +++ arch/arm/lib/spl_nand.c | 1 - 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/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/arch/arm/lib/spl_nand.c b/arch/arm/lib/spl_nand.c index 3e2f359..1e6b5f0 100644 --- a/arch/arm/lib/spl_nand.c +++ b/arch/arm/lib/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/include/configs/am3517_crane.h b/include/configs/am3517_crane.h index a5799d9..9f4c386 100644 --- a/include/configs/am3517_crane.h +++ b/include/configs/am3517_crane.h @@ -323,6 +323,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 #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 62da56e..8f2ac89 100644 --- a/include/configs/am3517_evm.h +++ b/include/configs/am3517_evm.h @@ -322,6 +322,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 #define CONFIG_SPL_MAX_SIZE (54 * 1024) /* 8 KB for stack */ diff --git a/include/configs/mcx.h b/include/configs/mcx.h index d91258a..4f29da6 100644 --- a/include/configs/mcx.h +++ b/include/configs/mcx.h @@ -310,6 +310,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/tam3517-common.h b/include/configs/tam3517-common.h index 8646d94..bb2cb7c 100644 --- a/include/configs/tam3517-common.h +++ b/include/configs/tam3517-common.h @@ -242,6 +242,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 #define CONFIG_SPL_NAND_SOFTECC

On 15/08/2012 23:30, Tom Rini wrote:
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/omap3/board.c | 3 +++ arch/arm/lib/spl_nand.c | 1 - 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
Ok, I was not so far when I commented the previous patch ;-)
Stefano

- 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 --- arch/arm/cpu/arm926ejs/davinci/spl.c | 45 +++++++------------------------ arch/arm/include/asm/arch-davinci/spl.h | 28 +++++++++++++++++++ include/configs/cam_enc_4xx.h | 2 ++ include/configs/da850evm.h | 2 ++ include/configs/hawkboard.h | 2 ++ 5 files changed, 44 insertions(+), 35 deletions(-) create mode 100644 arch/arm/include/asm/arch-davinci/spl.h
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c index 74632e5..833f721 100644 --- a/arch/arm/cpu/arm926ejs/davinci/spl.c +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c @@ -21,6 +21,7 @@ * MA 02111-1307 USA */ #include <common.h> +#include <asm/spl.h> #include <asm/u-boot.h> #include <asm/utils.h> #include <nand.h> @@ -29,14 +30,7 @@ #include <malloc.h> #include <spi_flash.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) { @@ -54,14 +48,7 @@ void putc(char c)
#endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
-inline void hang(void) -{ - puts("### ERROR ### Please RESET the board ###\n"); - for (;;) - ; -} - -void board_init_f(ulong dummy) +void spl_board_init(void) { #ifdef CONFIG_SOC_DM365 dm36x_lowlevel_init(0); @@ -69,28 +56,16 @@ void board_init_f(ulong dummy) #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) +u32 spl_boot_device(void) { #ifdef CONFIG_SPL_NAND_LOAD - nand_init(); - puts("Nand boot...\n"); - nand_boot(); -#endif -#ifdef CONFIG_SPL_SPI_LOAD - mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, - CONFIG_SYS_MALLOC_LEN); - - gd = &gdata; - gd->bd = &bdata; - gd->flags |= GD_FLG_RELOC; - gd->baudrate = CONFIG_BAUDRATE; - serial_init(); /* serial communications setup */ - gd->have_console = 1; - - puts("SPI boot...\n"); - spi_boot(); + return BOOT_DEVICE_NAND; +#elif defined(CONFIG_SPL_SPI_LOAD) + return BOOT_DEVICE_SPI; +#else + puts("Unknown boot device\n"); + hang(); #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..f9c5131 --- /dev/null +++ b/arch/arm/include/asm/arch-davinci/spl.h @@ -0,0 +1,28 @@ +/* + * (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 +#endif diff --git a/include/configs/cam_enc_4xx.h b/include/configs/cam_enc_4xx.h index 771ac9c..fe28278 100644 --- a/include/configs/cam_enc_4xx.h +++ b/include/configs/cam_enc_4xx.h @@ -217,6 +217,8 @@
/* 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 diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index e6adb1f..5bb5379 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -313,6 +313,8 @@
/* defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK +#define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_SPI_SUPPORT #define CONFIG_SPL_SPI_FLASH_SUPPORT #define CONFIG_SPL_SPI_LOAD diff --git a/include/configs/hawkboard.h b/include/configs/hawkboard.h index c6e9ce5..838e572 100644 --- a/include/configs/hawkboard.h +++ b/include/configs/hawkboard.h @@ -59,6 +59,8 @@
/* 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

Hi Tom, I tested the entire patchset with the da850evm booting from SPI flash with SPL (make da850evm_config && make u-boot.ais).
I had to add defines for mem_malloc_init to make it work, please see my comment below.
On Wed, Aug 15, 2012 at 11:30 PM, Tom Rini trini@ti.com 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
arch/arm/cpu/arm926ejs/davinci/spl.c | 45 +++++++------------------------ arch/arm/include/asm/arch-davinci/spl.h | 28 +++++++++++++++++++ include/configs/cam_enc_4xx.h | 2 ++ include/configs/da850evm.h | 2 ++ include/configs/hawkboard.h | 2 ++ 5 files changed, 44 insertions(+), 35 deletions(-) create mode 100644 arch/arm/include/asm/arch-davinci/spl.h
[...]
diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index e6adb1f..5bb5379 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -313,6 +313,8 @@
/* defines for SPL */ #define CONFIG_SPL +#define CONFIG_SPL_FRAMEWORK +#define CONFIG_SPL_BOARD_INIT #define CONFIG_SPL_SPI_SUPPORT #define CONFIG_SPL_SPI_FLASH_SUPPORT #define CONFIG_SPL_SPI_LOAD
Please add
#define CONFIG_SYS_SPL_MALLOC_START (CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN) #define CONFIG_SYS_SPL_MALLOC_SIZE CONFIG_SYS_MALLOC_LEN
here, booting from SPI requires malloc.
Apart from that it works great, I like it :-) Thank you!
Regards, Christian

Takes the load function from arch/arm/lib/spl_nand.c instead. This will allow for easier integration of SPL-boots-Linux code on other arches. Kill off CONFIG_SPL_NAND_LOAD as a separate option.
Signed-off-by: Tom Rini trini@ti.com --- arch/arm/cpu/arm926ejs/davinci/spl.c | 2 +- arch/arm/lib/Makefile | 1 - arch/arm/lib/spl_nand.c | 102 ---------------------------------- doc/README.SPL | 1 - drivers/mtd/nand/Makefile | 7 +-- drivers/mtd/nand/nand_spl_load.c | 89 +++++++++++++++++++++-------- include/configs/cam_enc_4xx.h | 1 - include/configs/hawkboard.h | 1 - 8 files changed, 67 insertions(+), 137 deletions(-) delete mode 100644 arch/arm/lib/spl_nand.c
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c index 833f721..f1a97cb 100644 --- a/arch/arm/cpu/arm926ejs/davinci/spl.c +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c @@ -60,7 +60,7 @@ void spl_board_init(void)
u32 spl_boot_device(void) { -#ifdef CONFIG_SPL_NAND_LOAD +#ifdef CONFIG_SPL_NAND_SIMPLE return BOOT_DEVICE_NAND; #elif defined(CONFIG_SPL_SPI_LOAD) return BOOT_DEVICE_SPI; diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index abf550a..d8e565f 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -29,7 +29,6 @@ LIBGCC = $(obj)libgcc.o ifdef CONFIG_SPL_BUILD ifdef CONFIG_SPL_FRAMEWORK COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o -COBJS-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o COBJS-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o endif diff --git a/arch/arm/lib/spl_nand.c b/arch/arm/lib/spl_nand.c deleted file mode 100644 index 1e6b5f0..0000000 --- a/arch/arm/lib/spl_nand.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2011 - * Corscience GmbH & Co. KG - Simon Schwarz schwarz@corscience.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. - * - * 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 <asm/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) -{ - struct image_header *header; - int *src __attribute__((unused)); - int *dst __attribute__((unused)); - - debug("spl: nand - using hw ecc\n"); - nand_init(); - - /*use CONFIG_SYS_TEXT_BASE as temporary storage area */ - header = (struct image_header *)(CONFIG_SYS_TEXT_BASE); -#ifdef CONFIG_SPL_OS_BOOT - if (!spl_start_uboot()) { - /* - * load parameter image - * load to temp position since nand_spl_load_image reads - * a whole block which is typically larger than - * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite - * following sections like BSS - */ - nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS, - CONFIG_CMD_SPL_WRITE_SIZE, - (void *)CONFIG_SYS_TEXT_BASE); - /* copy to destintion */ - for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR, - src = (int *)CONFIG_SYS_TEXT_BASE; - src < (int *)(CONFIG_SYS_TEXT_BASE + - CONFIG_CMD_SPL_WRITE_SIZE); - src++, dst++) { - writel(readl(src), dst); - } - - /* load linux */ - nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS, - CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); - spl_parse_image_header(header); - if (header->ih_os == IH_OS_LINUX) { - /* happy - was a linux */ - nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS, - spl_image.size, (void *)spl_image.load_addr); - nand_deselect(); - return; - } else { - printf("The Expected Linux image was not" - "found. Please check your NAND" - "configuration.\n"); - printf("Trying to start u-boot now...\n"); - } - } -#endif -#ifdef CONFIG_NAND_ENV_DST - nand_spl_load_image(CONFIG_ENV_OFFSET, - CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); - spl_parse_image_header(header); - nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size, - (void *)spl_image.load_addr); -#ifdef CONFIG_ENV_OFFSET_REDUND - nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, - CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); - spl_parse_image_header(header); - nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size, - (void *)spl_image.load_addr); -#endif -#endif - /* Load u-boot */ - nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, - CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); - spl_parse_image_header(header); - nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, - spl_image.size, (void *)spl_image.load_addr); - nand_deselect(); -} diff --git a/doc/README.SPL b/doc/README.SPL index e4a5ac3..3faf91c 100644 --- a/doc/README.SPL +++ b/doc/README.SPL @@ -64,7 +64,6 @@ CONFIG_SPL_POWER_SUPPORT (drivers/power/libpower.o) CONFIG_SPL_NAND_SUPPORT (drivers/mtd/nand/libnand.o) 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)
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index 29dc20e..5475c8c 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile @@ -27,12 +27,7 @@ LIB := $(obj)libnand.o
ifdef CONFIG_CMD_NAND ifdef CONFIG_SPL_BUILD -ifdef CONFIG_SPL_NAND_SIMPLE -COBJS-y += nand_spl_simple.o -endif -ifdef CONFIG_SPL_NAND_LOAD -COBJS-y += nand_spl_load.o -endif +COBJS-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o nand_spl_load.o else COBJS-y += nand.o COBJS-y += nand_bbt.o diff --git a/drivers/mtd/nand/nand_spl_load.c b/drivers/mtd/nand/nand_spl_load.c index 215459a..a829ab2 100644 --- a/drivers/mtd/nand/nand_spl_load.c +++ b/drivers/mtd/nand/nand_spl_load.c @@ -20,36 +20,77 @@
#include <common.h> #include <nand.h> +#include <asm/io.h> +#include <asm/spl.h>
-/* - * The main entry for NAND booting. It's necessary that SDRAM is already - * configured and available since this code loads the main U-Boot image - * from NAND into SDRAM and starts it from there. - */ -void nand_boot(void) +void spl_nand_load_image(void) { - __attribute__((noreturn)) void (*uboot)(void); + struct image_header *header; + int *src __attribute__((unused)); + int *dst __attribute__((unused));
- /* - * Load U-Boot image from NAND into RAM - */ - nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, - CONFIG_SYS_NAND_U_BOOT_SIZE, - (void *)CONFIG_SYS_NAND_U_BOOT_DST); + nand_init();
-#ifdef CONFIG_NAND_ENV_DST - nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, - (void *)CONFIG_NAND_ENV_DST); + /* use CONFIG_SYS_TEXT_BASE as temporary storage area */ + header = (struct image_header *)(CONFIG_SYS_TEXT_BASE); +#ifdef CONFIG_SPL_OS_BOOT + if (!spl_start_uboot()) { + /* + * load parameter image + * load to temp position since nand_spl_load_image reads + * a whole block which is typically larger than + * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite + * following sections like BSS + */ + nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS, + CONFIG_CMD_SPL_WRITE_SIZE, + (void *)CONFIG_SYS_TEXT_BASE); + /* copy to destintion */ + for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR, + src = (int *)CONFIG_SYS_TEXT_BASE; + src < (int *)(CONFIG_SYS_TEXT_BASE + + CONFIG_CMD_SPL_WRITE_SIZE); + src++, dst++) { + writel(readl(src), dst); + }
+ /* load linux */ + nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS, + CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); + spl_parse_image_header(header); + if (header->ih_os == IH_OS_LINUX) { + /* happy - was a linux */ + nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS, + spl_image.size, (void *)spl_image.load_addr); + nand_deselect(); + return; + } else { + puts("The Expected Linux image was not " + "found. Please check your NAND " + "configuration.\n"); + puts("Trying to start u-boot now...\n"); + } + } +#endif +#ifdef CONFIG_NAND_ENV_DST + nand_spl_load_image(CONFIG_ENV_OFFSET, + CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); + spl_parse_image_header(header); + nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size, + (void *)spl_image.load_addr); #ifdef CONFIG_ENV_OFFSET_REDUND - nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, CONFIG_ENV_SIZE, - (void *)CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE); + nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, + CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); + spl_parse_image_header(header); + nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size, + (void *)spl_image.load_addr); #endif #endif - - /* - * Jump to U-Boot image - */ - uboot = (void *)CONFIG_SYS_NAND_U_BOOT_START; - (*uboot)(); + /* Load u-boot */ + nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, + CONFIG_SYS_NAND_PAGE_SIZE, (void *)header); + spl_parse_image_header(header); + nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, + spl_image.size, (void *)spl_image.load_addr); + nand_deselect(); } diff --git a/include/configs/cam_enc_4xx.h b/include/configs/cam_enc_4xx.h index fe28278..34aac8c 100644 --- a/include/configs/cam_enc_4xx.h +++ b/include/configs/cam_enc_4xx.h @@ -222,7 +222,6 @@ #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/hawkboard.h b/include/configs/hawkboard.h index 838e572..5f2aa62 100644 --- a/include/configs/hawkboard.h +++ b/include/configs/hawkboard.h @@ -63,7 +63,6 @@ #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 08/15/2012 04:30 PM, Tom Rini wrote:
Takes the load function from arch/arm/lib/spl_nand.c instead. This will allow for easier integration of SPL-boots-Linux code on other arches. Kill off CONFIG_SPL_NAND_LOAD as a separate option.
I would have complained about the loss of a small CONFIG_SPL_NAND_LOAD, if I hadn't found that moving it into the equivalent of nand_spl_simple.c resulted in a smaller binary. :-P
-Scott

Signed-off-by: Tom Rini trini@ti.com --- arch/arm/include/asm/spl.h | 2 +- arch/arm/lib/spl.c | 4 ++-- drivers/mtd/spi/spi_spl_load.c | 23 ++++++++++++----------- 3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/arch/arm/include/asm/spl.h b/arch/arm/include/asm/spl.h index f0eb96f..6e60902 100644 --- a/arch/arm/include/asm/spl.h +++ b/arch/arm/include/asm/spl.h @@ -61,7 +61,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); diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c index dc26750..2532111 100644 --- a/arch/arm/lib/spl.c +++ b/arch/arm/lib/spl.c @@ -177,8 +177,8 @@ void board_init_r(gd_t *id, ulong dummy) #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..f439ca5 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 <asm/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); }

Hi Tom,
On 08/15/2012 11:30 PM, Tom Rini wrote:
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 #ifndef CONFIG_SPL_BUILD in random places.
Making SPL more generic is great. So moving these files out of the omap-common directory is the way to go. But your approach moves them to arch/arm/lib, restricting it only to ARM. Wouldn't it be possible to move it into an even more common location, so that other archs may also benefit from it?
I'm asking, since I'm currently working on an PowerPC based board which shall also use the SPL OS booting feature (Falcon boot).
Are the files ARM specific (I'm just starting looking into them right now)?
Thanks, Stefan

On 08/15/2012 11:30 PM, Stefan Roese wrote:
Hi Tom,
On 08/15/2012 11:30 PM, Tom Rini wrote:
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 #ifndef CONFIG_SPL_BUILD in random places.
Making SPL more generic is great. So moving these files out of the omap-common directory is the way to go. But your approach moves them to arch/arm/lib, restricting it only to ARM. Wouldn't it be possible to move it into an even more common location, so that other archs may also benefit from it?
I'm asking, since I'm currently working on an PowerPC based board which shall also use the SPL OS booting feature (Falcon boot).
Are the files ARM specific (I'm just starting looking into them right now)?
In theory, these should be fine on other arches. I'm just hesitant to call these common and put them in common/ without someone else doing the work of making sure they really are usable elsewhere. Sounds like about now would be the time to try, so for v2 I can move them to common/spl.c common/spl_ymodem.c and drivers/mmc/spl_mmc.c (to match drivers/mtd/nand/nand_spl* and drivers/mtd/spi/spi_spl*).

On 08/16/2012 04:30 PM, Tom Rini wrote:
I'm asking, since I'm currently working on an PowerPC based board which shall also use the SPL OS booting feature (Falcon boot).
Are the files ARM specific (I'm just starting looking into them right now)?
In theory, these should be fine on other arches. I'm just hesitant to call these common and put them in common/ without someone else doing the work of making sure they really are usable elsewhere. Sounds like about now would be the time to try, so for v2 I can move them to common/spl.c common/spl_ymodem.c and drivers/mmc/spl_mmc.c (to match drivers/mtd/nand/nand_spl* and drivers/mtd/spi/spi_spl*).
Yes, please do. I'll work on the powerpc integration of this SPL stuff then.
Thanks, Stefan

On 15/08/2012 23:30, Tom Rini wrote:
Hey all,
Hi Tom,
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 #ifndef CONFIG_SPL_BUILD in random places.
Oh, I was working on the same concept to make SPL available for other SOCs. I can get through your patches, we get surely the same conflict between architecture.
Stefano
participants (5)
-
Christian Riesch
-
Scott Wood
-
Stefan Roese
-
Stefano Babic
-
Tom Rini