Lines Matching +full:usb +full:- +full:glue

1 // SPDX-License-Identifier: GPL-2.0
3 * dwc3-imx8mp.c - NXP imx8mp Specific Glue layer
21 /* USB wakeup registers */
41 /* USB glue registers */
45 #define USB_CTRL0_PORTPWR_EN BIT(12) /* 1 - PPC enabled (default) */
46 #define USB_CTRL0_USB3_FIXED BIT(22) /* 1 - USB3 permanent attached */
47 #define USB_CTRL0_USB2_FIXED BIT(23) /* 1 - USB2 permanent attached */
49 #define USB_CTRL1_OC_POLARITY BIT(16) /* 0 - HIGH / 1 - LOW */
50 #define USB_CTRL1_PWR_POLARITY BIT(17) /* 0 - HIGH / 1 - LOW */
66 struct device *dev = dwc3_imx->dev; in imx8mp_configure_glue()
69 if (!dwc3_imx->glue_base) in imx8mp_configure_glue()
72 value = readl(dwc3_imx->glue_base + USB_CTRL0); in imx8mp_configure_glue()
74 if (device_property_read_bool(dev, "fsl,permanently-attached")) in imx8mp_configure_glue()
79 if (device_property_read_bool(dev, "fsl,disable-port-power-control")) in imx8mp_configure_glue()
84 writel(value, dwc3_imx->glue_base + USB_CTRL0); in imx8mp_configure_glue()
86 value = readl(dwc3_imx->glue_base + USB_CTRL1); in imx8mp_configure_glue()
87 if (device_property_read_bool(dev, "fsl,over-current-active-low")) in imx8mp_configure_glue()
92 if (device_property_read_bool(dev, "fsl,power-active-low")) in imx8mp_configure_glue()
97 writel(value, dwc3_imx->glue_base + USB_CTRL1); in imx8mp_configure_glue()
103 struct dwc3 *dwc3 = platform_get_drvdata(dwc3_imx->dwc3); in dwc3_imx8mp_wakeup_enable()
109 val = readl(dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL); in dwc3_imx8mp_wakeup_enable()
111 if ((dwc3->current_dr_role == DWC3_GCTL_PRTCAP_HOST) && dwc3->xhci) { in dwc3_imx8mp_wakeup_enable()
120 writel(val, dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL); in dwc3_imx8mp_wakeup_enable()
127 val = readl(dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL); in dwc3_imx8mp_wakeup_disable()
129 writel(val, dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL); in dwc3_imx8mp_wakeup_disable()
133 PROPERTY_ENTRY_BOOL("xhci-missing-cas-quirk"),
134 PROPERTY_ENTRY_BOOL("xhci-skip-phy-init-quirk"),
145 struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3); in dwc3_imx8mp_interrupt()
147 if (!dwc3_imx->pm_suspended) in dwc3_imx8mp_interrupt()
150 disable_irq_nosync(dwc3_imx->irq); in dwc3_imx8mp_interrupt()
151 dwc3_imx->wakeup_pending = true; in dwc3_imx8mp_interrupt()
153 if ((dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST) && dwc->xhci) in dwc3_imx8mp_interrupt()
154 pm_runtime_resume(&dwc->xhci->dev); in dwc3_imx8mp_interrupt()
155 else if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_DEVICE) in dwc3_imx8mp_interrupt()
156 pm_runtime_get(dwc->dev); in dwc3_imx8mp_interrupt()
163 struct device *dev = &pdev->dev; in dwc3_imx8mp_probe()
164 struct device_node *node = dev->of_node; in dwc3_imx8mp_probe()
171 return -EINVAL; in dwc3_imx8mp_probe()
176 return -ENOMEM; in dwc3_imx8mp_probe()
180 dwc3_imx->dev = dev; in dwc3_imx8mp_probe()
182 dwc3_imx->hsio_blk_base = devm_platform_ioremap_resource(pdev, 0); in dwc3_imx8mp_probe()
183 if (IS_ERR(dwc3_imx->hsio_blk_base)) in dwc3_imx8mp_probe()
184 return PTR_ERR(dwc3_imx->hsio_blk_base); in dwc3_imx8mp_probe()
188 …dev_warn(dev, "Base address for glue layer missing. Continuing without, some features are missing … in dwc3_imx8mp_probe()
190 dwc3_imx->glue_base = devm_ioremap_resource(dev, res); in dwc3_imx8mp_probe()
191 if (IS_ERR(dwc3_imx->glue_base)) in dwc3_imx8mp_probe()
192 return PTR_ERR(dwc3_imx->glue_base); in dwc3_imx8mp_probe()
195 dwc3_imx->hsio_clk = devm_clk_get_enabled(dev, "hsio"); in dwc3_imx8mp_probe()
196 if (IS_ERR(dwc3_imx->hsio_clk)) in dwc3_imx8mp_probe()
197 return dev_err_probe(dev, PTR_ERR(dwc3_imx->hsio_clk), in dwc3_imx8mp_probe()
200 dwc3_imx->suspend_clk = devm_clk_get_enabled(dev, "suspend"); in dwc3_imx8mp_probe()
201 if (IS_ERR(dwc3_imx->suspend_clk)) in dwc3_imx8mp_probe()
202 return dev_err_probe(dev, PTR_ERR(dwc3_imx->suspend_clk), in dwc3_imx8mp_probe()
208 dwc3_imx->irq = irq; in dwc3_imx8mp_probe()
213 return dev_err_probe(dev, -ENODEV, "failed to find dwc3 core child\n"); in dwc3_imx8mp_probe()
225 err = -ENODEV; in dwc3_imx8mp_probe()
232 dev_err(&pdev->dev, "failed to create dwc3 core\n"); in dwc3_imx8mp_probe()
236 dwc3_imx->dwc3 = of_find_device_by_node(dwc3_np); in dwc3_imx8mp_probe()
237 if (!dwc3_imx->dwc3) { in dwc3_imx8mp_probe()
239 err = -ENODEV; in dwc3_imx8mp_probe()
246 dev_err(dev, "failed to request IRQ #%d --> %d\n", irq, err); in dwc3_imx8mp_probe()
268 struct device *dev = &pdev->dev; in dwc3_imx8mp_remove()
280 if (dwc3_imx->pm_suspended) in dwc3_imx8mp_suspend()
284 if (PMSG_IS_AUTO(msg) || device_may_wakeup(dwc3_imx->dev)) in dwc3_imx8mp_suspend()
287 dwc3_imx->pm_suspended = true; in dwc3_imx8mp_suspend()
294 struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3); in dwc3_imx8mp_resume()
297 if (!dwc3_imx->pm_suspended) in dwc3_imx8mp_resume()
302 dwc3_imx->pm_suspended = false; in dwc3_imx8mp_resume()
307 if (dwc3_imx->wakeup_pending) { in dwc3_imx8mp_resume()
308 dwc3_imx->wakeup_pending = false; in dwc3_imx8mp_resume()
309 if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_DEVICE) { in dwc3_imx8mp_resume()
310 pm_runtime_mark_last_busy(dwc->dev); in dwc3_imx8mp_resume()
311 pm_runtime_put_autosuspend(dwc->dev); in dwc3_imx8mp_resume()
319 enable_irq(dwc3_imx->irq); in dwc3_imx8mp_resume()
332 if (device_may_wakeup(dwc3_imx->dev)) in dwc3_imx8mp_pm_suspend()
333 enable_irq_wake(dwc3_imx->irq); in dwc3_imx8mp_pm_suspend()
335 clk_disable_unprepare(dwc3_imx->suspend_clk); in dwc3_imx8mp_pm_suspend()
337 clk_disable_unprepare(dwc3_imx->hsio_clk); in dwc3_imx8mp_pm_suspend()
348 if (device_may_wakeup(dwc3_imx->dev)) { in dwc3_imx8mp_pm_resume()
349 disable_irq_wake(dwc3_imx->irq); in dwc3_imx8mp_pm_resume()
351 ret = clk_prepare_enable(dwc3_imx->suspend_clk); in dwc3_imx8mp_pm_resume()
356 ret = clk_prepare_enable(dwc3_imx->hsio_clk); in dwc3_imx8mp_pm_resume()
358 clk_disable_unprepare(dwc3_imx->suspend_clk); in dwc3_imx8mp_pm_resume()
398 { .compatible = "fsl,imx8mp-dwc3", },
407 .name = "imx8mp-dwc3",
415 MODULE_ALIAS("platform:imx8mp-dwc3");
418 MODULE_DESCRIPTION("DesignWare USB3 imx8mp Glue Layer");