Skip to contentSkip to conversation

Set of patches for FDT support

U-Boot-Users New Grant Likely 6 participants 21 messages Oct 29, 2006 – Nov 29, 2006

lore
Share & tools
lore
#0 lore raw

[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.

#1 lore raw

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.

#2 lore raw

[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.

#3 lore raw

PATCH 1/1 Add 'ftinfo' command for displaying a flattened device tree image

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.

---
 common/ft_build.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
common/ft_build.c +23 -0
index 980e40f..9a36187 100644
@@ -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
Signature · 1 line
1.4.3.rc2.g0503
#4 lore raw

PATCH 1/1 Allow CONFIG_OF_FLAT_TREE to boot a non-arch/powerpc kernel

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.

---
 common/cmd_bootm.c |   54 +++++++++++++++++++++------------------------------
 1 files changed, 22 insertions(+), 32 deletions(-)
common/cmd_bootm.c +22 -32
index 3091a58..7aae8a6 100644
@@ -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 */
 
Signature · 1 line
1.4.3.rc2.g0503
#5 lore raw

PATCH 1/1 Enable the IceCube/lite5200 variants to pass a device tree to Linux.

This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.

---
 board/icecube/icecube.c   |   12 ++++++++++++
 cpu/mpc5xxx/cpu.c         |   28 ++++++++++++++++++++++++++++
 include/configs/IceCube.h |   13 +++++++++++++
 3 files changed, 53 insertions(+), 0 deletions(-)
board/icecube/icecube.c +12 -0
index 4f056b2..9b222da 100644
@@ -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
cpu/mpc5xxx/cpu.c +28 -0
index 6b6f828..20e6735 100644
@@ -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 at 3000/mac-address", &len);
+	if (p != NULL)
+		memcpy(p, bd->bi_enetaddr, 6);
+
+}
+#endif
include/configs/IceCube.h +13 -0
index 1152f83..0d38254 100644
@@ -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 at 0"
+#define OF_SOC			"soc5200 at f0000000"
+#define OF_TBCLK		(bd->bi_busfreq / 8)
+#define OF_STDOUT_PATH		"/soc5200 at f0000000/serial at 2000"
+
 /*
  * I2C configuration
  */
Signature · 1 line
1.4.3.rc2.g0503
#6 lore raw

PATCH 1/1 Enable the IceCube/lite5200 variants to pass a device tree to Linux.

Quoted 2 lines · In message <[email protected]> you wrote:

This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.

...

Quoted 2 lines
board/icecube/icecube.c +0 -0

...

board/icecube/icecube.c void ide_set_reset (int idereset) · line 348

Quoted 12 lines
board/icecube/icecube.c +8 -0
@@ -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

Signature · 5 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at 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
#7 lore raw

PATCH 1/1 Enable the IceCube/lite5200 variants to pass a device tree to Linux.

Quoted 16 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:

This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.

...

Quoted 2 lines
board/icecube/icecube.c +0 -0

...

Quoted 9 lines
board/icecube/icecube.c +5 -0
@@ -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)
+{
Quoted 8 lines

board/icecube/icecube.c void ide_set_reset (int idereset) · line 348

Quoted 3 lines
board/icecube/icecube.c +3 -0
+     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.

Quoted 12 lines

Best regards,

Wolfgang Denk

--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at 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

Signature · 4 lines
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely at secretlab.ca
(403) 399-0195
#8 lore raw

PATCH 1/1 Enable the IceCube/lite5200 variants to pass a device tree to Linux.

Quoted 26 lines · Grant Likely
Quoted 16 lines · Wolfgang Denk
Quoted 2 lines · In message <[email protected]> you wrote:

This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.

...

Quoted 2 lines
board/icecube/icecube.c +0 -0

...

Quoted 9 lines
board/icecube/icecube.c +5 -0
@@ -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)
+{
Quoted 8 lines

board/icecube/icecube.c void ide_set_reset (int idereset) · line 348

Quoted 3 lines
board/icecube/icecube.c +3 -0
+     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?

Quoted 5 lines

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.

Signature · 4 lines
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely at secretlab.ca
(403) 399-0195
Applied
#10 lore raw

PATCH 1/1 Enable the IceCube/lite5200 variants to pass a device tree to Linux.

In reply to Grant Likely
Quoted 2 lines · Grant Likely

This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.

Applied. Thanks.

Best regards,
Stefan

#11 lore raw

PATCH 1/1 Enable the IceCube/lite5200 variants to pass a device tree to Linux.

Quoted 5 lines · Stefan Roese
Quoted 2 lines · Grant Likely

This patch adds the code and configuration necessary to boot with an arch/powerpc Linux kernel.

Applied. Thanks.

Cool, thanks!

g.

Signature · 4 lines
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely at secretlab.ca
(403) 399-0195
#12 lore raw

PATCH 1/1 Allow CONFIG_OF_FLAT_TREE to boot a non-arch/powerpc kernel

In reply to Grant Likely

Dear Grant,

Quoted 1 line · in message <[email protected]> you wrote:

...

common/cmd_bootm.c #else /* CONFIG_OF_FLAT_TREE */ · line 956

Quoted 5 lines
common/cmd_bootm.c +0 -5
-	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

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Real programmers can write assembly code in any language.   :-)
                      - Larry Wall in  <[email protected]>
#13 lore raw

PATCH 1/1 Allow CONFIG_OF_FLAT_TREE to boot a non-arch/powerpc kernel

Quoted 13 lines · Wolfgang Denk

Dear Grant,

Quoted 1 line · in message <[email protected]> you wrote:

...

common/cmd_bootm.c #else /* CONFIG_OF_FLAT_TREE */ · line 956

Quoted 5 lines
common/cmd_bootm.c +0 -5
-     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() ?

Quoted 1 line

Why?

It's not actually removed. Rather it's no longer duplicated in two halves of a #if/#else/#endif block.

g.

Quoted 11 lines

Best regards,

Wolfgang Denk

--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Real programmers can write assembly code in any language. :-)
- Larry Wall in <[email protected]>

Signature · 4 lines
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely at secretlab.ca
(403) 399-0195
#14 lore raw

PATCH 1/1 Allow CONFIG_OF_FLAT_TREE to boot a non-arch/powerpc kernel

In reply to Grant Likely

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>
---

Applied
#15 lore raw

PATCH 1/1 Allow CONFIG_OF_FLAT_TREE to boot a non-arch/powerpc kernel

In reply to Grant Likely
Quoted 3 lines · Grant Likely

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

#16 lore raw

PATCH 1/1 Allow CONFIG_OF_FLAT_TREE to boot a non-arch/powerpc kernel

Quoted 6 lines · Stefan Roese
Quoted 3 lines · Grant Likely

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%2dsend%2demail%2dgrant.likely%40secretlab.ca%3e

Thanks,
g.

Signature · 4 lines
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely at secretlab.ca
(403) 399-0195
#17 lore raw

PATCH 1/1 Allow CONFIG_OF_FLAT_TREE to boot a non-arch/powerpc kernel

Quoted 5 lines · Grant Likely
Quoted 2 lines · Stefan Roese

Applied. Thanks.

Brilliant, thank you.

Indeed, thanks, Stefan.

Quoted 4 lines

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%2dsend%2demail%2dgrant.likely%40secretlab.ca%3e

And that would be the other patch I also ACK-ed.

jdl

#18 lore raw

PATCH 1/1 Allow CONFIG_OF_FLAT_TREE to boot a non-arch/powerpc kernel

Quoted 7 lines · Jon Loeliger
Quoted 4 lines · Grant Likely
Quoted 1 line · Stefan Roese

Applied. Thanks.

Brilliant, thank you.

Indeed, thanks, Stefan.

You're welcome. :-)

Quoted 7 lines
Quoted 5 lines

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

#19 lore raw

PATCH 1/1 Add 'ftinfo' command for displaying a flattened device tree image

In reply to Grant Likely
Quoted 4 lines · Grant Likely

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.

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=summary

-Matthew

#20 lore raw

PATCH 1/1 Add 'ftinfo' command for displaying a flattened device tree image

Quoted 8 lines · Matthew McClintock
Quoted 4 lines · Grant Likely

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.

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.

Signature · 4 lines
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely at secretlab.ca
(403) 399-0195