Lines Matching +full:usb +full:- +full:phy +full:- +full:controller

1 // SPDX-License-Identifier: GPL-2.0
13 #include <linux/usb.h>
14 #include <linux/usb/chipidea.h>
15 #include <linux/usb/hcd.h>
16 #include <linux/usb/of.h>
17 #include <linux/usb/phy.h>
30 struct usb_phy *phy; member
76 .compatible = "nvidia,tegra20-ehci",
79 .compatible = "nvidia,tegra30-ehci",
82 .compatible = "nvidia,tegra20-udc",
85 .compatible = "nvidia,tegra30-udc",
88 .compatible = "nvidia,tegra114-udc",
91 .compatible = "nvidia,tegra124-udc",
105 rst = devm_reset_control_get_shared(dev, "usb"); in tegra_usb_reset_controller()
111 phy_np = of_parse_phandle(dev->of_node, "nvidia,phy", 0); in tegra_usb_reset_controller()
113 return -ENOENT; in tegra_usb_reset_controller()
116 * The 1st USB controller contains some UTMI pad registers that are in tegra_usb_reset_controller()
118 * also cleared when reset is asserted to the 1st controller. in tegra_usb_reset_controller()
120 rst_utmi = of_reset_control_get_shared(phy_np, "utmi-pads"); in tegra_usb_reset_controller()
122 dev_warn(dev, "can't get utmi-pads reset from the PHY\n"); in tegra_usb_reset_controller()
126 * PHY driver performs UTMI-pads reset in a case of a in tegra_usb_reset_controller()
127 * non-legacy DT. in tegra_usb_reset_controller()
154 struct tegra_usb *usb = dev_get_drvdata(ci->dev->parent); in tegra_usb_notify_event() local
159 if (ci->hcd) { in tegra_usb_notify_event()
160 ehci = hcd_to_ehci(ci->hcd); in tegra_usb_notify_event()
161 ehci->has_tdi_phy_lpm = false; in tegra_usb_notify_event()
162 ehci_writel(ehci, usb->soc->txfifothresh << 16, in tegra_usb_notify_event()
163 &ehci->regs->txfill_tuning); in tegra_usb_notify_event()
179 saved_usbintr = ehci_readl(ehci, &ehci->regs->intr_enable); in tegra_usb_internal_port_reset()
180 /* disable USB interrupt */ in tegra_usb_internal_port_reset()
181 ehci_writel(ehci, 0, &ehci->regs->intr_enable); in tegra_usb_internal_port_reset()
182 spin_unlock_irqrestore(&ehci->lock, *flags); in tegra_usb_internal_port_reset()
206 } while (!(temp & PORT_PE) && tries--); in tegra_usb_internal_port_reset()
211 retval = -ETIMEDOUT; in tegra_usb_internal_port_reset()
224 temp = ehci_readl(ehci, &ehci->regs->status); in tegra_usb_internal_port_reset()
225 ehci_writel(ehci, temp, &ehci->regs->status); in tegra_usb_internal_port_reset()
227 /* restore original interrupt-enable bits */ in tegra_usb_internal_port_reset()
228 spin_lock_irqsave(&ehci->lock, *flags); in tegra_usb_internal_port_reset()
229 ehci_writel(ehci, saved_usbintr, &ehci->regs->intr_enable); in tegra_usb_internal_port_reset()
238 struct tegra_usb *usb = dev_get_drvdata(ci->dev->parent); in tegra_ehci_hub_control() local
239 struct ehci_hcd *ehci = hcd_to_ehci(ci->hcd); in tegra_ehci_hub_control()
243 status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1]; in tegra_ehci_hub_control()
247 if (wValue != USB_PORT_FEAT_RESET || !usb->needs_double_reset) in tegra_ehci_hub_control()
263 * hang CPU if USB controller is put into low power mode because in tegra_usb_enter_lpm()
264 * AHB USB clock is gated on Tegra in the LPM. in tegra_usb_enter_lpm()
266 * Tegra PHY has a separate register for checking the clock status in tegra_usb_enter_lpm()
268 * and restoring the PHY state on Tegra. Hence DEVLC/PORTSC registers in tegra_usb_enter_lpm()
271 usb_phy_set_suspend(ci->usb_phy, enable); in tegra_usb_enter_lpm()
277 struct tegra_usb *usb; in tegra_usb_probe() local
280 usb = devm_kzalloc(&pdev->dev, sizeof(*usb), GFP_KERNEL); in tegra_usb_probe()
281 if (!usb) in tegra_usb_probe()
282 return -ENOMEM; in tegra_usb_probe()
284 platform_set_drvdata(pdev, usb); in tegra_usb_probe()
286 soc = of_device_get_match_data(&pdev->dev); in tegra_usb_probe()
288 dev_err(&pdev->dev, "failed to match OF data\n"); in tegra_usb_probe()
289 return -EINVAL; in tegra_usb_probe()
292 usb->phy = devm_usb_get_phy_by_phandle(&pdev->dev, "nvidia,phy", 0); in tegra_usb_probe()
293 if (IS_ERR(usb->phy)) in tegra_usb_probe()
294 return dev_err_probe(&pdev->dev, PTR_ERR(usb->phy), in tegra_usb_probe()
295 "failed to get PHY\n"); in tegra_usb_probe()
297 usb->clk = devm_clk_get(&pdev->dev, NULL); in tegra_usb_probe()
298 if (IS_ERR(usb->clk)) { in tegra_usb_probe()
299 err = PTR_ERR(usb->clk); in tegra_usb_probe()
300 dev_err(&pdev->dev, "failed to get clock: %d\n", err); in tegra_usb_probe()
304 err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); in tegra_usb_probe()
308 pm_runtime_enable(&pdev->dev); in tegra_usb_probe()
309 err = pm_runtime_resume_and_get(&pdev->dev); in tegra_usb_probe()
313 if (device_property_present(&pdev->dev, "nvidia,needs-double-reset")) in tegra_usb_probe()
314 usb->needs_double_reset = true; in tegra_usb_probe()
316 err = tegra_usb_reset_controller(&pdev->dev); in tegra_usb_probe()
318 dev_err(&pdev->dev, "failed to reset controller: %d\n", err); in tegra_usb_probe()
323 * USB controller registers shouldn't be touched before PHY is in tegra_usb_probe()
325 * PHY driver controls gating of internal USB clocks on Tegra. in tegra_usb_probe()
327 err = usb_phy_init(usb->phy); in tegra_usb_probe()
332 usb->soc = soc; in tegra_usb_probe()
333 usb->data.name = "tegra-usb"; in tegra_usb_probe()
334 usb->data.flags = soc->flags; in tegra_usb_probe()
335 usb->data.usb_phy = usb->phy; in tegra_usb_probe()
336 usb->data.dr_mode = soc->dr_mode; in tegra_usb_probe()
337 usb->data.capoffset = DEF_CAPOFFSET; in tegra_usb_probe()
338 usb->data.enter_lpm = tegra_usb_enter_lpm; in tegra_usb_probe()
339 usb->data.hub_control = tegra_ehci_hub_control; in tegra_usb_probe()
340 usb->data.notify_event = tegra_usb_notify_event; in tegra_usb_probe()
342 /* Tegra PHY driver currently doesn't support LPM for ULPI */ in tegra_usb_probe()
343 if (of_usb_get_phy_mode(pdev->dev.of_node) == USBPHY_INTERFACE_MODE_ULPI) in tegra_usb_probe()
344 usb->data.flags &= ~CI_HDRC_SUPPORTS_RUNTIME_PM; in tegra_usb_probe()
346 usb->dev = ci_hdrc_add_device(&pdev->dev, pdev->resource, in tegra_usb_probe()
347 pdev->num_resources, &usb->data); in tegra_usb_probe()
348 if (IS_ERR(usb->dev)) { in tegra_usb_probe()
349 err = PTR_ERR(usb->dev); in tegra_usb_probe()
350 dev_err(&pdev->dev, "failed to add HDRC device: %d\n", err); in tegra_usb_probe()
357 usb_phy_shutdown(usb->phy); in tegra_usb_probe()
359 pm_runtime_put_sync_suspend(&pdev->dev); in tegra_usb_probe()
360 pm_runtime_force_suspend(&pdev->dev); in tegra_usb_probe()
367 struct tegra_usb *usb = platform_get_drvdata(pdev); in tegra_usb_remove() local
369 ci_hdrc_remove_device(usb->dev); in tegra_usb_remove()
370 usb_phy_shutdown(usb->phy); in tegra_usb_remove()
372 pm_runtime_put_sync_suspend(&pdev->dev); in tegra_usb_remove()
373 pm_runtime_force_suspend(&pdev->dev); in tegra_usb_remove()
380 struct tegra_usb *usb = dev_get_drvdata(dev); in tegra_usb_runtime_resume() local
383 err = clk_prepare_enable(usb->clk); in tegra_usb_runtime_resume()
394 struct tegra_usb *usb = dev_get_drvdata(dev); in tegra_usb_runtime_suspend() local
396 clk_disable_unprepare(usb->clk); in tegra_usb_runtime_suspend()
408 .name = "tegra-usb",
417 MODULE_DESCRIPTION("NVIDIA Tegra USB driver");