All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 6/8] fsl_dr_usb: Fixup disabled USB controllers nodes in	device tree
Date: Thu, 30 Apr 2009 01:50:06 +0400	[thread overview]
Message-ID: <20090429215006.GF1092@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <20090429214819.GA346@oksana.dev.rtsoft.ru>

We should add status = "disabled" property when USB controller can't
be used (for example when USB pins muxed away to another device).

Also convert whole fdt_fixup_dr_usb() to use more compact routines
from fdt_support.h.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 cpu/mpc83xx/cpu.c            |    4 +++
 drivers/usb/otg/fsl_dr_usb.c |   60 ++++++++++++++++++++++++-----------------
 2 files changed, 39 insertions(+), 25 deletions(-)

diff --git a/cpu/mpc83xx/cpu.c b/cpu/mpc83xx/cpu.c
index 876f5c7..034958c 100644
--- a/cpu/mpc83xx/cpu.c
+++ b/cpu/mpc83xx/cpu.c
@@ -404,6 +404,10 @@ int cpu_mmc_init(bd_t *bis)
 #endif
 }
 
+#ifdef CONFIG_HWCONFIG
+const char *cpu_hwconfig = "dr_usb";
+#endif
+
 #ifdef CONFIG_BOOTCOUNT_LIMIT
 
 #if !defined(CONFIG_MPC8360)
diff --git a/drivers/usb/otg/fsl_dr_usb.c b/drivers/usb/otg/fsl_dr_usb.c
index af9797f..97584f8 100644
--- a/drivers/usb/otg/fsl_dr_usb.c
+++ b/drivers/usb/otg/fsl_dr_usb.c
@@ -10,43 +10,53 @@
  */
 
 #include <common.h>
-#include <libfdt.h>
+#include <malloc.h>
+#include <hwconfig.h>
+#include <fdt_support.h>
 
 void fdt_fixup_dr_usb(void *blob, bd_t *bd)
 {
-	char *mode;
-	char *type;
 	const char *compat = "fsl-usb2-dr";
-	const char *prop_mode = "dr_mode";
-	const char *prop_type = "phy_type";
-	int node_offset;
-	int err;
-
-	mode = getenv("usb_dr_mode");
-	type = getenv("usb_phy_type");
-	if (!mode && !type)
+	const char *mode;
+	const char *type;
+	size_t modelen = 0;
+	size_t typelen = 0;
+	char *buf;
+	size_t bufsz;
+
+	if (!hwconfig("dr_usb")) {
+		const char *reason = "disabled";
+
+		do_fixup_by_compat(blob, compat, "status", reason,
+				   strlen(reason) + 1, 1);
+		return;
+	}
+
+	mode = hwconfig_arg("dr_usb_mode", &modelen);
+	type = hwconfig_arg("dr_usb_phy_type", &typelen);
+	bufsz = max(modelen, typelen);
+	if (!bufsz)
 		return;
 
-	node_offset = fdt_node_offset_by_compatible(blob, 0, compat);
-	if (node_offset < 0) {
-		printf("WARNING: could not find compatible node %s: %s.\n",
-			compat, fdt_strerror(node_offset));
+	buf = malloc(bufsz + 1);
+	if (!buf) {
+		printf("%s: unable to allocate memory\n", __func__);
 		return;
 	}
 
 	if (mode) {
-		err = fdt_setprop(blob, node_offset, prop_mode, mode,
-				  strlen(mode) + 1);
-		if (err < 0)
-			printf("WARNING: could not set %s for %s: %s.\n",
-			       prop_mode, compat, fdt_strerror(err));
+		strcpy(buf, mode);
+		buf[modelen] = '\0';
+		do_fixup_by_compat(blob, compat, "dr_mode", buf,
+				   modelen + 1, 1);
 	}
 
 	if (type) {
-		err = fdt_setprop(blob, node_offset, prop_type, type,
-				  strlen(type) + 1);
-		if (err < 0)
-			printf("WARNING: could not set %s for %s: %s.\n",
-			       prop_type, compat, fdt_strerror(err));
+		strcpy(buf, type);
+		buf[typelen] = '\0';
+		do_fixup_by_compat(blob, compat, "phy_type", buf,
+				   typelen + 1, 1);
 	}
+
+	free(buf);
 }
-- 
1.6.2.2

  parent reply	other threads:[~2009-04-29 21:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-29 21:48 [U-Boot] [PATCH 0/8] hwconfig and some its users (was: Re: [PATCH 2/6] Add FSL "Can use" framework) Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure Anton Vorontsov
2009-04-29 21:59   ` Anton Vorontsov
2009-04-30 20:00   ` Kim Phillips
2009-04-30 20:22     ` Anton Vorontsov
2009-04-30 22:31   ` Wolfgang Denk
2009-04-30 23:12     ` Anton Vorontsov
2009-05-01  7:33       ` Wolfgang Denk
2009-06-02 20:51   ` Andy Fleming
2009-06-02 22:11     ` Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 2/8] fsl_esdhc: Add device tree fixups Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 3/8] mpc83xx: MPC837XERDB: Add support for FSL eSDHC Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 4/8] mpc83xx: MPC837XEMDS: Fixup eSDHC nodes in device tree Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 5/8] fdt_support, usb: Move fdt_fixup_dr_usb routine to drivers/usb/otg Anton Vorontsov
2009-04-29 21:50 ` Anton Vorontsov [this message]
2009-04-29 21:50 ` [U-Boot] [PATCH 7/8] mpc83xx: MPC8315ERDB: Use hwconfig for board type selection Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 8/8] mpc83xx: MPC837xEMDS: Use hwconfig instead of pci_external_arbiter variable Anton Vorontsov
  -- strict thread matches above, loose matches on Subject: below --
2009-06-09 20:23 [U-Boot] [PATCH v3 0/8] hwconfig and some its users Anton Vorontsov
2009-06-09 20:25 ` [U-Boot] [PATCH 6/8] fsl_dr_usb: Fixup disabled USB controllers nodes in device tree Anton Vorontsov
2009-07-16 20:46   ` Wolfgang Denk

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=20090429215006.GF1092@oksana.dev.rtsoft.ru \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.