Lines Matching +full:usb +full:- +full:ehci
1 // SPDX-License-Identifier: GPL-2.0
12 #include <linux/usb.h>
13 #include <linux/usb/chipidea.h>
14 #include <linux/usb/hcd.h>
15 #include <linux/usb/of.h>
16 #include <linux/usb/phy.h>
18 #include "../host/ehci.h"
73 .compatible = "nvidia,tegra20-ehci",
76 .compatible = "nvidia,tegra30-ehci",
79 .compatible = "nvidia,tegra20-udc",
82 .compatible = "nvidia,tegra30-udc",
85 .compatible = "nvidia,tegra114-udc",
88 .compatible = "nvidia,tegra124-udc",
102 rst = devm_reset_control_get_shared(dev, "usb"); in tegra_usb_reset_controller()
104 dev_err(dev, "can't get ehci reset: %pe\n", rst); in tegra_usb_reset_controller()
108 phy_np = of_parse_phandle(dev->of_node, "nvidia,phy", 0); in tegra_usb_reset_controller()
110 return -ENOENT; in tegra_usb_reset_controller()
113 * The 1st USB controller contains some UTMI pad registers that are in tegra_usb_reset_controller()
117 rst_utmi = of_reset_control_get_shared(phy_np, "utmi-pads"); in tegra_usb_reset_controller()
119 dev_warn(dev, "can't get utmi-pads reset from the PHY\n"); in tegra_usb_reset_controller()
123 * PHY driver performs UTMI-pads reset in a case of a in tegra_usb_reset_controller()
124 * non-legacy DT. in tegra_usb_reset_controller()
151 struct tegra_usb *usb = dev_get_drvdata(ci->dev->parent); in tegra_usb_notify_event() local
152 struct ehci_hcd *ehci; in tegra_usb_notify_event() local
156 if (ci->hcd) { in tegra_usb_notify_event()
157 ehci = hcd_to_ehci(ci->hcd); in tegra_usb_notify_event()
158 ehci->has_tdi_phy_lpm = false; in tegra_usb_notify_event()
159 ehci_writel(ehci, usb->soc->txfifothresh << 16, in tegra_usb_notify_event()
160 &ehci->regs->txfill_tuning); in tegra_usb_notify_event()
168 static int tegra_usb_internal_port_reset(struct ehci_hcd *ehci, in tegra_usb_internal_port_reset() argument
176 saved_usbintr = ehci_readl(ehci, &ehci->regs->intr_enable); in tegra_usb_internal_port_reset()
177 /* disable USB interrupt */ in tegra_usb_internal_port_reset()
178 ehci_writel(ehci, 0, &ehci->regs->intr_enable); in tegra_usb_internal_port_reset()
179 spin_unlock_irqrestore(&ehci->lock, *flags); in tegra_usb_internal_port_reset()
186 temp = ehci_readl(ehci, portsc_reg); in tegra_usb_internal_port_reset()
188 ehci_writel(ehci, temp, portsc_reg); in tegra_usb_internal_port_reset()
191 ehci_writel(ehci, temp, portsc_reg); in tegra_usb_internal_port_reset()
202 temp = ehci_readl(ehci, portsc_reg); in tegra_usb_internal_port_reset()
203 } while (!(temp & PORT_PE) && tries--); in tegra_usb_internal_port_reset()
208 retval = -ETIMEDOUT; in tegra_usb_internal_port_reset()
215 ehci_writel(ehci, PORT_CSC, portsc_reg); in tegra_usb_internal_port_reset()
221 temp = ehci_readl(ehci, &ehci->regs->status); in tegra_usb_internal_port_reset()
222 ehci_writel(ehci, temp, &ehci->regs->status); in tegra_usb_internal_port_reset()
224 /* restore original interrupt-enable bits */ in tegra_usb_internal_port_reset()
225 spin_lock_irqsave(&ehci->lock, *flags); in tegra_usb_internal_port_reset()
226 ehci_writel(ehci, saved_usbintr, &ehci->regs->intr_enable); in tegra_usb_internal_port_reset()
235 struct tegra_usb *usb = dev_get_drvdata(ci->dev->parent); in tegra_ehci_hub_control() local
236 struct ehci_hcd *ehci = hcd_to_ehci(ci->hcd); in tegra_ehci_hub_control() local
240 status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1]; in tegra_ehci_hub_control()
244 if (wValue != USB_PORT_FEAT_RESET || !usb->needs_double_reset) in tegra_ehci_hub_control()
248 retval = tegra_usb_internal_port_reset(ehci, status_reg, flags); in tegra_ehci_hub_control()
260 * hang CPU if USB controller is put into low power mode because in tegra_usb_enter_lpm()
261 * AHB USB clock is gated on Tegra in the LPM. in tegra_usb_enter_lpm()
268 usb_phy_set_suspend(ci->usb_phy, enable); in tegra_usb_enter_lpm()
274 struct tegra_usb *usb; in tegra_usb_probe() local
277 usb = devm_kzalloc(&pdev->dev, sizeof(*usb), GFP_KERNEL); in tegra_usb_probe()
278 if (!usb) in tegra_usb_probe()
279 return -ENOMEM; in tegra_usb_probe()
281 soc = of_device_get_match_data(&pdev->dev); in tegra_usb_probe()
283 dev_err(&pdev->dev, "failed to match OF data\n"); in tegra_usb_probe()
284 return -EINVAL; in tegra_usb_probe()
287 usb->phy = devm_usb_get_phy_by_phandle(&pdev->dev, "nvidia,phy", 0); in tegra_usb_probe()
288 if (IS_ERR(usb->phy)) in tegra_usb_probe()
289 return dev_err_probe(&pdev->dev, PTR_ERR(usb->phy), in tegra_usb_probe()
292 usb->clk = devm_clk_get(&pdev->dev, NULL); in tegra_usb_probe()
293 if (IS_ERR(usb->clk)) { in tegra_usb_probe()
294 err = PTR_ERR(usb->clk); in tegra_usb_probe()
295 dev_err(&pdev->dev, "failed to get clock: %d\n", err); in tegra_usb_probe()
299 err = clk_prepare_enable(usb->clk); in tegra_usb_probe()
301 dev_err(&pdev->dev, "failed to enable clock: %d\n", err); in tegra_usb_probe()
305 if (device_property_present(&pdev->dev, "nvidia,needs-double-reset")) in tegra_usb_probe()
306 usb->needs_double_reset = true; in tegra_usb_probe()
308 err = tegra_usb_reset_controller(&pdev->dev); in tegra_usb_probe()
310 dev_err(&pdev->dev, "failed to reset controller: %d\n", err); in tegra_usb_probe()
315 * USB controller registers shouldn't be touched before PHY is in tegra_usb_probe()
317 * PHY driver controls gating of internal USB clocks on Tegra. in tegra_usb_probe()
319 err = usb_phy_init(usb->phy); in tegra_usb_probe()
323 platform_set_drvdata(pdev, usb); in tegra_usb_probe()
326 usb->soc = soc; in tegra_usb_probe()
327 usb->data.name = "tegra-usb"; in tegra_usb_probe()
328 usb->data.flags = soc->flags; in tegra_usb_probe()
329 usb->data.usb_phy = usb->phy; in tegra_usb_probe()
330 usb->data.dr_mode = soc->dr_mode; in tegra_usb_probe()
331 usb->data.capoffset = DEF_CAPOFFSET; in tegra_usb_probe()
332 usb->data.enter_lpm = tegra_usb_enter_lpm; in tegra_usb_probe()
333 usb->data.hub_control = tegra_ehci_hub_control; in tegra_usb_probe()
334 usb->data.notify_event = tegra_usb_notify_event; in tegra_usb_probe()
337 if (of_usb_get_phy_mode(pdev->dev.of_node) == USBPHY_INTERFACE_MODE_ULPI) in tegra_usb_probe()
338 usb->data.flags &= ~CI_HDRC_SUPPORTS_RUNTIME_PM; in tegra_usb_probe()
340 usb->dev = ci_hdrc_add_device(&pdev->dev, pdev->resource, in tegra_usb_probe()
341 pdev->num_resources, &usb->data); in tegra_usb_probe()
342 if (IS_ERR(usb->dev)) { in tegra_usb_probe()
343 err = PTR_ERR(usb->dev); in tegra_usb_probe()
344 dev_err(&pdev->dev, "failed to add HDRC device: %d\n", err); in tegra_usb_probe()
351 usb_phy_shutdown(usb->phy); in tegra_usb_probe()
353 clk_disable_unprepare(usb->clk); in tegra_usb_probe()
359 struct tegra_usb *usb = platform_get_drvdata(pdev); in tegra_usb_remove() local
361 ci_hdrc_remove_device(usb->dev); in tegra_usb_remove()
362 usb_phy_shutdown(usb->phy); in tegra_usb_remove()
363 clk_disable_unprepare(usb->clk); in tegra_usb_remove()
370 .name = "tegra-usb",
378 MODULE_DESCRIPTION("NVIDIA Tegra USB driver");