Lines Matching +full:imod +full:- +full:interval +full:- +full:ns

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
12 #include <linux/dma-mapping.h>
24 #include "xhci-plat.h"
25 #include "xhci-mvebu.h"
42 if (priv->plat_start) in xhci_priv_plat_start()
43 priv->plat_start(hcd); in xhci_priv_plat_start()
50 if (!priv->init_quirk) in xhci_priv_init_quirk()
53 return priv->init_quirk(hcd); in xhci_priv_init_quirk()
60 if (!priv->suspend_quirk) in xhci_priv_suspend_quirk()
63 return priv->suspend_quirk(hcd); in xhci_priv_suspend_quirk()
70 if (!priv->resume_quirk) in xhci_priv_resume_quirk()
73 return priv->resume_quirk(hcd); in xhci_priv_resume_quirk()
80 xhci->quirks |= priv->quirks; in xhci_plat_quirks()
117 .compatible = "generic-xhci",
119 .compatible = "xhci-platform",
121 .compatible = "marvell,armada-375-xhci",
124 .compatible = "marvell,armada-380-xhci",
127 .compatible = "marvell,armada3700-xhci",
130 .compatible = "brcm,xhci-brcm-v2",
133 .compatible = "brcm,bcm7445-xhci",
154 return -ENODEV; in xhci_plat_probe()
163 sysdev = &pdev->dev; in xhci_plat_probe()
169 pm_runtime_set_active(&pdev->dev); in xhci_plat_probe()
170 pm_runtime_enable(&pdev->dev); in xhci_plat_probe()
171 pm_runtime_get_noresume(&pdev->dev); in xhci_plat_probe()
173 hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, in xhci_plat_probe()
174 dev_name(&pdev->dev), NULL); in xhci_plat_probe()
176 ret = -ENOMEM; in xhci_plat_probe()
180 hcd->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in xhci_plat_probe()
181 if (IS_ERR(hcd->regs)) { in xhci_plat_probe()
182 ret = PTR_ERR(hcd->regs); in xhci_plat_probe()
186 hcd->rsrc_start = res->start; in xhci_plat_probe()
187 hcd->rsrc_len = resource_size(res); in xhci_plat_probe()
191 xhci->allow_single_roothub = 1; in xhci_plat_probe()
197 xhci->reg_clk = devm_clk_get_optional(&pdev->dev, "reg"); in xhci_plat_probe()
198 if (IS_ERR(xhci->reg_clk)) { in xhci_plat_probe()
199 ret = PTR_ERR(xhci->reg_clk); in xhci_plat_probe()
203 xhci->clk = devm_clk_get_optional(&pdev->dev, NULL); in xhci_plat_probe()
204 if (IS_ERR(xhci->clk)) { in xhci_plat_probe()
205 ret = PTR_ERR(xhci->clk); in xhci_plat_probe()
209 xhci->reset = devm_reset_control_array_get_optional_shared(&pdev->dev); in xhci_plat_probe()
210 if (IS_ERR(xhci->reset)) { in xhci_plat_probe()
211 ret = PTR_ERR(xhci->reset); in xhci_plat_probe()
215 ret = reset_control_deassert(xhci->reset); in xhci_plat_probe()
219 ret = clk_prepare_enable(xhci->reg_clk); in xhci_plat_probe()
223 ret = clk_prepare_enable(xhci->clk); in xhci_plat_probe()
233 device_set_wakeup_capable(&pdev->dev, true); in xhci_plat_probe()
235 xhci->main_hcd = hcd; in xhci_plat_probe()
238 xhci->imod_interval = 40000; in xhci_plat_probe()
241 for (tmpdev = &pdev->dev; tmpdev; tmpdev = tmpdev->parent) { in xhci_plat_probe()
243 if (device_property_read_bool(tmpdev, "usb2-lpm-disable")) in xhci_plat_probe()
244 xhci->quirks |= XHCI_HW_LPM_DISABLE; in xhci_plat_probe()
246 if (device_property_read_bool(tmpdev, "usb3-lpm-capable")) in xhci_plat_probe()
247 xhci->quirks |= XHCI_LPM_SUPPORT; in xhci_plat_probe()
249 if (device_property_read_bool(tmpdev, "quirk-broken-port-ped")) in xhci_plat_probe()
250 xhci->quirks |= XHCI_BROKEN_PORT_PED; in xhci_plat_probe()
252 device_property_read_u32(tmpdev, "imod-interval-ns", in xhci_plat_probe()
253 &xhci->imod_interval); in xhci_plat_probe()
256 hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0); in xhci_plat_probe()
257 if (IS_ERR(hcd->usb_phy)) { in xhci_plat_probe()
258 ret = PTR_ERR(hcd->usb_phy); in xhci_plat_probe()
259 if (ret == -EPROBE_DEFER) in xhci_plat_probe()
261 hcd->usb_phy = NULL; in xhci_plat_probe()
263 ret = usb_phy_init(hcd->usb_phy); in xhci_plat_probe()
268 hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node); in xhci_plat_probe()
270 if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT)) in xhci_plat_probe()
271 hcd->skip_phy_initialization = 1; in xhci_plat_probe()
273 if (priv && (priv->quirks & XHCI_SG_TRB_CACHE_SIZE_QUIRK)) in xhci_plat_probe()
274 xhci->quirks |= XHCI_SG_TRB_CACHE_SIZE_QUIRK; in xhci_plat_probe()
281 xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, in xhci_plat_probe()
282 dev_name(&pdev->dev), hcd); in xhci_plat_probe()
283 if (!xhci->shared_hcd) { in xhci_plat_probe()
284 ret = -ENOMEM; in xhci_plat_probe()
288 xhci->shared_hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, in xhci_plat_probe()
289 "usb-phy", 1); in xhci_plat_probe()
290 if (IS_ERR(xhci->shared_hcd->usb_phy)) { in xhci_plat_probe()
291 xhci->shared_hcd->usb_phy = NULL; in xhci_plat_probe()
293 ret = usb_phy_init(xhci->shared_hcd->usb_phy); in xhci_plat_probe()
299 xhci->shared_hcd->tpl_support = hcd->tpl_support; in xhci_plat_probe()
303 if (usb3_hcd && HCC_MAX_PSA(xhci->hcc_params) >= 4) in xhci_plat_probe()
304 usb3_hcd->can_do_streams = 1; in xhci_plat_probe()
306 if (xhci->shared_hcd) { in xhci_plat_probe()
307 ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); in xhci_plat_probe()
312 device_enable_async_suspend(&pdev->dev); in xhci_plat_probe()
313 pm_runtime_put_noidle(&pdev->dev); in xhci_plat_probe()
319 pm_runtime_forbid(&pdev->dev); in xhci_plat_probe()
325 usb_put_hcd(xhci->shared_hcd); in xhci_plat_probe()
331 usb_phy_shutdown(hcd->usb_phy); in xhci_plat_probe()
334 clk_disable_unprepare(xhci->clk); in xhci_plat_probe()
337 clk_disable_unprepare(xhci->reg_clk); in xhci_plat_probe()
340 reset_control_assert(xhci->reset); in xhci_plat_probe()
346 pm_runtime_put_noidle(&pdev->dev); in xhci_plat_probe()
347 pm_runtime_disable(&pdev->dev); in xhci_plat_probe()
363 * 2. xhci_plat is child of a device from firmware (dwc3-plat) in xhci_generic_plat_probe()
364 * 3. xhci_plat is grandchild of a pci device (dwc3-pci) in xhci_generic_plat_probe()
366 for (sysdev = &pdev->dev; sysdev; sysdev = sysdev->parent) { in xhci_generic_plat_probe()
367 if (is_of_node(sysdev->fwnode) || in xhci_generic_plat_probe()
368 is_acpi_device_node(sysdev->fwnode)) in xhci_generic_plat_probe()
375 sysdev = &pdev->dev; in xhci_generic_plat_probe()
377 if (WARN_ON(!sysdev->dma_mask)) { in xhci_generic_plat_probe()
384 if (pdev->dev.of_node) in xhci_generic_plat_probe()
385 priv_match = of_device_get_match_data(&pdev->dev); in xhci_generic_plat_probe()
387 priv_match = dev_get_platdata(&pdev->dev); in xhci_generic_plat_probe()
396 struct clk *clk = xhci->clk; in xhci_plat_remove()
397 struct clk *reg_clk = xhci->reg_clk; in xhci_plat_remove()
398 struct usb_hcd *shared_hcd = xhci->shared_hcd; in xhci_plat_remove()
400 xhci->xhc_state |= XHCI_STATE_REMOVING; in xhci_plat_remove()
401 pm_runtime_get_sync(&dev->dev); in xhci_plat_remove()
405 xhci->shared_hcd = NULL; in xhci_plat_remove()
408 usb_phy_shutdown(hcd->usb_phy); in xhci_plat_remove()
417 reset_control_assert(xhci->reset); in xhci_plat_remove()
420 pm_runtime_disable(&dev->dev); in xhci_plat_remove()
421 pm_runtime_put_noidle(&dev->dev); in xhci_plat_remove()
422 pm_runtime_set_suspended(&dev->dev); in xhci_plat_remove()
446 if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) { in xhci_plat_suspend()
447 clk_disable_unprepare(xhci->clk); in xhci_plat_suspend()
448 clk_disable_unprepare(xhci->reg_clk); in xhci_plat_suspend()
460 if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) { in xhci_plat_resume()
461 clk_prepare_enable(xhci->clk); in xhci_plat_resume()
462 clk_prepare_enable(xhci->reg_clk); in xhci_plat_resume()
512 /* XHCI-compliant USB Controller */
524 .name = "xhci-hcd",
530 MODULE_ALIAS("platform:xhci-hcd");