• Home
  • Raw
  • Download

Lines Matching +full:imx8mp +full:- +full:clock

1 // SPDX-License-Identifier: GPL-2.0
3 * dwc3-imx8mp.c - NXP imx8mp Specific Glue layer
44 #define USB_CTRL0_PORTPWR_EN BIT(12) /* 1 - PPC enabled (default) */
45 #define USB_CTRL0_USB3_FIXED BIT(22) /* 1 - USB3 permanent attached */
46 #define USB_CTRL0_USB2_FIXED BIT(23) /* 1 - USB2 permanent attached */
48 #define USB_CTRL1_OC_POLARITY BIT(16) /* 0 - HIGH / 1 - LOW */
49 #define USB_CTRL1_PWR_POLARITY BIT(17) /* 0 - HIGH / 1 - LOW */
65 struct device *dev = dwc3_imx->dev; in imx8mp_configure_glue()
68 if (!dwc3_imx->glue_base) in imx8mp_configure_glue()
71 value = readl(dwc3_imx->glue_base + USB_CTRL0); in imx8mp_configure_glue()
73 if (device_property_read_bool(dev, "fsl,permanently-attached")) in imx8mp_configure_glue()
78 if (device_property_read_bool(dev, "fsl,disable-port-power-control")) in imx8mp_configure_glue()
83 writel(value, dwc3_imx->glue_base + USB_CTRL0); in imx8mp_configure_glue()
85 value = readl(dwc3_imx->glue_base + USB_CTRL1); in imx8mp_configure_glue()
86 if (device_property_read_bool(dev, "fsl,over-current-active-low")) in imx8mp_configure_glue()
91 if (device_property_read_bool(dev, "fsl,power-active-low")) in imx8mp_configure_glue()
96 writel(value, dwc3_imx->glue_base + USB_CTRL1); in imx8mp_configure_glue()
101 struct dwc3 *dwc3 = platform_get_drvdata(dwc3_imx->dwc3); in dwc3_imx8mp_wakeup_enable()
107 val = readl(dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL); in dwc3_imx8mp_wakeup_enable()
109 if ((dwc3->current_dr_role == DWC3_GCTL_PRTCAP_HOST) && dwc3->xhci) in dwc3_imx8mp_wakeup_enable()
112 else if (dwc3->current_dr_role == DWC3_GCTL_PRTCAP_DEVICE) in dwc3_imx8mp_wakeup_enable()
116 writel(val, dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL); in dwc3_imx8mp_wakeup_enable()
123 val = readl(dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL); in dwc3_imx8mp_wakeup_disable()
125 writel(val, dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL); in dwc3_imx8mp_wakeup_disable()
131 struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3); in dwc3_imx8mp_interrupt()
133 if (!dwc3_imx->pm_suspended) in dwc3_imx8mp_interrupt()
136 disable_irq_nosync(dwc3_imx->irq); in dwc3_imx8mp_interrupt()
137 dwc3_imx->wakeup_pending = true; in dwc3_imx8mp_interrupt()
139 if ((dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST) && dwc->xhci) in dwc3_imx8mp_interrupt()
140 pm_runtime_resume(&dwc->xhci->dev); in dwc3_imx8mp_interrupt()
141 else if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_DEVICE) in dwc3_imx8mp_interrupt()
142 pm_runtime_get(dwc->dev); in dwc3_imx8mp_interrupt()
149 struct device *dev = &pdev->dev; in dwc3_imx8mp_probe()
150 struct device_node *dwc3_np, *node = dev->of_node; in dwc3_imx8mp_probe()
157 return -EINVAL; in dwc3_imx8mp_probe()
162 return -ENOMEM; in dwc3_imx8mp_probe()
166 dwc3_imx->dev = dev; in dwc3_imx8mp_probe()
168 dwc3_imx->hsio_blk_base = devm_platform_ioremap_resource(pdev, 0); in dwc3_imx8mp_probe()
169 if (IS_ERR(dwc3_imx->hsio_blk_base)) in dwc3_imx8mp_probe()
170 return PTR_ERR(dwc3_imx->hsio_blk_base); in dwc3_imx8mp_probe()
176 dwc3_imx->glue_base = devm_ioremap_resource(dev, res); in dwc3_imx8mp_probe()
177 if (IS_ERR(dwc3_imx->glue_base)) in dwc3_imx8mp_probe()
178 return PTR_ERR(dwc3_imx->glue_base); in dwc3_imx8mp_probe()
181 dwc3_imx->hsio_clk = devm_clk_get(dev, "hsio"); in dwc3_imx8mp_probe()
182 if (IS_ERR(dwc3_imx->hsio_clk)) { in dwc3_imx8mp_probe()
183 err = PTR_ERR(dwc3_imx->hsio_clk); in dwc3_imx8mp_probe()
188 err = clk_prepare_enable(dwc3_imx->hsio_clk); in dwc3_imx8mp_probe()
194 dwc3_imx->suspend_clk = devm_clk_get(dev, "suspend"); in dwc3_imx8mp_probe()
195 if (IS_ERR(dwc3_imx->suspend_clk)) { in dwc3_imx8mp_probe()
196 err = PTR_ERR(dwc3_imx->suspend_clk); in dwc3_imx8mp_probe()
201 err = clk_prepare_enable(dwc3_imx->suspend_clk); in dwc3_imx8mp_probe()
212 dwc3_imx->irq = irq; in dwc3_imx8mp_probe()
224 err = -ENODEV; in dwc3_imx8mp_probe()
231 dev_err(&pdev->dev, "failed to create dwc3 core\n"); in dwc3_imx8mp_probe()
235 dwc3_imx->dwc3 = of_find_device_by_node(dwc3_np); in dwc3_imx8mp_probe()
236 if (!dwc3_imx->dwc3) { in dwc3_imx8mp_probe()
238 err = -ENODEV; in dwc3_imx8mp_probe()
246 dev_err(dev, "failed to request IRQ #%d --> %d\n", irq, err); in dwc3_imx8mp_probe()
263 clk_disable_unprepare(dwc3_imx->suspend_clk); in dwc3_imx8mp_probe()
265 clk_disable_unprepare(dwc3_imx->hsio_clk); in dwc3_imx8mp_probe()
273 struct device *dev = &pdev->dev; in dwc3_imx8mp_remove()
278 clk_disable_unprepare(dwc3_imx->suspend_clk); in dwc3_imx8mp_remove()
279 clk_disable_unprepare(dwc3_imx->hsio_clk); in dwc3_imx8mp_remove()
288 if (dwc3_imx->pm_suspended) in dwc3_imx8mp_suspend()
292 if (PMSG_IS_AUTO(msg) || device_may_wakeup(dwc3_imx->dev)) in dwc3_imx8mp_suspend()
295 dwc3_imx->pm_suspended = true; in dwc3_imx8mp_suspend()
303 struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3); in dwc3_imx8mp_resume()
306 if (!dwc3_imx->pm_suspended) in dwc3_imx8mp_resume()
311 dwc3_imx->pm_suspended = false; in dwc3_imx8mp_resume()
316 if (dwc3_imx->wakeup_pending) { in dwc3_imx8mp_resume()
317 dwc3_imx->wakeup_pending = false; in dwc3_imx8mp_resume()
318 if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_DEVICE) { in dwc3_imx8mp_resume()
319 pm_runtime_mark_last_busy(dwc->dev); in dwc3_imx8mp_resume()
320 pm_runtime_put_autosuspend(dwc->dev); in dwc3_imx8mp_resume()
324 * clock to normal clock to detect connection. in dwc3_imx8mp_resume()
328 enable_irq(dwc3_imx->irq); in dwc3_imx8mp_resume()
341 if (device_may_wakeup(dwc3_imx->dev)) in dwc3_imx8mp_pm_suspend()
342 enable_irq_wake(dwc3_imx->irq); in dwc3_imx8mp_pm_suspend()
344 clk_disable_unprepare(dwc3_imx->suspend_clk); in dwc3_imx8mp_pm_suspend()
346 clk_disable_unprepare(dwc3_imx->hsio_clk); in dwc3_imx8mp_pm_suspend()
347 dev_dbg(dev, "dwc3 imx8mp pm suspend.\n"); in dwc3_imx8mp_pm_suspend()
357 if (device_may_wakeup(dwc3_imx->dev)) { in dwc3_imx8mp_pm_resume()
358 disable_irq_wake(dwc3_imx->irq); in dwc3_imx8mp_pm_resume()
360 ret = clk_prepare_enable(dwc3_imx->suspend_clk); in dwc3_imx8mp_pm_resume()
365 ret = clk_prepare_enable(dwc3_imx->hsio_clk); in dwc3_imx8mp_pm_resume()
375 dev_dbg(dev, "dwc3 imx8mp pm resume.\n"); in dwc3_imx8mp_pm_resume()
384 dev_dbg(dev, "dwc3 imx8mp runtime suspend.\n"); in dwc3_imx8mp_runtime_suspend()
393 dev_dbg(dev, "dwc3 imx8mp runtime resume.\n"); in dwc3_imx8mp_runtime_resume()
405 { .compatible = "fsl,imx8mp-dwc3", },
414 .name = "imx8mp-dwc3",
422 MODULE_ALIAS("platform:imx8mp-dwc3");
425 MODULE_DESCRIPTION("DesignWare USB3 imx8mp Glue Layer");