Lines Matching +full:generic +full:- +full:xhci
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>
24 #include "xhci.h"
25 #include "xhci-plat.h"
26 #include "xhci-mvebu.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()
81 xhci->quirks |= priv->quirks; in xhci_plat_quirks()
118 .compatible = "generic-xhci",
120 .compatible = "xhci-platform",
122 .compatible = "marvell,armada-375-xhci",
125 .compatible = "marvell,armada-380-xhci",
128 .compatible = "marvell,armada3700-xhci",
131 .compatible = "brcm,xhci-brcm-v2",
134 .compatible = "brcm,bcm2711-xhci",
137 .compatible = "brcm,bcm7445-xhci",
149 struct xhci_hcd *xhci; in xhci_plat_probe() local
158 return -ENODEV; in xhci_plat_probe()
167 sysdev = &pdev->dev; in xhci_plat_probe()
173 pm_runtime_set_active(&pdev->dev); in xhci_plat_probe()
174 pm_runtime_enable(&pdev->dev); in xhci_plat_probe()
175 pm_runtime_get_noresume(&pdev->dev); in xhci_plat_probe()
177 hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, in xhci_plat_probe()
178 dev_name(&pdev->dev), NULL); in xhci_plat_probe()
180 ret = -ENOMEM; in xhci_plat_probe()
184 hcd->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in xhci_plat_probe()
185 if (IS_ERR(hcd->regs)) { in xhci_plat_probe()
186 ret = PTR_ERR(hcd->regs); in xhci_plat_probe()
190 hcd->rsrc_start = res->start; in xhci_plat_probe()
191 hcd->rsrc_len = resource_size(res); in xhci_plat_probe()
193 xhci = hcd_to_xhci(hcd); in xhci_plat_probe()
195 xhci->allow_single_roothub = 1; in xhci_plat_probe()
201 xhci->reg_clk = devm_clk_get_optional(&pdev->dev, "reg"); in xhci_plat_probe()
202 if (IS_ERR(xhci->reg_clk)) { in xhci_plat_probe()
203 ret = PTR_ERR(xhci->reg_clk); in xhci_plat_probe()
207 xhci->clk = devm_clk_get_optional(&pdev->dev, NULL); in xhci_plat_probe()
208 if (IS_ERR(xhci->clk)) { in xhci_plat_probe()
209 ret = PTR_ERR(xhci->clk); in xhci_plat_probe()
213 xhci->reset = devm_reset_control_array_get_optional_shared(&pdev->dev); in xhci_plat_probe()
214 if (IS_ERR(xhci->reset)) { in xhci_plat_probe()
215 ret = PTR_ERR(xhci->reset); in xhci_plat_probe()
219 ret = reset_control_deassert(xhci->reset); in xhci_plat_probe()
223 ret = clk_prepare_enable(xhci->reg_clk); in xhci_plat_probe()
227 ret = clk_prepare_enable(xhci->clk); in xhci_plat_probe()
237 device_set_wakeup_capable(&pdev->dev, true); in xhci_plat_probe()
239 xhci->main_hcd = hcd; in xhci_plat_probe()
242 xhci->imod_interval = 40000; in xhci_plat_probe()
245 for (tmpdev = &pdev->dev; tmpdev; tmpdev = tmpdev->parent) { in xhci_plat_probe()
247 if (device_property_read_bool(tmpdev, "usb2-lpm-disable")) in xhci_plat_probe()
248 xhci->quirks |= XHCI_HW_LPM_DISABLE; in xhci_plat_probe()
250 if (device_property_read_bool(tmpdev, "usb3-lpm-capable")) in xhci_plat_probe()
251 xhci->quirks |= XHCI_LPM_SUPPORT; in xhci_plat_probe()
253 if (device_property_read_bool(tmpdev, "quirk-broken-port-ped")) in xhci_plat_probe()
254 xhci->quirks |= XHCI_BROKEN_PORT_PED; in xhci_plat_probe()
256 if (device_property_read_bool(tmpdev, "xhci-sg-trb-cache-size-quirk")) in xhci_plat_probe()
257 xhci->quirks |= XHCI_SG_TRB_CACHE_SIZE_QUIRK; in xhci_plat_probe()
259 if (device_property_read_bool(tmpdev, "write-64-hi-lo-quirk")) in xhci_plat_probe()
260 xhci->quirks |= XHCI_WRITE_64_HI_LO; in xhci_plat_probe()
262 if (device_property_read_bool(tmpdev, "xhci-missing-cas-quirk")) in xhci_plat_probe()
263 xhci->quirks |= XHCI_MISSING_CAS; in xhci_plat_probe()
265 if (device_property_read_bool(tmpdev, "xhci-skip-phy-init-quirk")) in xhci_plat_probe()
266 xhci->quirks |= XHCI_SKIP_PHY_INIT; in xhci_plat_probe()
268 device_property_read_u32(tmpdev, "imod-interval-ns", in xhci_plat_probe()
269 &xhci->imod_interval); in xhci_plat_probe()
274 * matching for the xhci platform device). in xhci_plat_probe()
276 of_match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev); in xhci_plat_probe()
278 hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0); in xhci_plat_probe()
279 if (IS_ERR(hcd->usb_phy)) { in xhci_plat_probe()
280 ret = PTR_ERR(hcd->usb_phy); in xhci_plat_probe()
281 if (ret == -EPROBE_DEFER) in xhci_plat_probe()
283 hcd->usb_phy = NULL; in xhci_plat_probe()
285 ret = usb_phy_init(hcd->usb_phy); in xhci_plat_probe()
291 hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node); in xhci_plat_probe()
293 if ((priv && (priv->quirks & XHCI_SKIP_PHY_INIT)) || in xhci_plat_probe()
294 (xhci->quirks & XHCI_SKIP_PHY_INIT)) in xhci_plat_probe()
295 hcd->skip_phy_initialization = 1; in xhci_plat_probe()
297 if (priv && (priv->quirks & XHCI_SG_TRB_CACHE_SIZE_QUIRK)) in xhci_plat_probe()
298 xhci->quirks |= XHCI_SG_TRB_CACHE_SIZE_QUIRK; in xhci_plat_probe()
304 if (!xhci_has_one_roothub(xhci)) { in xhci_plat_probe()
305 xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, in xhci_plat_probe()
306 dev_name(&pdev->dev), hcd); in xhci_plat_probe()
307 if (!xhci->shared_hcd) { in xhci_plat_probe()
308 ret = -ENOMEM; in xhci_plat_probe()
313 xhci->shared_hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, in xhci_plat_probe()
314 "usb-phy", 1); in xhci_plat_probe()
315 if (IS_ERR(xhci->shared_hcd->usb_phy)) { in xhci_plat_probe()
316 xhci->shared_hcd->usb_phy = NULL; in xhci_plat_probe()
318 ret = usb_phy_init(xhci->shared_hcd->usb_phy); in xhci_plat_probe()
325 xhci->shared_hcd->tpl_support = hcd->tpl_support; in xhci_plat_probe()
328 usb3_hcd = xhci_get_usb3_hcd(xhci); in xhci_plat_probe()
329 if (usb3_hcd && HCC_MAX_PSA(xhci->hcc_params) >= 4) in xhci_plat_probe()
330 usb3_hcd->can_do_streams = 1; in xhci_plat_probe()
332 if (xhci->shared_hcd) { in xhci_plat_probe()
333 xhci->shared_hcd->rsrc_start = hcd->rsrc_start; in xhci_plat_probe()
334 xhci->shared_hcd->rsrc_len = hcd->rsrc_len; in xhci_plat_probe()
335 ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); in xhci_plat_probe()
340 device_enable_async_suspend(&pdev->dev); in xhci_plat_probe()
341 pm_runtime_put_noidle(&pdev->dev); in xhci_plat_probe()
347 pm_runtime_forbid(&pdev->dev); in xhci_plat_probe()
353 usb_put_hcd(xhci->shared_hcd); in xhci_plat_probe()
359 usb_phy_shutdown(hcd->usb_phy); in xhci_plat_probe()
362 clk_disable_unprepare(xhci->clk); in xhci_plat_probe()
365 clk_disable_unprepare(xhci->reg_clk); in xhci_plat_probe()
368 reset_control_assert(xhci->reset); in xhci_plat_probe()
374 pm_runtime_put_noidle(&pdev->dev); in xhci_plat_probe()
375 pm_runtime_disable(&pdev->dev); in xhci_plat_probe()
391 * 2. xhci_plat is child of a device from firmware (dwc3-plat) in xhci_generic_plat_probe()
392 * 3. xhci_plat is grandchild of a pci device (dwc3-pci) in xhci_generic_plat_probe()
394 for (sysdev = &pdev->dev; sysdev; sysdev = sysdev->parent) { in xhci_generic_plat_probe()
395 if (is_of_node(sysdev->fwnode) || in xhci_generic_plat_probe()
396 is_acpi_device_node(sysdev->fwnode)) in xhci_generic_plat_probe()
403 sysdev = &pdev->dev; in xhci_generic_plat_probe()
405 if (WARN_ON(!sysdev->dma_mask)) { in xhci_generic_plat_probe()
412 if (pdev->dev.of_node) in xhci_generic_plat_probe()
413 priv_match = of_device_get_match_data(&pdev->dev); in xhci_generic_plat_probe()
415 priv_match = dev_get_platdata(&pdev->dev); in xhci_generic_plat_probe()
423 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_plat_remove() local
424 struct clk *clk = xhci->clk; in xhci_plat_remove()
425 struct clk *reg_clk = xhci->reg_clk; in xhci_plat_remove()
426 struct usb_hcd *shared_hcd = xhci->shared_hcd; in xhci_plat_remove()
428 xhci->xhc_state |= XHCI_STATE_REMOVING; in xhci_plat_remove()
429 pm_runtime_get_sync(&dev->dev); in xhci_plat_remove()
433 xhci->shared_hcd = NULL; in xhci_plat_remove()
436 usb_phy_shutdown(hcd->usb_phy); in xhci_plat_remove()
445 reset_control_assert(xhci->reset); in xhci_plat_remove()
448 pm_runtime_disable(&dev->dev); in xhci_plat_remove()
449 pm_runtime_put_noidle(&dev->dev); in xhci_plat_remove()
450 pm_runtime_set_suspended(&dev->dev); in xhci_plat_remove()
457 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_plat_suspend() local
470 ret = xhci_suspend(xhci, device_may_wakeup(dev)); in xhci_plat_suspend()
474 if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) { in xhci_plat_suspend()
475 clk_disable_unprepare(xhci->clk); in xhci_plat_suspend()
476 clk_disable_unprepare(xhci->reg_clk); in xhci_plat_suspend()
485 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_plat_resume_common() local
488 if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) { in xhci_plat_resume_common()
489 ret = clk_prepare_enable(xhci->clk); in xhci_plat_resume_common()
493 ret = clk_prepare_enable(xhci->reg_clk); in xhci_plat_resume_common()
495 clk_disable_unprepare(xhci->clk); in xhci_plat_resume_common()
504 ret = xhci_resume(xhci, pmsg); in xhci_plat_resume_common()
515 if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) { in xhci_plat_resume_common()
516 clk_disable_unprepare(xhci->clk); in xhci_plat_resume_common()
517 clk_disable_unprepare(xhci->reg_clk); in xhci_plat_resume_common()
536 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_plat_runtime_suspend() local
543 return xhci_suspend(xhci, true); in xhci_plat_runtime_suspend()
549 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_plat_runtime_resume() local
551 return xhci_resume(xhci, PMSG_AUTO_RESUME); in xhci_plat_runtime_resume()
570 /* XHCI-compliant USB Controller */
583 .name = "xhci-hcd",
589 MODULE_ALIAS("platform:xhci-hcd");
604 MODULE_DESCRIPTION("xHCI Platform Host Controller Driver");