Lines Matching +full:t +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0
18 #include <linux/usb/phy.h>
31 struct usb_phy *phy; member
77 .compatible = "nvidia,tegra20-ehci",
80 .compatible = "nvidia,tegra30-ehci",
83 .compatible = "nvidia,tegra20-udc",
86 .compatible = "nvidia,tegra30-udc",
89 .compatible = "nvidia,tegra114-udc",
92 .compatible = "nvidia,tegra124-udc",
108 dev_err(dev, "can't get ehci reset: %pe\n", rst); in tegra_usb_reset_controller()
112 phy_np = of_parse_phandle(dev->of_node, "nvidia,phy", 0); in tegra_usb_reset_controller()
114 return -ENOENT; in tegra_usb_reset_controller()
121 rst_utmi = of_reset_control_get_shared(phy_np, "utmi-pads"); in tegra_usb_reset_controller()
123 dev_warn(dev, "can't get utmi-pads reset from the PHY\n"); in tegra_usb_reset_controller()
127 * PHY driver performs UTMI-pads reset in a case of a in tegra_usb_reset_controller()
128 * non-legacy DT. in tegra_usb_reset_controller()
155 struct tegra_usb *usb = dev_get_drvdata(ci->dev->parent); in tegra_usb_notify_event()
160 if (ci->hcd) { in tegra_usb_notify_event()
161 ehci = hcd_to_ehci(ci->hcd); in tegra_usb_notify_event()
162 ehci->has_tdi_phy_lpm = false; in tegra_usb_notify_event()
163 ehci_writel(ehci, usb->soc->txfifothresh << 16, in tegra_usb_notify_event()
164 &ehci->regs->txfill_tuning); in tegra_usb_notify_event()
180 saved_usbintr = ehci_readl(ehci, &ehci->regs->intr_enable); in tegra_usb_internal_port_reset()
182 ehci_writel(ehci, 0, &ehci->regs->intr_enable); in tegra_usb_internal_port_reset()
183 spin_unlock_irqrestore(&ehci->lock, *flags); in tegra_usb_internal_port_reset()
207 } while (!(temp & PORT_PE) && tries--); in tegra_usb_internal_port_reset()
212 retval = -ETIMEDOUT; in tegra_usb_internal_port_reset()
216 * We can't clear PORT_PEC. It will also cause PORT_PE to be cleared. in tegra_usb_internal_port_reset()
225 temp = ehci_readl(ehci, &ehci->regs->status); in tegra_usb_internal_port_reset()
226 ehci_writel(ehci, temp, &ehci->regs->status); in tegra_usb_internal_port_reset()
228 /* restore original interrupt-enable bits */ in tegra_usb_internal_port_reset()
229 spin_lock_irqsave(&ehci->lock, *flags); in tegra_usb_internal_port_reset()
230 ehci_writel(ehci, saved_usbintr, &ehci->regs->intr_enable); in tegra_usb_internal_port_reset()
239 struct tegra_usb *usb = dev_get_drvdata(ci->dev->parent); in tegra_ehci_hub_control()
240 struct ehci_hcd *ehci = hcd_to_ehci(ci->hcd); in tegra_ehci_hub_control()
244 status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1]; in tegra_ehci_hub_control()
248 if (wValue != USB_PORT_FEAT_RESET || !usb->needs_double_reset) in tegra_ehci_hub_control()
267 * Tegra PHY has a separate register for checking the clock status in tegra_usb_enter_lpm()
269 * and restoring the PHY state on Tegra. Hence DEVLC/PORTSC registers in tegra_usb_enter_lpm()
270 * shouldn't be touched directly by the CI driver. in tegra_usb_enter_lpm()
272 usb_phy_set_suspend(ci->usb_phy, enable); in tegra_usb_enter_lpm()
281 usb = devm_kzalloc(&pdev->dev, sizeof(*usb), GFP_KERNEL); in tegra_usb_probe()
283 return -ENOMEM; in tegra_usb_probe()
287 soc = of_device_get_match_data(&pdev->dev); in tegra_usb_probe()
289 dev_err(&pdev->dev, "failed to match OF data\n"); in tegra_usb_probe()
290 return -EINVAL; in tegra_usb_probe()
293 usb->phy = devm_usb_get_phy_by_phandle(&pdev->dev, "nvidia,phy", 0); in tegra_usb_probe()
294 if (IS_ERR(usb->phy)) in tegra_usb_probe()
295 return dev_err_probe(&pdev->dev, PTR_ERR(usb->phy), in tegra_usb_probe()
296 "failed to get PHY"); in tegra_usb_probe()
298 usb->clk = devm_clk_get(&pdev->dev, NULL); in tegra_usb_probe()
299 if (IS_ERR(usb->clk)) in tegra_usb_probe()
300 return dev_err_probe(&pdev->dev, PTR_ERR(usb->clk), in tegra_usb_probe()
303 err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); in tegra_usb_probe()
307 pm_runtime_enable(&pdev->dev); in tegra_usb_probe()
308 err = pm_runtime_resume_and_get(&pdev->dev); in tegra_usb_probe()
312 if (device_property_present(&pdev->dev, "nvidia,needs-double-reset")) in tegra_usb_probe()
313 usb->needs_double_reset = true; in tegra_usb_probe()
315 err = tegra_usb_reset_controller(&pdev->dev); in tegra_usb_probe()
317 dev_err_probe(&pdev->dev, err, "failed to reset controller"); in tegra_usb_probe()
322 * USB controller registers shouldn't be touched before PHY is in tegra_usb_probe()
324 * PHY driver controls gating of internal USB clocks on Tegra. in tegra_usb_probe()
326 err = usb_phy_init(usb->phy); in tegra_usb_probe()
331 usb->soc = soc; in tegra_usb_probe()
332 usb->data.name = "tegra-usb"; in tegra_usb_probe()
333 usb->data.flags = soc->flags; in tegra_usb_probe()
334 usb->data.usb_phy = usb->phy; in tegra_usb_probe()
335 usb->data.dr_mode = soc->dr_mode; in tegra_usb_probe()
336 usb->data.capoffset = DEF_CAPOFFSET; in tegra_usb_probe()
337 usb->data.enter_lpm = tegra_usb_enter_lpm; in tegra_usb_probe()
338 usb->data.hub_control = tegra_ehci_hub_control; in tegra_usb_probe()
339 usb->data.notify_event = tegra_usb_notify_event; in tegra_usb_probe()
341 /* Tegra PHY driver currently doesn't support LPM for ULPI */ in tegra_usb_probe()
342 if (of_usb_get_phy_mode(pdev->dev.of_node) == USBPHY_INTERFACE_MODE_ULPI) in tegra_usb_probe()
343 usb->data.flags &= ~CI_HDRC_SUPPORTS_RUNTIME_PM; in tegra_usb_probe()
345 usb->dev = ci_hdrc_add_device(&pdev->dev, pdev->resource, in tegra_usb_probe()
346 pdev->num_resources, &usb->data); in tegra_usb_probe()
347 if (IS_ERR(usb->dev)) { in tegra_usb_probe()
348 err = dev_err_probe(&pdev->dev, PTR_ERR(usb->dev), in tegra_usb_probe()
356 usb_phy_shutdown(usb->phy); in tegra_usb_probe()
358 pm_runtime_put_sync_suspend(&pdev->dev); in tegra_usb_probe()
359 pm_runtime_force_suspend(&pdev->dev); in tegra_usb_probe()
368 ci_hdrc_remove_device(usb->dev); in tegra_usb_remove()
369 usb_phy_shutdown(usb->phy); in tegra_usb_remove()
371 pm_runtime_put_sync_suspend(&pdev->dev); in tegra_usb_remove()
372 pm_runtime_force_suspend(&pdev->dev); in tegra_usb_remove()
380 err = clk_prepare_enable(usb->clk); in tegra_usb_runtime_resume()
393 clk_disable_unprepare(usb->clk); in tegra_usb_runtime_suspend()
404 .name = "tegra-usb",