hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/phy/marvell/phy-pxa-28nm-usb2.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2015 Linaro, Ltd.
34 * Rob Herring <robh@kernel.org>
....@@ -5,16 +6,6 @@
56 * Based on vendor driver:
67 * Copyright (C) 2013 Marvell Inc.
78 * Author: Chao Xie <xiechao.mail@gmail.com>
8
- *
9
- * This software is licensed under the terms of the GNU General Public
10
- * License version 2, as published by the Free Software Foundation, and
11
- * may be copied, distributed, and modified under those terms.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
189 */
1910
2011 #include <linux/delay.h>
....@@ -22,6 +13,7 @@
2213 #include <linux/of.h>
2314 #include <linux/of_device.h>
2415 #include <linux/io.h>
16
+#include <linux/iopoll.h>
2517 #include <linux/err.h>
2618 #include <linux/clk.h>
2719 #include <linux/module.h>
....@@ -147,15 +139,12 @@
147139 struct clk *clk;
148140 };
149141
150
-static bool wait_for_reg(void __iomem *reg, u32 mask, unsigned long timeout)
142
+static int wait_for_reg(void __iomem *reg, u32 mask, u32 ms)
151143 {
152
- timeout += jiffies;
153
- while (time_is_after_eq_jiffies(timeout)) {
154
- if ((readl(reg) & mask) == mask)
155
- return true;
156
- msleep(1);
157
- }
158
- return false;
144
+ u32 val;
145
+
146
+ return readl_poll_timeout(reg, val, ((val & mask) == mask),
147
+ 1000, 1000 * ms);
159148 }
160149
161150 static int mv_usb2_phy_28nm_init(struct phy *phy)
....@@ -217,24 +206,23 @@
217206 */
218207
219208 /* Make sure PHY Calibration is ready */
220
- if (!wait_for_reg(base + PHY_28NM_CAL_REG,
221
- PHY_28NM_PLL_PLLCAL_DONE | PHY_28NM_PLL_IMPCAL_DONE,
222
- HZ / 10)) {
209
+ ret = wait_for_reg(base + PHY_28NM_CAL_REG,
210
+ PHY_28NM_PLL_PLLCAL_DONE | PHY_28NM_PLL_IMPCAL_DONE,
211
+ 100);
212
+ if (ret) {
223213 dev_warn(&pdev->dev, "USB PHY PLL calibrate not done after 100mS.");
224
- ret = -ETIMEDOUT;
225214 goto err_clk;
226215 }
227
- if (!wait_for_reg(base + PHY_28NM_RX_REG1,
228
- PHY_28NM_RX_SQCAL_DONE, HZ / 10)) {
216
+ ret = wait_for_reg(base + PHY_28NM_RX_REG1,
217
+ PHY_28NM_RX_SQCAL_DONE, 100);
218
+ if (ret) {
229219 dev_warn(&pdev->dev, "USB PHY RX SQ calibrate not done after 100mS.");
230
- ret = -ETIMEDOUT;
231220 goto err_clk;
232221 }
233222 /* Make sure PHY PLL is ready */
234
- if (!wait_for_reg(base + PHY_28NM_PLL_REG0,
235
- PHY_28NM_PLL_READY, HZ / 10)) {
223
+ ret = wait_for_reg(base + PHY_28NM_PLL_REG0, PHY_28NM_PLL_READY, 100);
224
+ if (ret) {
236225 dev_warn(&pdev->dev, "PLL_READY not set after 100mS.");
237
- ret = -ETIMEDOUT;
238226 goto err_clk;
239227 }
240228