forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/usb/host/ohci-exynos.c
....@@ -19,7 +19,7 @@
1919
2020 #include "ohci.h"
2121
22
-#define DRIVER_DESC "OHCI EXYNOS driver"
22
+#define DRIVER_DESC "OHCI Exynos driver"
2323
2424 static const char hcd_name[] = "ohci-exynos";
2525 static struct hc_driver __read_mostly exynos_ohci_hc_driver;
....@@ -30,7 +30,9 @@
3030
3131 struct exynos_ohci_hcd {
3232 struct clk *clk;
33
+ struct device_node *of_node;
3334 struct phy *phy[PHY_NUMBER];
35
+ bool legacy_phy;
3436 };
3537
3638 static int exynos_ohci_get_phy(struct device *dev,
....@@ -38,10 +40,22 @@
3840 {
3941 struct device_node *child;
4042 struct phy *phy;
41
- int phy_number;
43
+ int phy_number, num_phys;
4244 int ret;
4345
4446 /* Get PHYs for the controller */
47
+ num_phys = of_count_phandle_with_args(dev->of_node, "phys",
48
+ "#phy-cells");
49
+ for (phy_number = 0; phy_number < num_phys; phy_number++) {
50
+ phy = devm_of_phy_get_by_index(dev, dev->of_node, phy_number);
51
+ if (IS_ERR(phy))
52
+ return PTR_ERR(phy);
53
+ exynos_ohci->phy[phy_number] = phy;
54
+ }
55
+ if (num_phys > 0)
56
+ return 0;
57
+
58
+ /* Get PHYs using legacy bindings */
4559 for_each_available_child_of_node(dev->of_node, child) {
4660 ret = of_property_read_u32(child, "reg", &phy_number);
4761 if (ret) {
....@@ -72,6 +86,7 @@
7286 }
7387 }
7488
89
+ exynos_ohci->legacy_phy = true;
7590 return 0;
7691 }
7792
....@@ -169,6 +184,14 @@
169184 goto fail_io;
170185 }
171186
187
+ /*
188
+ * Workaround: reset of_node pointer to avoid conflict between legacy
189
+ * Exynos OHCI port subnodes and generic USB device bindings
190
+ */
191
+ exynos_ohci->of_node = pdev->dev.of_node;
192
+ if (exynos_ohci->legacy_phy)
193
+ pdev->dev.of_node = NULL;
194
+
172195 err = usb_add_hcd(hcd, irq, IRQF_SHARED);
173196 if (err) {
174197 dev_err(&pdev->dev, "Failed to add USB HCD\n");
....@@ -179,6 +202,7 @@
179202
180203 fail_add_hcd:
181204 exynos_ohci_phy_disable(&pdev->dev);
205
+ pdev->dev.of_node = exynos_ohci->of_node;
182206 fail_io:
183207 clk_disable_unprepare(exynos_ohci->clk);
184208 fail_clk:
....@@ -191,6 +215,8 @@
191215 struct usb_hcd *hcd = platform_get_drvdata(pdev);
192216 struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
193217
218
+ pdev->dev.of_node = exynos_ohci->of_node;
219
+
194220 usb_remove_hcd(hcd);
195221
196222 exynos_ohci_phy_disable(&pdev->dev);