.. | .. |
---|
8 | 8 | #include <linux/mbus.h> |
---|
9 | 9 | #include <linux/of.h> |
---|
10 | 10 | #include <linux/platform_device.h> |
---|
| 11 | +#include <linux/phy/phy.h> |
---|
11 | 12 | |
---|
12 | 13 | #include <linux/usb.h> |
---|
13 | 14 | #include <linux/usb/hcd.h> |
---|
14 | 15 | |
---|
15 | 16 | #include "xhci-mvebu.h" |
---|
| 17 | +#include "xhci.h" |
---|
16 | 18 | |
---|
17 | 19 | #define USB3_MAX_WINDOWS 4 |
---|
18 | 20 | #define USB3_WIN_CTRL(w) (0x0 + ((w) * 8)) |
---|
.. | .. |
---|
72 | 74 | |
---|
73 | 75 | return 0; |
---|
74 | 76 | } |
---|
| 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 | +} |
---|