[U-Boot] [PATCH 3/6] fsl_dr_usb: Fixup disabled USB controllers nodes in device tree

Anton Vorontsov avorontsov at ru.mvista.com
Thu Feb 19 16:45:47 CET 2009


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 at ru.mvista.com>
---
 drivers/usb/fsl_dr_usb.c |   44 +++++++++++++++++---------------------------
 1 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/drivers/usb/fsl_dr_usb.c b/drivers/usb/fsl_dr_usb.c
index af9797f..a646846 100644
--- a/drivers/usb/fsl_dr_usb.c
+++ b/drivers/usb/fsl_dr_usb.c
@@ -10,43 +10,33 @@
  */
 
 #include <common.h>
-#include <libfdt.h>
+#include <fsl_can_use.h>
+#include <fdt_support.h>
 
 void fdt_fixup_dr_usb(void *blob, bd_t *bd)
 {
+	const char *compat = "fsl-usb2-dr";
 	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;
+
+	if (!fsl_can_use_dr_usb()) {
+		const char *reason = "disabled";
+
+		do_fixup_by_compat(blob, compat, "status", reason,
+				   strlen(reason) + 1, 1);
+		return;
+	}
 
 	mode = getenv("usb_dr_mode");
 	type = getenv("usb_phy_type");
 	if (!mode && !type)
 		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));
-		return;
-	}
+	if (mode)
+		do_fixup_by_compat(blob, compat, "dr_mode", mode,
+				   strlen(mode) + 1, 1);
 
-	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));
-	}
-
-	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));
-	}
+	if (type)
+		do_fixup_by_compat(blob, compat, "type", type,
+				   strlen(type) + 1, 1);
 }
-- 
1.5.6.5



More information about the U-Boot mailing list