Lines Matching full:omap

3  * dwc3-omap.c - OMAP Specific Glue layer
29 * All these registers belong to OMAP's Wrapper around the
151 static u32 dwc3_omap_read_utmi_ctrl(struct dwc3_omap *omap) in dwc3_omap_read_utmi_ctrl() argument
153 return dwc3_omap_readl(omap->base, USBOTGSS_UTMI_OTG_CTRL + in dwc3_omap_read_utmi_ctrl()
154 omap->utmi_otg_offset); in dwc3_omap_read_utmi_ctrl()
157 static void dwc3_omap_write_utmi_ctrl(struct dwc3_omap *omap, u32 value) in dwc3_omap_write_utmi_ctrl() argument
159 dwc3_omap_writel(omap->base, USBOTGSS_UTMI_OTG_CTRL + in dwc3_omap_write_utmi_ctrl()
160 omap->utmi_otg_offset, value); in dwc3_omap_write_utmi_ctrl()
164 static u32 dwc3_omap_read_irq0_status(struct dwc3_omap *omap) in dwc3_omap_read_irq0_status() argument
166 return dwc3_omap_readl(omap->base, USBOTGSS_IRQSTATUS_RAW_0 - in dwc3_omap_read_irq0_status()
167 omap->irq0_offset); in dwc3_omap_read_irq0_status()
170 static void dwc3_omap_write_irq0_status(struct dwc3_omap *omap, u32 value) in dwc3_omap_write_irq0_status() argument
172 dwc3_omap_writel(omap->base, USBOTGSS_IRQSTATUS_0 - in dwc3_omap_write_irq0_status()
173 omap->irq0_offset, value); in dwc3_omap_write_irq0_status()
177 static u32 dwc3_omap_read_irqmisc_status(struct dwc3_omap *omap) in dwc3_omap_read_irqmisc_status() argument
179 return dwc3_omap_readl(omap->base, USBOTGSS_IRQSTATUS_RAW_MISC + in dwc3_omap_read_irqmisc_status()
180 omap->irqmisc_offset); in dwc3_omap_read_irqmisc_status()
183 static void dwc3_omap_write_irqmisc_status(struct dwc3_omap *omap, u32 value) in dwc3_omap_write_irqmisc_status() argument
185 dwc3_omap_writel(omap->base, USBOTGSS_IRQSTATUS_MISC + in dwc3_omap_write_irqmisc_status()
186 omap->irqmisc_offset, value); in dwc3_omap_write_irqmisc_status()
190 static void dwc3_omap_write_irqmisc_set(struct dwc3_omap *omap, u32 value) in dwc3_omap_write_irqmisc_set() argument
192 dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_MISC + in dwc3_omap_write_irqmisc_set()
193 omap->irqmisc_offset, value); in dwc3_omap_write_irqmisc_set()
197 static void dwc3_omap_write_irq0_set(struct dwc3_omap *omap, u32 value) in dwc3_omap_write_irq0_set() argument
199 dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_SET_0 - in dwc3_omap_write_irq0_set()
200 omap->irq0_offset, value); in dwc3_omap_write_irq0_set()
203 static void dwc3_omap_write_irqmisc_clr(struct dwc3_omap *omap, u32 value) in dwc3_omap_write_irqmisc_clr() argument
205 dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_CLR_MISC + in dwc3_omap_write_irqmisc_clr()
206 omap->irqmisc_offset, value); in dwc3_omap_write_irqmisc_clr()
209 static void dwc3_omap_write_irq0_clr(struct dwc3_omap *omap, u32 value) in dwc3_omap_write_irq0_clr() argument
211 dwc3_omap_writel(omap->base, USBOTGSS_IRQENABLE_CLR_0 - in dwc3_omap_write_irq0_clr()
212 omap->irq0_offset, value); in dwc3_omap_write_irq0_clr()
215 static void dwc3_omap_set_mailbox(struct dwc3_omap *omap, in dwc3_omap_set_mailbox() argument
223 if (omap->vbus_reg) { in dwc3_omap_set_mailbox()
224 ret = regulator_enable(omap->vbus_reg); in dwc3_omap_set_mailbox()
226 dev_err(omap->dev, "regulator enable failed\n"); in dwc3_omap_set_mailbox()
231 val = dwc3_omap_read_utmi_ctrl(omap); in dwc3_omap_set_mailbox()
233 dwc3_omap_write_utmi_ctrl(omap, val); in dwc3_omap_set_mailbox()
237 val = dwc3_omap_read_utmi_ctrl(omap); in dwc3_omap_set_mailbox()
241 dwc3_omap_write_utmi_ctrl(omap, val); in dwc3_omap_set_mailbox()
245 if (omap->vbus_reg && regulator_is_enabled(omap->vbus_reg)) in dwc3_omap_set_mailbox()
246 regulator_disable(omap->vbus_reg); in dwc3_omap_set_mailbox()
247 val = dwc3_omap_read_utmi_ctrl(omap); in dwc3_omap_set_mailbox()
249 dwc3_omap_write_utmi_ctrl(omap, val); in dwc3_omap_set_mailbox()
253 val = dwc3_omap_read_utmi_ctrl(omap); in dwc3_omap_set_mailbox()
257 dwc3_omap_write_utmi_ctrl(omap, val); in dwc3_omap_set_mailbox()
261 dev_WARN(omap->dev, "invalid state\n"); in dwc3_omap_set_mailbox()
265 static void dwc3_omap_enable_irqs(struct dwc3_omap *omap);
266 static void dwc3_omap_disable_irqs(struct dwc3_omap *omap);
270 struct dwc3_omap *omap = _omap; in dwc3_omap_interrupt() local
272 if (dwc3_omap_read_irqmisc_status(omap) || in dwc3_omap_interrupt()
273 dwc3_omap_read_irq0_status(omap)) { in dwc3_omap_interrupt()
275 dwc3_omap_disable_irqs(omap); in dwc3_omap_interrupt()
284 struct dwc3_omap *omap = _omap; in dwc3_omap_interrupt_thread() local
288 reg = dwc3_omap_read_irqmisc_status(omap); in dwc3_omap_interrupt_thread()
289 dwc3_omap_write_irqmisc_status(omap, reg); in dwc3_omap_interrupt_thread()
291 reg = dwc3_omap_read_irq0_status(omap); in dwc3_omap_interrupt_thread()
292 dwc3_omap_write_irq0_status(omap, reg); in dwc3_omap_interrupt_thread()
295 dwc3_omap_enable_irqs(omap); in dwc3_omap_interrupt_thread()
300 static void dwc3_omap_enable_irqs(struct dwc3_omap *omap) in dwc3_omap_enable_irqs() argument
306 dwc3_omap_write_irq0_set(omap, reg); in dwc3_omap_enable_irqs()
318 dwc3_omap_write_irqmisc_set(omap, reg); in dwc3_omap_enable_irqs()
321 static void dwc3_omap_disable_irqs(struct dwc3_omap *omap) in dwc3_omap_disable_irqs() argument
327 dwc3_omap_write_irq0_clr(omap, reg); in dwc3_omap_disable_irqs()
339 dwc3_omap_write_irqmisc_clr(omap, reg); in dwc3_omap_disable_irqs()
345 struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, id_nb); in dwc3_omap_id_notifier() local
348 dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND); in dwc3_omap_id_notifier()
350 dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_FLOAT); in dwc3_omap_id_notifier()
358 struct dwc3_omap *omap = container_of(nb, struct dwc3_omap, vbus_nb); in dwc3_omap_vbus_notifier() local
361 dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID); in dwc3_omap_vbus_notifier()
363 dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_OFF); in dwc3_omap_vbus_notifier()
368 static void dwc3_omap_map_offset(struct dwc3_omap *omap) in dwc3_omap_map_offset() argument
370 struct device_node *node = omap->dev->of_node; in dwc3_omap_map_offset()
381 omap->irq_eoi_offset = USBOTGSS_EOI_OFFSET; in dwc3_omap_map_offset()
382 omap->irq0_offset = USBOTGSS_IRQ0_OFFSET; in dwc3_omap_map_offset()
383 omap->irqmisc_offset = USBOTGSS_IRQMISC_OFFSET; in dwc3_omap_map_offset()
384 omap->utmi_otg_offset = USBOTGSS_UTMI_OTG_OFFSET; in dwc3_omap_map_offset()
385 omap->debug_offset = USBOTGSS_DEBUG_OFFSET; in dwc3_omap_map_offset()
389 static void dwc3_omap_set_utmi_mode(struct dwc3_omap *omap) in dwc3_omap_set_utmi_mode() argument
392 struct device_node *node = omap->dev->of_node; in dwc3_omap_set_utmi_mode()
395 reg = dwc3_omap_read_utmi_ctrl(omap); in dwc3_omap_set_utmi_mode()
407 dev_WARN(omap->dev, "UNKNOWN utmi mode %d\n", utmi_mode); in dwc3_omap_set_utmi_mode()
410 dwc3_omap_write_utmi_ctrl(omap, reg); in dwc3_omap_set_utmi_mode()
413 static int dwc3_omap_extcon_register(struct dwc3_omap *omap) in dwc3_omap_extcon_register() argument
416 struct device_node *node = omap->dev->of_node; in dwc3_omap_extcon_register()
420 edev = extcon_get_edev_by_phandle(omap->dev, 0); in dwc3_omap_extcon_register()
422 dev_vdbg(omap->dev, "couldn't get extcon device\n"); in dwc3_omap_extcon_register()
426 omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier; in dwc3_omap_extcon_register()
427 ret = devm_extcon_register_notifier(omap->dev, edev, in dwc3_omap_extcon_register()
428 EXTCON_USB, &omap->vbus_nb); in dwc3_omap_extcon_register()
430 dev_vdbg(omap->dev, "failed to register notifier for USB\n"); in dwc3_omap_extcon_register()
432 omap->id_nb.notifier_call = dwc3_omap_id_notifier; in dwc3_omap_extcon_register()
433 ret = devm_extcon_register_notifier(omap->dev, edev, in dwc3_omap_extcon_register()
434 EXTCON_USB_HOST, &omap->id_nb); in dwc3_omap_extcon_register()
436 dev_vdbg(omap->dev, "failed to register notifier for USB-HOST\n"); in dwc3_omap_extcon_register()
439 dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID); in dwc3_omap_extcon_register()
441 dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_OFF); in dwc3_omap_extcon_register()
444 dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND); in dwc3_omap_extcon_register()
446 dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_FLOAT); in dwc3_omap_extcon_register()
448 omap->edev = edev; in dwc3_omap_extcon_register()
458 struct dwc3_omap *omap; in dwc3_omap_probe() local
472 omap = devm_kzalloc(dev, sizeof(*omap), GFP_KERNEL); in dwc3_omap_probe()
473 if (!omap) in dwc3_omap_probe()
476 platform_set_drvdata(pdev, omap); in dwc3_omap_probe()
494 omap->dev = dev; in dwc3_omap_probe()
495 omap->irq = irq; in dwc3_omap_probe()
496 omap->base = base; in dwc3_omap_probe()
497 omap->vbus_reg = vbus_reg; in dwc3_omap_probe()
506 dwc3_omap_map_offset(omap); in dwc3_omap_probe()
507 dwc3_omap_set_utmi_mode(omap); in dwc3_omap_probe()
509 ret = dwc3_omap_extcon_register(omap); in dwc3_omap_probe()
519 ret = devm_request_threaded_irq(dev, omap->irq, dwc3_omap_interrupt, in dwc3_omap_probe()
521 "dwc3-omap", omap); in dwc3_omap_probe()
524 omap->irq, ret); in dwc3_omap_probe()
527 dwc3_omap_enable_irqs(omap); in dwc3_omap_probe()
541 struct dwc3_omap *omap = platform_get_drvdata(pdev); in dwc3_omap_remove() local
543 dwc3_omap_disable_irqs(omap); in dwc3_omap_remove()
544 disable_irq(omap->irq); in dwc3_omap_remove()
545 of_platform_depopulate(omap->dev); in dwc3_omap_remove()
564 struct dwc3_omap *omap = dev_get_drvdata(dev); in dwc3_omap_suspend() local
566 omap->utmi_otg_ctrl = dwc3_omap_read_utmi_ctrl(omap); in dwc3_omap_suspend()
567 dwc3_omap_disable_irqs(omap); in dwc3_omap_suspend()
574 struct dwc3_omap *omap = dev_get_drvdata(dev); in dwc3_omap_resume() local
576 dwc3_omap_write_utmi_ctrl(omap, omap->utmi_otg_ctrl); in dwc3_omap_resume()
577 dwc3_omap_enable_irqs(omap); in dwc3_omap_resume()
588 struct dwc3_omap *omap = dev_get_drvdata(dev); in dwc3_omap_complete() local
590 if (extcon_get_state(omap->edev, EXTCON_USB)) in dwc3_omap_complete()
591 dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID); in dwc3_omap_complete()
593 dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_OFF); in dwc3_omap_complete()
595 if (extcon_get_state(omap->edev, EXTCON_USB_HOST)) in dwc3_omap_complete()
596 dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND); in dwc3_omap_complete()
598 dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_FLOAT); in dwc3_omap_complete()
616 .name = "omap-dwc3",
624 MODULE_ALIAS("platform:omap-dwc3");
627 MODULE_DESCRIPTION("DesignWare USB3 OMAP Glue Layer");