Commit 38af68cb authored by Chunfeng Yun's avatar Chunfeng Yun Committed by Vinod Koul

phy: phy-qcom-apq8064-sata: convert to readl_relaxed_poll_timeout()

Use readl_relaxed_poll_timeout() to simplify code, rename local function
read_poll_timeout() as poll_timeout() to avoid repeated definition
Signed-off-by: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1598320987-25518-4-git-send-email-chunfeng.yun@mediatek.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 6f2a7218
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
*/ */
#include <linux/io.h> #include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
...@@ -72,18 +73,12 @@ struct qcom_apq8064_sata_phy { ...@@ -72,18 +73,12 @@ struct qcom_apq8064_sata_phy {
}; };
/* Helper function to do poll and timeout */ /* Helper function to do poll and timeout */
static int read_poll_timeout(void __iomem *addr, u32 mask) static int poll_timeout(void __iomem *addr, u32 mask)
{ {
unsigned long timeout = jiffies + msecs_to_jiffies(TIMEOUT_MS); u32 val;
do { return readl_relaxed_poll_timeout(addr, val, (val & mask),
if (readl_relaxed(addr) & mask) DELAY_INTERVAL_US, TIMEOUT_MS * 1000);
return 0;
usleep_range(DELAY_INTERVAL_US, DELAY_INTERVAL_US + 50);
} while (!time_after(jiffies, timeout));
return (readl_relaxed(addr) & mask) ? 0 : -ETIMEDOUT;
} }
static int qcom_apq8064_sata_phy_init(struct phy *generic_phy) static int qcom_apq8064_sata_phy_init(struct phy *generic_phy)
...@@ -137,21 +132,21 @@ static int qcom_apq8064_sata_phy_init(struct phy *generic_phy) ...@@ -137,21 +132,21 @@ static int qcom_apq8064_sata_phy_init(struct phy *generic_phy)
writel_relaxed(0x05, base + UNIPHY_PLL_LKDET_CFG2); writel_relaxed(0x05, base + UNIPHY_PLL_LKDET_CFG2);
/* PLL Lock wait */ /* PLL Lock wait */
ret = read_poll_timeout(base + UNIPHY_PLL_STATUS, UNIPHY_PLL_LOCK); ret = poll_timeout(base + UNIPHY_PLL_STATUS, UNIPHY_PLL_LOCK);
if (ret) { if (ret) {
dev_err(phy->dev, "poll timeout UNIPHY_PLL_STATUS\n"); dev_err(phy->dev, "poll timeout UNIPHY_PLL_STATUS\n");
return ret; return ret;
} }
/* TX Calibration */ /* TX Calibration */
ret = read_poll_timeout(base + SATA_PHY_TX_IMCAL_STAT, SATA_PHY_TX_CAL); ret = poll_timeout(base + SATA_PHY_TX_IMCAL_STAT, SATA_PHY_TX_CAL);
if (ret) { if (ret) {
dev_err(phy->dev, "poll timeout SATA_PHY_TX_IMCAL_STAT\n"); dev_err(phy->dev, "poll timeout SATA_PHY_TX_IMCAL_STAT\n");
return ret; return ret;
} }
/* RX Calibration */ /* RX Calibration */
ret = read_poll_timeout(base + SATA_PHY_RX_IMCAL_STAT, SATA_PHY_RX_CAL); ret = poll_timeout(base + SATA_PHY_RX_IMCAL_STAT, SATA_PHY_RX_CAL);
if (ret) { if (ret) {
dev_err(phy->dev, "poll timeout SATA_PHY_RX_IMCAL_STAT\n"); dev_err(phy->dev, "poll timeout SATA_PHY_RX_IMCAL_STAT\n");
return ret; return ret;
......
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