Lines Matching +full:xhci +full:- +full:r8a7795
1 // SPDX-License-Identifier: GPL-2.0
3 * xhci-plat.c - xHCI host controller driver platform Bus Glue.
5 * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com
8 * A lot of code borrowed from the Linux xHCI driver.
12 #include <linux/dma-mapping.h>
23 #include "xhci.h"
24 #include "xhci-plat.h"
25 #include "xhci-mvebu.h"
26 #include "xhci-rcar.h"
43 if (priv->plat_start) in xhci_priv_plat_start()
44 priv->plat_start(hcd); in xhci_priv_plat_start()
51 if (!priv->init_quirk) in xhci_priv_init_quirk()
54 return priv->init_quirk(hcd); in xhci_priv_init_quirk()
61 if (!priv->suspend_quirk) in xhci_priv_suspend_quirk()
64 return priv->suspend_quirk(hcd); in xhci_priv_suspend_quirk()
71 if (!priv->resume_quirk) in xhci_priv_resume_quirk()
74 return priv->resume_quirk(hcd); in xhci_priv_resume_quirk()
77 static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci) in xhci_plat_quirks() argument
79 struct xhci_plat_priv *priv = xhci_to_priv(xhci); in xhci_plat_quirks()
86 xhci->quirks |= XHCI_PLAT | priv->quirks; in xhci_plat_quirks()
131 .compatible = "generic-xhci",
133 .compatible = "xhci-platform",
135 .compatible = "marvell,armada-375-xhci",
138 .compatible = "marvell,armada-380-xhci",
141 .compatible = "marvell,armada3700-xhci",
144 .compatible = "renesas,xhci-r8a7790",
147 .compatible = "renesas,xhci-r8a7791",
150 .compatible = "renesas,xhci-r8a7793",
153 .compatible = "renesas,xhci-r8a7795",
156 .compatible = "renesas,xhci-r8a7796",
159 .compatible = "renesas,rcar-gen2-xhci",
162 .compatible = "renesas,rcar-gen3-xhci",
165 .compatible = "brcm,xhci-brcm-v2",
168 .compatible = "brcm,bcm7445-xhci",
181 struct xhci_hcd *xhci; in xhci_plat_probe() local
190 return -ENODEV; in xhci_plat_probe()
202 * 2. xhci_plat is child of a device from firmware (dwc3-plat) in xhci_plat_probe()
203 * 3. xhci_plat is grandchild of a pci device (dwc3-pci) in xhci_plat_probe()
205 for (sysdev = &pdev->dev; sysdev; sysdev = sysdev->parent) { in xhci_plat_probe()
206 if (is_of_node(sysdev->fwnode) || in xhci_plat_probe()
207 is_acpi_device_node(sysdev->fwnode)) in xhci_plat_probe()
210 else if (sysdev->bus == &pci_bus_type) in xhci_plat_probe()
216 sysdev = &pdev->dev; in xhci_plat_probe()
218 /* Try to set 64-bit DMA first */ in xhci_plat_probe()
219 if (WARN_ON(!sysdev->dma_mask)) in xhci_plat_probe()
226 /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */ in xhci_plat_probe()
233 pm_runtime_set_active(&pdev->dev); in xhci_plat_probe()
234 pm_runtime_enable(&pdev->dev); in xhci_plat_probe()
235 pm_runtime_get_noresume(&pdev->dev); in xhci_plat_probe()
237 hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, in xhci_plat_probe()
238 dev_name(&pdev->dev), NULL); in xhci_plat_probe()
240 ret = -ENOMEM; in xhci_plat_probe()
244 hcd->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in xhci_plat_probe()
245 if (IS_ERR(hcd->regs)) { in xhci_plat_probe()
246 ret = PTR_ERR(hcd->regs); in xhci_plat_probe()
250 hcd->rsrc_start = res->start; in xhci_plat_probe()
251 hcd->rsrc_len = resource_size(res); in xhci_plat_probe()
253 xhci = hcd_to_xhci(hcd); in xhci_plat_probe()
259 xhci->reg_clk = devm_clk_get_optional(&pdev->dev, "reg"); in xhci_plat_probe()
260 if (IS_ERR(xhci->reg_clk)) { in xhci_plat_probe()
261 ret = PTR_ERR(xhci->reg_clk); in xhci_plat_probe()
265 ret = clk_prepare_enable(xhci->reg_clk); in xhci_plat_probe()
269 xhci->clk = devm_clk_get_optional(&pdev->dev, NULL); in xhci_plat_probe()
270 if (IS_ERR(xhci->clk)) { in xhci_plat_probe()
271 ret = PTR_ERR(xhci->clk); in xhci_plat_probe()
275 ret = clk_prepare_enable(xhci->clk); in xhci_plat_probe()
279 if (pdev->dev.of_node) in xhci_plat_probe()
280 priv_match = of_device_get_match_data(&pdev->dev); in xhci_plat_probe()
282 priv_match = dev_get_platdata(&pdev->dev); in xhci_plat_probe()
290 device_set_wakeup_capable(&pdev->dev, true); in xhci_plat_probe()
292 xhci->main_hcd = hcd; in xhci_plat_probe()
293 xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, in xhci_plat_probe()
294 dev_name(&pdev->dev), hcd); in xhci_plat_probe()
295 if (!xhci->shared_hcd) { in xhci_plat_probe()
296 ret = -ENOMEM; in xhci_plat_probe()
301 xhci->imod_interval = 40000; in xhci_plat_probe()
304 for (tmpdev = &pdev->dev; tmpdev; tmpdev = tmpdev->parent) { in xhci_plat_probe()
306 if (device_property_read_bool(tmpdev, "usb2-lpm-disable")) in xhci_plat_probe()
307 xhci->quirks |= XHCI_HW_LPM_DISABLE; in xhci_plat_probe()
309 if (device_property_read_bool(tmpdev, "usb3-lpm-capable")) in xhci_plat_probe()
310 xhci->quirks |= XHCI_LPM_SUPPORT; in xhci_plat_probe()
312 if (device_property_read_bool(tmpdev, "quirk-broken-port-ped")) in xhci_plat_probe()
313 xhci->quirks |= XHCI_BROKEN_PORT_PED; in xhci_plat_probe()
315 device_property_read_u32(tmpdev, "imod-interval-ns", in xhci_plat_probe()
316 &xhci->imod_interval); in xhci_plat_probe()
319 hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0); in xhci_plat_probe()
320 if (IS_ERR(hcd->usb_phy)) { in xhci_plat_probe()
321 ret = PTR_ERR(hcd->usb_phy); in xhci_plat_probe()
322 if (ret == -EPROBE_DEFER) in xhci_plat_probe()
324 hcd->usb_phy = NULL; in xhci_plat_probe()
326 ret = usb_phy_init(hcd->usb_phy); in xhci_plat_probe()
331 hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node); in xhci_plat_probe()
332 xhci->shared_hcd->tpl_support = hcd->tpl_support; in xhci_plat_probe()
333 if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT)) in xhci_plat_probe()
334 hcd->skip_phy_initialization = 1; in xhci_plat_probe()
340 if (HCC_MAX_PSA(xhci->hcc_params) >= 4) in xhci_plat_probe()
341 xhci->shared_hcd->can_do_streams = 1; in xhci_plat_probe()
343 ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); in xhci_plat_probe()
347 device_enable_async_suspend(&pdev->dev); in xhci_plat_probe()
348 pm_runtime_put_noidle(&pdev->dev); in xhci_plat_probe()
354 pm_runtime_forbid(&pdev->dev); in xhci_plat_probe()
363 usb_phy_shutdown(hcd->usb_phy); in xhci_plat_probe()
366 usb_put_hcd(xhci->shared_hcd); in xhci_plat_probe()
369 clk_disable_unprepare(xhci->clk); in xhci_plat_probe()
372 clk_disable_unprepare(xhci->reg_clk); in xhci_plat_probe()
378 pm_runtime_put_noidle(&pdev->dev); in xhci_plat_probe()
379 pm_runtime_disable(&pdev->dev); in xhci_plat_probe()
387 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_plat_remove() local
388 struct clk *clk = xhci->clk; in xhci_plat_remove()
389 struct clk *reg_clk = xhci->reg_clk; in xhci_plat_remove()
390 struct usb_hcd *shared_hcd = xhci->shared_hcd; in xhci_plat_remove()
392 pm_runtime_get_sync(&dev->dev); in xhci_plat_remove()
393 xhci->xhc_state |= XHCI_STATE_REMOVING; in xhci_plat_remove()
396 xhci->shared_hcd = NULL; in xhci_plat_remove()
397 usb_phy_shutdown(hcd->usb_phy); in xhci_plat_remove()
406 pm_runtime_disable(&dev->dev); in xhci_plat_remove()
407 pm_runtime_put_noidle(&dev->dev); in xhci_plat_remove()
408 pm_runtime_set_suspended(&dev->dev); in xhci_plat_remove()
416 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_plat_suspend() local
426 return xhci_suspend(xhci, device_may_wakeup(dev)); in xhci_plat_suspend()
432 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_plat_resume() local
439 ret = xhci_resume(xhci, 0); in xhci_plat_resume()
453 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_plat_runtime_suspend() local
460 return xhci_suspend(xhci, true); in xhci_plat_runtime_suspend()
466 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_plat_runtime_resume() local
468 return xhci_resume(xhci, 0); in xhci_plat_runtime_resume()
481 /* XHCI-compliant USB Controller */
493 .name = "xhci-hcd",
499 MODULE_ALIAS("platform:xhci-hcd");
514 MODULE_DESCRIPTION("xHCI Platform Host Controller Driver");