Lines Matching +full:imx8mp +full:- +full:clock
1 // SPDX-License-Identifier: GPL-2.0
3 * dwc3-imx8mp.c - NXP imx8mp Specific Glue layer
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()
135 struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3); in dwc3_imx8mp_interrupt()
137 if (!dwc3_imx->pm_suspended) in dwc3_imx8mp_interrupt()
140 disable_irq_nosync(dwc3_imx->irq); in dwc3_imx8mp_interrupt()
141 dwc3_imx->wakeup_pending = true; in dwc3_imx8mp_interrupt()
143 if ((dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST) && dwc->xhci) in dwc3_imx8mp_interrupt()
144 pm_runtime_resume(&dwc->xhci->dev); in dwc3_imx8mp_interrupt()
145 else if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_DEVICE) in dwc3_imx8mp_interrupt()
146 pm_runtime_get(dwc->dev); in dwc3_imx8mp_interrupt()
156 props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-missing-cas-quirk"); in dwc3_imx8mp_set_software_node()
157 props[prop_idx++] = PROPERTY_ENTRY_BOOL("xhci-skip-phy-init-quirk"); in dwc3_imx8mp_set_software_node()
164 struct device *dev = &pdev->dev; in dwc3_imx8mp_probe()
165 struct device_node *node = dev->of_node; in dwc3_imx8mp_probe()
172 return -EINVAL; in dwc3_imx8mp_probe()
177 return -ENOMEM; in dwc3_imx8mp_probe()
181 dwc3_imx->dev = dev; in dwc3_imx8mp_probe()
183 dwc3_imx->hsio_blk_base = devm_platform_ioremap_resource(pdev, 0); in dwc3_imx8mp_probe()
184 if (IS_ERR(dwc3_imx->hsio_blk_base)) in dwc3_imx8mp_probe()
185 return PTR_ERR(dwc3_imx->hsio_blk_base); in dwc3_imx8mp_probe()
191 dwc3_imx->glue_base = devm_ioremap_resource(dev, res); in dwc3_imx8mp_probe()
192 if (IS_ERR(dwc3_imx->glue_base)) in dwc3_imx8mp_probe()
193 return PTR_ERR(dwc3_imx->glue_base); in dwc3_imx8mp_probe()
196 dwc3_imx->hsio_clk = devm_clk_get_enabled(dev, "hsio"); in dwc3_imx8mp_probe()
197 if (IS_ERR(dwc3_imx->hsio_clk)) in dwc3_imx8mp_probe()
198 return dev_err_probe(dev, PTR_ERR(dwc3_imx->hsio_clk), in dwc3_imx8mp_probe()
201 dwc3_imx->suspend_clk = devm_clk_get_enabled(dev, "suspend"); in dwc3_imx8mp_probe()
202 if (IS_ERR(dwc3_imx->suspend_clk)) in dwc3_imx8mp_probe()
203 return dev_err_probe(dev, PTR_ERR(dwc3_imx->suspend_clk), in dwc3_imx8mp_probe()
209 dwc3_imx->irq = irq; in dwc3_imx8mp_probe()
214 return dev_err_probe(dev, -ENODEV, "failed to find dwc3 core child\n"); in dwc3_imx8mp_probe()
226 err = -ENODEV; in dwc3_imx8mp_probe()
233 dev_err(&pdev->dev, "failed to create dwc3 core\n"); in dwc3_imx8mp_probe()
237 dwc3_imx->dwc3 = of_find_device_by_node(dwc3_np); in dwc3_imx8mp_probe()
238 if (!dwc3_imx->dwc3) { in dwc3_imx8mp_probe()
240 err = -ENODEV; in dwc3_imx8mp_probe()
247 dev_err(dev, "failed to request IRQ #%d --> %d\n", irq, err); in dwc3_imx8mp_probe()
267 struct device *dev = &pdev->dev; in dwc3_imx8mp_remove()
278 if (dwc3_imx->pm_suspended) in dwc3_imx8mp_suspend()
282 if (PMSG_IS_AUTO(msg) || device_may_wakeup(dwc3_imx->dev)) in dwc3_imx8mp_suspend()
285 dwc3_imx->pm_suspended = true; in dwc3_imx8mp_suspend()
292 struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3); in dwc3_imx8mp_resume()
295 if (!dwc3_imx->pm_suspended) in dwc3_imx8mp_resume()
300 dwc3_imx->pm_suspended = false; in dwc3_imx8mp_resume()
305 if (dwc3_imx->wakeup_pending) { in dwc3_imx8mp_resume()
306 dwc3_imx->wakeup_pending = false; in dwc3_imx8mp_resume()
307 if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_DEVICE) { in dwc3_imx8mp_resume()
308 pm_runtime_mark_last_busy(dwc->dev); in dwc3_imx8mp_resume()
309 pm_runtime_put_autosuspend(dwc->dev); in dwc3_imx8mp_resume()
313 * clock to normal clock to detect connection. in dwc3_imx8mp_resume()
317 enable_irq(dwc3_imx->irq); in dwc3_imx8mp_resume()
330 if (device_may_wakeup(dwc3_imx->dev)) in dwc3_imx8mp_pm_suspend()
331 enable_irq_wake(dwc3_imx->irq); in dwc3_imx8mp_pm_suspend()
333 clk_disable_unprepare(dwc3_imx->suspend_clk); in dwc3_imx8mp_pm_suspend()
335 clk_disable_unprepare(dwc3_imx->hsio_clk); in dwc3_imx8mp_pm_suspend()
336 dev_dbg(dev, "dwc3 imx8mp pm suspend.\n"); in dwc3_imx8mp_pm_suspend()
346 if (device_may_wakeup(dwc3_imx->dev)) { in dwc3_imx8mp_pm_resume()
347 disable_irq_wake(dwc3_imx->irq); in dwc3_imx8mp_pm_resume()
349 ret = clk_prepare_enable(dwc3_imx->suspend_clk); in dwc3_imx8mp_pm_resume()
354 ret = clk_prepare_enable(dwc3_imx->hsio_clk); in dwc3_imx8mp_pm_resume()
356 clk_disable_unprepare(dwc3_imx->suspend_clk); in dwc3_imx8mp_pm_resume()
366 dev_dbg(dev, "dwc3 imx8mp pm resume.\n"); in dwc3_imx8mp_pm_resume()
375 dev_dbg(dev, "dwc3 imx8mp runtime suspend.\n"); in dwc3_imx8mp_runtime_suspend()
384 dev_dbg(dev, "dwc3 imx8mp runtime resume.\n"); in dwc3_imx8mp_runtime_resume()
396 { .compatible = "fsl,imx8mp-dwc3", },
405 .name = "imx8mp-dwc3",
413 MODULE_ALIAS("platform:imx8mp-dwc3");
416 MODULE_DESCRIPTION("DesignWare USB3 imx8mp Glue Layer");