diff mbox

[U-Boot,V9,4/4] omap-common/spl: Add linux boot to SPL

Message ID 1323196478-14254-5-git-send-email-simonschwarzcor@gmail.com
State Superseded, archived
Delegated to: Tom Rini
Headers show

Commit Message

Simon Schwarz Dec. 6, 2011, 6:34 p.m. UTC
From: Simon Schwarz <simonschwarzcor@googlemail.com>

This adds Linux booting to the SPL

This depends on CONFIG_MACH_TYPE patch by Igor Grinberg
(http://article.gmane.org/gmane.comp.boot-loaders.u-boot/105809)

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_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 <simonschwarzcor@gmail.com>
---
V2 changes:
nothing

V3 changes:
nothing

V4 changes:
CHG Using CONFIG_MACH_TYPE now.
DEL CONFIG_SYS_SPL_MACHID
CHG Use CONFIG_MACH_TYPE for machine id config - This makes the patch
	depending on the patch linked above

V5 changes:
FIX compile errors for OMAP4
REBASE u-boot-ti adapted new general gpio interface

V6 changes:
nothing

V7 changes:
FIX multiline comment style
	(http://article.gmane.org/gmane.comp.boot-loaders.u-boot/113501)

V8 changes:
REBASE on u-boot
---
 arch/arm/cpu/armv7/omap-common/spl.c |   51 ++++++++++++++++++++++++++++++++-
 include/configs/devkit8000.h         |    6 +++-
 2 files changed, 54 insertions(+), 3 deletions(-)

Comments

Mike Frysinger Dec. 8, 2011, 12:50 a.m. UTC | #1
On Tuesday 06 December 2011 13:34:38 Simon Schwarz wrote:
> --- a/arch/arm/cpu/armv7/omap-common/spl.c
> +++ b/arch/arm/cpu/armv7/omap-common/spl.c
>
> +void jump_to_image_linux(void *arg)
> +{
> ...
> +}
> +void jump_to_image_linux(void *) __attribute__ ((noreturn));

no need for this.  do it in one line:
__noreturn void jump_to_image_linux(void *arg)
{
	...
}

(include linux/compiler.h if need be)
-mike
Tom Rini Dec. 8, 2011, 1:09 a.m. UTC | #2
On Wed, Dec 7, 2011 at 5:50 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Tuesday 06 December 2011 13:34:38 Simon Schwarz wrote:
>> --- a/arch/arm/cpu/armv7/omap-common/spl.c
>> +++ b/arch/arm/cpu/armv7/omap-common/spl.c
>>
>> +void jump_to_image_linux(void *arg)
>> +{
>> ...
>> +}
>> +void jump_to_image_linux(void *) __attribute__ ((noreturn));
>
> no need for this.  do it in one line:
> __noreturn void jump_to_image_linux(void *arg)
> {
>        ...
> }
>
> (include linux/compiler.h if need be)

Style?  I prefer the single line version myself but I've seen lots of
the long form when poking around before.
Mike Frysinger Dec. 8, 2011, 5:39 a.m. UTC | #3
On Wednesday 07 December 2011 20:09:13 Tom Rini wrote:
> On Wed, Dec 7, 2011 at 5:50 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> > On Tuesday 06 December 2011 13:34:38 Simon Schwarz wrote:
> >> --- a/arch/arm/cpu/armv7/omap-common/spl.c
> >> +++ b/arch/arm/cpu/armv7/omap-common/spl.c
> >> 
> >> +void jump_to_image_linux(void *arg)
> >> +{
> >> ...
> >> +}
> >> +void jump_to_image_linux(void *) __attribute__ ((noreturn));
> > 
> > no need for this.  do it in one line:
> > __noreturn void jump_to_image_linux(void *arg)
> > {
> >        ...
> > }
> > 
> > (include linux/compiler.h if need be)
> 
> Style?  I prefer the single line version myself but I've seen lots of
> the long form when poking around before.

i think it's a matter of people not knowing the subtle behavior of gcc 
attributes and func prototypes vs func definitions.

i.e. they're used to seeing:
void foo(void) __attribute__((...));

so they try doing:
void foo(void) __attribute__((...))
{
}

which fails to build, so they get confused and just copy & paste the line 
twice since that works.  that's my biggest problem with this -- the manual 
duplication of the func signature.

what they don't realize is you can do w/out duplication:
void __attribute__((...)) foo(void)
{
}
-mike
Tom Rini Dec. 8, 2011, 6 a.m. UTC | #4
On Wednesday, December 7, 2011, Mike Frysinger <vapier@gentoo.org> wrote:
> On Wednesday 07 December 2011 20:09:13 Tom Rini wrote:
>> On Wed, Dec 7, 2011 at 5:50 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>> > On Tuesday 06 December 2011 13:34:38 Simon Schwarz wrote:
>> >> --- a/arch/arm/cpu/armv7/omap-common/spl.c
>> >> +++ b/arch/arm/cpu/armv7/omap-common/spl.c
>> >>
>> >> +void jump_to_image_linux(void *arg)
>> >> +{
>> >> ...
>> >> +}
>> >> +void jump_to_image_linux(void *) __attribute__ ((noreturn));
>> >
>> > no need for this.  do it in one line:
>> > __noreturn void jump_to_image_linux(void *arg)
>> > {
>> >        ...
>> > }
>> >
>> > (include linux/compiler.h if need be)
>>
>> Style?  I prefer the single line version myself but I've seen lots of
>> the long form when poking around before.
>
> i think it's a matter of people not knowing the subtle behavior of gcc
> attributes and func prototypes vs func definitions.
>
> i.e. they're used to seeing:
> void foo(void) __attribute__((...));
>
> so they try doing:
> void foo(void) __attribute__((...))
> {
> }
>
> which fails to build, so they get confused and just copy & paste the line
> twice since that works.  that's my biggest problem with this -- the manual
> duplication of the func signature.
>
> what they don't realize is you can do w/out duplication:
> void __attribute__((...)) foo(void)
> {
> }

Quite possible.  Wolfgang, is there a style thing here or would you like to
see all of the long form versions converted to the short form and use
<linux/compiler.h>?  If so I'll make a note on my todo list...  Thanks!
Wolfgang Denk Dec. 8, 2011, 7:11 a.m. UTC | #5
Dear Tom Rini,

In message <CA+M6bXn-YQyYWcp++xN8Nyu283wfW2kOgiEQ8P08pbHsg7sM7w@mail.gmail.com> you wrote:
>
> > what they don't realize is you can do w/out duplication:
> > void __attribute__((...)) foo(void)
> > {
> > }
> 
> Quite possible.  Wolfgang, is there a style thing here or would you like to
> see all of the long form versions converted to the short form and use
> <linux/compiler.h>?  If so I'll make a note on my todo list...  Thanks!

It would be nice to see this converted to using the short form.

Thanks in advance.

> Content-Type: text/html; charset=ISO-8859-1
> Content-Transfer-Encoding: quoted-printable
> 
> On Wednesday, December 7, 2011, Mike Frysinger &lt;<a href=3D"mailto:vapier=
> @gentoo.org">vapier@gentoo.org</a>&gt; wrote:<br>&gt; On Wednesday 07 Decem=
> ber 2011 20:09:13 Tom Rini wrote:<br>&gt;&gt; On Wed, Dec 7, 2011 at 5:50 P=
> M, Mike Frysinger &lt;<a href=3D"mailto:vapier@gentoo.org">vapier@gentoo.or=
> g</a>&gt; wrote:<br>
...

Um... please don't.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c
index d6d7d65..a739ba7 100644
--- a/arch/arm/cpu/armv7/omap-common/spl.c
+++ b/arch/arm/cpu/armv7/omap-common/spl.c
@@ -35,6 +35,7 @@ 
 #include <i2c.h>
 #include <image.h>
 #include <malloc.h>
+#include <asm/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -64,6 +65,26 @@  void board_init_f(ulong dummy)
 	relocate_code(CONFIG_SPL_STACK, &gdata, CONFIG_SPL_TEXT_BASE);
 }
 
+/*
+ * Return the value of the U-boot key
+ *
+ * RETURN
+ * 0 if not pressed
+ * positiv if pressed
+ */
+#ifdef CONFIG_SPL_OS_BOOT
+int spl_uboot_key(void)
+{
+	int val = 0;
+	if (!gpio_request(CONFIG_SPL_OS_BOOT_KEY, "U-Boot key")) {
+		gpio_direction_input(CONFIG_SPL_OS_BOOT_KEY);
+		val = gpio_get_value(CONFIG_SPL_OS_BOOT_KEY);
+		gpio_free(CONFIG_SPL_OS_BOOT_KEY);
+	}
+	return !val;
+}
+#endif
+
 void spl_parse_image_header(const struct image_header *header)
 {
 	u32 header_size = sizeof(struct image_header);
@@ -91,7 +112,26 @@  void spl_parse_image_header(const struct image_header *header)
 	}
 }
 
-static void jump_to_image_no_args(void)
+/*
+ * This function jumps to an image with argument. Normally an FDT or ATAGS
+ * image.
+ * arg: Pointer to paramter image in RAM
+ */
+#ifdef CONFIG_SPL_OS_BOOT
+void 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_MACH_TYPE, arg);
+}
+void jump_to_image_linux(void *) __attribute__ ((noreturn));
+#endif
+
+void jump_to_image_no_args(void)
 {
 	typedef void (*image_entry_noargs_t)(u32 *)__attribute__ ((noreturn));
 	image_entry_noargs_t image_entry =
@@ -104,8 +144,8 @@  static void jump_to_image_no_args(void)
 #endif
 	image_entry((u32 *)&boot_params_ptr);
 }
-
 void jump_to_image_no_args(void) __attribute__ ((noreturn));
+
 void board_init_r(gd_t *id, ulong dummy)
 {
 	u32 boot_device;
@@ -142,6 +182,13 @@  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");
+		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();
diff --git a/include/configs/devkit8000.h b/include/configs/devkit8000.h
index bb7509b..668253f 100644
--- a/include/configs/devkit8000.h
+++ b/include/configs/devkit8000.h
@@ -36,6 +36,7 @@ 
 #define CONFIG_OMAP34XX		1	/* which is a 34XX */
 #define CONFIG_OMAP3430		1	/* which is in a 3430 */
 #define CONFIG_OMAP3_DEVKIT8000	1	/* working with DevKit8000 */
+#define CONFIG_MACH_TYPE		MACH_TYPE_DEVKIT8000
 
 /*
  * 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM
@@ -339,7 +340,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 */
@@ -373,6 +374,9 @@ 
 #define CONFIG_CMD_SPL_WRITE_SIZE	0x400 /* 1024 byte */
 #define CONFIG_CMD_SPL_NAND_OFS	(CONFIG_SYS_NAND_SPL_KERNEL_OFFS+\
 						0x400000)
+#define CONFIG_SPL_OS_BOOT
+#define CONFIG_SPL_OS_BOOT_KEY	26
+
 #define CONFIG_SYS_NAND_SPL_KERNEL_OFFS	0x280000
 #define CONFIG_SYS_SPL_ARGS_ADDR	(PHYS_SDRAM_1 + 0x100)
 #endif /* __CONFIG_H */