[U-Boot-Users] [PATCH 6/7] 83xx/fdt_support: let user specifiy FSL USB Dual-Role controller role

Kim Phillips kim.phillips at freescale.com
Tue Mar 25 00:00:49 CET 2008


On Mon, 24 Mar 2008 17:44:19 +0300
Anton Vorontsov <avorontsov at ru.mvista.com> wrote:

> On Wed, Mar 19, 2008 at 08:35:58PM -0500, Kim Phillips wrote:
> > On Fri, 14 Mar 2008 23:20:18 +0300
> > Anton Vorontsov <avorontsov at ru.mvista.com> wrote:
> > 
> > 
> > > diff --git a/include/fdt_support.h b/include/fdt_support.h
> > > index 7836f28..c10de8a 100644
> > > --- a/include/fdt_support.h
> > > +++ b/include/fdt_support.h
> > > @@ -50,6 +50,12 @@ int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
> > >  			 const void *val, int len, int create);
> > >  void fdt_fixup_qe_firmware(void *fdt);
> > >  
> > > +#ifdef CONFIG_HAS_FSL_DR_USB
> > > +void fdt_fixup_dr_usb(void *blob, bd_t *bd);
> > > +#else
> > > +static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {}
> > > +#endif /* CONFIG_HAS_FSL_DR_USB */
> > > +
> > 
> > this looks like a prime candidate for a weak function (which would also
> > eliminate the need for the new CONFIG_HAS_FSL_DR_USB introduced here).
> 
> Are you sure it's supposed to work like this?.. I don't see the linker
> dropping unused weak symbols with the patch below.

with something like the following I get 24 bytes more text in
fdt_support.o, and 200 total bytes added 83xx-wide:

diff --git a/board/freescale/mpc837xerdb/mpc837xerdb.c b/board/freescale/mpc837xerdb/mpc837xerdb.c
index a3b20b8..e8d130c 100644
--- a/board/freescale/mpc837xerdb/mpc837xerdb.c
+++ b/board/freescale/mpc837xerdb/mpc837xerdb.c
@@ -13,6 +13,7 @@
  */
 
 #include <common.h>
+#include <fdt_support.h>
 #include <i2c.h>
 #include <asm/io.h>
 #include <spd_sdram.h>
@@ -153,6 +154,7 @@ int misc_init_r(void)
 }
 
 #if defined(CONFIG_OF_BOARD_SETUP)
+extern void fdt_fixup_dr_usb(void *);
 
 void ft_board_setup(void *blob, bd_t *bd)
 {
@@ -160,5 +162,6 @@ void ft_board_setup(void *blob, bd_t *bd)
 	ft_pci_setup(blob, bd);
 #endif
 	ft_cpu_setup(blob, bd);
+	fdt_fixup_dr_usb(blob);
 }
 #endif /* CONFIG_OF_BOARD_SETUP */
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 69eb667..355b741 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -615,3 +615,10 @@ void fdt_fixup_ethernet(void *fdt, bd_t *bd)
 	}
 }
 #endif
+
+void __fdt_fixup_dr_usb(void *fdt)
+{
+	/* add your own */
+}
+void fdt_fixup_dr_usb(void *fdt) __attribute__((weak,
+	alias("__fdt_fixup_dr_usb")));
diff --git a/cpu/mpc83xx/fdt.c b/cpu/mpc83xx/fdt.c
index 6f55932..3224286 100644
--- a/cpu/mpc83xx/fdt.c
+++ b/cpu/mpc83xx/fdt.c
@@ -68,4 +68,27 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 
 	fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
 }
+
+void fdt_fixup_dr_usb(void *fdt)
+{
+	char *mode;
+	const char *compat = "fsl-usb2-dr";
+	const char *prop = "dr_mode";
+	int node_offset;
+	int err;
+
+	mode = getenv("usb_dr_mode");
+	if (!mode)
+		return;
+
+	node_offset = fdt_node_offset_by_compatible(fdt, 0, compat);
+	if (node_offset < 0)
+		printf("WARNING: could not find compatible node %s: %s.\n",
+			compat, fdt_strerror(node_offset));
+
+	err = fdt_setprop(fdt, node_offset, prop, mode, strlen(mode) + 1);
+	if (err < 0)
+		printf("WARNING: could not set %s for %s: %s.\n",
+		       prop, compat, fdt_strerror(err));
+}
 #endif /* CONFIG_OF_LIBFDT */

but the QE based 83xx SoCs don't use this fixup.  So while
CONFIG_HAS_FSL_DR_USB gives you more control, I doubt saving 200 bytes
justifies the new config either.  Either way really, but I tend to be
against any new CONFIG_s.

Kim




More information about the U-Boot mailing list