hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/phy/broadcom/phy-bcm-ns-usb3.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Broadcom Northstar USB 3.0 PHY Driver
34 *
....@@ -7,15 +8,12 @@
78 * All magic values used for initialization (and related comments) were obtained
89 * from Broadcom's SDK:
910 * Copyright (c) Broadcom Corp, 2012
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License version 2 as
13
- * published by the Free Software Foundation.
1411 */
1512
1613 #include <linux/bcma/bcma.h>
1714 #include <linux/delay.h>
1815 #include <linux/err.h>
16
+#include <linux/iopoll.h>
1917 #include <linux/mdio.h>
2018 #include <linux/module.h>
2119 #include <linux/of_address.h>
....@@ -261,29 +259,24 @@
261259 **************************************************/
262260
263261 static int bcm_ns_usb3_wait_reg(struct bcm_ns_usb3 *usb3, void __iomem *addr,
264
- u32 mask, u32 value, unsigned long timeout)
262
+ u32 mask, u32 value, int usec)
265263 {
266
- unsigned long deadline = jiffies + timeout;
267264 u32 val;
265
+ int ret;
268266
269
- do {
270
- val = readl(addr);
271
- if ((val & mask) == value)
272
- return 0;
273
- cpu_relax();
274
- udelay(10);
275
- } while (!time_after_eq(jiffies, deadline));
267
+ ret = readl_poll_timeout_atomic(addr, val, ((val & mask) == value),
268
+ 10, usec);
269
+ if (ret)
270
+ dev_err(usb3->dev, "Timeout waiting for register %p\n", addr);
276271
277
- dev_err(usb3->dev, "Timeout waiting for register %p\n", addr);
278
-
279
- return -EBUSY;
272
+ return ret;
280273 }
281274
282275 static inline int bcm_ns_usb3_mii_mng_wait_idle(struct bcm_ns_usb3 *usb3)
283276 {
284277 return bcm_ns_usb3_wait_reg(usb3, usb3->ccb_mii + BCMA_CCB_MII_MNG_CTL,
285278 0x0100, 0x0000,
286
- usecs_to_jiffies(BCM_NS_USB3_MII_MNG_TIMEOUT_US));
279
+ BCM_NS_USB3_MII_MNG_TIMEOUT_US);
287280 }
288281
289282 static int bcm_ns_usb3_platform_phy_write(struct bcm_ns_usb3 *usb3, u16 reg,