hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/usb/host/xhci-mvebu.c
....@@ -8,11 +8,13 @@
88 #include <linux/mbus.h>
99 #include <linux/of.h>
1010 #include <linux/platform_device.h>
11
+#include <linux/phy/phy.h>
1112
1213 #include <linux/usb.h>
1314 #include <linux/usb/hcd.h>
1415
1516 #include "xhci-mvebu.h"
17
+#include "xhci.h"
1618
1719 #define USB3_MAX_WINDOWS 4
1820 #define USB3_WIN_CTRL(w) (0x0 + ((w) * 8))
....@@ -72,3 +74,54 @@
7274
7375 return 0;
7476 }
77
+
78
+int xhci_mvebu_a3700_plat_setup(struct usb_hcd *hcd)
79
+{
80
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
81
+ struct device *dev = hcd->self.controller;
82
+ struct phy *phy;
83
+ int ret;
84
+
85
+ /* Old bindings miss the PHY handle */
86
+ phy = of_phy_get(dev->of_node, "usb3-phy");
87
+ if (IS_ERR(phy) && PTR_ERR(phy) == -EPROBE_DEFER)
88
+ return -EPROBE_DEFER;
89
+ else if (IS_ERR(phy))
90
+ goto phy_out;
91
+
92
+ ret = phy_init(phy);
93
+ if (ret)
94
+ goto phy_put;
95
+
96
+ ret = phy_set_mode(phy, PHY_MODE_USB_HOST_SS);
97
+ if (ret)
98
+ goto phy_exit;
99
+
100
+ ret = phy_power_on(phy);
101
+ if (ret == -EOPNOTSUPP) {
102
+ /* Skip initializatin of XHCI PHY when it is unsupported by firmware */
103
+ dev_warn(dev, "PHY unsupported by firmware\n");
104
+ xhci->quirks |= XHCI_SKIP_PHY_INIT;
105
+ }
106
+ if (ret)
107
+ goto phy_exit;
108
+
109
+ phy_power_off(phy);
110
+phy_exit:
111
+ phy_exit(phy);
112
+phy_put:
113
+ of_phy_put(phy);
114
+phy_out:
115
+
116
+ return 0;
117
+}
118
+
119
+int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd)
120
+{
121
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
122
+
123
+ /* Without reset on resume, the HC won't work at all */
124
+ xhci->quirks |= XHCI_RESET_ON_RESUME;
125
+
126
+ return 0;
127
+}