public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] fdt: Add fdt_fixup_nor_flash_size() to fixup NOR FLASH size in dtb
@ 2009-10-21 11:25 Stefan Roese
  2009-10-22 22:10 ` Jerry Van Baren
  2009-10-23 13:54 ` Stefan Roese
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Roese @ 2009-10-21 11:25 UTC (permalink / raw)
  To: u-boot

This function can be used to update the size in the "reg" property
of the NOR FLASH device nodes. This is necessary for boards with
non-fixed NOR FLASH sizes.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Gerald Van Baren <vanbaren@cideas.com>
---
 common/fdt_support.c  |   44 ++++++++++++++++++++++++++++++++++++++++++++
 include/fdt_support.h |    2 ++
 2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 89164a1..40ff00a 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -692,3 +692,47 @@ int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose) {
 	return 0;
 }
 #endif
+
+#ifdef CONFIG_FDT_FIXUP_NOR_FLASH_SIZE
+/*
+ * This function can be used to update the size in the "reg" property
+ * of the NOR FLASH device nodes. This is necessary for boards with
+ * non-fixed NOR FLASH sizes.
+ */
+int fdt_fixup_nor_flash_size(void *blob, int cs, u32 size)
+{
+	char compat[][16] = { "cfi-flash", "jedec-flash" };
+	int off;
+	int len;
+	struct fdt_property *prop;
+	u32 *reg;
+	int i;
+
+	for (i = 0; i < 2; i++) {
+		off = fdt_node_offset_by_compatible(blob, -1, compat[i]);
+		while (off != -FDT_ERR_NOTFOUND) {
+			/*
+			 * Found one compatible node, now check if this one
+			 * has the correct CS
+			 */
+			prop = fdt_get_property_w(blob, off, "reg", &len);
+			if (prop) {
+				reg = (u32 *)&prop->data[0];
+				if (reg[0] == cs) {
+					reg[2] = size;
+					fdt_setprop(blob, off, "reg", reg,
+						    3 * sizeof(u32));
+
+					return 0;
+				}
+			}
+
+			/* Move to next compatible node */
+			off = fdt_node_offset_by_compatible(blob, off,
+							    compat[i]);
+		}
+	}
+
+	return -1;
+}
+#endif
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 16734c5..0a9dd0d 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -79,5 +79,7 @@ void ft_pci_setup(void *blob, bd_t *bd);
 void set_working_fdt_addr(void *addr);
 int fdt_resize(void *blob);
 
+int fdt_fixup_nor_flash_size(void *blob, int cs, u32 size);
+
 #endif /* ifdef CONFIG_OF_LIBFDT */
 #endif /* ifndef __FDT_SUPPORT_H */
-- 
1.6.5.1

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

* [U-Boot] [PATCH 1/2] fdt: Add fdt_fixup_nor_flash_size() to fixup NOR FLASH size in dtb
  2009-10-21 11:25 [U-Boot] [PATCH 1/2] fdt: Add fdt_fixup_nor_flash_size() to fixup NOR FLASH size in dtb Stefan Roese
@ 2009-10-22 22:10 ` Jerry Van Baren
  2009-10-23  8:33   ` Wolfgang Denk
  2009-10-23 13:54 ` Stefan Roese
  1 sibling, 1 reply; 5+ messages in thread
From: Jerry Van Baren @ 2009-10-22 22:10 UTC (permalink / raw)
  To: u-boot

Hi Stefan, Wolfgang,

Stefan Roese wrote:
> This function can be used to update the size in the "reg" property
> of the NOR FLASH device nodes. This is necessary for boards with
> non-fixed NOR FLASH sizes.
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Gerald Van Baren <vanbaren@cideas.com>

Looking at the code, I'm OK with it.

Are you looking to get this into the current release (v2009.11) as a 
bugfix or the next release (v2010.02)?

If you need it in the v2009.11 release, you have my
   Acked-by Gerald Van Baren <vanbaren@cideas.com>
and I suggest you run it through the ppc4xx repository with its sister 
patch.

Thanks,
gvb

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

* [U-Boot] [PATCH 1/2] fdt: Add fdt_fixup_nor_flash_size() to fixup NOR FLASH size in dtb
  2009-10-22 22:10 ` Jerry Van Baren
@ 2009-10-23  8:33   ` Wolfgang Denk
  2009-10-23  9:22     ` Stefan Roese
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Denk @ 2009-10-23  8:33 UTC (permalink / raw)
  To: u-boot

Dear Jerry Van Baren,

In message <4AE0D860.7030305@gmail.com> you wrote:
> 
> Stefan Roese wrote:
> > This function can be used to update the size in the "reg" property
> > of the NOR FLASH device nodes. This is necessary for boards with
> > non-fixed NOR FLASH sizes.
> > 
> > Signed-off-by: Stefan Roese <sr@denx.de>
> > Cc: Wolfgang Denk <wd@denx.de>
> > Cc: Gerald Van Baren <vanbaren@cideas.com>
> 
> Looking at the code, I'm OK with it.
> 
> Are you looking to get this into the current release (v2009.11) as a 
> bugfix or the next release (v2010.02)?

I consider it a bug fix, as failing to adjust the flash size prevents
booting on some boards where the real flash size deviates from the
entry in the default DT in the Linux kernel.

> If you need it in the v2009.11 release, you have my
>    Acked-by Gerald Van Baren <vanbaren@cideas.com>
> and I suggest you run it through the ppc4xx repository with its sister 
> patch.

Thanks.

Stefan - also

Acked-by: Wolfgang Denk <wd@denx.de> 

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
If it went on at this rate, in several billion  years  he'd  be  rich
beyond his wildest dreams!            - Terry Pratchett, _Soul Music_

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

* [U-Boot] [PATCH 1/2] fdt: Add fdt_fixup_nor_flash_size() to fixup NOR FLASH size in dtb
  2009-10-23  8:33   ` Wolfgang Denk
@ 2009-10-23  9:22     ` Stefan Roese
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Roese @ 2009-10-23  9:22 UTC (permalink / raw)
  To: u-boot

On Friday 23 October 2009 10:33:10 Wolfgang Denk wrote:
> > Looking at the code, I'm OK with it.
> >
> > Are you looking to get this into the current release (v2009.11) as a
> > bugfix or the next release (v2010.02)?
> 
> I consider it a bug fix, as failing to adjust the flash size prevents
> booting on some boards where the real flash size deviates from the
> entry in the default DT in the Linux kernel.
> 
> > If you need it in the v2009.11 release, you have my
> >    Acked-by Gerald Van Baren <vanbaren@cideas.com>
> > and I suggest you run it through the ppc4xx repository with its sister
> > patch.
> 
> Thanks.
> 
> Stefan - also
> 
> Acked-by: Wolfgang Denk <wd@denx.de>

Thanks. I'll integrate this and other patches into the ppc4xx repository and 
send a pull request later today.
 
Cheers,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de

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

* [U-Boot] [PATCH 1/2] fdt: Add fdt_fixup_nor_flash_size() to fixup NOR FLASH size in dtb
  2009-10-21 11:25 [U-Boot] [PATCH 1/2] fdt: Add fdt_fixup_nor_flash_size() to fixup NOR FLASH size in dtb Stefan Roese
  2009-10-22 22:10 ` Jerry Van Baren
@ 2009-10-23 13:54 ` Stefan Roese
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Roese @ 2009-10-23 13:54 UTC (permalink / raw)
  To: u-boot

On Wednesday 21 October 2009 13:25:07 Stefan Roese wrote:
> This function can be used to update the size in the "reg" property
> of the NOR FLASH device nodes. This is necessary for boards with
> non-fixed NOR FLASH sizes.

Applied to u-boot-ppc4xx/master. Thanks.

Cheers,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de

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

end of thread, other threads:[~2009-10-23 13:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-21 11:25 [U-Boot] [PATCH 1/2] fdt: Add fdt_fixup_nor_flash_size() to fixup NOR FLASH size in dtb Stefan Roese
2009-10-22 22:10 ` Jerry Van Baren
2009-10-23  8:33   ` Wolfgang Denk
2009-10-23  9:22     ` Stefan Roese
2009-10-23 13:54 ` Stefan Roese

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