This adds Linux booting to the SPL

Related CONFIGs:
CONFIG_SPL_OS_BOOT
        Activates/Deactivates the OS booting feature
CONFIG_SPL_OS_BOOT_KEY
        defines the IO-pin number u-boot switch - if pressed u-boot is booted
CONFIG_SYS_SPL_MACHID
        Machine ID of the used board
CONFIG_SYS_NAND_SPL_KERNEL_OFFS
        Offset in NAND of direct boot kernel image to use in SPL
CONFIG_SYS_SPL_ARGS_ADDR
        Address where the kernel boot arguments are expected - this is normaly
        RAM-begin + 0x100

Signed-off-by: Simon Schwarz <simonschwarz...@gmail.com>
---

V2 changes:
nothing
---
 arch/arm/cpu/armv7/omap-common/spl.c |   48 ++++++++++++++++++++++++++++++++-
 include/configs/devkit8000.h         |    7 +++-
 2 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap-common/spl.c 
b/arch/arm/cpu/armv7/omap-common/spl.c
index c76fea6..9c22c7a 100644
--- a/arch/arm/cpu/armv7/omap-common/spl.c
+++ b/arch/arm/cpu/armv7/omap-common/spl.c
@@ -35,6 +35,7 @@
 #include <asm/arch/mmc_host_def.h>
 #include <i2c.h>
 #include <image.h>
+#include <asm/omap_gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -63,6 +64,25 @@ void board_init_f(ulong dummy)
        relocate_code(CONFIG_SPL_STACK, &gdata, CONFIG_SPL_TEXT_BASE);
 }
 
+#ifdef CONFIG_SPL_OS_BOOT
+/* Return the value of the U-boot key
+ *
+ * RETURN
+ * 0 if not pressed
+ * positiv if pressed
+ */
+int spl_uboot_key(void)
+{
+       int val = 0;
+       if (!omap_request_gpio(CONFIG_SPL_OS_BOOT_KEY)) {
+               omap_set_gpio_direction(CONFIG_SPL_OS_BOOT_KEY, 1);
+               val = omap_get_gpio_datain(CONFIG_SPL_OS_BOOT_KEY);
+               omap_free_gpio(CONFIG_SPL_OS_BOOT_KEY);
+       }
+       return !val;
+}
+#endif  /* CONFIG_SPL_OS_BOOT */
+
 void spl_parse_image_header(const struct image_header *header)
 {
        u32 header_size = sizeof(struct image_header);
@@ -90,7 +110,25 @@ void spl_parse_image_header(const struct image_header 
*header)
        }
 }
 
-static void jump_to_image_no_args(void)
+#ifdef CONFIG_SPL_OS_BOOT
+/* This function jumps to an image with argument. Normally an FDT or ATAGS
+ * image.
+ * arg: Pointer to paramter image in RAM
+ */
+void jump_to_image_linux(void *arg)
+{
+       debug("Entering kernel arg pointer: 0x%X\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(); */ /*write SPL function for that*/
+       image_entry(0, CONFIG_SYS_SPL_MACHID, arg);
+}
+void jump_to_image_linux(void *) __attribute__ ((noreturn));
+#endif
+
+void jump_to_image_no_args(void)
 {
        typedef void (*image_entry_noargs_t)(void)__attribute__ ((noreturn));
        image_entry_noargs_t image_entry =
@@ -99,8 +137,8 @@ static void jump_to_image_no_args(void)
        debug("image entry point: 0x%X\n", spl_image.entry_point);
        image_entry();
 }
-
 void jump_to_image_no_args(void) __attribute__ ((noreturn));
+
 void board_init_r(gd_t *id, ulong dummy)
 {
        u32 boot_device;
@@ -134,6 +172,12 @@ void board_init_r(gd_t *id, ulong dummy)
                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");
+               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();
diff --git a/include/configs/devkit8000.h b/include/configs/devkit8000.h
index 4d0573c..3897ab4 100644
--- a/include/configs/devkit8000.h
+++ b/include/configs/devkit8000.h
@@ -38,7 +38,7 @@
 #define CONFIG_OMAP3430                1       /* which is in a 3430 */
 #define CONFIG_OMAP3_DEVKIT8000        1       /* working with DevKit8000 */
 
-#define        CONFIG_SYS_TEXT_BASE    0x80008000
+#define        CONFIG_SYS_TEXT_BASE    0x80100000
 
 #define CONFIG_SDRC    /* The chip has SDRC controller */
 
@@ -328,7 +328,7 @@
 #define CONFIG_SPL_MAX_SIZE            0xB400  /* 45 K */
 #define CONFIG_SPL_STACK               LOW_LEVEL_SRAM_STACK
 
-#define CONFIG_SPL_BSS_START_ADDR      0x80000000 /*CONFIG_SYS_SDRAM_BASE*/
+#define CONFIG_SPL_BSS_START_ADDR      0x80000500 /* leave space for bootargs*/
 #define CONFIG_SPL_BSS_MAX_SIZE                0x80000
 
 /* NAND boot config */
@@ -358,6 +358,9 @@
 #define CONFIG_CMD_SAVEBP_WRITE_SIZE   0x400 /* 1024 byte */
 #define CONFIG_CMD_SAVEBP_NAND_OFS     (CONFIG_SYS_NAND_SPL_KERNEL_OFFS+\
                                                0x400000)
+#define CONFIG_SPL_OS_BOOT
+#define CONFIG_SPL_OS_BOOT_KEY 26
+#define CONFIG_SYS_SPL_MACHID  MACH_TYPE_DEVKIT8000
 #define CONFIG_SYS_NAND_SPL_KERNEL_OFFS        0x280000
 #define CONFIG_SYS_SPL_ARGS_ADDR       (PHYS_SDRAM_1 + 0x100)
 #endif /* __CONFIG_H */
-- 
1.7.4.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to