public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH 6/7] 83xx/fdt_support: let user specifiy FSL USB Dual-Role controller role
Date: Tue, 25 Mar 2008 19:06:34 +0300	[thread overview]
Message-ID: <20080325160634.GA13440@localhost.localdomain> (raw)
In-Reply-To: <20080325104211.dbc40a03.kim.phillips@freescale.com>

On Tue, Mar 25, 2008 at 10:42:11AM -0500, Kim Phillips wrote:
[...]
> > > 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.
> > 
> > Hm... maybe then it's better to place fdt_fixup_usb_dr function
> > inside the fdt_support.h, marking it with static inline -- it's used
> > just once per board anyway..? Then neither space wasted nor the new
> > configs introduced.
> 
> I'd like to see that.  Do you want to send a patch?

Sure, here it is.

- - - -
From: Anton Vorontsov <avorontsov@ru.mvista.com>
Subject: mpc83xx/fdt_support: let user specifiy FSL USB Dual-Role controller role

Linux understands "host" (default), "peripheral" and "otg" (broken).
Though, U-Boot doesn't restrict dr_mode variable to these values (think
of renames in future).

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 board/freescale/mpc837xerdb/mpc837xerdb.c |    2 ++
 include/fdt_support.h                     |   24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/board/freescale/mpc837xerdb/mpc837xerdb.c b/board/freescale/mpc837xerdb/mpc837xerdb.c
index d091538..70f52da 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 <asm/fsl_serdes.h>
@@ -197,5 +198,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/include/fdt_support.h b/include/fdt_support.h
index 7836f28..933ef41 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -27,6 +27,7 @@
 #ifdef CONFIG_OF_LIBFDT
 
 #include <fdt.h>
+#include <libfdt.h>
 
 int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force);
 void do_fixup_by_path(void *fdt, const char *path, const char *prop,
@@ -64,5 +65,28 @@ void ft_cpu_setup(void *blob, bd_t *bd);
 void ft_pci_setup(void *blob, bd_t *bd);
 #endif
 
+static inline 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 /* ifdef CONFIG_OF_LIBFDT */
 #endif /* ifndef __FDT_SUPPORT_H */
-- 
1.5.2.2

  reply	other threads:[~2008-03-25 16:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-14 20:20 [U-Boot-Users] [PATCH 6/7] 83xx/fdt_support: let user specifiy FSL USB Dual-Role controller role Anton Vorontsov
2008-03-20  1:35 ` Kim Phillips
2008-03-24 14:44   ` Anton Vorontsov
2008-03-24 23:00     ` Kim Phillips
2008-03-25 13:48       ` Anton Vorontsov
2008-03-25 15:42         ` Kim Phillips
2008-03-25 16:06           ` Anton Vorontsov [this message]
2008-03-25 16:32             ` Jerry Van Baren
2008-03-25 16:33             ` Kim Phillips
2008-03-25 16:35               ` Jerry Van Baren
2008-03-26  0:27 ` Kim Phillips

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080325160634.GA13440@localhost.localdomain \
    --to=avorontsov@ru.mvista.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox