public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
@ 2007-10-25 13:43 Martin Krause
  2007-10-25 14:13 ` Jerry Van Baren
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Martin Krause @ 2007-10-25 13:43 UTC (permalink / raw)
  To: u-boot

Add the function fdt_memory() to fixup the /memory node of the fdt
with the memory values detected by U-Boot (bd->bi_memstart and
bd->bi_memsize).

To activate this feature CONFIG_OF_MEMORY_FIXUP has to be defined
in the board config file.

Signed-off-by: Martin Krause <martin.krause@tqs.de>
---
The patch was tested on the TQM5200 board. Any comments are welcome!

Best Regards,
Martin Krause

 common/cmd_bootm.c        |    7 +++++++
 common/fdt_support.c      |   44 ++++++++++++++++++++++++++++++++++++++++++++
 include/configs/TQM5200.h |    1 +
 include/fdt_support.h     |    4 ++++
 4 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index d816349..fe9f9bc 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -992,6 +992,13 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
 			do_reset (cmdtp, flag, argc, argv);
 		}
 #endif
+#ifdef CONFIG_OF_MEMORY_FIXUP
+		if (fdt_memory(of_flat_tree) < 0) {
+			puts ("ERROR: /memory node create failed - "
+				"must RESET the board to recover.\n");
+			do_reset (cmdtp, flag, argc, argv);
+		}
+#endif
 #ifdef CONFIG_OF_BOARD_SETUP
 		/* Call the board-specific fixup routine */
 		ft_board_setup(of_flat_tree, gd->bd);
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 175d59e..86f22e0 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -348,4 +348,48 @@ int fdt_bd_t(void *fdt)
 }
 #endif /* ifdef CONFIG_OF_HAS_BD_T */
 
+/********************************************************************/
+
+#ifdef CONFIG_OF_MEMORY_FIXUP
+
+int fdt_memory(void *fdt)
+{
+	int   nodeoffset;
+	int   err;
+	u32   tmp[2];
+	bd_t *bd = gd->bd;
+
+	err = fdt_check_header(fdt);
+	if (err < 0) {
+		printf("fdt_memory: %s\n", fdt_strerror(err));
+		return err;
+	}
+	/* update, or add and update /memory node */
+	nodeoffset = fdt_find_node_by_path(fdt, "/memory");
+	if (nodeoffset < 0) {
+		nodeoffset = fdt_add_subnode(fdt, 0, "memory");
+		if (nodeoffset < 0)
+			printf("WARNING could not create /memory: %s.\n",
+				fdt_strerror(nodeoffset));
+		return nodeoffset;
+	}
+	err = fdt_setprop(fdt, nodeoffset, "device_type", "memory",
+			  sizeof("memory"));
+	if (err < 0) {
+		printf("WARNING: could not set %s %s.\n",
+		       "device_type", fdt_strerror(err));
+		return err;
+	}
+	tmp[0] = cpu_to_be32(bd->bi_memstart);
+	tmp[1] = cpu_to_be32(bd->bi_memsize);
+	err = fdt_setprop(fdt, nodeoffset, "reg", tmp, sizeof(tmp));
+	if (err < 0) {
+		printf("WARNING: could not set %s %s.\n",
+		       "reg", fdt_strerror(err));
+		return err;
+	}
+	return 0;
+}
+#endif /* CONFIG_OF_MEMORY_FIXUP */
+
 #endif /* CONFIG_OF_LIBFDT */
diff --git a/include/configs/TQM5200.h b/include/configs/TQM5200.h
index 8076e70..59b8cff 100644
--- a/include/configs/TQM5200.h
+++ b/include/configs/TQM5200.h
@@ -727,6 +727,7 @@
  */
 #define CONFIG_OF_LIBFDT	1
 #define CONFIG_OF_BOARD_SETUP	1
+#define CONFIG_OF_MEMORY_FIXUP	1
 
 #define OF_CPU			"PowerPC,5200 at 0"
 #define OF_SOC			"soc5200@f0000000"
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 60fa423..92766f3 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -38,6 +38,10 @@ int fdt_env(void *fdt);
 int fdt_bd_t(void *fdt);
 #endif
 
+#ifdef CONFIG_OF_MEMORY_FIXUP
+int fdt_memory(void *fdt);
+#endif
+
 #ifdef CONFIG_OF_BOARD_SETUP
 void ft_board_setup(void *blob, bd_t *bd);
 void ft_cpu_setup(void *blob, bd_t *bd);

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-25 13:43 Martin Krause
@ 2007-10-25 14:13 ` Jerry Van Baren
  2007-10-25 15:05   ` Kumar Gala
  2007-10-25 14:39 ` Kim Phillips
  2007-10-25 15:05 ` Kumar Gala
  2 siblings, 1 reply; 26+ messages in thread
From: Jerry Van Baren @ 2007-10-25 14:13 UTC (permalink / raw)
  To: u-boot

Martin Krause wrote:
> Add the function fdt_memory() to fixup the /memory node of the fdt
> with the memory values detected by U-Boot (bd->bi_memstart and
> bd->bi_memsize).
> 
> To activate this feature CONFIG_OF_MEMORY_FIXUP has to be defined
> in the board config file.
> 
> Signed-off-by: Martin Krause <martin.krause@tqs.de>
> ---
> The patch was tested on the TQM5200 board. Any comments are welcome!
> 
> Best Regards,
> Martin Krause

Thanks for the patches, Martin and Kumar.  I should be able to make 
progress on fdt improvements this weekend and next week.

Best regards,
gvb

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-25 13:43 Martin Krause
  2007-10-25 14:13 ` Jerry Van Baren
@ 2007-10-25 14:39 ` Kim Phillips
  2007-10-25 15:47   ` Martin Krause
  2007-10-25 15:05 ` Kumar Gala
  2 siblings, 1 reply; 26+ messages in thread
From: Kim Phillips @ 2007-10-25 14:39 UTC (permalink / raw)
  To: u-boot

On Thu, 25 Oct 2007 15:43:27 +0200
Martin Krause <martin.krause@tqs.de> wrote:

> 
> +#define CONFIG_OF_MEMORY_FIXUP	1
>  
is it possible to consolidate the memory fixup code config into an
existing CONFIG, such as libfdt's or OF_BOARD_SETUP, instead of making
a new one?

also, will you be updating the other boards/platforms?

Kim

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-25 14:13 ` Jerry Van Baren
@ 2007-10-25 15:05   ` Kumar Gala
  2007-10-26  0:01     ` Wolfgang Denk
  0 siblings, 1 reply; 26+ messages in thread
From: Kumar Gala @ 2007-10-25 15:05 UTC (permalink / raw)
  To: u-boot


On Oct 25, 2007, at 9:13 AM, Jerry Van Baren wrote:

> Martin Krause wrote:
>> Add the function fdt_memory() to fixup the /memory node of the fdt
>> with the memory values detected by U-Boot (bd->bi_memstart and
>> bd->bi_memsize).
>> To activate this feature CONFIG_OF_MEMORY_FIXUP has to be defined
>> in the board config file.
>> Signed-off-by: Martin Krause <martin.krause@tqs.de>
>> ---
>> The patch was tested on the TQM5200 board. Any comments are welcome!
>> Best Regards,
>> Martin Krause
>
> Thanks for the patches, Martin and Kumar.  I should be able to make  
> progress on fdt improvements this weekend and next week.

Great, I've got a set of patches for using new libfdt, but I might  
put them in a git tree since the libfdt import is big and difficult  
to post to the list.

- k

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-25 13:43 Martin Krause
  2007-10-25 14:13 ` Jerry Van Baren
  2007-10-25 14:39 ` Kim Phillips
@ 2007-10-25 15:05 ` Kumar Gala
  2007-10-25 15:57   ` Martin Krause
  2 siblings, 1 reply; 26+ messages in thread
From: Kumar Gala @ 2007-10-25 15:05 UTC (permalink / raw)
  To: u-boot


On Oct 25, 2007, at 8:43 AM, Martin Krause wrote:

> Add the function fdt_memory() to fixup the /memory node of the fdt
> with the memory values detected by U-Boot (bd->bi_memstart and
> bd->bi_memsize).
>
> To activate this feature CONFIG_OF_MEMORY_FIXUP has to be defined
> in the board config file.

Any reason we should even bother with a CONFIG for this?

- k

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-25 14:39 ` Kim Phillips
@ 2007-10-25 15:47   ` Martin Krause
  0 siblings, 0 replies; 26+ messages in thread
From: Martin Krause @ 2007-10-25 15:47 UTC (permalink / raw)
  To: u-boot

Kim Phillips wrote on Thursday, October 25, 2007 4:39 PM:
> On Thu, 25 Oct 2007 15:43:27 +0200
> Martin Krause <martin.krause@tqs.de> wrote:
> 
> > 
> > +#define CONFIG_OF_MEMORY_FIXUP	1
> > 
> is it possible to consolidate the memory fixup code config into an
> existing CONFIG, such as libfdt's or OF_BOARD_SETUP, instead of making
> a new one?

Yes, I can change this. But then all boards wich have OF_BOARD_SETUP
defined, will use the new global memory fixup function. Currently not
all boards which define OF_BOARD_SETUP do already a memory fixup.
This boards would be forced to the fixup. Don't know, if this would
be OK or could lead to some unwanted side effects (one propably would
be an enlarged footprint of the resulting u-boot binary).

> also, will you be updating the other boards/platforms?

Yes, I can create a patch. I didn't do this yet, because I wasn't sure
if the change would be accepted at all.

Best Regards,
Martin Krause

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-25 15:05 ` Kumar Gala
@ 2007-10-25 15:57   ` Martin Krause
  2007-10-25 16:08     ` Kim Phillips
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Krause @ 2007-10-25 15:57 UTC (permalink / raw)
  To: u-boot

Kumar Gala wrote on Thursday, October 25, 2007 5:06 PM:
> On Oct 25, 2007, at 8:43 AM, Martin Krause wrote:
> 
> > Add the function fdt_memory() to fixup the /memory node of the fdt
> > with the memory values detected by U-Boot (bd->bi_memstart and
> > bd->bi_memsize). 
> > 
> > To activate this feature CONFIG_OF_MEMORY_FIXUP has to be defined
> > in the board config file.
> 
> Any reason we should even bother with a CONFIG for this?

Then the memory fixup will be done on _all_ boards using OF_LIBFDT.
If no one raises his hand, not to do this, I'll create a patch
(which will remove the boardspecific memory fixup code from all boards
already doing a memory fixup and switch them to the global fixup).

Best Regards,
Martin Krause

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-25 15:57   ` Martin Krause
@ 2007-10-25 16:08     ` Kim Phillips
  0 siblings, 0 replies; 26+ messages in thread
From: Kim Phillips @ 2007-10-25 16:08 UTC (permalink / raw)
  To: u-boot

On Thu, 25 Oct 2007 17:57:10 +0200
"Martin Krause" <Martin.Krause@tqs.de> wrote:

> Kumar Gala wrote on Thursday, October 25, 2007 5:06 PM:
> > On Oct 25, 2007, at 8:43 AM, Martin Krause wrote:
> > 
> > > Add the function fdt_memory() to fixup the /memory node of the fdt
> > > with the memory values detected by U-Boot (bd->bi_memstart and
> > > bd->bi_memsize). 
> > > 
> > > To activate this feature CONFIG_OF_MEMORY_FIXUP has to be defined
> > > in the board config file.
> > 
> > Any reason we should even bother with a CONFIG for this?
> 
> Then the memory fixup will be done on _all_ boards using OF_LIBFDT.
> If no one raises his hand, not to do this, I'll create a patch
> (which will remove the boardspecific memory fixup code from all boards
> already doing a memory fixup and switch them to the global fixup).

Hi Martin, this is what I was alluding to in the other thread.  My hand
is down :).

Kim

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-25 15:05   ` Kumar Gala
@ 2007-10-26  0:01     ` Wolfgang Denk
  2007-10-26  4:57       ` Kumar Gala
  0 siblings, 1 reply; 26+ messages in thread
From: Wolfgang Denk @ 2007-10-26  0:01 UTC (permalink / raw)
  To: u-boot

In message <6A2E9F87-25A3-469E-9541-55D200F10296@kernel.crashing.org> you wrote:
> 
> Great, I've got a set of patches for using new libfdt, but I might  
> put them in a git tree since the libfdt import is big and difficult  
> to post to the list.

You git tree will be likely ignored if you don't post the patches.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
: 1.  What is the possibility of this being added in the future?
In the near future, the probability is close to zero. In the  distant
future, I'll be dead, and posterity can do whatever they like... :-)
                                                              - lwall

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-26  0:01     ` Wolfgang Denk
@ 2007-10-26  4:57       ` Kumar Gala
  2007-10-26 10:00         ` Wolfgang Denk
  2007-10-26 11:26         ` Jerry Van Baren
  0 siblings, 2 replies; 26+ messages in thread
From: Kumar Gala @ 2007-10-26  4:57 UTC (permalink / raw)
  To: u-boot


On Oct 25, 2007, at 7:01 PM, Wolfgang Denk wrote:

> In message  
> <6A2E9F87-25A3-469E-9541-55D200F10296@kernel.crashing.org> you wrote:
>>
>> Great, I've got a set of patches for using new libfdt, but I might
>> put them in a git tree since the libfdt import is big and difficult
>> to post to the list.
>
> You git tree will be likely ignored if you don't post the patches.

I've posted two of the the three patches in my tree.

Any suggestions on how to deal with the third, its beyond the size  
limit for the list?

- k

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
@ 2007-10-26  8:49 Martin Krause
  2007-10-26  9:55 ` Kumar Gala
  2007-10-26 11:14 ` Jerry Van Baren
  0 siblings, 2 replies; 26+ messages in thread
From: Martin Krause @ 2007-10-26  8:49 UTC (permalink / raw)
  To: u-boot

Add the function fdt_memory() to fixup the /memory node of the fdt
with the memory values detected by U-Boot (taken from bd->bi_memstart
and bd->bi_memsize).

The new function is called for all boards which define CONFIG_OF_LIBFDT.

This patch removes already existing board specific memory fixup routines
for boards wich have CONFIG_OF_LIBFDT defined and switches them to the
new routine. Boards wich use the CONIFG_OF_FLAT_TREE method are not
 touched.

Signed-off-by: Martin Krause <martin.krause@tqs.de>
---
Since no one raised his hand - here is the patch :)

Best Regards,
Martin Krause

 board/cds/common/ft_board.c     |    9 ---------
 board/cm5200/cm5200.c           |   22 ++-------------------
 board/mpc7448hpc2/mpc7448hpc2.c |    9 ---------
 board/mpc8540ads/mpc8540ads.c   |    9 ---------
 board/mpc8568mds/ft_board.c     |    7 -------
 board/sbc8349/sbc8349.c         |    9 ---------
 board/sbc8641d/sbc8641d.c       |    9 ---------
 common/cmd_bootm.c              |   10 ++++++++++
 common/fdt_support.c            |   41 +++++++++++++++++++++++++++++++++++++++
 include/fdt_support.h           |    1 +
 10 files changed, 54 insertions(+), 72 deletions(-)

diff --git a/board/cds/common/ft_board.c b/board/cds/common/ft_board.c
index 9d97905..be0e824 100644
--- a/board/cds/common/ft_board.c
+++ b/board/cds/common/ft_board.c
@@ -56,20 +56,11 @@ static void cds_pci_fixup(void *blob)
 void
 ft_board_setup(void *blob, bd_t *bd)
 {
-	u32 *p;
-	int len;
-
 #ifdef CONFIG_PCI
 	ft_pci_setup(blob, bd);
 #endif
 	ft_cpu_setup(blob, bd);
 
-	p = ft_get_prop(blob, "/memory/reg", &len);
-	if (p != NULL) {
-		*p++ = cpu_to_be32(bd->bi_memstart);
-		*p = cpu_to_be32(bd->bi_memsize);
-	}
-
 	cds_pci_fixup(blob);
 }
 #endif
diff --git a/board/cm5200/cm5200.c b/board/cm5200/cm5200.c
index e2ab5b8..b2a64c7 100644
--- a/board/cm5200/cm5200.c
+++ b/board/cm5200/cm5200.c
@@ -256,14 +256,13 @@ static void compose_hostname(hw_id_t hw_id, char *buf)
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
 /*
- * Update 'model' and 'memory' properties in the blob according to the module
- * that we are running on.
+ * Update 'model' property in the blob according to the module that we are
+ * running on.
  */
 static void ft_blob_update(void *blob, bd_t *bd)
 {
 	int len, ret, nodeoffset = 0;
 	char module_name[MODULE_NAME_MAXLEN] = {0};
-	ulong memory_data[2] = {0};
 
 	compose_module_name(hw_id, module_name);
 	len = strlen(module_name) + 1;
@@ -272,23 +271,6 @@ static void ft_blob_update(void *blob, bd_t *bd)
 	if (ret < 0)
 	printf("ft_blob_update(): cannot set /model property err:%s\n",
 		fdt_strerror(ret));
-
-	memory_data[0] = cpu_to_be32(bd->bi_memstart);
-	memory_data[1] = cpu_to_be32(bd->bi_memsize);
-
-	nodeoffset = fdt_find_node_by_path (blob, "/memory");
-	if (nodeoffset >= 0) {
-		ret = fdt_setprop(blob, nodeoffset, "reg", memory_data,
-					sizeof(memory_data));
-	if (ret < 0)
-		printf("ft_blob_update): cannot set /memory/reg "
-			"property err:%s\n", fdt_strerror(ret));
-	}
-	else {
-		/* memory node is required in dts */
-		printf("ft_blob_update(): cannot find /memory node "
-		"err:%s\n", fdt_strerror(nodeoffset));
-	}
 }
 #endif /* defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) */
 
diff --git a/board/mpc7448hpc2/mpc7448hpc2.c b/board/mpc7448hpc2/mpc7448hpc2.c
index 81846eb..68b2222 100644
--- a/board/mpc7448hpc2/mpc7448hpc2.c
+++ b/board/mpc7448hpc2/mpc7448hpc2.c
@@ -93,15 +93,6 @@ long int initdram (int board_type)
 void
 ft_board_setup (void *blob, bd_t *bd)
 {
-	u32 *p;
-	int len;
-
 	ft_cpu_setup (blob, bd);
-
-	p = ft_get_prop (blob, "/memory/reg", &len);
-	if (p != NULL) {
-		*p++ = cpu_to_be32 (bd->bi_memstart);
-		*p = cpu_to_be32 (bd->bi_memsize);
-	}
 }
 #endif
diff --git a/board/mpc8540ads/mpc8540ads.c b/board/mpc8540ads/mpc8540ads.c
index 914e51a..1171e14 100644
--- a/board/mpc8540ads/mpc8540ads.c
+++ b/board/mpc8540ads/mpc8540ads.c
@@ -335,18 +335,9 @@ pci_init_board(void)
 void
 ft_board_setup(void *blob, bd_t *bd)
 {
-	u32 *p;
-	int len;
-
 #ifdef CONFIG_PCI
 	ft_pci_setup(blob, bd);
 #endif
 	ft_cpu_setup(blob, bd);
-
-	p = ft_get_prop(blob, "/memory/reg", &len);
-	if (p != NULL) {
-		*p++ = cpu_to_be32(bd->bi_memstart);
-		*p = cpu_to_be32(bd->bi_memsize);
-	}
 }
 #endif
diff --git a/board/mpc8568mds/ft_board.c b/board/mpc8568mds/ft_board.c
index 36815cc..1f79b22 100644
--- a/board/mpc8568mds/ft_board.c
+++ b/board/mpc8568mds/ft_board.c
@@ -30,16 +30,9 @@ extern void ft_cpu_setup(void *blob, bd_t *bd);
 void
 ft_board_setup(void *blob, bd_t *bd)
 {
-	u32 *p;
-	int len;
 #ifdef CONFIG_PCI
 	ft_pci_setup(blob, bd);
 #endif
 	ft_cpu_setup(blob, bd);
-	p = ft_get_prop(blob, "/memory/reg", &len);
-	if (p != NULL) {
-		*p++ = cpu_to_be32(bd->bi_memstart);
-		*p = cpu_to_be32(bd->bi_memsize);
-	}
 }
 #endif /* CONFIG_OF_FLAT_TREE && CONFIG_OF_BOARD_SETUP */
diff --git a/board/sbc8349/sbc8349.c b/board/sbc8349/sbc8349.c
index 86166ea..ec9c15d 100644
--- a/board/sbc8349/sbc8349.c
+++ b/board/sbc8349/sbc8349.c
@@ -565,18 +565,9 @@ U_BOOT_CMD(
 void
 ft_board_setup(void *blob, bd_t *bd)
 {
-	u32 *p;
-	int len;
-
 #ifdef CONFIG_PCI
 	ft_pci_setup(blob, bd);
 #endif
 	ft_cpu_setup(blob, bd);
-
-	p = ft_get_prop(blob, "/memory/reg", &len);
-	if (p != NULL) {
-		*p++ = cpu_to_be32(bd->bi_memstart);
-		*p = cpu_to_be32(bd->bi_memsize);
-	}
 }
 #endif
diff --git a/board/sbc8641d/sbc8641d.c b/board/sbc8641d/sbc8641d.c
index 7adc42f..3f8b008 100644
--- a/board/sbc8641d/sbc8641d.c
+++ b/board/sbc8641d/sbc8641d.c
@@ -344,16 +344,7 @@ void pci_init_board(void)
 #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
 void ft_board_setup (void *blob, bd_t * bd)
 {
-	u32 *p;
-	int len;
-
 	ft_cpu_setup (blob, bd);
-
-	p = ft_get_prop (blob, "/memory/reg", &len);
-	if (p != NULL) {
-		*p++ = cpu_to_be32 (bd->bi_memstart);
-		*p = cpu_to_be32 (bd->bi_memsize);
-	}
 }
 #endif
 
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index d816349..3381c07 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -992,6 +992,16 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
 			do_reset (cmdtp, flag, argc, argv);
 		}
 #endif
+		/*
+		 * Add the "/memory" node if it does not exist, and do a fixup
+		 * of the "reg" property with values detected by U-Boot
+		 * (taken from bd->bi_memstart and bd->bi_memsize).
+		 */
+		if (fdt_memory(of_flat_tree) < 0) {
+			puts ("ERROR: /memory node create failed - "
+				"must RESET the board to recover.\n");
+			do_reset (cmdtp, flag, argc, argv);
+		}
 #ifdef CONFIG_OF_BOARD_SETUP
 		/* Call the board-specific fixup routine */
 		ft_board_setup(of_flat_tree, gd->bd);
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 175d59e..ee434d6 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -348,4 +348,45 @@ int fdt_bd_t(void *fdt)
 }
 #endif /* ifdef CONFIG_OF_HAS_BD_T */
 
+/********************************************************************/
+
+int fdt_memory(void *fdt)
+{
+	int   nodeoffset;
+	int   err;
+	u32   tmp[2];
+	bd_t *bd = gd->bd;
+
+	err = fdt_check_header(fdt);
+	if (err < 0) {
+		printf("fdt_memory: %s\n", fdt_strerror(err));
+		return err;
+	}
+	/* update, or add and update /memory node */
+	nodeoffset = fdt_find_node_by_path(fdt, "/memory");
+	if (nodeoffset < 0) {
+		nodeoffset = fdt_add_subnode(fdt, 0, "memory");
+		if (nodeoffset < 0)
+			printf("WARNING could not create /memory: %s.\n",
+				fdt_strerror(nodeoffset));
+		return nodeoffset;
+	}
+	err = fdt_setprop(fdt, nodeoffset, "device_type", "memory",
+			  sizeof("memory"));
+	if (err < 0) {
+		printf("WARNING: could not set %s %s.\n",
+		       "device_type", fdt_strerror(err));
+		return err;
+	}
+	tmp[0] = cpu_to_be32(bd->bi_memstart);
+	tmp[1] = cpu_to_be32(bd->bi_memsize);
+	err = fdt_setprop(fdt, nodeoffset, "reg", tmp, sizeof(tmp));
+	if (err < 0) {
+		printf("WARNING: could not set %s %s.\n",
+		       "reg", fdt_strerror(err));
+		return err;
+	}
+	return 0;
+}
+
 #endif /* CONFIG_OF_LIBFDT */
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 60fa423..eca2186 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -29,6 +29,7 @@
 #include <fdt.h>
 
 int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force);
+int fdt_memory(void *fdt);
 
 #ifdef CONFIG_OF_HAS_UBOOT_ENV
 int fdt_env(void *fdt);

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-26  8:49 [U-Boot-Users] [PATCH] fdt: add common memory fixup function Martin Krause
@ 2007-10-26  9:55 ` Kumar Gala
  2007-10-26 10:09   ` Martin Krause
  2007-10-26 11:14 ` Jerry Van Baren
  1 sibling, 1 reply; 26+ messages in thread
From: Kumar Gala @ 2007-10-26  9:55 UTC (permalink / raw)
  To: u-boot


On Oct 26, 2007, at 3:49 AM, Martin Krause wrote:

> Add the function fdt_memory() to fixup the /memory node of the fdt
> with the memory values detected by U-Boot (taken from bd->bi_memstart
> and bd->bi_memsize).
>
> The new function is called for all boards which define  
> CONFIG_OF_LIBFDT.
>
> This patch removes already existing board specific memory fixup  
> routines
> for boards wich have CONFIG_OF_LIBFDT defined and switches them to the
> new routine. Boards wich use the CONIFG_OF_FLAT_TREE method are not
>  touched.
>
> Signed-off-by: Martin Krause <martin.krause@tqs.de>
> ---
> Since no one raised his hand - here is the patch :)
>
> Best Regards,
> Martin Krause
>
>  board/cds/common/ft_board.c     |    9 ---------
>  board/cm5200/cm5200.c           |   22 ++-------------------
>  board/mpc7448hpc2/mpc7448hpc2.c |    9 ---------
>  board/mpc8540ads/mpc8540ads.c   |    9 ---------
>  board/mpc8568mds/ft_board.c     |    7 -------
>  board/sbc8349/sbc8349.c         |    9 ---------
>  board/sbc8641d/sbc8641d.c       |    9 ---------
>  common/cmd_bootm.c              |   10 ++++++++++
>  common/fdt_support.c            |   41 ++++++++++++++++++++++++++++ 
> +++++++++++
>  include/fdt_support.h           |    1 +
>  10 files changed, 54 insertions(+), 72 deletions(-)

Not all the boards you touched used libfdt today (mpc7448hpc2,  
mpc8540ads, sbc8349, sbc8641d)

- k

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-26  4:57       ` Kumar Gala
@ 2007-10-26 10:00         ` Wolfgang Denk
  2007-10-26 11:26         ` Jerry Van Baren
  1 sibling, 0 replies; 26+ messages in thread
From: Wolfgang Denk @ 2007-10-26 10:00 UTC (permalink / raw)
  To: u-boot

Dear Kumar,

in message <77096504-D90D-4732-B0B1-25403C1DE331@kernel.crashing.org> you wrote:
> 
> Any suggestions on how to deal with the third, its beyond the size  
> limit for the list?

Please see http://www.denx.de/wiki/UBoot/Patches , bullet 9.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"What is wanted is not the will to believe, but the will to find out,
which is the exact opposite." - Bertrand Russell, _Sceptical_Essays_,
1928

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-26  9:55 ` Kumar Gala
@ 2007-10-26 10:09   ` Martin Krause
  0 siblings, 0 replies; 26+ messages in thread
From: Martin Krause @ 2007-10-26 10:09 UTC (permalink / raw)
  To: u-boot

Kumar Gala wrote on Friday, October 26, 2007 11:55 AM:
> On Oct 26, 2007, at 3:49 AM, Martin Krause wrote:
> 
> > Add the function fdt_memory() to fixup the /memory node of the fdt
> > with the memory values detected by U-Boot (taken from
> > bd->bi_memstart and bd->bi_memsize). 
> > 
> > The new function is called for all boards which define
> > CONFIG_OF_LIBFDT. 
> > 
> > This patch removes already existing board specific memory fixup
> > routines for boards wich have CONFIG_OF_LIBFDT defined and switches
> > them to the new routine. Boards wich use the CONIFG_OF_FLAT_TREE
> > method are not  touched. 
> > 
> > Signed-off-by: Martin Krause <martin.krause@tqs.de> ---
> > Since no one raised his hand - here is the patch :)
> > 
> > Best Regards,
> > Martin Krause
> > 
> >  board/cds/common/ft_board.c     |    9 ---------
> >  board/cm5200/cm5200.c           |   22 ++-------------------
> >  board/mpc7448hpc2/mpc7448hpc2.c |    9 ---------
> >  board/mpc8540ads/mpc8540ads.c   |    9 ---------
> >  board/mpc8568mds/ft_board.c     |    7 -------
> >  board/sbc8349/sbc8349.c         |    9 ---------
> >  board/sbc8641d/sbc8641d.c       |    9 ---------
> >  common/cmd_bootm.c              |   10 ++++++++++
> >  common/fdt_support.c            |   41
> >  ++++++++++++++++++++++++++++ +++++++++++ include/fdt_support.h    
> >  |    1 + 10 files changed, 54 insertions(+), 72 deletions(-)
> 
> Not all the boards you touched used libfdt today (mpc7448hpc2,
> mpc8540ads, sbc8349, sbc8641d)

Ups, you are right! The flow of patching carried me away ...
I'll redo the patch. Sorry for the noise!

Best Regards,
Martin Krause

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-26  8:49 [U-Boot-Users] [PATCH] fdt: add common memory fixup function Martin Krause
  2007-10-26  9:55 ` Kumar Gala
@ 2007-10-26 11:14 ` Jerry Van Baren
  2007-10-26 11:26   ` Martin Krause
  1 sibling, 1 reply; 26+ messages in thread
From: Jerry Van Baren @ 2007-10-26 11:14 UTC (permalink / raw)
  To: u-boot

Martin Krause wrote:
> Add the function fdt_memory() to fixup the /memory node of the fdt
> with the memory values detected by U-Boot (taken from bd->bi_memstart
> and bd->bi_memsize).
> 
> The new function is called for all boards which define CONFIG_OF_LIBFDT.
> 
> This patch removes already existing board specific memory fixup routines
> for boards wich have CONFIG_OF_LIBFDT defined and switches them to the
> new routine. Boards wich use the CONIFG_OF_FLAT_TREE method are not
>  touched.
> 
> Signed-off-by: Martin Krause <martin.krause@tqs.de>
> ---
> Since no one raised his hand - here is the patch :)
> 
> Best Regards,
> Martin Krause

Thanks, into the "in" basket it goes...

gvb

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-26 11:14 ` Jerry Van Baren
@ 2007-10-26 11:26   ` Martin Krause
  2007-10-26 11:27     ` Jerry Van Baren
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Krause @ 2007-10-26 11:26 UTC (permalink / raw)
  To: u-boot

Jerry Van Baren wrote on Friday, October 26, 2007 1:14 PM:
> Martin Krause wrote:
> > Add the function fdt_memory() to fixup the /memory node of the fdt
> > with the memory values detected by U-Boot (taken from
> > bd->bi_memstart and bd->bi_memsize). 
> > 
> > The new function is called for all boards which define
> > CONFIG_OF_LIBFDT. 
> > 
> > This patch removes already existing board specific memory fixup
> > routines for boards wich have CONFIG_OF_LIBFDT defined and switches
> > them to the new routine. Boards wich use the CONIFG_OF_FLAT_TREE
> > method are not  touched. 
> > 
> > Signed-off-by: Martin Krause <martin.krause@tqs.de> ---
> > Since no one raised his hand - here is the patch :)
> > 
> > Best Regards,
> > Martin Krause
> 
> Thanks, into the "in" basket it goes...

Ah, please wait, I'm working on an update. I missed some boards
already doing a board specific fixup (and instead cought some 
boards not using libfdt yet ...).

Best Regards,
Martin Krause

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-26  4:57       ` Kumar Gala
  2007-10-26 10:00         ` Wolfgang Denk
@ 2007-10-26 11:26         ` Jerry Van Baren
  2007-10-26 14:45           ` Kumar Gala
  1 sibling, 1 reply; 26+ messages in thread
From: Jerry Van Baren @ 2007-10-26 11:26 UTC (permalink / raw)
  To: u-boot

Kumar Gala wrote:
> On Oct 25, 2007, at 7:01 PM, Wolfgang Denk wrote:
> 
>> In message  
>> <6A2E9F87-25A3-469E-9541-55D200F10296@kernel.crashing.org> you wrote:
>>> Great, I've got a set of patches for using new libfdt, but I might
>>> put them in a git tree since the libfdt import is big and difficult
>>> to post to the list.
>> You git tree will be likely ignored if you don't post the patches.
> 
> I've posted two of the the three patches in my tree.
> 
> Any suggestions on how to deal with the third, its beyond the size  
> limit for the list?
> 
> - k

Hi Kumar,

Individually, the files will fit through the list.  Based on sizes, even 
if the patches blow up to 2x the current file size, they should still 
fit through the list.
$ ls -l
total 88
-rw-r--r-- 1 vanbaren users  4572 2007-10-26 07:18 fdt.c
-rw-r--r-- 1 vanbaren users  1691 2007-10-26 07:18 fdt.h
-rw-r--r-- 1 vanbaren users 12281 2007-10-26 07:18 fdt_ro.c
-rw-r--r-- 1 vanbaren users  9621 2007-10-26 07:18 fdt_rw.c
-rw-r--r-- 1 vanbaren users  3321 2007-10-26 07:18 fdt_strerror.c
-rw-r--r-- 1 vanbaren users  7087 2007-10-26 07:18 fdt_sw.c
-rw-r--r-- 1 vanbaren users  4048 2007-10-26 07:18 fdt_wip.c
-rw-r--r-- 1 vanbaren users   502 2007-10-26 07:18 libfdt_env.h
-rw-r--r-- 1 vanbaren users 17522 2007-10-26 07:18 libfdt.h
-rw-r--r-- 1 vanbaren users  3520 2007-10-26 07:18 libfdt_internal.h
-rw-r--r-- 1 vanbaren users   436 2007-10-26 07:18 Makefile.libfdt
-rw-r--r-- 1 vanbaren users   142 2007-10-26 07:18 TODO

Best regards,
gvb

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-26 11:26   ` Martin Krause
@ 2007-10-26 11:27     ` Jerry Van Baren
  0 siblings, 0 replies; 26+ messages in thread
From: Jerry Van Baren @ 2007-10-26 11:27 UTC (permalink / raw)
  To: u-boot

Martin Krause wrote:
> Jerry Van Baren wrote on Friday, October 26, 2007 1:14 PM:
>> Martin Krause wrote:
>>> Add the function fdt_memory() to fixup the /memory node of the fdt
>>> with the memory values detected by U-Boot (taken from
>>> bd->bi_memstart and bd->bi_memsize). 
>>>
>>> The new function is called for all boards which define
>>> CONFIG_OF_LIBFDT. 
>>>
>>> This patch removes already existing board specific memory fixup
>>> routines for boards wich have CONFIG_OF_LIBFDT defined and switches
>>> them to the new routine. Boards wich use the CONIFG_OF_FLAT_TREE
>>> method are not  touched. 
>>>
>>> Signed-off-by: Martin Krause <martin.krause@tqs.de> ---
>>> Since no one raised his hand - here is the patch :)
>>>
>>> Best Regards,
>>> Martin Krause
>> Thanks, into the "in" basket it goes...
> 
> Ah, please wait, I'm working on an update. I missed some boards
> already doing a board specific fixup (and instead cought some 
> boards not using libfdt yet ...).
> 
> Best Regards,
> Martin Krause

Yeah, I fell into the "ack before reading the whole thread" trap. ;-)

gvb

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
@ 2007-10-26 11:47 Martin Krause
  2007-11-20 20:34 ` Kumar Gala
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Krause @ 2007-10-26 11:47 UTC (permalink / raw)
  To: u-boot

Add the function fdt_memory() to fixup the /memory node of the fdt
with the memory values detected by U-Boot (taken from bd->bi_memstart
and bd->bi_memsize).

The new function is called for all boards which define CONFIG_OF_LIBFDT.

This patch removes already existing board specific memory fixup routines
for boards wich have CONFIG_OF_LIBFDT defined and switches them to the
new routine. Boards wich use the CONIFG_OF_FLAT_TREE method are not
touched.

Signed-off-by: Martin Krause <martin.krause@tqs.de>
---
Updated patch. Please ignore all former versions.

Best Regards,
Martin Krause


 board/cds/common/ft_board.c |    9 ---------
 board/cm5200/cm5200.c       |   22 ++--------------------
 common/cmd_bootm.c          |   10 ++++++++++
 common/fdt_support.c        |   41 +++++++++++++++++++++++++++++++++++++++++
 cpu/mpc83xx/cpu.c           |   17 -----------------
 include/fdt_support.h       |    1 +
 6 files changed, 54 insertions(+), 46 deletions(-)

diff --git a/board/cds/common/ft_board.c b/board/cds/common/ft_board.c
index 9d97905..be0e824 100644
--- a/board/cds/common/ft_board.c
+++ b/board/cds/common/ft_board.c
@@ -56,20 +56,11 @@ static void cds_pci_fixup(void *blob)
 void
 ft_board_setup(void *blob, bd_t *bd)
 {
-	u32 *p;
-	int len;
-
 #ifdef CONFIG_PCI
 	ft_pci_setup(blob, bd);
 #endif
 	ft_cpu_setup(blob, bd);
 
-	p = ft_get_prop(blob, "/memory/reg", &len);
-	if (p != NULL) {
-		*p++ = cpu_to_be32(bd->bi_memstart);
-		*p = cpu_to_be32(bd->bi_memsize);
-	}
-
 	cds_pci_fixup(blob);
 }
 #endif
diff --git a/board/cm5200/cm5200.c b/board/cm5200/cm5200.c
index e2ab5b8..b2a64c7 100644
--- a/board/cm5200/cm5200.c
+++ b/board/cm5200/cm5200.c
@@ -256,14 +256,13 @@ static void compose_hostname(hw_id_t hw_id, char *buf)
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
 /*
- * Update 'model' and 'memory' properties in the blob according to the module
- * that we are running on.
+ * Update 'model' property in the blob according to the module that we are
+ * running on.
  */
 static void ft_blob_update(void *blob, bd_t *bd)
 {
 	int len, ret, nodeoffset = 0;
 	char module_name[MODULE_NAME_MAXLEN] = {0};
-	ulong memory_data[2] = {0};
 
 	compose_module_name(hw_id, module_name);
 	len = strlen(module_name) + 1;
@@ -272,23 +271,6 @@ static void ft_blob_update(void *blob, bd_t *bd)
 	if (ret < 0)
 	printf("ft_blob_update(): cannot set /model property err:%s\n",
 		fdt_strerror(ret));
-
-	memory_data[0] = cpu_to_be32(bd->bi_memstart);
-	memory_data[1] = cpu_to_be32(bd->bi_memsize);
-
-	nodeoffset = fdt_find_node_by_path (blob, "/memory");
-	if (nodeoffset >= 0) {
-		ret = fdt_setprop(blob, nodeoffset, "reg", memory_data,
-					sizeof(memory_data));
-	if (ret < 0)
-		printf("ft_blob_update): cannot set /memory/reg "
-			"property err:%s\n", fdt_strerror(ret));
-	}
-	else {
-		/* memory node is required in dts */
-		printf("ft_blob_update(): cannot find /memory node "
-		"err:%s\n", fdt_strerror(nodeoffset));
-	}
 }
 #endif /* defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) */
 
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index d816349..3381c07 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -992,6 +992,16 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
 			do_reset (cmdtp, flag, argc, argv);
 		}
 #endif
+		/*
+		 * Add the "/memory" node if it does not exist, and do a fixup
+		 * of the "reg" property with values detected by U-Boot
+		 * (taken from bd->bi_memstart and bd->bi_memsize).
+		 */
+		if (fdt_memory(of_flat_tree) < 0) {
+			puts ("ERROR: /memory node create failed - "
+				"must RESET the board to recover.\n");
+			do_reset (cmdtp, flag, argc, argv);
+		}
 #ifdef CONFIG_OF_BOARD_SETUP
 		/* Call the board-specific fixup routine */
 		ft_board_setup(of_flat_tree, gd->bd);
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 175d59e..ee434d6 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -348,4 +348,45 @@ int fdt_bd_t(void *fdt)
 }
 #endif /* ifdef CONFIG_OF_HAS_BD_T */
 
+/********************************************************************/
+
+int fdt_memory(void *fdt)
+{
+	int   nodeoffset;
+	int   err;
+	u32   tmp[2];
+	bd_t *bd = gd->bd;
+
+	err = fdt_check_header(fdt);
+	if (err < 0) {
+		printf("fdt_memory: %s\n", fdt_strerror(err));
+		return err;
+	}
+	/* update, or add and update /memory node */
+	nodeoffset = fdt_find_node_by_path(fdt, "/memory");
+	if (nodeoffset < 0) {
+		nodeoffset = fdt_add_subnode(fdt, 0, "memory");
+		if (nodeoffset < 0)
+			printf("WARNING could not create /memory: %s.\n",
+				fdt_strerror(nodeoffset));
+		return nodeoffset;
+	}
+	err = fdt_setprop(fdt, nodeoffset, "device_type", "memory",
+			  sizeof("memory"));
+	if (err < 0) {
+		printf("WARNING: could not set %s %s.\n",
+		       "device_type", fdt_strerror(err));
+		return err;
+	}
+	tmp[0] = cpu_to_be32(bd->bi_memstart);
+	tmp[1] = cpu_to_be32(bd->bi_memsize);
+	err = fdt_setprop(fdt, nodeoffset, "reg", tmp, sizeof(tmp));
+	if (err < 0) {
+		printf("WARNING: could not set %s %s.\n",
+		       "reg", fdt_strerror(err));
+		return err;
+	}
+	return 0;
+}
+
 #endif /* CONFIG_OF_LIBFDT */
diff --git a/cpu/mpc83xx/cpu.c b/cpu/mpc83xx/cpu.c
index e634f0a..51b63e6 100644
--- a/cpu/mpc83xx/cpu.c
+++ b/cpu/mpc83xx/cpu.c
@@ -526,7 +526,6 @@ ft_cpu_setup(void *blob, bd_t *bd)
 	int nodeoffset;
 	int err;
 	int j;
-	int tmp[2];
 
 	for (j = 0; j < (sizeof(fixup_props) / sizeof(fixup_props[0])); j++) {
 		nodeoffset = fdt_find_node_by_path(blob, fixup_props[j].node);
@@ -542,22 +541,6 @@ ft_cpu_setup(void *blob, bd_t *bd)
 			      fixup_props[j].node, fdt_strerror(nodeoffset));
 		}
 	}
-
-	/* update, or add and update /memory node */
-	nodeoffset = fdt_find_node_by_path(blob, "/memory");
-	if (nodeoffset < 0) {
-		nodeoffset = fdt_add_subnode(blob, 0, "memory");
-		if (nodeoffset < 0)
-			debug("failed to add /memory node: %s\n",
-			      fdt_strerror(nodeoffset));
-	}
-	if (nodeoffset >= 0) {
-		fdt_setprop(blob, nodeoffset, "device_type",
-			    "memory", sizeof("memory"));
-		tmp[0] = cpu_to_be32(bd->bi_memstart);
-		tmp[1] = cpu_to_be32(bd->bi_memsize);
-		fdt_setprop(blob, nodeoffset, "reg", tmp, sizeof(tmp));
-	}
 }
 #elif defined(CONFIG_OF_FLAT_TREE)
 void
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 60fa423..eca2186 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -29,6 +29,7 @@
 #include <fdt.h>
 
 int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force);
+int fdt_memory(void *fdt);
 
 #ifdef CONFIG_OF_HAS_UBOOT_ENV
 int fdt_env(void *fdt);

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-26 11:26         ` Jerry Van Baren
@ 2007-10-26 14:45           ` Kumar Gala
  0 siblings, 0 replies; 26+ messages in thread
From: Kumar Gala @ 2007-10-26 14:45 UTC (permalink / raw)
  To: u-boot


On Oct 26, 2007, at 6:26 AM, Jerry Van Baren wrote:

> Kumar Gala wrote:
>> On Oct 25, 2007, at 7:01 PM, Wolfgang Denk wrote:
>>> In message   
>>> <6A2E9F87-25A3-469E-9541-55D200F10296@kernel.crashing.org> you  
>>> wrote:
>>>> Great, I've got a set of patches for using new libfdt, but I might
>>>> put them in a git tree since the libfdt import is big and difficult
>>>> to post to the list.
>>> You git tree will be likely ignored if you don't post the patches.
>> I've posted two of the the three patches in my tree.
>> Any suggestions on how to deal with the third, its beyond the  
>> size  limit for the list?
>> - k
>
> Hi Kumar,
>
> Individually, the files will fit through the list.  Based on sizes,  
> even if the patches blow up to 2x the current file size, they  
> should still fit through the list.
> $ ls -l
> total 88
> -rw-r--r-- 1 vanbaren users  4572 2007-10-26 07:18 fdt.c
> -rw-r--r-- 1 vanbaren users  1691 2007-10-26 07:18 fdt.h
> -rw-r--r-- 1 vanbaren users 12281 2007-10-26 07:18 fdt_ro.c
> -rw-r--r-- 1 vanbaren users  9621 2007-10-26 07:18 fdt_rw.c
> -rw-r--r-- 1 vanbaren users  3321 2007-10-26 07:18 fdt_strerror.c
> -rw-r--r-- 1 vanbaren users  7087 2007-10-26 07:18 fdt_sw.c
> -rw-r--r-- 1 vanbaren users  4048 2007-10-26 07:18 fdt_wip.c
> -rw-r--r-- 1 vanbaren users   502 2007-10-26 07:18 libfdt_env.h
> -rw-r--r-- 1 vanbaren users 17522 2007-10-26 07:18 libfdt.h
> -rw-r--r-- 1 vanbaren users  3520 2007-10-26 07:18 libfdt_internal.h
> -rw-r--r-- 1 vanbaren users   436 2007-10-26 07:18 Makefile.libfdt
> -rw-r--r-- 1 vanbaren users   142 2007-10-26 07:18 TODO


Agreed, I was trying to avoid splitting into multiple patches/commits  
so we didn't have a build breakage if one did a git-bisect in the  
future.

- k

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-10-26 11:47 Martin Krause
@ 2007-11-20 20:34 ` Kumar Gala
  2007-11-27  8:02   ` Martin Krause
  0 siblings, 1 reply; 26+ messages in thread
From: Kumar Gala @ 2007-11-20 20:34 UTC (permalink / raw)
  To: u-boot

> diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
> index d816349..3381c07 100644
> --- a/common/cmd_bootm.c
> +++ b/common/cmd_bootm.c
> @@ -992,6 +992,16 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
> 			do_reset (cmdtp, flag, argc, argv);
> 		}
> #endif
> +		/*
> +		 * Add the "/memory" node if it does not exist, and do a fixup
> +		 * of the "reg" property with values detected by U-Boot
> +		 * (taken from bd->bi_memstart and bd->bi_memsize).
> +		 */
> +		if (fdt_memory(of_flat_tree) < 0) {
> +			puts ("ERROR: /memory node create failed - "
> +				"must RESET the board to recover.\n");
> +			do_reset (cmdtp, flag, argc, argv);
> +		}
> #ifdef CONFIG_OF_BOARD_SETUP
> 		/* Call the board-specific fixup routine */
> 		ft_board_setup(of_flat_tree, gd->bd);

Was thinking about this some more and realized I don't like  
fdt_memory() getting called via bootm w/o the board code have control.

I think Kim suggest we have a CONFIG_OF_MEMORY_FIXUP that this call is  
wrapped around.  But leave fdt_memory() available.  I want it such  
that the board code/config is in control of what fixups gets called  
for it.

There are cases in which we don't want fdt_memory() called as it stands.

- k

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-11-20 20:34 ` Kumar Gala
@ 2007-11-27  8:02   ` Martin Krause
  2007-11-27 14:13     ` Kumar Gala
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Krause @ 2007-11-27  8:02 UTC (permalink / raw)
  To: u-boot

Hi Kumar,

sorry for the late response. I've been very busy the last days ...

Kumar Gala wrote on Tuesday, November 20, 2007 9:34 PM:
> > diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
> > index d816349..3381c07 100644
> > --- a/common/cmd_bootm.c
> > +++ b/common/cmd_bootm.c
> > @@ -992,6 +992,16 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
> > 			do_reset (cmdtp, flag, argc, argv);
> > 		}
> > #endif
> > +		/*
> > +		 * Add the "/memory" node if it does not exist, and do a fixup
> > +		 * of the "reg" property with values detected by U-Boot
> > +		 * (taken from bd->bi_memstart and bd->bi_memsize). +		 */
> > +		if (fdt_memory(of_flat_tree) < 0) {
> > +			puts ("ERROR: /memory node create failed - "
> > +				"must RESET the board to recover.\n");
> > +			do_reset (cmdtp, flag, argc, argv);
> > +		}
> > #ifdef CONFIG_OF_BOARD_SETUP
> > 		/* Call the board-specific fixup routine */
> > 		ft_board_setup(of_flat_tree, gd->bd);
> 
> Was thinking about this some more and realized I don't like
> fdt_memory() getting called via bootm w/o the board code have control.
> 
> I think Kim suggest we have a CONFIG_OF_MEMORY_FIXUP that this call is
> wrapped around.  But leave fdt_memory() available.  I want it such
> that the board code/config is in control of what fixups gets called
> for it.

That's funny. My first patch wrapped the fixup in CONFIG_OF_MEMORY_FIXUP
and it was you, who suggested to drop this ;-). AFAIR Kim suggested to
wrap it in the existing OF_LIBFDT instead - what I did then. But I 
have no objections, if you put CONFIG_OF_MEMORY_FIXUP in place again.

Best Regards,
Martin Krause

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-11-27  8:02   ` Martin Krause
@ 2007-11-27 14:13     ` Kumar Gala
  2007-11-27 16:39       ` Kim Phillips
  0 siblings, 1 reply; 26+ messages in thread
From: Kumar Gala @ 2007-11-27 14:13 UTC (permalink / raw)
  To: u-boot

>> Was thinking about this some more and realized I don't like
>> fdt_memory() getting called via bootm w/o the board code have  
>> control.
>>
>> I think Kim suggest we have a CONFIG_OF_MEMORY_FIXUP that this call  
>> is
>> wrapped around.  But leave fdt_memory() available.  I want it such
>> that the board code/config is in control of what fixups gets called
>> for it.
>
> That's funny. My first patch wrapped the fixup in  
> CONFIG_OF_MEMORY_FIXUP
> and it was you, who suggested to drop this ;-). AFAIR Kim suggested to
> wrap it in the existing OF_LIBFDT instead - what I did then. But I
> have no objections, if you put CONFIG_OF_MEMORY_FIXUP in place again.

Yeah, I know.  I realized later that we should leave it to board code  
to decide what it wants in such cases.  The reason for that is if you  
can envision having multiple device trees in multiprocessor system  
with each processor running a different OS.

- k

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-11-27 14:13     ` Kumar Gala
@ 2007-11-27 16:39       ` Kim Phillips
  2007-11-27 17:16         ` Kumar Gala
  0 siblings, 1 reply; 26+ messages in thread
From: Kim Phillips @ 2007-11-27 16:39 UTC (permalink / raw)
  To: u-boot

On Tue, 27 Nov 2007 08:13:07 -0600
Kumar Gala <galak@kernel.crashing.org> wrote:

> >> Was thinking about this some more and realized I don't like
> >> fdt_memory() getting called via bootm w/o the board code have  
> >> control.
> >>
> >> I think Kim suggest we have a CONFIG_OF_MEMORY_FIXUP that this call  
> >> is
> >> wrapped around.  But leave fdt_memory() available.  I want it such
> >> that the board code/config is in control of what fixups gets called
> >> for it.
> >
> > That's funny. My first patch wrapped the fixup in  
> > CONFIG_OF_MEMORY_FIXUP
> > and it was you, who suggested to drop this ;-). AFAIR Kim suggested to
> > wrap it in the existing OF_LIBFDT instead - what I did then. But I
> > have no objections, if you put CONFIG_OF_MEMORY_FIXUP in place again.
> 
> Yeah, I know.  I realized later that we should leave it to board code  
> to decide what it wants in such cases.  The reason for that is if you  
> can envision having multiple device trees in multiprocessor system  
> with each processor running a different OS.

so make it a weak fn then?

Kim

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-11-27 16:39       ` Kim Phillips
@ 2007-11-27 17:16         ` Kumar Gala
  2007-11-27 17:58           ` Kim Phillips
  0 siblings, 1 reply; 26+ messages in thread
From: Kumar Gala @ 2007-11-27 17:16 UTC (permalink / raw)
  To: u-boot


On Nov 27, 2007, at 10:39 AM, Kim Phillips wrote:

> On Tue, 27 Nov 2007 08:13:07 -0600
> Kumar Gala <galak@kernel.crashing.org> wrote:
>
>>>> Was thinking about this some more and realized I don't like
>>>> fdt_memory() getting called via bootm w/o the board code have
>>>> control.
>>>>
>>>> I think Kim suggest we have a CONFIG_OF_MEMORY_FIXUP that this call
>>>> is
>>>> wrapped around.  But leave fdt_memory() available.  I want it such
>>>> that the board code/config is in control of what fixups gets called
>>>> for it.
>>>
>>> That's funny. My first patch wrapped the fixup in
>>> CONFIG_OF_MEMORY_FIXUP
>>> and it was you, who suggested to drop this ;-). AFAIR Kim  
>>> suggested to
>>> wrap it in the existing OF_LIBFDT instead - what I did then. But I
>>> have no objections, if you put CONFIG_OF_MEMORY_FIXUP in place  
>>> again.
>>
>> Yeah, I know.  I realized later that we should leave it to board code
>> to decide what it wants in such cases.  The reason for that is if you
>> can envision having multiple device trees in multiprocessor system
>> with each processor running a different OS.
>
> so make it a weak fn then?

weak doesn't cover it.  I don't want to implement my own version of  
fdt_memory_fixup().  I want to control how its called.

- k

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [U-Boot-Users] [PATCH] fdt: add common memory fixup function
  2007-11-27 17:16         ` Kumar Gala
@ 2007-11-27 17:58           ` Kim Phillips
  0 siblings, 0 replies; 26+ messages in thread
From: Kim Phillips @ 2007-11-27 17:58 UTC (permalink / raw)
  To: u-boot

On Tue, 27 Nov 2007 11:16:50 -0600
Kumar Gala <galak@kernel.crashing.org> wrote:

> 
> On Nov 27, 2007, at 10:39 AM, Kim Phillips wrote:
> 
> > On Tue, 27 Nov 2007 08:13:07 -0600
> > Kumar Gala <galak@kernel.crashing.org> wrote:
> >
> >>>> Was thinking about this some more and realized I don't like
> >>>> fdt_memory() getting called via bootm w/o the board code have
> >>>> control.
> >>>>
> >>>> I think Kim suggest we have a CONFIG_OF_MEMORY_FIXUP that this call
> >>>> is
> >>>> wrapped around.  But leave fdt_memory() available.  I want it such
> >>>> that the board code/config is in control of what fixups gets called
> >>>> for it.
> >>>
> >>> That's funny. My first patch wrapped the fixup in
> >>> CONFIG_OF_MEMORY_FIXUP
> >>> and it was you, who suggested to drop this ;-). AFAIR Kim  
> >>> suggested to
> >>> wrap it in the existing OF_LIBFDT instead - what I did then. But I
> >>> have no objections, if you put CONFIG_OF_MEMORY_FIXUP in place  
> >>> again.
> >>
> >> Yeah, I know.  I realized later that we should leave it to board code
> >> to decide what it wants in such cases.  The reason for that is if you
> >> can envision having multiple device trees in multiprocessor system
> >> with each processor running a different OS.
> >
> > so make it a weak fn then?
> 
> weak doesn't cover it.  I don't want to implement my own version of  
> fdt_memory_fixup().  I want to control how its called.

ya, ok.  I see this now.

Kim

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2007-11-27 17:58 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-26  8:49 [U-Boot-Users] [PATCH] fdt: add common memory fixup function Martin Krause
2007-10-26  9:55 ` Kumar Gala
2007-10-26 10:09   ` Martin Krause
2007-10-26 11:14 ` Jerry Van Baren
2007-10-26 11:26   ` Martin Krause
2007-10-26 11:27     ` Jerry Van Baren
  -- strict thread matches above, loose matches on Subject: below --
2007-10-26 11:47 Martin Krause
2007-11-20 20:34 ` Kumar Gala
2007-11-27  8:02   ` Martin Krause
2007-11-27 14:13     ` Kumar Gala
2007-11-27 16:39       ` Kim Phillips
2007-11-27 17:16         ` Kumar Gala
2007-11-27 17:58           ` Kim Phillips
2007-10-25 13:43 Martin Krause
2007-10-25 14:13 ` Jerry Van Baren
2007-10-25 15:05   ` Kumar Gala
2007-10-26  0:01     ` Wolfgang Denk
2007-10-26  4:57       ` Kumar Gala
2007-10-26 10:00         ` Wolfgang Denk
2007-10-26 11:26         ` Jerry Van Baren
2007-10-26 14:45           ` Kumar Gala
2007-10-25 14:39 ` Kim Phillips
2007-10-25 15:47   ` Martin Krause
2007-10-25 15:05 ` Kumar Gala
2007-10-25 15:57   ` Martin Krause
2007-10-25 16:08     ` Kim Phillips

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox