diff mbox

[U-Boot,3/5] usb: ohci-lpc32xx: Use shared wait_for_bit

Message ID 1450138168-25102-4-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).
No config files are updated, as there is no board using this driver.

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

 drivers/usb/host/ohci-lpc32xx.c | 36 ++++++++++--------------------------
 1 file changed, 10 insertions(+), 26 deletions(-)

Comments

LEMIEUX, SYLVAIN Dec. 15, 2015, 6:49 p.m. UTC | #1
> From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Mateusz Kulikowski
> Sent: 14-Dec-15 7:09 PM
> To: u-boot@lists.denx.de; Marek Vasut; Joe Hershberger
> Subject: [U-Boot] [PATCH 3/5] usb: ohci-lpc32xx: Use shared wait_for_bit
>
> Use existing library function to poll bit(s).
> No config files are updated, as there is no board using this driver.

I tested the change using our custom lpc32xx board.

>
> Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
> ---
>
>  drivers/usb/host/ohci-lpc32xx.c | 36 ++++++++++--------------------------
>  1 file changed, 10 insertions(+), 26 deletions(-)
>

...
Tested-by: Sylvain Lemieux <slemieux@tycoint.com>
Mateusz Kulikowski Dec. 15, 2015, 9:20 p.m. UTC | #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 15.12.2015 19:49, LEMIEUX, SYLVAIN wrote:
> 
>> From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Mateusz Kulikowski
>> Sent: 14-Dec-15 7:09 PM
>> To: u-boot@lists.denx.de; Marek Vasut; Joe Hershberger
>> Subject: [U-Boot] [PATCH 3/5] usb: ohci-lpc32xx: Use shared wait_for_bit
>>
>> Use existing library function to poll bit(s).
>> No config files are updated, as there is no board using this driver.
> 
> I tested the change using our custom lpc32xx board.

Thanks!

> 
>>
>> Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
>> ---
>>
>>  drivers/usb/host/ohci-lpc32xx.c | 36 ++++++++++--------------------------
>>  1 file changed, 10 insertions(+), 26 deletions(-)
>>
> 
> ...
> Tested-by: Sylvain Lemieux <slemieux@tycoint.com>
> 
> ________________________________
> 
> This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJWcIP+AAoJELvtohmVtQzB6A0H/2bB0WFXSiaxoM1z52wRZQNM
gqHEZs0Dj299h/wtwzOTUnnKxV1G2PA2WX6+SwiF9tf1JlNBlGJ6OwN6UJS0FIeA
2adqDzq7GJ0H9MrBjrMJJz1wASfG/2ryn+yFUjTBEwIb8Kjo1MBh3IiJv/HpHMif
1mLSLsvc3ukMKiJln/sXBZJEXIUT5uzP9OUt2ZPi2Yz7ujvD1Axhyntfx3xVpHZq
tG6PIPB0cuT8mwxSBjZGOC+z9ppcCKuEEpLU5isXdTYVPkneOq7UaX+Ryebr2x2R
so59vc1iXaBQoapglTi7asS8BEXPciBjSEzjodlgzlNVO+KVPCqItbaTq+GvTbo=
=Znto
-----END PGP SIGNATURE-----
diff mbox

Patch

diff --git a/drivers/usb/host/ohci-lpc32xx.c b/drivers/usb/host/ohci-lpc32xx.c
index 48d338e..1101f6f 100644
--- a/drivers/usb/host/ohci-lpc32xx.c
+++ b/drivers/usb/host/ohci-lpc32xx.c
@@ -10,6 +10,7 @@ 
 
 #include <common.h>
 #include <errno.h>
+#include <wait_bit.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/clk.h>
@@ -80,29 +81,9 @@  struct otg_regs {
 static struct otg_regs *otg = (struct otg_regs *)USB_BASE;
 static struct clk_pm_regs *clk_pwr = (struct clk_pm_regs *)CLK_PM_BASE;
 
-static int wait_for_bit(void *reg, const u32 mask, bool set)
-{
-	u32 val;
-	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) > CONFIG_SYS_HZ)
-			break;
-
-		udelay(1);
-	}
-
-	error("Timeout (reg=%p mask=%08x wait_set=%i)\n", reg, mask, set);
-
-	return -ETIMEDOUT;
-}
+#ifndef CONFIG_LIB_WAIT_BIT
+#error CONFIG_LIB_WAIT_BIT is required for ohci-lpc32xx driver
+#endif
 
 static int isp1301_set_value(int reg, u8 value)
 {
@@ -158,7 +139,8 @@  static int usbpll_setup(void)
 	setbits_le32(&clk_pwr->usb_ctrl, CLK_USBCTRL_POSTDIV_2POW(0x01));
 	setbits_le32(&clk_pwr->usb_ctrl, CLK_USBCTRL_PLL_PWRUP);
 
-	ret = wait_for_bit(&clk_pwr->usb_ctrl, CLK_USBCTRL_PLL_STS, 1);
+	ret = wait_for_bit(__func__, &clk_pwr->usb_ctrl, CLK_USBCTRL_PLL_STS,
+			   true, CONFIG_SYS_HZ, false);
 	if (ret)
 		return ret;
 
@@ -183,7 +165,8 @@  int usb_cpu_init(void)
 
 	/* enable I2C clock */
 	writel(OTG_CLK_I2C_EN, &otg->otg_clk_ctrl);
-	ret = wait_for_bit(&otg->otg_clk_sts, OTG_CLK_I2C_EN, 1);
+	ret = wait_for_bit(__func__, &otg->otg_clk_sts, OTG_CLK_I2C_EN, true,
+			   CONFIG_SYS_HZ, false);
 	if (ret)
 		return ret;
 
@@ -203,7 +186,8 @@  int usb_cpu_init(void)
 			 OTG_CLK_I2C_EN | OTG_CLK_HOST_EN;
 	writel(mask, &otg->otg_clk_ctrl);
 
-	ret = wait_for_bit(&otg->otg_clk_sts, mask, 1);
+	ret = wait_for_bit(__func__, &otg->otg_clk_sts, mask, true,
+			   CONFIG_SYS_HZ, false);
 	if (ret)
 		return ret;