diff mbox

[U-Boot,4/5] usb: ehci-mx6: Use shared wait_for_bit

Message ID 1450138168-25102-5-git-send-email-mateusz.kulikowski@gmail.com
State Changes Requested
Delegated to: Marek Vasut
Headers show

Commit Message

Mateusz Kulikowski Dec. 15, 2015, 12:09 a.m. UTC
Use existing library function to poll bit(s).
Update configs using ehci-mx6.

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
---

 drivers/usb/host/ehci-mx6.c           | 37 +++++++++--------------------------
 include/configs/aristainetos-common.h |  1 +
 include/configs/cgtqmx6eval.h         |  1 +
 include/configs/embestmx6boards.h     |  1 +
 include/configs/gw_ventana.h          |  1 +
 include/configs/mx6cuboxi.h           |  1 +
 include/configs/mx6qarm2.h            |  1 +
 include/configs/mx6qsabreauto.h       |  1 +
 include/configs/mx6sabresd.h          |  1 +
 include/configs/mx6slevk.h            |  1 +
 include/configs/mx6sxsabresd.h        |  1 +
 include/configs/mx6ul_14x14_evk.h     |  1 +
 include/configs/nitrogen6x.h          |  1 +
 include/configs/novena.h              |  1 +
 include/configs/ot1200.h              |  1 +
 include/configs/platinum.h            |  1 +
 include/configs/tbs2910.h             |  1 +
 include/configs/titanium.h            |  1 +
 include/configs/tqma6.h               |  1 +
 include/configs/wandboard.h           |  1 +
 include/configs/warp.h                |  1 +
 21 files changed, 29 insertions(+), 28 deletions(-)
diff mbox

Patch

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 2666351..ed269be 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -8,6 +8,7 @@ 
 #include <common.h>
 #include <usb.h>
 #include <errno.h>
+#include <wait_bit.h>
 #include <linux/compiler.h>
 #include <usb/ehci-fsl.h>
 #include <asm/io.h>
@@ -57,6 +58,11 @@ 
 #define UCMD_RESET		(1 << 1) /* controller reset */
 
 #if defined(CONFIG_MX6)
+
+#ifndef CONFIG_LIB_WAIT_BIT
+#error CONFIG_LIB_WAIT_BIT is required for ehci-mx6 driver
+#endif
+
 static const unsigned phy_bases[] = {
 	USB_PHY0_BASE_ADDR,
 	USB_PHY1_BASE_ADDR,
@@ -117,32 +123,6 @@  static void usb_power_config(int index)
 		     pll_480_ctrl_set);
 }
 
-static int wait_for_bit(u32 *reg, const u32 mask, bool set)
-{
-	u32 val;
-	const unsigned int timeout = 10000;
-	unsigned long start = get_timer(0);
-
-	while(1) {
-		val = readl(reg);
-		if (!set)
-			val = ~val;
-
-		if ((val & mask) == mask)
-			return 0;
-
-		if (get_timer(start) > timeout)
-			break;
-
-		udelay(1);
-	}
-
-	debug("%s: Timeout (reg=%p mask=%08x wait_set=%i)\n",
-			__func__, reg, mask, set);
-
-	return -ETIMEDOUT;
-}
-
 /* Return 0 : host node, <>0 : device mode */
 static int usb_phy_enable(int index, struct usb_ehci *ehci)
 {
@@ -160,12 +140,13 @@  static int usb_phy_enable(int index, struct usb_ehci *ehci)
 
 	/* Stop then Reset */
 	clrbits_le32(usb_cmd, UCMD_RUN_STOP);
-	ret = wait_for_bit(usb_cmd, UCMD_RUN_STOP, 0);
+	ret = wait_for_bit(__func__, usb_cmd, UCMD_RUN_STOP, false, 10000,
+			   false);
 	if (ret)
 		return ret;
 
 	setbits_le32(usb_cmd, UCMD_RESET);
-	ret = wait_for_bit(usb_cmd, UCMD_RESET, 0);
+	ret = wait_for_bit(__func__, usb_cmd, UCMD_RESET, false, 10000, false);
 	if (ret)
 		return ret;
 
diff --git a/include/configs/aristainetos-common.h b/include/configs/aristainetos-common.h
index 0b97ccc..c97c352 100644
--- a/include/configs/aristainetos-common.h
+++ b/include/configs/aristainetos-common.h
@@ -218,6 +218,7 @@ 
 /* USB Configs */
 #define CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_USB_MAX_CONTROLLER_COUNT 2
diff --git a/include/configs/cgtqmx6eval.h b/include/configs/cgtqmx6eval.h
index 487c011..380e1c8 100644
--- a/include/configs/cgtqmx6eval.h
+++ b/include/configs/cgtqmx6eval.h
@@ -75,6 +75,7 @@ 
 #define CONFIG_CMD_USB
 #define CONFIG_CMD_FAT
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET
diff --git a/include/configs/embestmx6boards.h b/include/configs/embestmx6boards.h
index 90cd959..feaa78e 100644
--- a/include/configs/embestmx6boards.h
+++ b/include/configs/embestmx6boards.h
@@ -41,6 +41,7 @@ 
 /* USB Configs */
 #define CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_USB_HOST_ETHER
diff --git a/include/configs/gw_ventana.h b/include/configs/gw_ventana.h
index b7b9c78..b672aab 100644
--- a/include/configs/gw_ventana.h
+++ b/include/configs/gw_ventana.h
@@ -178,6 +178,7 @@ 
 /* USB Configs */
 #define CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_USB_HOST_ETHER
diff --git a/include/configs/mx6cuboxi.h b/include/configs/mx6cuboxi.h
index 4feb121..8363b27 100644
--- a/include/configs/mx6cuboxi.h
+++ b/include/configs/mx6cuboxi.h
@@ -58,6 +58,7 @@ 
 /* USB */
 #define CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET
diff --git a/include/configs/mx6qarm2.h b/include/configs/mx6qarm2.h
index 86a0316..588eb76 100644
--- a/include/configs/mx6qarm2.h
+++ b/include/configs/mx6qarm2.h
@@ -135,6 +135,7 @@ 
 #define CONFIG_CMD_USB
 #ifdef CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET
diff --git a/include/configs/mx6qsabreauto.h b/include/configs/mx6qsabreauto.h
index 1c99805..641a5bc 100644
--- a/include/configs/mx6qsabreauto.h
+++ b/include/configs/mx6qsabreauto.h
@@ -18,6 +18,7 @@ 
 /* USB Configs */
 #define CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_USB_HOST_ETHER
diff --git a/include/configs/mx6sabresd.h b/include/configs/mx6sabresd.h
index bfc4f61..66b9405 100644
--- a/include/configs/mx6sabresd.h
+++ b/include/configs/mx6sabresd.h
@@ -58,6 +58,7 @@ 
 #define CONFIG_CMD_USB
 #ifdef CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET
diff --git a/include/configs/mx6slevk.h b/include/configs/mx6slevk.h
index 6937924..23938ac 100644
--- a/include/configs/mx6slevk.h
+++ b/include/configs/mx6slevk.h
@@ -182,6 +182,7 @@ 
 #define CONFIG_CMD_USB
 #ifdef CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET
diff --git a/include/configs/mx6sxsabresd.h b/include/configs/mx6sxsabresd.h
index 0aec296..8f967d5 100644
--- a/include/configs/mx6sxsabresd.h
+++ b/include/configs/mx6sxsabresd.h
@@ -158,6 +158,7 @@ 
 #define CONFIG_CMD_USB
 #ifdef CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET
diff --git a/include/configs/mx6ul_14x14_evk.h b/include/configs/mx6ul_14x14_evk.h
index 2712b27..1afefd4 100644
--- a/include/configs/mx6ul_14x14_evk.h
+++ b/include/configs/mx6ul_14x14_evk.h
@@ -211,6 +211,7 @@ 
 #define CONFIG_CMD_USB
 #ifdef CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET
diff --git a/include/configs/nitrogen6x.h b/include/configs/nitrogen6x.h
index 3416ce3..0d72e0b 100644
--- a/include/configs/nitrogen6x.h
+++ b/include/configs/nitrogen6x.h
@@ -84,6 +84,7 @@ 
 /* USB Configs */
 #define CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_USB_HOST_ETHER
diff --git a/include/configs/novena.h b/include/configs/novena.h
index 4b4f2d7..3371ced 100644
--- a/include/configs/novena.h
+++ b/include/configs/novena.h
@@ -153,6 +153,7 @@ 
 /* USB Configs */
 #ifdef CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_USB_KEYBOARD
diff --git a/include/configs/ot1200.h b/include/configs/ot1200.h
index 879ad58..5b5ec9f 100644
--- a/include/configs/ot1200.h
+++ b/include/configs/ot1200.h
@@ -61,6 +61,7 @@ 
 #define CONFIG_CMD_USB
 #define CONFIG_USB_STORAGE
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_MXC_USB_PORTSC   (PORT_PTS_UTMI | PORT_PTS_PTW)
 #define CONFIG_USB_MAX_CONTROLLER_COUNT 2
diff --git a/include/configs/platinum.h b/include/configs/platinum.h
index bb7e845..94ab45d 100644
--- a/include/configs/platinum.h
+++ b/include/configs/platinum.h
@@ -63,6 +63,7 @@ 
 
 /* USB config */
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_MXC_USB_PORT			1
diff --git a/include/configs/tbs2910.h b/include/configs/tbs2910.h
index 17b0213..f3b2f60 100644
--- a/include/configs/tbs2910.h
+++ b/include/configs/tbs2910.h
@@ -122,6 +122,7 @@ 
 #define CONFIG_CMD_USB
 #ifdef CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_MAX_CONTROLLER_COUNT 2
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET
diff --git a/include/configs/titanium.h b/include/configs/titanium.h
index acfa84a..1d4b143 100644
--- a/include/configs/titanium.h
+++ b/include/configs/titanium.h
@@ -57,6 +57,7 @@ 
 /* USB Configs */
 #define CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_MXC_USB_PORT	1
diff --git a/include/configs/tqma6.h b/include/configs/tqma6.h
index 31d7757..7ac6032 100644
--- a/include/configs/tqma6.h
+++ b/include/configs/tqma6.h
@@ -93,6 +93,7 @@ 
 /* USB Configs */
 #define CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_USB_HOST_ETHER
diff --git a/include/configs/wandboard.h b/include/configs/wandboard.h
index 4c8e9e9..8ecf8df 100644
--- a/include/configs/wandboard.h
+++ b/include/configs/wandboard.h
@@ -50,6 +50,7 @@ 
 /* USB Configs */
 #define CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_USB_MAX_CONTROLLER_COUNT	2
diff --git a/include/configs/warp.h b/include/configs/warp.h
index 3e9a5a3..e2ebc86 100644
--- a/include/configs/warp.h
+++ b/include/configs/warp.h
@@ -66,6 +66,7 @@ 
 #define CONFIG_CMD_USB
 #ifdef CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_LIB_WAIT_BIT
 #define CONFIG_USB_EHCI_MX6
 #define CONFIG_USB_STORAGE
 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET