[U-Boot-Users] Set of patches for FDT support

[RESEND] My first email didn't get sent to the list
Matt, Jon, Kumar,
Here are some changes for u-boot fdt support. Please take a look and make sure I've taken the right approach. Once you guys are happy I'll ask Wolfgang to pull them into his tree
Thanks, g.

GIT: Please enter your email below. GIT: Lines beginning in "GIT: " will be removed. GIT: Consider including an overall diffstat or table of contents GIT: for the patch you are writing.
[RESEND] My first email didn't get sent to the list
Matt, Jon, Kumar,
Here are some changes for u-boot fdt support. Please take a look and make sure I've taken the right approach. Once you guys are happy I'll ask Wolfgang to pull them into his tree
Thanks, g.

[RESEND] My first email didn't get sent to the list
Matt, Jon, Kumar,
Here are some changes for u-boot fdt support. Please take a look and make sure I've taken the right approach. Once you guys are happy I'll ask Wolfgang to pull them into his tree
Thanks, g.

Note: I've added this command to ft_build.c instead of a seperate cmd_*.c because it is such a small amount of code.
Signed-off-by: Grant Likely grant.likely@secretlab.ca --- common/ft_build.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/common/ft_build.c b/common/ft_build.c index 980e40f..9a36187 100644 --- a/common/ft_build.c +++ b/common/ft_build.c @@ -20,6 +20,7 @@ */
#include <common.h> +#include <command.h> #include <malloc.h> #include <environment.h>
@@ -588,4 +589,26 @@ #ifdef DEBUG ft_dump_blob(blob); #endif } + +int do_ftinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + void* addr; + if (argc < 2) { + printf ("Usage:\n%s\n", cmdtp->usage); + return 1; + } + + addr = (void*)simple_strtoul(argv[1], NULL, 16); + printf("Printing device tree at 0x%x\n", addr); + ft_dump_blob(addr); + return 0; +} + +/* -------------------------------------------------------------------- */ + +U_BOOT_CMD( + ftinfo, 2, 2, do_ftinfo, "ftinfo - print a flattened device tree\n", + "ftinfo addr\n" + " - print device tree at address 'addr'\n" +); #endif

This patch allows an arch/ppc kernel to be booted by just passing 1 or 2 arguments to bootm. It removes the getenv("disable_of") test that used to be used for this purpose.
Signed-off-by: Grant Likely grant.likely@secretlab.ca --- common/cmd_bootm.c | 54 +++++++++++++++++++++------------------------------ 1 files changed, 22 insertions(+), 32 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 3091a58..7aae8a6 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -833,10 +833,6 @@ #endif printf ("ERROR: flat device tree size does not agree with image\n"); return; } - - } else if (getenv("disable_of") == NULL) { - printf ("ERROR: bootm needs flat device tree as third argument\n"); - return; } #endif if (!data) { @@ -913,23 +909,11 @@ #endif /* CONFIG_HW_WATCHDOG || CONFIG_W
SHOW_BOOT_PROGRESS (15);
-#ifndef CONFIG_OF_FLAT_TREE - #if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) unlock_ram_in_cache(); #endif
- /* - * Linux Kernel Parameters: - * r3: ptr to board info data - * r4: initrd_start or 0 if no initrd - * r5: initrd_end - unused if r4 is 0 - * r6: Start of command line string - * r7: End of command line string - */ - (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); - -#else /* CONFIG_OF_FLAT_TREE */ +#ifdef CONFIG_OF_FLAT_TREE /* move of_flat_tree if needed */ if (of_data) { ulong of_start, of_len; @@ -948,30 +932,36 @@ #else /* CONFIG_OF_FLAT_TREE */ of_start, of_start + of_len - 1); memmove ((void *)of_start, (void *)of_data, of_len); } +#endif
- ft_setup(of_flat_tree, kbd, initrd_start, initrd_end); - /* ft_dump_blob(of_flat_tree); */ - -#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) - unlock_ram_in_cache(); + /* + * Linux Kernel Parameters (passing board info data): + * r3: ptr to board info data + * r4: initrd_start or 0 if no initrd + * r5: initrd_end - unused if r4 is 0 + * r6: Start of command line string + * r7: End of command line string + */ +#ifdef CONFIG_OF_FLAT_TREE + if (!of_flat_tree) /* no device tree; boot old style */ #endif + (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); + /* does not return */ + +#ifdef CONFIG_OF_FLAT_TREE /* - * Linux Kernel Parameters: + * Linux Kernel Parameters (passing device tree): * r3: ptr to OF flat tree, followed by the board info data * r4: physical pointer to the kernel itself * r5: NULL * r6: NULL * r7: NULL */ - if (getenv("disable_of") != NULL) - (*kernel) ((bd_t *)of_flat_tree, initrd_start, initrd_end, - cmd_start, cmd_end); - else { - ft_setup(of_flat_tree, kbd, initrd_start, initrd_end); - /* ft_dump_blob(of_flat_tree); */ - (*kernel) ((bd_t *)of_flat_tree, (ulong)kernel, 0, 0, 0); - } -#endif /* CONFIG_OF_FLAT_TREE */ + ft_setup(of_flat_tree, kbd, initrd_start, initrd_end); + /* ft_dump_blob(of_flat_tree); */ + + (*kernel) ((bd_t *)of_flat_tree, (ulong)kernel, 0, 0, 0); +#endif } #endif /* CONFIG_PPC */

This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.
Signed-off-by: Grant Likely grant.likely@gmail.com --- board/icecube/icecube.c | 12 ++++++++++++ cpu/mpc5xxx/cpu.c | 28 ++++++++++++++++++++++++++++ include/configs/IceCube.h | 13 +++++++++++++ 3 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/board/icecube/icecube.c b/board/icecube/icecube.c index 4f056b2..9b222da 100644 --- a/board/icecube/icecube.c +++ b/board/icecube/icecube.c @@ -29,6 +29,10 @@ #include <mpc5xxx.h> #include <pci.h> #include <asm/processor.h>
+#if defined(CONFIG_OF_FLAT_TREE) +#include <ft_build.h> +#endif + #if defined(CONFIG_LITE5200B) #include "mt46v32m16.h" #else @@ -334,3 +338,11 @@ void ide_set_reset (int idereset) } } #endif /* defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET) */ + +#if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) +void +ft_board_setup(void *blob, bd_t *bd) +{ + ft_cpu_setup(blob, bd); +} +#endif diff --git a/cpu/mpc5xxx/cpu.c b/cpu/mpc5xxx/cpu.c index 6b6f828..20e6735 100644 --- a/cpu/mpc5xxx/cpu.c +++ b/cpu/mpc5xxx/cpu.c @@ -31,6 +31,10 @@ #include <command.h> #include <mpc5xxx.h> #include <asm/processor.h>
+#if defined(CONFIG_OF_FLAT_TREE) +#include <ft_build.h> +#endif + DECLARE_GLOBAL_DATA_PTR;
int checkcpu (void) @@ -102,3 +106,27 @@ unsigned long get_tbclk (void) }
/* ------------------------------------------------------------------------- */ + +#ifdef CONFIG_OF_FLAT_TREE +void +ft_cpu_setup(void *blob, bd_t *bd) +{ + u32 *p; + ulong clock; + int len; + + clock = bd->bi_busfreq; + p = ft_get_prop(blob, "/cpus/" OF_CPU "/bus-frequency", &len); + if (p != NULL) + *p = cpu_to_be32(clock); + + p = ft_get_prop(blob, "/" OF_SOC "/bus-frequency", &len); + if (p != NULL) + *p = cpu_to_be32(clock); + + p = ft_get_prop(blob, "/" OF_SOC "/ethernet@3000/mac-address", &len); + if (p != NULL) + memcpy(p, bd->bi_enetaddr, 6); + +} +#endif diff --git a/include/configs/IceCube.h b/include/configs/IceCube.h index 1152f83..0d38254 100644 --- a/include/configs/IceCube.h +++ b/include/configs/IceCube.h @@ -172,6 +172,19 @@ #else #undef CFG_IPBSPEED_133 /* define for 133MHz speed */ #endif #endif /* CONFIG_MPC5200 */ + +/* pass open firmware flat tree */ +#define CONFIG_OF_FLAT_TREE 1 +#define CONFIG_OF_BOARD_SETUP 1 + +/* maximum size of the flat tree (8K) */ +#define OF_FLAT_TREE_MAX_SIZE 8192 + +#define OF_CPU "PowerPC,5200@0" +#define OF_SOC "soc5200@f0000000" +#define OF_TBCLK (bd->bi_busfreq / 8) +#define OF_STDOUT_PATH "/soc5200@f0000000/serial@2000" + /* * I2C configuration */

In message 11621624513123-git-send-email-grant.likely@secretlab.ca you wrote:
This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.
...
--- a/board/icecube/icecube.c +++ b/board/icecube/icecube.c
...
@@ -334,3 +338,11 @@ void ide_set_reset (int idereset) } } #endif /* defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET) */
+#if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) +void +ft_board_setup(void *blob, bd_t *bd) +{
- ft_cpu_setup(blob, bd);
+} +#endif
How much of this is really board dependent? How likely is it, then all other 5200 boards will just copy & paste these few lines of code? Maybe we can make this common code, and just allow for board-specific overwrites when really needed?
Best regards,
Wolfgang Denk

On 10/29/06, Wolfgang Denk wd@denx.de wrote:
In message 11621624513123-git-send-email-grant.likely@secretlab.ca you wrote:
This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.
...
--- a/board/icecube/icecube.c +++ b/board/icecube/icecube.c
...
@@ -334,3 +338,11 @@ void ide_set_reset (int idereset) } } #endif /* defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET) */
+#if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) +void +ft_board_setup(void *blob, bd_t *bd) +{
ft_cpu_setup(blob, bd);
+} +#endif
How much of this is really board dependent? How likely is it, then all other 5200 boards will just copy & paste these few lines of code? Maybe we can make this common code, and just allow for board-specific overwrites when really needed?
Oh, probably. :)
In this case I was following the convention already established w/ the other boards. I can take another look and see about making a recommendation for cleaning up this construct.
Cheers, g.
Best regards,
Wolfgang Denk
-- Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de "The bad reputation UNIX has gotten is totally undeserved, laid on by people who don't understand, who have not gotten in there and tried anything." -- Jim Joyce, owner of Jim Joyce's UNIX Bookstore

On 10/29/06, Grant Likely grant.likely@secretlab.ca wrote:
On 10/29/06, Wolfgang Denk wd@denx.de wrote:
In message 11621624513123-git-send-email-grant.likely@secretlab.ca you wrote:
This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.
...
--- a/board/icecube/icecube.c +++ b/board/icecube/icecube.c
...
@@ -334,3 +338,11 @@ void ide_set_reset (int idereset) } } #endif /* defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET) */
+#if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) +void +ft_board_setup(void *blob, bd_t *bd) +{
ft_cpu_setup(blob, bd);
+} +#endif
How much of this is really board dependent? How likely is it, then all other 5200 boards will just copy & paste these few lines of code? Maybe we can make this common code, and just allow for board-specific overwrites when really needed?
Oh, probably. :)
In this case I was following the convention already established w/ the other boards. I can take another look and see about making a recommendation for cleaning up this construct.
Wolfgang,
I'd like to defer this change to another patch. This convention is used by all boards that support OF booting, so it should all be changed at once. Plus there is still discussion about what the correct layout should be between ft_setup, ft_cpu_setup and ft_board_setup calls.
Is that okay by you?
Cheers, g.

On Sun, 2006-10-29 at 16:54, Grant Likely wrote:
This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.
Signed-off-by: Grant Likely grant.likely@gmail.com
Acked-by: Jon Loeliger jdl@freescale.com

On Sunday 29 October 2006 23:54, Grant Likely wrote:
This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.
Applied. Thanks.
Best regards, Stefan

On 11/29/06, Stefan Roese sr@denx.de wrote:
On Sunday 29 October 2006 23:54, Grant Likely wrote:
This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.
Applied. Thanks.
Cool, thanks!
g.

Dear Grant,
in message 1162162451757-git-send-email-grant.likely@secretlab.ca you wrote:
...
- ft_setup(of_flat_tree, kbd, initrd_start, initrd_end);
- /* ft_dump_blob(of_flat_tree); */
-#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500)
- unlock_ram_in_cache();
Are you sure you want to remove this unlock_ram_in_cache() ?
Why?
Best regards,
Wolfgang Denk

On 10/29/06, Wolfgang Denk wd@denx.de wrote:
Dear Grant,
in message 1162162451757-git-send-email-grant.likely@secretlab.ca you wrote:
...
ft_setup(of_flat_tree, kbd, initrd_start, initrd_end);
/* ft_dump_blob(of_flat_tree); */
-#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500)
unlock_ram_in_cache();
Are you sure you want to remove this unlock_ram_in_cache() ?
Why?
It's not actually removed. Rather it's no longer duplicated in two halves of a #if/#else/#endif block.
g.
Best regards,
Wolfgang Denk
-- Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de Real programmers can write assembly code in any language. :-) - Larry Wall in 8571@jpl-devvax.JPL.NASA.GOV

This patch allows an arch/ppc kernel to be booted by just passing 1 or 2 arguments to bootm. It removes the getenv("disable_of") test that used to be used for this purpose.
Signed-off-by: Grant Likely <grant.likely <at> secretlab.ca> ---
Acked-by: Jon Loeliger jdl@freescale.com

On Sunday 29 October 2006 23:54, Grant Likely wrote:
This patch allows an arch/ppc kernel to be booted by just passing 1 or 2 arguments to bootm. It removes the getenv("disable_of") test that used to be used for this purpose.
Applied. Thanks.
Best regards, Stefan

On 11/28/06, Stefan Roese sr@denx.de wrote:
On Sunday 29 October 2006 23:54, Grant Likely wrote:
This patch allows an arch/ppc kernel to be booted by just passing 1 or 2 arguments to bootm. It removes the getenv("disable_of") test that used to be used for this purpose.
Applied. Thanks.
Brilliant, thank you. Are you able to apply the lite5200 fdt support patch also (it was sent at the same time)?
http://news.gmane.org/find-root.php?message_id=%3c11621624513123%2dgit%2dsen...
Thanks, g.

On Tue, 2006-11-28 at 08:37, Grant Likely wrote:
On 11/28/06, Stefan Roese sr@denx.de wrote:
Applied. Thanks.
Brilliant, thank you.
Indeed, thanks, Stefan.
Are you able to apply the lite5200 fdt support patch also (it was sent at the same time)?
http://news.gmane.org/find-root.php?message_id=%3c11621624513123%2dgit%2dsen...
And that would be the other patch I also ACK-ed.
jdl

On Tuesday 28 November 2006 17:13, Jon Loeliger wrote:
On Tue, 2006-11-28 at 08:37, Grant Likely wrote:
On 11/28/06, Stefan Roese sr@denx.de wrote:
Applied. Thanks.
Brilliant, thank you.
Indeed, thanks, Stefan.
You're welcome. :-)
Are you able to apply the lite5200 fdt support patch also (it was sent at the same time)?
http://news.gmane.org/find-root.php?message_id=%3c11621624513123%2dgit%2d send%2demail%2dgrant.likely%40secretlab.ca%3e
And that would be the other patch I also ACK-ed.
Hold your horses. Will do my best... ;-)
Best regards, Stefan

On Sun, 2006-10-29 at 15:54 -0700, Grant Likely wrote:
Note: I've added this command to ft_build.c instead of a seperate cmd_*.c because it is such a small amount of code.
Signed-off-by: Grant Likely grant.likely@secretlab.ca
Jerry Van Barren has a similar, yet slightly more robust "of" command implementation floating around that might be worth looking into.
http://www.cideas.us/cgi-bin/gitweb.cgi?p=u-boot/u-boot-pq2fads.git;a=summar...
-Matthew

On 10/30/06, Matthew McClintock msm@freescale.com wrote:
On Sun, 2006-10-29 at 15:54 -0700, Grant Likely wrote:
Note: I've added this command to ft_build.c instead of a seperate cmd_*.c because it is such a small amount of code.
Signed-off-by: Grant Likely grant.likely@secretlab.ca
Jerry Van Barren has a similar, yet slightly more robust "of" command implementation floating around that might be worth looking into.
Yeah, I saw that today. The ability to dump a subset of the tree looks useful
g.
participants (6)
-
Grant Likely
-
Jon Loeliger
-
Jon Loeliger
-
Matthew McClintock
-
Stefan Roese
-
Wolfgang Denk