All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] drivers:usb:common:fsl-dt-fixup: Fix the dt for all type of usb controllers
@ 2016-06-20  4:15 Sriram Dash
  2016-06-20 14:16 ` Marek Vasut
  2016-08-17  8:16 ` [U-Boot] [PATCH v2] drivers: usb: fsl-dt-fixup: Fix the dt for multiple USB nodes in single traversal of device tree Sriram Dash
  0 siblings, 2 replies; 13+ messages in thread
From: Sriram Dash @ 2016-06-20  4:15 UTC (permalink / raw)
  To: u-boot

Currently, U-boot doesn't allow to compile more than one type of USB protocol
simultaneously. Hence, EHCI and XHCI controllers cannot co-exist and
CONFIG_USB_MAX_CONTROLLER_COUNT macro represents count of only one type of
controller.

For the Socs which have more than one type of controller e.g. EHCI and XHCI,
and the device tree has to support both of them, the macro
CONFIG_USB_MAX_CONTROLLER_COUNT will not work for fixing dt from u boot.

So, instead of taking the hard coded number of controller from U boot,
count the total number of controller present in dt and then fix the dt
accordingly.

Signed-off-by: Sriram Dash <sriram.dash@nxp.com>
Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
---
 drivers/usb/common/fsl-dt-fixup.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/common/fsl-dt-fixup.c b/drivers/usb/common/fsl-dt-fixup.c
index 9c48852..1edf146 100644
--- a/drivers/usb/common/fsl-dt-fixup.c
+++ b/drivers/usb/common/fsl-dt-fixup.c
@@ -131,10 +131,29 @@ static int fdt_fixup_erratum(int *usb_erratum_off, void *blob,
 	return 0;
 }
 
+static int fdt_max_controller_count(void *blob)
+{
+	int count = 0;
+	int node_offset = -1;
+	int i;
+
+	for (i = 0; compat_usb_fsl[i]; i++) {
+		do {
+			node_offset = fdt_node_offset_by_compatible
+					(blob, node_offset,
+					 compat_usb_fsl[i]);
+			if (node_offset >= 0)
+				count++;
+		} while (node_offset != -FDT_ERR_NOTFOUND);
+	}
+	return count;
+}
+
 void fdt_fixup_dr_usb(void *blob, bd_t *bd)
 {
 	static const char * const modes[] = { "host", "peripheral", "otg" };
 	static const char * const phys[] = { "ulpi", "utmi", "utmi_dual" };
+	unsigned int usb_max_controller_count;
 	int usb_erratum_a006261_off = -1;
 	int usb_erratum_a007075_off = -1;
 	int usb_erratum_a007792_off = -1;
@@ -146,7 +165,13 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd)
 	int i, j;
 	int ret;
 
-	for (i = 1; i <= CONFIG_USB_MAX_CONTROLLER_COUNT; i++) {
+	usb_max_controller_count = fdt_max_controller_count(blob);
+	if (!usb_max_controller_count) {
+		printf("ERROR: FDT fixup erratum fail.\n");
+		return;
+	}
+
+	for (i = 1; i <= usb_max_controller_count; i++) {
 		const char *dr_mode_type = NULL;
 		const char *dr_phy_type = NULL;
 		int mode_idx = -1, phy_idx = -1;
-- 
2.1.0

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

end of thread, other threads:[~2016-09-16 10:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-20  4:15 [U-Boot] [PATCH] drivers:usb:common:fsl-dt-fixup: Fix the dt for all type of usb controllers Sriram Dash
2016-06-20 14:16 ` Marek Vasut
2016-07-20  3:55   ` Sriram Dash
2016-07-20  5:57     ` Marek Vasut
2016-08-17  8:16 ` [U-Boot] [PATCH v2] drivers: usb: fsl-dt-fixup: Fix the dt for multiple USB nodes in single traversal of device tree Sriram Dash
2016-09-14  5:22   ` Sriram Dash
2016-09-14 21:22     ` Marek Vasut
2016-09-14 22:29       ` york sun
2016-09-15  6:40         ` Sriram Dash
2016-09-15 22:01         ` Marek Vasut
2016-09-16  8:47           ` Sriram Dash
2016-09-16  9:17             ` Marek Vasut
2016-09-16 10:27               ` Sriram Dash

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.