Lines Matching refs:dwc3_imx

64 static void imx8mp_configure_glue(struct dwc3_imx8mp *dwc3_imx)  in imx8mp_configure_glue()  argument
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()
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()
97 writel(value, dwc3_imx->glue_base + USB_CTRL1); in imx8mp_configure_glue()
100 static void dwc3_imx8mp_wakeup_enable(struct dwc3_imx8mp *dwc3_imx, in dwc3_imx8mp_wakeup_enable() argument
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()
120 writel(val, dwc3_imx->hsio_blk_base + USB_WAKEUP_CTRL); in dwc3_imx8mp_wakeup_enable()
123 static void dwc3_imx8mp_wakeup_disable(struct dwc3_imx8mp *dwc3_imx) in dwc3_imx8mp_wakeup_disable() argument
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()
134 struct dwc3_imx8mp *dwc3_imx = _dwc3_imx; in dwc3_imx8mp_interrupt() local
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()
166 struct dwc3_imx8mp *dwc3_imx; in dwc3_imx8mp_probe() local
175 dwc3_imx = devm_kzalloc(dev, sizeof(*dwc3_imx), GFP_KERNEL); in dwc3_imx8mp_probe()
176 if (!dwc3_imx) in dwc3_imx8mp_probe()
179 platform_set_drvdata(pdev, dwc3_imx); 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()
216 imx8mp_configure_glue(dwc3_imx); 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()
245 IRQF_ONESHOT, dev_name(dev), dwc3_imx); in dwc3_imx8mp_probe()
276 static int dwc3_imx8mp_suspend(struct dwc3_imx8mp *dwc3_imx, pm_message_t msg) in dwc3_imx8mp_suspend() argument
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()
283 dwc3_imx8mp_wakeup_enable(dwc3_imx, msg); in dwc3_imx8mp_suspend()
285 dwc3_imx->pm_suspended = true; in dwc3_imx8mp_suspend()
290 static int dwc3_imx8mp_resume(struct dwc3_imx8mp *dwc3_imx, pm_message_t msg) in dwc3_imx8mp_resume() argument
292 struct dwc3 *dwc = platform_get_drvdata(dwc3_imx->dwc3); in dwc3_imx8mp_resume()
295 if (!dwc3_imx->pm_suspended) in dwc3_imx8mp_resume()
299 dwc3_imx8mp_wakeup_disable(dwc3_imx); in dwc3_imx8mp_resume()
300 dwc3_imx->pm_suspended = false; in dwc3_imx8mp_resume()
303 imx8mp_configure_glue(dwc3_imx); in dwc3_imx8mp_resume()
305 if (dwc3_imx->wakeup_pending) { in dwc3_imx8mp_resume()
306 dwc3_imx->wakeup_pending = false; in dwc3_imx8mp_resume()
317 enable_irq(dwc3_imx->irq); in dwc3_imx8mp_resume()
325 struct dwc3_imx8mp *dwc3_imx = dev_get_drvdata(dev); in dwc3_imx8mp_pm_suspend() local
328 ret = dwc3_imx8mp_suspend(dwc3_imx, PMSG_SUSPEND); in dwc3_imx8mp_pm_suspend()
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()
343 struct dwc3_imx8mp *dwc3_imx = dev_get_drvdata(dev); in dwc3_imx8mp_pm_resume() local
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()
360 ret = dwc3_imx8mp_resume(dwc3_imx, PMSG_RESUME); in dwc3_imx8mp_pm_resume()
373 struct dwc3_imx8mp *dwc3_imx = dev_get_drvdata(dev); in dwc3_imx8mp_runtime_suspend() local
377 return dwc3_imx8mp_suspend(dwc3_imx, PMSG_AUTO_SUSPEND); in dwc3_imx8mp_runtime_suspend()
382 struct dwc3_imx8mp *dwc3_imx = dev_get_drvdata(dev); in dwc3_imx8mp_runtime_resume() local
386 return dwc3_imx8mp_resume(dwc3_imx, PMSG_AUTO_RESUME); in dwc3_imx8mp_runtime_resume()