hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/phy/samsung/phy-exynos5-usbdrd.c
....@@ -1,14 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
2
- * Samsung EXYNOS5 SoC series USB DRD PHY driver
3
+ * Samsung Exynos5 SoC series USB DRD PHY driver
34 *
45 * Phy provider for USB 3.0 DRD controller on Exynos5 SoC series
56 *
67 * Copyright (C) 2014 Samsung Electronics Co., Ltd.
78 * Author: Vivek Gautam <gautam.vivek@samsung.com>
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2 as
11
- * published by the Free Software Foundation.
129 */
1310
1411 #include <linux/clk.h>
....@@ -19,6 +16,7 @@
1916 #include <linux/of.h>
2017 #include <linux/of_address.h>
2118 #include <linux/of_device.h>
19
+#include <linux/iopoll.h>
2220 #include <linux/phy/phy.h>
2321 #include <linux/platform_device.h>
2422 #include <linux/mutex.h>
....@@ -36,7 +34,7 @@
3634 #define EXYNOS5_FSEL_24MHZ 0x5
3735 #define EXYNOS5_FSEL_50MHZ 0x7
3836
39
-/* EXYNOS5: USB 3.0 DRD PHY registers */
37
+/* Exynos5: USB 3.0 DRD PHY registers */
4038 #define EXYNOS5_DRD_LINKSYSTEM 0x04
4139
4240 #define LINKSYSTEM_FLADJ_MASK (0x3f << 1)
....@@ -183,14 +181,14 @@
183181 * @utmiclk: clock for utmi+ phy
184182 * @itpclk: clock for ITP generation
185183 * @drv_data: pointer to SoC level driver data structure
186
- * @phys[]: array for 'EXYNOS5_DRDPHYS_NUM' number of PHY
184
+ * @phys: array for 'EXYNOS5_DRDPHYS_NUM' number of PHY
187185 * instances each with its 'phy' and 'phy_cfg'.
188186 * @extrefclk: frequency select settings when using 'separate
189187 * reference clocks' for SS and HS operations
190188 * @ref_clk: reference clock to PHY block from which PHY's
191189 * operational clocks are derived
192
- * vbus: VBUS regulator for phy
193
- * vbus_boost: Boost regulator for VBUS present on few Exynos boards
190
+ * @vbus: VBUS regulator for phy
191
+ * @vbus_boost: Boost regulator for VBUS present on few Exynos boards
194192 */
195193 struct exynos5_usbdrd_phy {
196194 struct device *dev;
....@@ -559,41 +557,25 @@
559557 static int crport_handshake(struct exynos5_usbdrd_phy *phy_drd,
560558 u32 val, u32 cmd)
561559 {
562
- u32 usec = 100;
563560 unsigned int result;
561
+ int err;
564562
565563 writel(val | cmd, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0);
566564
567
- do {
568
- result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1);
569
- if (result & PHYREG1_CR_ACK)
570
- break;
571
-
572
- udelay(1);
573
- } while (usec-- > 0);
574
-
575
- if (!usec) {
576
- dev_err(phy_drd->dev,
577
- "CRPORT handshake timeout1 (0x%08x)\n", val);
578
- return -ETIME;
565
+ err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1,
566
+ result, (result & PHYREG1_CR_ACK), 1, 100);
567
+ if (err == -ETIMEDOUT) {
568
+ dev_err(phy_drd->dev, "CRPORT handshake timeout1 (0x%08x)\n", val);
569
+ return err;
579570 }
580
-
581
- usec = 100;
582571
583572 writel(val, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0);
584573
585
- do {
586
- result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1);
587
- if (!(result & PHYREG1_CR_ACK))
588
- break;
589
-
590
- udelay(1);
591
- } while (usec-- > 0);
592
-
593
- if (!usec) {
594
- dev_err(phy_drd->dev,
595
- "CRPORT handshake timeout2 (0x%08x)\n", val);
596
- return -ETIME;
574
+ err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1,
575
+ result, !(result & PHYREG1_CR_ACK), 1, 100);
576
+ if (err == -ETIMEDOUT) {
577
+ dev_err(phy_drd->dev, "CRPORT handshake timeout2 (0x%08x)\n", val);
578
+ return err;
597579 }
598580
599581 return 0;
....@@ -958,11 +940,12 @@
958940 .driver = {
959941 .of_match_table = exynos5_usbdrd_phy_of_match,
960942 .name = "exynos5_usb3drd_phy",
943
+ .suppress_bind_attrs = true,
961944 }
962945 };
963946
964947 module_platform_driver(exynos5_usb3drd_phy);
965
-MODULE_DESCRIPTION("Samsung EXYNOS5 SoCs USB 3.0 DRD controller PHY driver");
948
+MODULE_DESCRIPTION("Samsung Exynos5 SoCs USB 3.0 DRD controller PHY driver");
966949 MODULE_AUTHOR("Vivek Gautam <gautam.vivek@samsung.com>");
967950 MODULE_LICENSE("GPL v2");
968951 MODULE_ALIAS("platform:exynos5_usb3drd_phy");