Commit e3be4dd2 authored by Alain Volmat's avatar Alain Volmat Committed by Vinod Koul

phy: st: miphy28lp: use _poll_timeout functions for waits

This commit introduces _poll_timeout functions usage instead of
wait loops waiting for a status bit.
Signed-off-by: default avatarAlain Volmat <avolmat@me.com>
Reviewed-by: default avatarPatrice Chotard <patrice.chotard@foss.st.com>
Link: https://lore.kernel.org/r/20230210224309.98452-1-avolmat@me.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 8b798761
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#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>
...@@ -484,19 +485,11 @@ static inline void miphy28lp_pcie_config_gen(struct miphy28lp_phy *miphy_phy) ...@@ -484,19 +485,11 @@ static inline void miphy28lp_pcie_config_gen(struct miphy28lp_phy *miphy_phy)
static inline int miphy28lp_wait_compensation(struct miphy28lp_phy *miphy_phy) static inline int miphy28lp_wait_compensation(struct miphy28lp_phy *miphy_phy)
{ {
unsigned long finish = jiffies + 5 * HZ;
u8 val; u8 val;
/* Waiting for Compensation to complete */ /* Waiting for Compensation to complete */
do { return readb_relaxed_poll_timeout(miphy_phy->base + MIPHY_COMP_FSM_6,
val = readb_relaxed(miphy_phy->base + MIPHY_COMP_FSM_6); val, val & COMP_DONE, 1, 5 * USEC_PER_SEC);
if (time_after_eq(jiffies, finish))
return -EBUSY;
cpu_relax();
} while (!(val & COMP_DONE));
return 0;
} }
...@@ -805,7 +798,6 @@ static inline void miphy28lp_configure_usb3(struct miphy28lp_phy *miphy_phy) ...@@ -805,7 +798,6 @@ static inline void miphy28lp_configure_usb3(struct miphy28lp_phy *miphy_phy)
static inline int miphy_is_ready(struct miphy28lp_phy *miphy_phy) static inline int miphy_is_ready(struct miphy28lp_phy *miphy_phy)
{ {
unsigned long finish = jiffies + 5 * HZ;
u8 mask = HFC_PLL | HFC_RDY; u8 mask = HFC_PLL | HFC_RDY;
u8 val; u8 val;
...@@ -816,21 +808,14 @@ static inline int miphy_is_ready(struct miphy28lp_phy *miphy_phy) ...@@ -816,21 +808,14 @@ static inline int miphy_is_ready(struct miphy28lp_phy *miphy_phy)
if (miphy_phy->type == PHY_TYPE_SATA) if (miphy_phy->type == PHY_TYPE_SATA)
mask |= PHY_RDY; mask |= PHY_RDY;
do { return readb_relaxed_poll_timeout(miphy_phy->base + MIPHY_STATUS_1,
val = readb_relaxed(miphy_phy->base + MIPHY_STATUS_1); val, (val & mask) == mask, 1,
if ((val & mask) != mask) 5 * USEC_PER_SEC);
cpu_relax();
else
return 0;
} while (!time_after_eq(jiffies, finish));
return -EBUSY;
} }
static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy) static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
{ {
struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
unsigned long finish = jiffies + 5 * HZ;
u32 val; u32 val;
if (!miphy_phy->osc_rdy) if (!miphy_phy->osc_rdy)
...@@ -839,17 +824,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy) ...@@ -839,17 +824,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
if (!miphy_phy->syscfg_reg[SYSCFG_STATUS]) if (!miphy_phy->syscfg_reg[SYSCFG_STATUS])
return -EINVAL; return -EINVAL;
do { return regmap_read_poll_timeout(miphy_dev->regmap,
regmap_read(miphy_dev->regmap, miphy_phy->syscfg_reg[SYSCFG_STATUS],
miphy_phy->syscfg_reg[SYSCFG_STATUS], &val); val, val & MIPHY_OSC_RDY, 1,
5 * USEC_PER_SEC);
if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
cpu_relax();
else
return 0;
} while (!time_after_eq(jiffies, finish));
return -EBUSY;
} }
static int miphy28lp_get_resource_byname(struct device_node *child, static int miphy28lp_get_resource_byname(struct device_node *child,
......
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