forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-20 ea08eeccae9297f7aabd2ef7f0c2517ac4549acc
kernel/drivers/usb/host/ehci-exynos.c
....@@ -1,6 +1,6 @@
11 // SPDX-License-Identifier: GPL-2.0+
22 /*
3
- * SAMSUNG EXYNOS USB HOST EHCI Controller
3
+ * Samsung Exynos USB HOST EHCI Controller
44 *
55 * Copyright (C) 2011 Samsung Electronics Co.Ltd
66 * Author: Jingoo Han <jg1.han@samsung.com>
....@@ -21,7 +21,7 @@
2121
2222 #include "ehci.h"
2323
24
-#define DRIVER_DESC "EHCI EXYNOS driver"
24
+#define DRIVER_DESC "EHCI Exynos driver"
2525
2626 #define EHCI_INSNREG00(base) (base + 0x90)
2727 #define EHCI_INSNREG00_ENA_INCR16 (0x1 << 25)
....@@ -39,7 +39,9 @@
3939
4040 struct exynos_ehci_hcd {
4141 struct clk *clk;
42
+ struct device_node *of_node;
4243 struct phy *phy[PHY_NUMBER];
44
+ bool legacy_phy;
4345 };
4446
4547 #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)->priv)
....@@ -49,10 +51,22 @@
4951 {
5052 struct device_node *child;
5153 struct phy *phy;
52
- int phy_number;
54
+ int phy_number, num_phys;
5355 int ret;
5456
5557 /* Get PHYs for the controller */
58
+ num_phys = of_count_phandle_with_args(dev->of_node, "phys",
59
+ "#phy-cells");
60
+ for (phy_number = 0; phy_number < num_phys; phy_number++) {
61
+ phy = devm_of_phy_get_by_index(dev, dev->of_node, phy_number);
62
+ if (IS_ERR(phy))
63
+ return PTR_ERR(phy);
64
+ exynos_ehci->phy[phy_number] = phy;
65
+ }
66
+ if (num_phys > 0)
67
+ return 0;
68
+
69
+ /* Get PHYs using legacy bindings */
5670 for_each_available_child_of_node(dev->of_node, child) {
5771 ret = of_property_read_u32(child, "reg", &phy_number);
5872 if (ret) {
....@@ -83,6 +97,7 @@
8397 }
8498 }
8599
100
+ exynos_ehci->legacy_phy = true;
86101 return 0;
87102 }
88103
....@@ -202,6 +217,14 @@
202217 ehci = hcd_to_ehci(hcd);
203218 ehci->caps = hcd->regs;
204219
220
+ /*
221
+ * Workaround: reset of_node pointer to avoid conflict between legacy
222
+ * Exynos EHCI port subnodes and generic USB device bindings
223
+ */
224
+ exynos_ehci->of_node = pdev->dev.of_node;
225
+ if (exynos_ehci->legacy_phy)
226
+ pdev->dev.of_node = NULL;
227
+
205228 /* DMA burst Enable */
206229 writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs));
207230
....@@ -218,6 +241,7 @@
218241
219242 fail_add_hcd:
220243 exynos_ehci_phy_disable(&pdev->dev);
244
+ pdev->dev.of_node = exynos_ehci->of_node;
221245 fail_io:
222246 clk_disable_unprepare(exynos_ehci->clk);
223247 fail_clk:
....@@ -230,6 +254,8 @@
230254 struct usb_hcd *hcd = platform_get_drvdata(pdev);
231255 struct exynos_ehci_hcd *exynos_ehci = to_exynos_ehci(hcd);
232256
257
+ pdev->dev.of_node = exynos_ehci->of_node;
258
+
233259 usb_remove_hcd(hcd);
234260
235261 exynos_ehci_phy_disable(&pdev->dev);