Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

phy: rockchip-pcie: Use regmap_read_poll_timeout() for PCIe reference clk PLL status

Replace open-coded phy PCIe reference clk PLL status polling with
regmap_read_poll_timeout API. This change simplifies the code without
altering functionality.

Signed-off-by: Anand Moon <linux.amoon@gmail.com>
Link: https://lore.kernel.org/r/20241012071919.3726-4-linux.amoon@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Anand Moon and committed by
Vinod Koul
cb0ba26a e96397db

+15 -41
+15 -41
drivers/phy/rockchip/phy-rockchip-pcie.c
··· 162 162 struct rockchip_pcie_phy *rk_phy = to_pcie_phy(inst); 163 163 int err = 0; 164 164 u32 status; 165 - unsigned long timeout; 166 165 167 166 mutex_lock(&rk_phy->pcie_mutex); 168 167 ··· 190 191 * so we make it large enough here. And we use loop-break 191 192 * method which should not be harmful. 192 193 */ 193 - timeout = jiffies + msecs_to_jiffies(1000); 194 - 195 - err = -EINVAL; 196 - while (time_before(jiffies, timeout)) { 197 - regmap_read(rk_phy->reg_base, 198 - rk_phy->phy_data->pcie_status, 199 - &status); 200 - if (status & PHY_PLL_LOCKED) { 201 - dev_dbg(&phy->dev, "pll locked!\n"); 202 - err = 0; 203 - break; 204 - } 205 - msleep(20); 206 - } 207 - 194 + err = regmap_read_poll_timeout(rk_phy->reg_base, 195 + rk_phy->phy_data->pcie_status, 196 + status, 197 + status & PHY_PLL_LOCKED, 198 + 200, 100000); 208 199 if (err) { 209 200 dev_err(&phy->dev, "pll lock timeout!\n"); 210 201 goto err_pll_lock; ··· 203 214 phy_wr_cfg(rk_phy, PHY_CFG_CLK_TEST, PHY_CFG_SEPE_RATE); 204 215 phy_wr_cfg(rk_phy, PHY_CFG_CLK_SCC, PHY_CFG_PLL_100M); 205 216 206 - err = -ETIMEDOUT; 207 - while (time_before(jiffies, timeout)) { 208 - regmap_read(rk_phy->reg_base, 209 - rk_phy->phy_data->pcie_status, 210 - &status); 211 - if (!(status & PHY_PLL_OUTPUT)) { 212 - dev_dbg(&phy->dev, "pll output enable done!\n"); 213 - err = 0; 214 - break; 215 - } 216 - msleep(20); 217 - } 218 - 217 + err = regmap_read_poll_timeout(rk_phy->reg_base, 218 + rk_phy->phy_data->pcie_status, 219 + status, 220 + !(status & PHY_PLL_OUTPUT), 221 + 200, 100000); 219 222 if (err) { 220 223 dev_err(&phy->dev, "pll output enable timeout!\n"); 221 224 goto err_pll_lock; ··· 217 236 HIWORD_UPDATE(PHY_CFG_PLL_LOCK, 218 237 PHY_CFG_ADDR_MASK, 219 238 PHY_CFG_ADDR_SHIFT)); 220 - err = -EINVAL; 221 - while (time_before(jiffies, timeout)) { 222 - regmap_read(rk_phy->reg_base, 223 - rk_phy->phy_data->pcie_status, 224 - &status); 225 - if (status & PHY_PLL_LOCKED) { 226 - dev_dbg(&phy->dev, "pll relocked!\n"); 227 - err = 0; 228 - break; 229 - } 230 - msleep(20); 231 - } 232 239 240 + err = regmap_read_poll_timeout(rk_phy->reg_base, 241 + rk_phy->phy_data->pcie_status, 242 + status, 243 + status & PHY_PLL_LOCKED, 244 + 200, 100000); 233 245 if (err) { 234 246 dev_err(&phy->dev, "pll relock timeout!\n"); 235 247 goto err_pll_lock;