Skip to contentSkip to conversation

Add Flat OF tree support.

PATCH New Pantelis Antoniou 2 participants 10 messages Sep 2, 2005 – Oct 13, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add Flat OF tree support.

Hi all.

As you well know, as part of the ongoing cleanup of the linux trees regarding PPC, it has been decreed that the preferred way to pass bootloader information shall be the flat OF tree.

http://ozlabs.org/pipermail/linuxppc-dev/2005-August/019408.html
http://ozlabs.org/pipermail/linuxppc-dev/2005-August/019362.html

The following patch (broken in two parts), implements just that.

Please be aware that in order to test it, you'll need a fairly recent dtc tool, which is available by git at

rsync://ozlabs.org/dtc/dtc.git

The xxd binary dumper is needed too which I got from

ftp://ftp.uni-erlangen.de/pub/utilities/etc/xxd-1.10.tar.gz

Linux patches will follow...

Awaiting comments.

Regards

Pantelis

P.S. Sorry for cross-posting, but it seems to be appropriate at this time. -------------- next part --------------

common/Makefile +1 -1
@@ -51,7 +51,7 @@ COBJS	= main.o ACEX1K.o altera.o bedbug.
 	  memsize.o miiphybb.o miiphyutil.o \
 	  s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o \
 	  usb.o usb_kbd.o usb_storage.o \
-	  virtex2.o xilinx.o
+	  virtex2.o xilinx.o ft_build.o
 
 OBJS	= $(AOBJS) $(COBJS)
 
common/cmd_bootm.c +38 -1
@@ -34,6 +34,10 @@
 #include <environment.h>
 #include <asm/byteorder.h>
 
+#ifdef CONFIG_OF_FLAT_TREE
+#include <ft_build.h>
+#endif
+
  /*cmd_boot.c*/
  extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
@@ -487,6 +491,9 @@ fixup_silent_linux ()
 }
 #endif /* CONFIG_SILENT_CONSOLE */
 
+extern const unsigned char oftree_dtb[];
+extern const unsigned int oftree_dtb_len;
+
 #ifdef CONFIG_PPC
 static void
 do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
@@ -509,6 +516,9 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 	bd_t	*kbd;
 	void	(*kernel)(bd_t *, ulong, ulong, ulong, ulong);
 	image_header_t *hdr = &header;
+#ifdef CONFIG_OF_FLAT_TREE
+	char	*of_flat_tree;
+#endif
 
 	if ((s = getenv ("initrd_high")) != NULL) {
 		/* a value of "no" or a similar string will act like 0,
@@ -773,16 +783,24 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 		initrd_start = 0;
 		initrd_end = 0;
 	}
-
+#ifdef CONFIG_OF_FLAT_TREE
+	if (initrd_start == 0)
+		of_flat_tree = (char *)(((ulong)kbd - OF_FLAT_TREE_MAX_SIZE) & ~0xF);
+	else
+		of_flat_tree = (char *)((initrd_start - OF_FLAT_TREE_MAX_SIZE) & ~0xF);
+#endif
 
 	debug ("## Transferring control to Linux (at address %08lx) ...\n",
 		(ulong)kernel);
 
 	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
@@ -792,6 +810,25 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int fl
 	 *   r7: End   of command line string
 	 */
 	(*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
+#else
+
+	ft_setup(of_flat_tree, OF_FLAT_TREE_MAX_SIZE, kbd);
+	/* ft_dump_blob(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) ((bd_t *)of_flat_tree, initrd_start, initrd_end, cmd_start, cmd_end);
+
+#endif
 }
 #endif /* CONFIG_PPC */
 
common/ft_build.c new file +751 -0

751 lines not on this page · raw message

include/ft_build.h new file +66 -0

66 lines not on this page · raw message

-------------- next part --------------

board/stxxtc/Makefile +10 -1
@@ -25,11 +25,19 @@ include $(TOPDIR)/config.mk
 
 LIB	= lib$(BOARD).a
 
-OBJS	= $(BOARD).o
+OBJS	= $(BOARD).o oftree.o
 
 $(LIB):	.depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
+%.dtb: %.dts
+	dtc -f -V 0x10 -I dts -O dtb $< >$@
+
+%.c: %.dtb
+	xxd -i $< \
+	   | sed -e "s/^unsigned char/const unsigned char/g" \
+	   | sed -e "s/^unsigned int/const unsigned int/g" > $@
+
 #########################################################################
 
 .depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
@@ -38,3 +46,4 @@ $(LIB):	.depend $(OBJS)
 sinclude .depend
 
 #########################################################################
+
board/stxxtc/oftree.dts new file +52 -0

52 lines not on this page · raw message

board/stxxtc/stxxtc.c +7 -0
@@ -38,6 +38,13 @@
 #include <watchdog.h>
 #endif
 
+#include <ft_build.h>
+
+/****************************************************************/
+
+extern const unsigned char oftree_dtb[];
+extern const unsigned int oftree_dtb_len;
+
 /****************************************************************/
 
 /* some sane bit macros */
include/configs/stxxtc.h +7 -12
@@ -574,19 +574,14 @@ typedef unsigned int led_id_t;
 #define CONFIG_CRC32_VERIFY	1
 #define CONFIG_HUSH_OLD_PARSER_COMPATIBLE	1
 
-/* Note: change below for your network setting!!!
- * This was done just to facilitate manufacturing test and configuration.
- */
-#define CONFIG_ETHADDR	 00:e0:0c:07:9b:8a
+/*****************************************************************************/
 
-#define CONFIG_SERVERIP 	192.168.08.1
-#define CONFIG_IPADDR  		192.168.08.85
-#define CONFIG_GATEWAYIP	192.168.08.1
-#define CONFIG_NETMASK		255.255.255.0
-#define CONFIG_HOSTNAME 	stx_xtc
-#define CONFIG_ROOTPATH 	/xtcroot
-#define CONFIG_BOOTFILE 	uImage
-#define CONFIG_LOADADDR		0x1000000
+/* pass open firmware flat tree */
+#define CONFIG_OF_FLAT_TREE	1
 
+/* maximum size of the flat tree (8K) */
+#define OF_FLAT_TREE_MAX_SIZE	8192
+
+#define OF_CPU			"PowerPC,MPC870 at 0"
 
 #endif	/* __CONFIG_H */
#1 lore raw

PATCH 1/1 Add Flat OF tree support.

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

As you well know, as part of the ongoing cleanup of the linux trees regarding PPC, it has been decreed that the preferred way to pass bootloader information shall be the flat OF tree.

Hear, hear!

Quoted 1 line

The following patch (broken in two parts), implements just that.

No, it does not. It does more than this on one hand, and less than reqired on the other.

Please clean up and resubmit:

common/Makefile COBJS = main.o ACEX1K.o altera.o bedbug. · line 54

Quoted 9 lines
common/Makefile +1 -1
@@ -51,7 +51,7 @@ COBJS	= main.o ACEX1K.o altera.o bedbug.
 	  memsize.o miiphybb.o miiphyutil.o \
 	  s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o \
 	  usb.o usb_kbd.o usb_storage.o \
-	  virtex2.o xilinx.o
+	  virtex2.o xilinx.o ft_build.o

Lists shall be kept sorted. Don't be lazy and just append at the end, please.

Quoted 2 lines
common/cmd_bootm.c +0 -0

...

common/cmd_bootm.c do_bootm_linux (cmd_tbl_t *cmdtp, int fl · line 829

Quoted 9 lines
common/cmd_bootm.c +9 -0
+	/*
+	 * 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) ((bd_t *)of_flat_tree, initrd_start, initrd_end, cmd_start, cmd_end);

Is it board info data or an OF tree? I think the comment needs to be adjusted to match the code.

Quoted 4 lines
common/ft_build.c new file +0 -0
new file mode 100644

...

common/ft_build.c line 594

Quoted 6 lines
common/ft_build.c new file +6 -0
+	/* paste the bd_t at the end of the flat tree */
+	end = (char *)blob +
+	    be32_to_cpu(((struct boot_param_header *)blob)->totalsize);
+	memcpy(end, bd, sizeof(*bd));
+
+#ifdef __powerpc__

I understand that *all* of this is PPC specific, so why do you #ifdef just this part? IMHO all of this should disappear for all non-PPC versions?

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/memstart", &len);

...

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/memsize", &len);

...

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/flashstart", &len);

...

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/flashsize", &len);

...

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/flashoffset", &len);

...

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/sramstart", &len);

...

common/ft_build.c line 620

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/sramsize", &len);

...

That's alot or repeated string constants, which just waste memory in the data segment. Any way for a leaner implementation?

While we are at it: did you check how much this patch adds to the memory footprint?

Quoted 5 lines
common/ft_build.c new file +5 -0
+#if defined(CONFIG_MPC5xxx)
+	p = ft_get_prop(blob, "/u-boot-bd_t/mbar_base", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(bd->bi_mbar_base);
+#endif

...

common/ft_build.c line 721

Quoted 10 lines
common/ft_build.c new file +10 -0
+#if defined(CONFIG_MPC5xxx)
+
+	p = ft_get_prop(blob, "/u-boot-bd_t/ipbfreq", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(bd->bi_ipbfreq);
+
+	p = ft_get_prop(blob, "/u-boot-bd_t/pcifreq", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(bd->bi_pcifreq);
+#endif

Maybe you can sort these things to minimize the groups of #ifdef's needed?

common/ft_build.c line 736

Quoted 10 lines
common/ft_build.c new file +10 -0
+#if defined(CONFIG_8xx)
+	clock = gd->cpu_clk;
+#elif defined(CONFIG_8260)
+	clock = gd->brg_clk;
+#else
+	clock = 0;
+#endif
+	p = ft_get_prop(blob, "/cpus/" OF_CPU "/clock-frequency", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(clock);

clock = 0 for anything but 8xx and 8260???

common/ft_build.c line 740

Quoted 3 lines
common/ft_build.c new file +3 -0
+	p = ft_get_prop(blob, "/cpus/" OF_CPU "/timebase-frequency", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(clock / 4);	/* XXX I'm just guessing */

... and probably wrong?

There is no CHANGELOG entry.

Rejected.

Quoted 6 lines

Content-Type: text/plain;
charset="us-ascii";
name="of-uboot-stxxtc.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="of-uboot-stxxtc.patch"

There is no CHANGELOG entry.

Rejected.

Best regards,

Wolfgang Denk

Signature · 7 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You'll learn something  about  men  and  women  --  the  way  they're
supposed  to  be. Caring for each other, being happy with each other,
being good to each other. That's what we call love. You'll like  that
a lot.
	-- Kirk, "The Apple", stardate 3715.6
#2 lore raw

PATCH 1/1 Add Flat OF tree support.

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

As you well know, as part of the ongoing cleanup of the linux trees regarding PPC, it has been decreed that the preferred way to pass bootloader information shall be the flat OF tree.

Quoted 7 lines

Hear, hear!

Quoted 1 line

The following patch (broken in two parts), implements just that.

No, it does not. It does more than this on one hand, and less than reqired on the other.

That's vague, to put it mildly.

Quoted 13 lines

Please clean up and resubmit:

common/Makefile COBJS = main.o ACEX1K.o altera.o bedbug. · line 54

Quoted 9 lines
common/Makefile +1 -1
@@ -51,7 +51,7 @@ COBJS	= main.o ACEX1K.o altera.o bedbug.
 	  memsize.o miiphybb.o miiphyutil.o \
 	  s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o \
 	  usb.o usb_kbd.o usb_storage.o \
-	  virtex2.o xilinx.o
+	  virtex2.o xilinx.o ft_build.o

Lists shall be kept sorted. Don't be lazy and just append at the end, please.

OK

Quoted 6 lines
Quoted 3 lines
common/cmd_bootm.c +0 -0

...

Quoted 13 lines
Quoted 10 lines
common/cmd_bootm.c +9 -0
+	/*
+	 * 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) ((bd_t *)of_flat_tree, initrd_start, initrd_end, cmd_start,

cmd_end);

Is it board info data or an OF tree? I think the comment needs to be adjusted to match the code.

It's both, after the OF tree the bd_t is pasted. We'll have a nice transition period when both are present. The target is for bd_t to be gone completely.

Quoted 8 lines
Quoted 5 lines
common/ft_build.c new file +0 -0
new file mode 100644

...

Quoted 10 lines

common/ft_build.c

Quoted 6 lines
common/ft_build.c new file +6 -0
+	/* paste the bd_t at the end of the flat tree */
+	end = (char *)blob +
+	    be32_to_cpu(((struct boot_param_header *)blob)->totalsize);
+	memcpy(end, bd, sizeof(*bd));
+
+#ifdef __powerpc__

I understand that *all* of this is PPC specific, so why do you #ifdef just this part? IMHO all of this should disappear for all non-PPC versions?

There's nothing PPC specific about the patch. Endianess issues are handled. OF trees are a superset of all the current ways that firmware passes settings to the kernel. In theory other architectures can use it for the same reason.

Quoted 25 lines
Quoted 2 lines
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/memstart", &len);

...

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/memsize", &len);

...

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/flashstart", &len);

...

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/flashsize", &len);

...

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/flashoffset", &len);

...

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/sramstart", &len);

...

Quoted 7 lines

common/ft_build.c

Quoted 1 line
common/ft_build.c new file +1 -0
+	p = ft_get_prop(blob, "/u-boot-bd_t/sramsize", &len);

...

That's alot or repeated string constants, which just waste memory in the data segment. Any way for a leaner implementation?

Fixed.

Quoted 2 lines

While we are at it: did you check how much this patch adds to the memory footprint?

It is controlled by a define, CONFIG_OF_FLAT_TREE, so if you don't use it there's no overhead.

The difference between a build with and without was about 5.5K. About 1K was the OF tree proper, which will grow when we start populating it with the device tree.

Quoted 9 lines
Quoted 6 lines
common/ft_build.c new file +5 -0
+#if defined(CONFIG_MPC5xxx)
+	p = ft_get_prop(blob, "/u-boot-bd_t/mbar_base", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(bd->bi_mbar_base);
+#endif

...

Quoted 13 lines

common/ft_build.c

Quoted 10 lines
common/ft_build.c new file +10 -0
+#if defined(CONFIG_MPC5xxx)
+
+	p = ft_get_prop(blob, "/u-boot-bd_t/ipbfreq", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(bd->bi_ipbfreq);
+
+	p = ft_get_prop(blob, "/u-boot-bd_t/pcifreq", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(bd->bi_pcifreq);
+#endif

Maybe you can sort these things to minimize the groups of #ifdef's needed?

???

The define mess on the bd_t is one of the reasons we're moving to this format.

bd_t is not long for this world anyway.

Quoted 14 lines

common/ft_build.c

Quoted 11 lines
common/ft_build.c new file +10 -0
+#if defined(CONFIG_8xx)
+	clock = gd->cpu_clk;
+#elif defined(CONFIG_8260)
+	clock = gd->brg_clk;
+#else
+	clock = 0;
+#endif
+	p = ft_get_prop(blob, "/cpus/" OF_CPU "/clock-frequency", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(clock);

clock = 0 for anything but 8xx and 8260???

Used intfreq instead.

Quoted 7 lines

common/ft_build.c

Quoted 3 lines
common/ft_build.c new file +3 -0
+	p = ft_get_prop(blob, "/cpus/" OF_CPU "/timebase-frequency", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(clock / 4);	/* XXX I'm just guessing */

... and probably wrong?

Yeah, put a OF_TBCLK define instead, since it's board specific.

Quoted 12 lines

There is no CHANGELOG entry.

Rejected.

Quoted 6 lines

Content-Type: text/plain;
charset="us-ascii";
name="of-uboot-stxxtc.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="of-uboot-stxxtc.patch"

Quoted 5 lines

There is no CHANGELOG entry.

Rejected.

Changelog entry added.

Quoted 3 lines

Best regards,

Wolfgang Denk

Regards

Pantelis
-------------- next part --------------

common/Makefile +1 -1
@@ -46,7 +46,7 @@ COBJS	= main.o ACEX1K.o altera.o bedbug.
 	  env_nand.o env_dataflash.o env_flash.o env_eeprom.o \
 	  env_nvram.o env_nowhere.o \
 	  exports.o \
-	  flash.o fpga.o \
+	  flash.o fpga.o ft_build.o \
 	  hush.o kgdb.o lcd.o lists.o lynxkdi.o \
 	  memsize.o miiphybb.o miiphyutil.o \
 	  s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o \
common/cmd_bootm.c +40 -1

80 lines not on this page · raw message

common/ft_build.c new file +684 -0

684 lines not on this page · raw message

include/ft_build.h new file +66 -0

66 lines not on this page · raw message

-------------- next part --------------

board/stxxtc/Makefile +10 -1
@@ -25,11 +25,19 @@ include $(TOPDIR)/config.mk
 
 LIB	= lib$(BOARD).a
 
-OBJS	= $(BOARD).o
+OBJS	= $(BOARD).o oftree.o
 
 $(LIB):	.depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
+%.dtb: %.dts
+	dtc -f -V 0x10 -I dts -O dtb $< >$@
+
+%.c: %.dtb
+	xxd -i $< \
+	   | sed -e "s/^unsigned char/const unsigned char/g" \
+	   | sed -e "s/^unsigned int/const unsigned int/g" > $@
+
 #########################################################################
 
 .depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
@@ -38,3 +46,4 @@ $(LIB):	.depend $(OBJS)
 sinclude .depend
 
 #########################################################################
+
board/stxxtc/oftree.dts new file +52 -0

52 lines not on this page · raw message

include/configs/stxxtc.h +8 -12
@@ -574,19 +574,15 @@ typedef unsigned int led_id_t;
 #define CONFIG_CRC32_VERIFY	1
 #define CONFIG_HUSH_OLD_PARSER_COMPATIBLE	1
 
-/* Note: change below for your network setting!!!
- * This was done just to facilitate manufacturing test and configuration.
- */
-#define CONFIG_ETHADDR	 00:e0:0c:07:9b:8a
+/*****************************************************************************/
 
-#define CONFIG_SERVERIP 	192.168.08.1
-#define CONFIG_IPADDR  		192.168.08.85
-#define CONFIG_GATEWAYIP	192.168.08.1
-#define CONFIG_NETMASK		255.255.255.0
-#define CONFIG_HOSTNAME 	stx_xtc
-#define CONFIG_ROOTPATH 	/xtcroot
-#define CONFIG_BOOTFILE 	uImage
-#define CONFIG_LOADADDR		0x1000000
+/* pass open firmware flat tree */
+#define CONFIG_OF_FLAT_TREE	1
 
+/* maximum size of the flat tree (8K) */
+#define OF_FLAT_TREE_MAX_SIZE	8192
+
+#define OF_CPU			"PowerPC,MPC870 at 0"
+#define OF_TBCLK		(MPC8XX_HZ / 16)
 
 #endif	/* __CONFIG_H */

-------------- next part --------------

CHANGELOG +3 -0
@@ -2,6 +2,9 @@
 Changes for U-Boot 1.1.4:
 ======================================================================
 
+* Support passing of OF flat trees to the kernel.
+  Patch by Pantelis Antoniou, 04 Sep 2005
+
 * Fix default command set (don't include CFG_CMD_DISPLAY command)
   Patch by Pantelis Antoniou, 02 Sep 2005
 
#3 lore raw

PATCH 1/1 Add Flat OF tree support.

Quoted 15 lines · In message <[email protected]> you wrote:
Quoted 14 lines
Quoted 11 lines
common/cmd_bootm.c +9 -0
+	/*
+	 * 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) ((bd_t *)of_flat_tree, initrd_start, initrd_end, cmd_start,

cmd_end);

Is it board info data or an OF tree? I think the comment needs to be adjusted to match the code.

Quoted 1 line

It's both, after the OF tree the bd_t is pasted.

Where is this done? I don't see it. And "after" does not help - an old kernel is still expecting it right at the address pointed to by r3.

Quoted 1 line

We'll have a nice transition period when both are present.

Please explain how this is supposed to work. You code does not contain much comments or explanations for the implementation (which is IMHO bad), but at first glance I had the impression that with your patch there are two situations:

1) CONFIG_OF_FLAT_TREE is not defined; we pass a bd_t to the kernel, and everything is as before. Only kernels expecting an bd_t can be booted.

2) CONFIG_OF_FLAT_TREE is defined; we pass an OF tree to the kernel. No backward compatibility is provided: kernels expecting an bd_t will crash miserably. Only kernels expecting an OF tree can be booted.

Quoted 1 line

The target is for bd_t to be gone completely.

Yes, but I don't see where the "transition period" is implemented.

I would expect that (when CONFIG_OF_FLAT_TREE is enabled) there is an environment variable that allows to switch between boot interfaces (similar to the clock_in_mhz variable), so that one and the same U-Boot image can boot both older and newer kernels?

Am I missing something?

Quoted 5 lines
Quoted 3 lines

I understand that *all* of this is PPC specific, so why do you #ifdef just this part? IMHO all of this should disappear for all non-PPC versions?

There's nothing PPC specific about the patch. Endianess issues are handled.

Come on, be realistic. There is not the slightest hint that ARM or MIPS considered using this.

All this *is* PPC specific code only.

And by the way: the whole function do_bootm_linux() you're patching is already enclosed in "#ifdef CONFIG_PPC" - ARM and MIPS etc. use different implementations of this function which you did not modify.

Also, in the rest of the code we use "#ifdef CONFIG_PPC", so please use this consistently (instead of "#ifdef __powerpc__".

Quoted 3 lines

OF trees are a superset of all the current ways that firmware passes settings to the kernel. In theory other architectures can use it for the same reason.

The key words here are "in theory". Do you have any information that there might be a realistic chance they would?

Quoted 5 lines
Quoted 2 lines

While we are at it: did you check how much this patch adds to the memory footprint?

It is controlled by a define, CONFIG_OF_FLAT_TREE, so if you don't use it there's no overhead.

That was not the question.

Quoted 3 lines

The difference between a build with and without was about 5.5K. About 1K was the OF tree proper, which will grow when we start populating it with the device tree.

6.5k or typically 5 % of the total size of U-Boot, tendency growing?

Outch...

There was discussion that we could leave out the OFT builder and just "load" a pre-built blob.Do you intend to implement this, too?

Quoted 22 lines
Quoted 8 lines
Quoted 5 lines
(quoted diff) +5 -0
+#if defined(CONFIG_MPC5xxx)
+	p = ft_get_prop(blob, "/u-boot-bd_t/mbar_base", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(bd->bi_mbar_base);
+#endif

...

Quoted 13 lines

common/ft_build.c line 673

Quoted 10 lines
common/ft_build.c new file +10 -0
+#if defined(CONFIG_MPC5xxx)
+
+	p = ft_get_prop(blob, "/u-boot-bd_t/ipbfreq", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(bd->bi_ipbfreq);
+
+	p = ft_get_prop(blob, "/u-boot-bd_t/pcifreq", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(bd->bi_pcifreq);
+#endif

Maybe you can sort these things to minimize the groups of #ifdef's needed?

Quoted 1 line

???

Why must you have several blocks "#if defined(CONFIG_MPC5xxx)" ? Put all this code in a single block.

BTW: where is the name "u-boot-bd_t" coming from? I think it's ugly. Can we shorten this to either "u-boot" or "bd_t", please?

Now you submit two patches: "of-uboot-base.patch" and
"of-uboot-stxxtc.patch" and a separate "of-uboot-changelog.patch" which does not mention a bit about what the second patch does.

Each patch needs it's own description and it's own CHANGELOG entry (commit message). Also, as documented by the RAEDME, CHANGELOG entries are required as plain text.

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
I can't understand it. I can't even understand  the  people  who  can
understand it.                    - Queen Juliana of the Netherlands.
#4 lore raw

PATCH 1/1 Add Flat OF tree support.

Quoted 15 lines · Wolfgang Denk
Quoted 14 lines · In message <[email protected]> you wrote:
Quoted 13 lines
Quoted 10 lines
(quoted diff) +9 -0
+	/*
+	 * 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) ((bd_t *)of_flat_tree, initrd_start, initrd_end,

cmd_start, cmd_end);

Is it board info data or an OF tree? I think the comment needs to be adjusted to match the code.

Quoted 6 lines
Quoted 1 line

It's both, after the OF tree the bd_t is pasted.

Where is this done? I don't see it. And "after" does not help - an old kernel is still expecting it right at the address pointed to by r3.

A new kernel detects a OF flat tree by the magic signature, and fallbacks to bd_t in that case.

Check ft_build and see what it does.

Quoted 11 lines
Quoted 1 line

We'll have a nice transition period when both are present.

Please explain how this is supposed to work. You code does not contain much comments or explanations for the implementation (which is IMHO bad), but at first glance I had the impression that with your patch there are two situations:

1) CONFIG_OF_FLAT_TREE is not defined; we pass a bd_t to the kernel, and everything is as before. Only kernels expecting an bd_t can be booted.

No, newer kernels detect that the OF tree is missing and use the bd_t as before.

Quoted 4 lines

2) CONFIG_OF_FLAT_TREE is defined; we pass an OF tree to the kernel. No backward compatibility is provided: kernels expecting an bd_t will crash miserably. Only kernels expecting an OF tree can be booted.

There is a reason for that. As you well know as per the ppc64 docs r3 points to the OF tree, so taking into account the ongoing merge that's where the OF tree is expected to be.

The fact that now r3 points to bd_t is unfortunate.

Quoted 11 lines
Quoted 2 lines

The target is for bd_t to be gone completely.

Yes, but I don't see where the "transition period" is implemented.

I would expect that (when CONFIG_OF_FLAT_TREE is enabled) there is an environment variable that allows to switch between boot interfaces (similar to the clock_in_mhz variable), so that one and the same U-Boot image can boot both older and newer kernels?

Am I missing something?

OK, that's reasonable.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

I understand that *all* of this is PPC specific, so why do you #ifdef just this part? IMHO all of this should disappear for all non-PPC versions?

Quoted 8 lines
Quoted 2 lines

There's nothing PPC specific about the patch. Endianess issues are handled.

Come on, be realistic. There is not the slightest hint that ARM or MIPS considered using this.

All this *is* PPC specific code only.

We shall see.

Quoted 7 lines

And by the way: the whole function do_bootm_linux() you're patching is already enclosed in "#ifdef CONFIG_PPC" - ARM and MIPS etc. use different implementations of this function which you did not modify.

Also, in the rest of the code we use "#ifdef CONFIG_PPC", so please use this consistently (instead of "#ifdef __powerpc__".

Quoted 7 lines
Quoted 3 lines

OF trees are a superset of all the current ways that firmware passes settings to the kernel. In theory other architectures can use it for the same reason.

The key words here are "in theory". Do you have any information that there might be a realistic chance they would?

I know that MIPS is contemplating porting over the ppc platform devices. And at least MIPS does not have a defined firmware interface. ARM I guess not.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

While we are at it: did you check how much this patch adds to the memory footprint?

It is controlled by a define, CONFIG_OF_FLAT_TREE, so if you don't use it there's no overhead.

That was not the question.

Quoted 7 lines
Quoted 3 lines

The difference between a build with and without was about 5.5K. About 1K was the OF tree proper, which will grow when we start populating it with the device tree.

6.5k or typically 5 % of the total size of U-Boot, tendency growing?

Outch...

That's the price of progress. No-one is forcing to use this on old-designs. Just take this into account on newer designs.

Quoted 4 lines

There was discussion that we could leave out the OFT builder and just "load" a pre-built blob.Do you intend to implement this, too?

No. A pre-build blob does not contain the full environment. The specs are clear; at least the chosen node must reflect current settings.

Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 5 lines
(quoted diff) +5 -0
+#if defined(CONFIG_MPC5xxx)
+	p = ft_get_prop(blob, "/u-boot-bd_t/mbar_base", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(bd->bi_mbar_base);
+#endif

...

Review

Quoted 10 lines
(quoted diff) +10 -0
+#if defined(CONFIG_MPC5xxx)
+
+	p = ft_get_prop(blob, "/u-boot-bd_t/ipbfreq", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(bd->bi_ipbfreq);
+
+	p = ft_get_prop(blob, "/u-boot-bd_t/pcifreq", &len);
+	if (p != NULL)
+		*p = cpu_to_be32(bd->bi_pcifreq);
+#endif

Maybe you can sort these things to minimize the groups of #ifdef's needed?

Quoted 8 lines
Quoted 1 line

???

Why must you have several blocks "#if defined(CONFIG_MPC5xxx)" ? Put all this code in a single block.

BTW: where is the name "u-boot-bd_t" coming from? I think it's ugly. Can we shorten this to either "u-boot" or "bd_t", please?

bd_t then.

Quoted 9 lines

Now you submit two patches: "of-uboot-base.patch" and
"of-uboot-stxxtc.patch" and a separate "of-uboot-changelog.patch" which does not mention a bit about what the second patch does.

Each patch needs it's own description and it's own CHANGELOG entry (commit message). Also, as documented by the RAEDME, CHANGELOG entries are required as plain text.

----------------------- snip ------------------------------
* Support passing of OF flat trees to the kernel. Specific support for the STXtc.
Patch by Pantelis Antoniou, 04 Sep 2005

----------------------- snip ------------------------------

Quoted 3 lines

Best regards,

Wolfgang Denk

Combined patch follows.

Regards

Pantelis
-------------- next part --------------

CHANGELOG +3 -0
@@ -2,6 +2,9 @@
 Changes for U-Boot 1.1.4:
 ======================================================================
 
+* Support passing of OF flat trees to the kernel.
+  Patch by Pantelis Antoniou, 04 Sep 2005
+
 * Fix default command set (don't include CFG_CMD_DISPLAY command)
   Patch by Pantelis Antoniou, 02 Sep 2005
 
README +14 -0
@@ -397,6 +397,20 @@ The following options need to be configu
 		expect it to be in bytes, others in MB.
 		Define CONFIG_MEMSIZE_IN_BYTES to make it in bytes.
 
+		CONFIG_OF_FLAT_TREE
+
+		New kernel versions are expecting firmware settings to be
+		passed using the flat open firmware trees.
+		The environment variable "disable_of" when set, disables this
+		functionality.
+
+		CONFIG_OF_FLAT_TREE_MAX_SIZE
+
+		The maximum size of the constructed OF tree. 
+
+		OF_CPU - The proper name of the cpus node.
+		OF_TBCLK - The timebase frequency.
+
 - Serial Ports:
 		CFG_PL010_SERIAL
 
board/stxxtc/Makefile +10 -1
@@ -25,11 +25,19 @@ include $(TOPDIR)/config.mk
 
 LIB	= lib$(BOARD).a
 
-OBJS	= $(BOARD).o
+OBJS	= $(BOARD).o oftree.o
 
 $(LIB):	.depend $(OBJS)
 	$(AR) crv $@ $(OBJS)
 
+%.dtb: %.dts
+	dtc -f -V 0x10 -I dts -O dtb $< >$@
+
+%.c: %.dtb
+	xxd -i $< \
+	   | sed -e "s/^unsigned char/const unsigned char/g" \
+	   | sed -e "s/^unsigned int/const unsigned int/g" > $@
+
 #########################################################################
 
 .depend:	Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
@@ -38,3 +46,4 @@ $(LIB):	.depend $(OBJS)
 sinclude .depend
 
 #########################################################################
+
board/stxxtc/oftree.dts new file +52 -0

52 lines not on this page · raw message

common/Makefile +1 -1
@@ -46,7 +46,7 @@ COBJS	= main.o ACEX1K.o altera.o bedbug.
 	  env_nand.o env_dataflash.o env_flash.o env_eeprom.o \
 	  env_nvram.o env_nowhere.o \
 	  exports.o \
-	  flash.o fpga.o \
+	  flash.o fpga.o ft_build.o \
 	  hush.o kgdb.o lcd.o lists.o lynxkdi.o \
 	  memsize.o miiphybb.o miiphyutil.o \
 	  s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o \
common/cmd_bootm.c +40 -1

80 lines not on this page · raw message

common/ft_build.c new file +695 -0

695 lines not on this page · raw message

include/configs/stxxtc.h +8 -12
@@ -574,19 +574,15 @@ typedef unsigned int led_id_t;
 #define CONFIG_CRC32_VERIFY	1
 #define CONFIG_HUSH_OLD_PARSER_COMPATIBLE	1
 
-/* Note: change below for your network setting!!!
- * This was done just to facilitate manufacturing test and configuration.
- */
-#define CONFIG_ETHADDR	 00:e0:0c:07:9b:8a
+/*****************************************************************************/
 
-#define CONFIG_SERVERIP 	192.168.08.1
-#define CONFIG_IPADDR  		192.168.08.85
-#define CONFIG_GATEWAYIP	192.168.08.1
-#define CONFIG_NETMASK		255.255.255.0
-#define CONFIG_HOSTNAME 	stx_xtc
-#define CONFIG_ROOTPATH 	/xtcroot
-#define CONFIG_BOOTFILE 	uImage
-#define CONFIG_LOADADDR		0x1000000
+/* pass open firmware flat tree */
+#define CONFIG_OF_FLAT_TREE	1
 
+/* maximum size of the flat tree (8K) */
+#define OF_FLAT_TREE_MAX_SIZE	8192
+
+#define OF_CPU			"PowerPC,MPC870 at 0"
+#define OF_TBCLK		(MPC8XX_HZ / 16)
 
 #endif	/* __CONFIG_H */
include/ft_build.h new file +66 -0

66 lines not on this page · raw message

#5 lore raw

PATCH 1/1 Add Flat OF tree support.

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

Where is this done? I don't see it. And "after" does not help - an old kernel is still expecting it right at the address pointed to by r3.

A new kernel detects a OF flat tree by the magic signature, and fallbacks to bd_t in that case.

Yes - but what about old kernels?

Quoted 6 lines
Quoted 3 lines

1) CONFIG_OF_FLAT_TREE is not defined; we pass a bd_t to the kernel, and everything is as before. Only kernels expecting an bd_t can be booted.

No, newer kernels detect that the OF tree is missing and use the bd_t as before.

OK. So an old version of U-Boot is compatible with old and new kernels. At least for some transition period. Good.

Quoted 6 lines
Quoted 4 lines

2) CONFIG_OF_FLAT_TREE is defined; we pass an OF tree to the kernel. No backward compatibility is provided: kernels expecting an bd_t will crash miserably. Only kernels expecting an OF tree can be booted.

There is a reason for that. As you well know as per the ppc64 docs

No matter what the reason is... It is an indispensable practical requirement that we will have to be able to install a version of U-Boot on a certain hardware which can boot both old and new kernels.

Quoted 10 lines
Quoted 8 lines

Yes, but I don't see where the "transition period" is implemented.

I would expect that (when CONFIG_OF_FLAT_TREE is enabled) there is an environment variable that allows to switch between boot interfaces (similar to the clock_in_mhz variable), so that one and the same U-Boot image can boot both older and newer kernels?

Am I missing something?

OK, that's reasonable.

Can you please implement that?

Quoted 3 lines

No. A pre-build blob does not contain the full environment. The specs are clear; at least the chosen node must reflect current settings.

It was one of Ben's major arguments in this debate that we might leave out of this OFT building code and just load a small binary blob; IIRC he was talking about less than 0.5 kB ...

Quoted 1 line

Combined patch follows.

Thanks.

...

Quoted 3 lines
common/ft_build.c new file +3 -0
+#if defined(CONFIG_MPC5xxx)
+	BDM(mbar_base),
+#endif

...

common/ft_build.c line 574

Quoted 4 lines
common/ft_build.c new file +4 -0
+#if defined(CONFIG_MPC5xxx)
+	BDM(ipbfreq),
+	BDM(pcifreq),
+#endif

Did you just miss this (in which case I will clean it up), or is there any technical reason for not combining these two groups into one?

Best regards,

Wolfgang Denk

Signature · 6 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Computers make excellent and efficient servants, but I have  no  wish
to  serve under them. Captain, a starship also runs on loyalty to one
man. And nothing can replace it or him.
	-- Spock, "The Ultimate Computer", stardate 4729.4
#6 lore raw

PATCH 1/1 Add Flat OF tree support.

In reply to Pantelis Antoniou
Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 4 lines

Where is this done? I don't see it. And "after" does not help - an old kernel is still expecting it right at the address pointed to by r3.

A new kernel detects a OF flat tree by the magic signature, and fallbacks to bd_t in that case.

Yes - but what about old kernels?

Quoted 6 lines
Quoted 3 lines

1) CONFIG_OF_FLAT_TREE is not defined; we pass a bd_t to the kernel, and everything is as before. Only kernels expecting an bd_t can be booted.

No, newer kernels detect that the OF tree is missing and use the bd_t as before.

OK. So an old version of U-Boot is compatible with old and new kernels. At least for some transition period. Good.

Quoted 6 lines
Quoted 4 lines

2) CONFIG_OF_FLAT_TREE is defined; we pass an OF tree to the kernel. No backward compatibility is provided: kernels expecting an bd_t will crash miserably. Only kernels expecting an OF tree can be booted.

There is a reason for that. As you well know as per the ppc64 docs

No matter what the reason is... It is an indispensable practical requirement that we will have to be able to install a version of U-Boot on a certain hardware which can boot both old and new kernels.

Quoted 10 lines
Quoted 8 lines

Yes, but I don't see where the "transition period" is implemented.

I would expect that (when CONFIG_OF_FLAT_TREE is enabled) there is an environment variable that allows to switch between boot interfaces (similar to the clock_in_mhz variable), so that one and the same U-Boot image can boot both older and newer kernels?

Am I missing something?

OK, that's reasonable.

Can you please implement that?

Quoted 3 lines

No. A pre-build blob does not contain the full environment. The specs are clear; at least the chosen node must reflect current settings.

It was one of Ben's major arguments in this debate that we might leave out of this OFT building code and just load a small binary blob; IIRC he was talking about less than 0.5 kB ...

Quoted 1 line

Combined patch follows.

Thanks.

...

Quoted 3 lines
common/ft_build.c new file +3 -0
+#if defined(CONFIG_MPC5xxx)
+	BDM(mbar_base),
+#endif

...

common/ft_build.c line 574

Quoted 4 lines
common/ft_build.c new file +4 -0
+#if defined(CONFIG_MPC5xxx)
+	BDM(ipbfreq),
+	BDM(pcifreq),
+#endif

Did you just miss this (in which case I will clean it up), or is there any technical reason for not combining these two groups into one?

Best regards,

Wolfgang Denk

Signature · 6 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Computers make excellent and efficient servants, but I have  no  wish
to  serve under them. Captain, a starship also runs on loyalty to one
man. And nothing can replace it or him.
	-- Spock, "The Ultimate Computer", stardate 4729.4
#7 lore raw

PATCH 1/1 Add Flat OF tree support.

In reply to Pantelis Antoniou

In message <[email protected]> you wrote:
...

Quoted 3 lines

* Support passing of OF flat trees to the kernel.
Specific support for the STXtc.
Patch by Pantelis Antoniou, 04 Sep 2005

Added, thanks.

Note 1: can you please submit a new patch to add a show doc/README.OFT
or so which explains where the required dtc tool can be found?

Note 2: you owe Stefan Roese a beer or two.

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
God may be subtle, but He isn't plain mean.         - Albert Einstein
#8 lore raw

PATCH 1/1 Add Flat OF tree support.

Quoted 11 lines · Wolfgang Denk

In message <[email protected]> you wrote:
...

Quoted 3 lines

* Support passing of OF flat trees to the kernel.
Specific support for the STXtc.
Patch by Pantelis Antoniou, 04 Sep 2005

Added, thanks.

Note 1: can you please submit a new patch to add a show doc/README.OFT
or so which explains where the required dtc tool can be found?

Here you go.

Quoted 2 lines

Note 2: you owe Stefan Roese a beer or two.

Only one? I was thinking of a case :).

Quoted 4 lines

Best regards,

Wolfgang Denk

Regards

Pantelis
-------------- next part --------------
Added a small doc file for pointing out where the tools for OF tree support are located.

---
commit a014911ad67dfcdd40b5258be8fe666bc13930c0
tree 10cddfbab8571a2a459a54441b4fdf29e5464cf6
parent 0cdd3d61b6489a8a25cd07e256072b6581200871
author Pantelis Antoniou <[email protected]> Thu, 13 Oct 2005 08:30:11 +0300 committer Pantelis Antoniou <[email protected]> Thu, 13 Oct 2005 08:30:11 +0300

 doc/README.OFT |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
doc/README.OFT new file +26 -0
new file mode 100644
@@ -0,0 +1,26 @@
+Open Firmware Flat Tree and usage.
+----------------------------------
+
+As part of the ongoing cleanup of the linux PPC trees, the preferred
+way to pass bootloader and board setup information is the open
+firmware flat tree.
+
+Please take a look at the following email discussion for some 
+background.
+
+  http://ozlabs.org/pipermail/linuxppc-dev/2005-August/019408.html
+  http://ozlabs.org/pipermail/linuxppc-dev/2005-August/019362.html
+
+The generated tree is part static and part dynamic.
+
+There is a static part which is compiled in with DTC and a dynamic
+part which is programmatically appended.
+
+You'll need a fairly recent DTC tool, which is available by git at.
+
+  rsync://ozlabs.org/dtc/dtc.git
+
+The xxd binary dumper is needed too which I got from
+
+  ftp://ftp.uni-erlangen.de/pub/utilities/etc/xxd-1.10.tar.gz
+
#9 lore raw

PATCH 1/1 Add Flat OF tree support.

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

Note 1: can you please submit a new patch to add a show doc/README.OFT
or so which explains where the required dtc tool can be found?

Here you go.

Checked in, thanks.

Quoted 3 lines
Quoted 1 line

Note 2: you owe Stefan Roese a beer or two.

Only one? I was thinking of a case :).

Please don't. He needs to get some work done :-)

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Computers are not intelligent. They only think they are.