aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/host/xhci-mem.c12
-rw-r--r--drivers/usb/host/xhci-plat.c35
-rw-r--r--drivers/usb/host/xhci.c15
3 files changed, 44 insertions, 18 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index ba1853f4e407..032a7020a6b0 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -586,7 +586,7 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci,
586 unsigned int num_stream_ctxs, 586 unsigned int num_stream_ctxs,
587 struct xhci_stream_ctx *stream_ctx, dma_addr_t dma) 587 struct xhci_stream_ctx *stream_ctx, dma_addr_t dma)
588{ 588{
589 struct device *dev = xhci_to_hcd(xhci)->self.controller; 589 struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
590 size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; 590 size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
591 591
592 if (size > MEDIUM_STREAM_ARRAY_SIZE) 592 if (size > MEDIUM_STREAM_ARRAY_SIZE)
@@ -614,7 +614,7 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci,
614 unsigned int num_stream_ctxs, dma_addr_t *dma, 614 unsigned int num_stream_ctxs, dma_addr_t *dma,
615 gfp_t mem_flags) 615 gfp_t mem_flags)
616{ 616{
617 struct device *dev = xhci_to_hcd(xhci)->self.controller; 617 struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
618 size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; 618 size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
619 619
620 if (size > MEDIUM_STREAM_ARRAY_SIZE) 620 if (size > MEDIUM_STREAM_ARRAY_SIZE)
@@ -1686,7 +1686,7 @@ void xhci_slot_copy(struct xhci_hcd *xhci,
1686static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) 1686static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
1687{ 1687{
1688 int i; 1688 int i;
1689 struct device *dev = xhci_to_hcd(xhci)->self.controller; 1689 struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
1690 int num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2); 1690 int num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2);
1691 1691
1692 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 1692 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
@@ -1758,7 +1758,7 @@ static void scratchpad_free(struct xhci_hcd *xhci)
1758{ 1758{
1759 int num_sp; 1759 int num_sp;
1760 int i; 1760 int i;
1761 struct device *dev = xhci_to_hcd(xhci)->self.controller; 1761 struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
1762 1762
1763 if (!xhci->scratchpad) 1763 if (!xhci->scratchpad)
1764 return; 1764 return;
@@ -1831,7 +1831,7 @@ void xhci_free_command(struct xhci_hcd *xhci,
1831 1831
1832void xhci_mem_cleanup(struct xhci_hcd *xhci) 1832void xhci_mem_cleanup(struct xhci_hcd *xhci)
1833{ 1833{
1834 struct device *dev = xhci_to_hcd(xhci)->self.controller; 1834 struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
1835 int size; 1835 int size;
1836 int i, j, num_ports; 1836 int i, j, num_ports;
1837 1837
@@ -2373,7 +2373,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
2373int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) 2373int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2374{ 2374{
2375 dma_addr_t dma; 2375 dma_addr_t dma;
2376 struct device *dev = xhci_to_hcd(xhci)->self.controller; 2376 struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
2377 unsigned int val, val2; 2377 unsigned int val, val2;
2378 u64 val_64; 2378 u64 val_64;
2379 struct xhci_segment *seg; 2379 struct xhci_segment *seg;
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index bd02a6cd8e2c..fa97826d0058 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -14,6 +14,7 @@
14#include <linux/clk.h> 14#include <linux/clk.h>
15#include <linux/dma-mapping.h> 15#include <linux/dma-mapping.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/pci.h>
17#include <linux/of.h> 18#include <linux/of.h>
18#include <linux/platform_device.h> 19#include <linux/platform_device.h>
19#include <linux/usb/phy.h> 20#include <linux/usb/phy.h>
@@ -148,6 +149,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
148{ 149{
149 const struct of_device_id *match; 150 const struct of_device_id *match;
150 const struct hc_driver *driver; 151 const struct hc_driver *driver;
152 struct device *sysdev;
151 struct xhci_hcd *xhci; 153 struct xhci_hcd *xhci;
152 struct resource *res; 154 struct resource *res;
153 struct usb_hcd *hcd; 155 struct usb_hcd *hcd;
@@ -164,22 +166,39 @@ static int xhci_plat_probe(struct platform_device *pdev)
164 if (irq < 0) 166 if (irq < 0)
165 return -ENODEV; 167 return -ENODEV;
166 168
169 /*
170 * sysdev must point to a device that is known to the system firmware
171 * or PCI hardware. We handle these three cases here:
172 * 1. xhci_plat comes from firmware
173 * 2. xhci_plat is child of a device from firmware (dwc3-plat)
174 * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
175 */
176 sysdev = &pdev->dev;
177 if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
178 sysdev = sysdev->parent;
179#ifdef CONFIG_PCI
180 else if (sysdev->parent && sysdev->parent->parent &&
181 sysdev->parent->parent->bus == &pci_bus_type)
182 sysdev = sysdev->parent->parent;
183#endif
184
167 /* Try to set 64-bit DMA first */ 185 /* Try to set 64-bit DMA first */
168 if (!pdev->dev.dma_mask) 186 if (WARN_ON(!sysdev->dma_mask))
169 /* Platform did not initialize dma_mask */ 187 /* Platform did not initialize dma_mask */
170 ret = dma_coerce_mask_and_coherent(&pdev->dev, 188 ret = dma_coerce_mask_and_coherent(sysdev,
171 DMA_BIT_MASK(64)); 189 DMA_BIT_MASK(64));
172 else 190 else
173 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); 191 ret = dma_set_mask_and_coherent(sysdev, DMA_BIT_MASK(64));
174 192
175 /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */ 193 /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
176 if (ret) { 194 if (ret) {
177 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); 195 ret = dma_set_mask_and_coherent(sysdev, DMA_BIT_MASK(32));
178 if (ret) 196 if (ret)
179 return ret; 197 return ret;
180 } 198 }
181 199
182 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); 200 hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
201 dev_name(&pdev->dev), NULL);
183 if (!hcd) 202 if (!hcd)
184 return -ENOMEM; 203 return -ENOMEM;
185 204
@@ -222,20 +241,20 @@ static int xhci_plat_probe(struct platform_device *pdev)
222 241
223 xhci->clk = clk; 242 xhci->clk = clk;
224 xhci->main_hcd = hcd; 243 xhci->main_hcd = hcd;
225 xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev, 244 xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
226 dev_name(&pdev->dev), hcd); 245 dev_name(&pdev->dev), hcd);
227 if (!xhci->shared_hcd) { 246 if (!xhci->shared_hcd) {
228 ret = -ENOMEM; 247 ret = -ENOMEM;
229 goto disable_clk; 248 goto disable_clk;
230 } 249 }
231 250
232 if (device_property_read_bool(&pdev->dev, "usb3-lpm-capable")) 251 if (device_property_read_bool(sysdev, "usb3-lpm-capable"))
233 xhci->quirks |= XHCI_LPM_SUPPORT; 252 xhci->quirks |= XHCI_LPM_SUPPORT;
234 253
235 if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped")) 254 if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped"))
236 xhci->quirks |= XHCI_BROKEN_PORT_PED; 255 xhci->quirks |= XHCI_BROKEN_PORT_PED;
237 256
238 hcd->usb_phy = devm_usb_get_phy_by_phandle(&pdev->dev, "usb-phy", 0); 257 hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0);
239 if (IS_ERR(hcd->usb_phy)) { 258 if (IS_ERR(hcd->usb_phy)) {
240 ret = PTR_ERR(hcd->usb_phy); 259 ret = PTR_ERR(hcd->usb_phy);
241 if (ret == -EPROBE_DEFER) 260 if (ret == -EPROBE_DEFER)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index bb0becf8561c..1828695ddab8 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -237,6 +237,9 @@ static int xhci_free_msi(struct xhci_hcd *xhci)
237static int xhci_setup_msi(struct xhci_hcd *xhci) 237static int xhci_setup_msi(struct xhci_hcd *xhci)
238{ 238{
239 int ret; 239 int ret;
240 /*
241 * TODO:Check with MSI Soc for sysdev
242 */
240 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 243 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
241 244
242 ret = pci_enable_msi(pdev); 245 ret = pci_enable_msi(pdev);
@@ -263,7 +266,7 @@ static int xhci_setup_msi(struct xhci_hcd *xhci)
263 */ 266 */
264static void xhci_free_irq(struct xhci_hcd *xhci) 267static void xhci_free_irq(struct xhci_hcd *xhci)
265{ 268{
266 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 269 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.sysdev);
267 int ret; 270 int ret;
268 271
269 /* return if using legacy interrupt */ 272 /* return if using legacy interrupt */
@@ -748,7 +751,7 @@ void xhci_shutdown(struct usb_hcd *hcd)
748 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 751 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
749 752
750 if (xhci->quirks & XHCI_SPURIOUS_REBOOT) 753 if (xhci->quirks & XHCI_SPURIOUS_REBOOT)
751 usb_disable_xhci_ports(to_pci_dev(hcd->self.controller)); 754 usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
752 755
753 spin_lock_irq(&xhci->lock); 756 spin_lock_irq(&xhci->lock);
754 xhci_halt(xhci); 757 xhci_halt(xhci);
@@ -765,7 +768,7 @@ void xhci_shutdown(struct usb_hcd *hcd)
765 768
766 /* Yet another workaround for spurious wakeups at shutdown with HSW */ 769 /* Yet another workaround for spurious wakeups at shutdown with HSW */
767 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) 770 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
768 pci_set_power_state(to_pci_dev(hcd->self.controller), PCI_D3hot); 771 pci_set_power_state(to_pci_dev(hcd->self.sysdev), PCI_D3hot);
769} 772}
770 773
771#ifdef CONFIG_PM 774#ifdef CONFIG_PM
@@ -4801,7 +4804,11 @@ int xhci_get_frame(struct usb_hcd *hcd)
4801int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) 4804int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
4802{ 4805{
4803 struct xhci_hcd *xhci; 4806 struct xhci_hcd *xhci;
4804 struct device *dev = hcd->self.controller; 4807 /*
4808 * TODO: Check with DWC3 clients for sysdev according to
4809 * quirks
4810 */
4811 struct device *dev = hcd->self.sysdev;
4805 int retval; 4812 int retval;
4806 4813
4807 /* Accept arbitrarily long scatter-gather lists */ 4814 /* Accept arbitrarily long scatter-gather lists */