Commit a85643d4 authored by Anand Moon's avatar Anand Moon Committed by Vinod Koul

phy: samsung: Use readl_poll_timeout function

Instead of a busy waiting while loop using udelay
use readl_poll_timeout function to check the condition
is met or timeout occurs in crport_handshake function.
readl_poll_timeout is called in non atomic context so
it safe to sleep until the condition is met.
Signed-off-by: default avatarAnand Moon <linux.amoon@gmail.com>
Link: https://lore.kernel.org/r/20200720173502.542-1-linux.amoon@gmail.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 9123e3a7
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/iopoll.h>
#include <linux/phy/phy.h> #include <linux/phy/phy.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mutex.h> #include <linux/mutex.h>
...@@ -556,41 +557,25 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy) ...@@ -556,41 +557,25 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy)
static int crport_handshake(struct exynos5_usbdrd_phy *phy_drd, static int crport_handshake(struct exynos5_usbdrd_phy *phy_drd,
u32 val, u32 cmd) u32 val, u32 cmd)
{ {
u32 usec = 100;
unsigned int result; unsigned int result;
int err;
writel(val | cmd, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); writel(val | cmd, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0);
do { err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1,
result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1); result, (result & PHYREG1_CR_ACK), 1, 100);
if (result & PHYREG1_CR_ACK) if (err == -ETIMEDOUT) {
break; dev_err(phy_drd->dev, "CRPORT handshake timeout1 (0x%08x)\n", val);
return err;
udelay(1);
} while (usec-- > 0);
if (!usec) {
dev_err(phy_drd->dev,
"CRPORT handshake timeout1 (0x%08x)\n", val);
return -ETIME;
} }
usec = 100;
writel(val, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); writel(val, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0);
do { err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1,
result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1); result, !(result & PHYREG1_CR_ACK), 1, 100);
if (!(result & PHYREG1_CR_ACK)) if (err == -ETIMEDOUT) {
break; dev_err(phy_drd->dev, "CRPORT handshake timeout2 (0x%08x)\n", val);
return err;
udelay(1);
} while (usec-- > 0);
if (!usec) {
dev_err(phy_drd->dev,
"CRPORT handshake timeout2 (0x%08x)\n", val);
return -ETIME;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment