2 * dwc3-omap.c - OMAP Specific Glue layer
4 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
6 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 of
11 * the License as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #include <linux/module.h>
20 #include <linux/kernel.h>
21 #include <linux/slab.h>
22 #include <linux/interrupt.h>
23 #include <linux/spinlock.h>
24 #include <linux/platform_device.h>
25 #include <linux/platform_data/dwc3-omap.h>
26 #include <linux/pm_runtime.h>
27 #include <linux/dma-mapping.h>
28 #include <linux/ioport.h>
31 #include <linux/of_platform.h>
32 #include <linux/extcon.h>
33 #include <linux/extcon/of_extcon.h>
34 #include <linux/regulator/consumer.h>
36 #include <linux/usb/otg.h>
39 * All these registers belong to OMAP's Wrapper around the
40 * DesignWare USB3 Core.
43 #define USBOTGSS_REVISION 0x0000
44 #define USBOTGSS_SYSCONFIG 0x0010
45 #define USBOTGSS_IRQ_EOI 0x0020
46 #define USBOTGSS_EOI_OFFSET 0x0008
47 #define USBOTGSS_IRQSTATUS_RAW_0 0x0024
48 #define USBOTGSS_IRQSTATUS_0 0x0028
49 #define USBOTGSS_IRQENABLE_SET_0 0x002c
50 #define USBOTGSS_IRQENABLE_CLR_0 0x0030
51 #define USBOTGSS_IRQ0_OFFSET 0x0004
52 #define USBOTGSS_IRQSTATUS_RAW_1 0x0030
53 #define USBOTGSS_IRQSTATUS_1 0x0034
54 #define USBOTGSS_IRQENABLE_SET_1 0x0038
55 #define USBOTGSS_IRQENABLE_CLR_1 0x003c
56 #define USBOTGSS_IRQSTATUS_RAW_2 0x0040
57 #define USBOTGSS_IRQSTATUS_2 0x0044
58 #define USBOTGSS_IRQENABLE_SET_2 0x0048
59 #define USBOTGSS_IRQENABLE_CLR_2 0x004c
60 #define USBOTGSS_IRQSTATUS_RAW_3 0x0050
61 #define USBOTGSS_IRQSTATUS_3 0x0054
62 #define USBOTGSS_IRQENABLE_SET_3 0x0058
63 #define USBOTGSS_IRQENABLE_CLR_3 0x005c
64 #define USBOTGSS_IRQSTATUS_EOI_MISC 0x0030
65 #define USBOTGSS_IRQSTATUS_RAW_MISC 0x0034
66 #define USBOTGSS_IRQSTATUS_MISC 0x0038
67 #define USBOTGSS_IRQENABLE_SET_MISC 0x003c
68 #define USBOTGSS_IRQENABLE_CLR_MISC 0x0040
69 #define USBOTGSS_IRQMISC_OFFSET 0x03fc
70 #define USBOTGSS_UTMI_OTG_CTRL 0x0080
71 #define USBOTGSS_UTMI_OTG_STATUS 0x0084
72 #define USBOTGSS_UTMI_OTG_OFFSET 0x0480
73 #define USBOTGSS_TXFIFO_DEPTH 0x0508
74 #define USBOTGSS_RXFIFO_DEPTH 0x050c
75 #define USBOTGSS_MMRAM_OFFSET 0x0100
76 #define USBOTGSS_FLADJ 0x0104
77 #define USBOTGSS_DEBUG_CFG 0x0108
78 #define USBOTGSS_DEBUG_DATA 0x010c
79 #define USBOTGSS_DEV_EBC_EN 0x0110
80 #define USBOTGSS_DEBUG_OFFSET 0x0600
82 /* REVISION REGISTER */
83 #define USBOTGSS_REVISION_XMAJOR(reg) ((reg >> 8) & 0x7)
84 #define USBOTGSS_REVISION_XMAJOR1 1
85 #define USBOTGSS_REVISION_XMAJOR2 2
86 /* SYSCONFIG REGISTER */
87 #define USBOTGSS_SYSCONFIG_DMADISABLE (1 << 16)
89 /* IRQ_EOI REGISTER */
90 #define USBOTGSS_IRQ_EOI_LINE_NUMBER (1 << 0)
93 #define USBOTGSS_IRQO_COREIRQ_ST (1 << 0)
96 #define USBOTGSS_IRQMISC_DMADISABLECLR (1 << 17)
97 #define USBOTGSS_IRQMISC_OEVT (1 << 16)
98 #define USBOTGSS_IRQMISC_DRVVBUS_RISE (1 << 13)
99 #define USBOTGSS_IRQMISC_CHRGVBUS_RISE (1 << 12)
100 #define USBOTGSS_IRQMISC_DISCHRGVBUS_RISE (1 << 11)
101 #define USBOTGSS_IRQMISC_IDPULLUP_RISE (1 << 8)
102 #define USBOTGSS_IRQMISC_DRVVBUS_FALL (1 << 5)
103 #define USBOTGSS_IRQMISC_CHRGVBUS_FALL (1 << 4)
104 #define USBOTGSS_IRQMISC_DISCHRGVBUS_FALL (1 << 3)
105 #define USBOTGSS_IRQMISC_IDPULLUP_FALL (1 << 0)
107 /* UTMI_OTG_CTRL REGISTER */
108 #define USBOTGSS_UTMI_OTG_CTRL_DRVVBUS (1 << 5)
109 #define USBOTGSS_UTMI_OTG_CTRL_CHRGVBUS (1 << 4)
110 #define USBOTGSS_UTMI_OTG_CTRL_DISCHRGVBUS (1 << 3)
111 #define USBOTGSS_UTMI_OTG_CTRL_IDPULLUP (1 << 0)
113 /* UTMI_OTG_STATUS REGISTER */
114 #define USBOTGSS_UTMI_OTG_STATUS_SW_MODE (1 << 31)
115 #define USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT (1 << 9)
116 #define USBOTGSS_UTMI_OTG_STATUS_TXBITSTUFFENABLE (1 << 8)
117 #define USBOTGSS_UTMI_OTG_STATUS_IDDIG (1 << 4)
118 #define USBOTGSS_UTMI_OTG_STATUS_SESSEND (1 << 3)
119 #define USBOTGSS_UTMI_OTG_STATUS_SESSVALID (1 << 2)
120 #define USBOTGSS_UTMI_OTG_STATUS_VBUSVALID (1 << 1)
141 struct extcon_specific_cable_nb extcon_vbus_dev
;
142 struct extcon_specific_cable_nb extcon_id_dev
;
143 struct notifier_block vbus_nb
;
144 struct notifier_block id_nb
;
146 struct regulator
*vbus_reg
;
149 enum omap_dwc3_vbus_id_status
{
153 OMAP_DWC3_VBUS_VALID
,
156 static inline u32
dwc3_omap_readl(void __iomem
*base
, u32 offset
)
158 return readl(base
+ offset
);
161 static inline void dwc3_omap_writel(void __iomem
*base
, u32 offset
, u32 value
)
163 writel(value
, base
+ offset
);
166 static u32
dwc3_omap_read_utmi_status(struct dwc3_omap
*omap
)
168 return dwc3_omap_readl(omap
->base
, USBOTGSS_UTMI_OTG_STATUS
+
169 omap
->utmi_otg_offset
);
172 static void dwc3_omap_write_utmi_status(struct dwc3_omap
*omap
, u32 value
)
174 dwc3_omap_writel(omap
->base
, USBOTGSS_UTMI_OTG_STATUS
+
175 omap
->utmi_otg_offset
, value
);
179 static u32
dwc3_omap_read_irq0_status(struct dwc3_omap
*omap
)
181 return dwc3_omap_readl(omap
->base
, USBOTGSS_IRQSTATUS_0
-
185 static void dwc3_omap_write_irq0_status(struct dwc3_omap
*omap
, u32 value
)
187 dwc3_omap_writel(omap
->base
, USBOTGSS_IRQSTATUS_0
-
188 omap
->irq0_offset
, value
);
192 static u32
dwc3_omap_read_irqmisc_status(struct dwc3_omap
*omap
)
194 return dwc3_omap_readl(omap
->base
, USBOTGSS_IRQSTATUS_MISC
+
195 omap
->irqmisc_offset
);
198 static void dwc3_omap_write_irqmisc_status(struct dwc3_omap
*omap
, u32 value
)
200 dwc3_omap_writel(omap
->base
, USBOTGSS_IRQSTATUS_MISC
+
201 omap
->irqmisc_offset
, value
);
205 static void dwc3_omap_write_irqmisc_set(struct dwc3_omap
*omap
, u32 value
)
207 dwc3_omap_writel(omap
->base
, USBOTGSS_IRQENABLE_SET_MISC
+
208 omap
->irqmisc_offset
, value
);
212 static void dwc3_omap_write_irq0_set(struct dwc3_omap
*omap
, u32 value
)
214 dwc3_omap_writel(omap
->base
, USBOTGSS_IRQENABLE_SET_0
-
215 omap
->irq0_offset
, value
);
218 static void dwc3_omap_write_irqmisc_clr(struct dwc3_omap
*omap
, u32 value
)
220 dwc3_omap_writel(omap
->base
, USBOTGSS_IRQENABLE_CLR_MISC
+
221 omap
->irqmisc_offset
, value
);
224 static void dwc3_omap_write_irq0_clr(struct dwc3_omap
*omap
, u32 value
)
226 dwc3_omap_writel(omap
->base
, USBOTGSS_IRQENABLE_CLR_0
-
227 omap
->irq0_offset
, value
);
230 static void dwc3_omap_set_mailbox(struct dwc3_omap
*omap
,
231 enum omap_dwc3_vbus_id_status status
)
237 case OMAP_DWC3_ID_GROUND
:
238 dev_dbg(omap
->dev
, "ID GND\n");
240 if (omap
->vbus_reg
) {
241 ret
= regulator_enable(omap
->vbus_reg
);
243 dev_dbg(omap
->dev
, "regulator enable failed\n");
248 val
= dwc3_omap_read_utmi_status(omap
);
249 val
&= ~(USBOTGSS_UTMI_OTG_STATUS_IDDIG
250 | USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
251 | USBOTGSS_UTMI_OTG_STATUS_SESSEND
);
252 val
|= USBOTGSS_UTMI_OTG_STATUS_SESSVALID
253 | USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT
;
254 dwc3_omap_write_utmi_status(omap
, val
);
257 case OMAP_DWC3_VBUS_VALID
:
258 dev_dbg(omap
->dev
, "VBUS Connect\n");
260 val
= dwc3_omap_read_utmi_status(omap
);
261 val
&= ~USBOTGSS_UTMI_OTG_STATUS_SESSEND
;
262 val
|= USBOTGSS_UTMI_OTG_STATUS_IDDIG
263 | USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
264 | USBOTGSS_UTMI_OTG_STATUS_SESSVALID
265 | USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT
;
266 dwc3_omap_write_utmi_status(omap
, val
);
269 case OMAP_DWC3_ID_FLOAT
:
271 regulator_disable(omap
->vbus_reg
);
273 case OMAP_DWC3_VBUS_OFF
:
274 dev_dbg(omap
->dev
, "VBUS Disconnect\n");
276 val
= dwc3_omap_read_utmi_status(omap
);
277 val
&= ~(USBOTGSS_UTMI_OTG_STATUS_SESSVALID
278 | USBOTGSS_UTMI_OTG_STATUS_VBUSVALID
279 | USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT
);
280 val
|= USBOTGSS_UTMI_OTG_STATUS_SESSEND
281 | USBOTGSS_UTMI_OTG_STATUS_IDDIG
;
282 dwc3_omap_write_utmi_status(omap
, val
);
286 dev_dbg(omap
->dev
, "invalid state\n");
290 static irqreturn_t
dwc3_omap_interrupt(int irq
, void *_omap
)
292 struct dwc3_omap
*omap
= _omap
;
295 spin_lock(&omap
->lock
);
297 reg
= dwc3_omap_read_irqmisc_status(omap
);
299 if (reg
& USBOTGSS_IRQMISC_DMADISABLECLR
) {
300 dev_dbg(omap
->dev
, "DMA Disable was Cleared\n");
301 omap
->dma_status
= false;
304 if (reg
& USBOTGSS_IRQMISC_OEVT
)
305 dev_dbg(omap
->dev
, "OTG Event\n");
307 if (reg
& USBOTGSS_IRQMISC_DRVVBUS_RISE
)
308 dev_dbg(omap
->dev
, "DRVVBUS Rise\n");
310 if (reg
& USBOTGSS_IRQMISC_CHRGVBUS_RISE
)
311 dev_dbg(omap
->dev
, "CHRGVBUS Rise\n");
313 if (reg
& USBOTGSS_IRQMISC_DISCHRGVBUS_RISE
)
314 dev_dbg(omap
->dev
, "DISCHRGVBUS Rise\n");
316 if (reg
& USBOTGSS_IRQMISC_IDPULLUP_RISE
)
317 dev_dbg(omap
->dev
, "IDPULLUP Rise\n");
319 if (reg
& USBOTGSS_IRQMISC_DRVVBUS_FALL
)
320 dev_dbg(omap
->dev
, "DRVVBUS Fall\n");
322 if (reg
& USBOTGSS_IRQMISC_CHRGVBUS_FALL
)
323 dev_dbg(omap
->dev
, "CHRGVBUS Fall\n");
325 if (reg
& USBOTGSS_IRQMISC_DISCHRGVBUS_FALL
)
326 dev_dbg(omap
->dev
, "DISCHRGVBUS Fall\n");
328 if (reg
& USBOTGSS_IRQMISC_IDPULLUP_FALL
)
329 dev_dbg(omap
->dev
, "IDPULLUP Fall\n");
331 dwc3_omap_write_irqmisc_status(omap
, reg
);
333 reg
= dwc3_omap_read_irq0_status(omap
);
335 dwc3_omap_write_irq0_status(omap
, reg
);
337 spin_unlock(&omap
->lock
);
342 static int dwc3_omap_remove_core(struct device
*dev
, void *c
)
344 struct platform_device
*pdev
= to_platform_device(dev
);
346 platform_device_unregister(pdev
);
351 static void dwc3_omap_enable_irqs(struct dwc3_omap
*omap
)
355 /* enable all IRQs */
356 reg
= USBOTGSS_IRQO_COREIRQ_ST
;
357 dwc3_omap_write_irq0_set(omap
, reg
);
359 reg
= (USBOTGSS_IRQMISC_OEVT
|
360 USBOTGSS_IRQMISC_DRVVBUS_RISE
|
361 USBOTGSS_IRQMISC_CHRGVBUS_RISE
|
362 USBOTGSS_IRQMISC_DISCHRGVBUS_RISE
|
363 USBOTGSS_IRQMISC_IDPULLUP_RISE
|
364 USBOTGSS_IRQMISC_DRVVBUS_FALL
|
365 USBOTGSS_IRQMISC_CHRGVBUS_FALL
|
366 USBOTGSS_IRQMISC_DISCHRGVBUS_FALL
|
367 USBOTGSS_IRQMISC_IDPULLUP_FALL
);
369 dwc3_omap_write_irqmisc_set(omap
, reg
);
372 static void dwc3_omap_disable_irqs(struct dwc3_omap
*omap
)
376 /* disable all IRQs */
377 reg
= USBOTGSS_IRQO_COREIRQ_ST
;
378 dwc3_omap_write_irq0_clr(omap
, reg
);
380 reg
= (USBOTGSS_IRQMISC_OEVT
|
381 USBOTGSS_IRQMISC_DRVVBUS_RISE
|
382 USBOTGSS_IRQMISC_CHRGVBUS_RISE
|
383 USBOTGSS_IRQMISC_DISCHRGVBUS_RISE
|
384 USBOTGSS_IRQMISC_IDPULLUP_RISE
|
385 USBOTGSS_IRQMISC_DRVVBUS_FALL
|
386 USBOTGSS_IRQMISC_CHRGVBUS_FALL
|
387 USBOTGSS_IRQMISC_DISCHRGVBUS_FALL
|
388 USBOTGSS_IRQMISC_IDPULLUP_FALL
);
390 dwc3_omap_write_irqmisc_clr(omap
, reg
);
393 static u64 dwc3_omap_dma_mask
= DMA_BIT_MASK(32);
395 static int dwc3_omap_id_notifier(struct notifier_block
*nb
,
396 unsigned long event
, void *ptr
)
398 struct dwc3_omap
*omap
= container_of(nb
, struct dwc3_omap
, id_nb
);
401 dwc3_omap_set_mailbox(omap
, OMAP_DWC3_ID_GROUND
);
403 dwc3_omap_set_mailbox(omap
, OMAP_DWC3_ID_FLOAT
);
408 static int dwc3_omap_vbus_notifier(struct notifier_block
*nb
,
409 unsigned long event
, void *ptr
)
411 struct dwc3_omap
*omap
= container_of(nb
, struct dwc3_omap
, vbus_nb
);
414 dwc3_omap_set_mailbox(omap
, OMAP_DWC3_VBUS_VALID
);
416 dwc3_omap_set_mailbox(omap
, OMAP_DWC3_VBUS_OFF
);
421 static int dwc3_omap_probe(struct platform_device
*pdev
)
423 struct device_node
*node
= pdev
->dev
.of_node
;
425 struct dwc3_omap
*omap
;
426 struct resource
*res
;
427 struct device
*dev
= &pdev
->dev
;
428 struct extcon_dev
*edev
;
429 struct regulator
*vbus_reg
= NULL
;
442 dev_err(dev
, "device node not found\n");
446 omap
= devm_kzalloc(dev
, sizeof(*omap
), GFP_KERNEL
);
448 dev_err(dev
, "not enough memory\n");
452 platform_set_drvdata(pdev
, omap
);
454 irq
= platform_get_irq(pdev
, 0);
456 dev_err(dev
, "missing IRQ resource\n");
460 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
462 dev_err(dev
, "missing memory base resource\n");
466 base
= devm_ioremap_resource(dev
, res
);
468 return PTR_ERR(base
);
470 if (of_property_read_bool(node
, "vbus-supply")) {
471 vbus_reg
= devm_regulator_get(dev
, "vbus");
472 if (IS_ERR(vbus_reg
)) {
473 dev_err(dev
, "vbus init failed\n");
474 return PTR_ERR(vbus_reg
);
478 spin_lock_init(&omap
->lock
);
483 omap
->vbus_reg
= vbus_reg
;
484 dev
->dma_mask
= &dwc3_omap_dma_mask
;
486 pm_runtime_enable(dev
);
487 ret
= pm_runtime_get_sync(dev
);
489 dev_err(dev
, "get_sync failed with err %d\n", ret
);
493 reg
= dwc3_omap_readl(omap
->base
, USBOTGSS_REVISION
);
494 omap
->revision
= reg
;
495 x_major
= USBOTGSS_REVISION_XMAJOR(reg
);
497 /* Differentiate between OMAP5 and AM437x */
499 case USBOTGSS_REVISION_XMAJOR1
:
500 case USBOTGSS_REVISION_XMAJOR2
:
501 omap
->irq_eoi_offset
= 0;
502 omap
->irq0_offset
= 0;
503 omap
->irqmisc_offset
= 0;
504 omap
->utmi_otg_offset
= 0;
505 omap
->debug_offset
= 0;
508 /* Default to the latest revision */
509 omap
->irq_eoi_offset
= USBOTGSS_EOI_OFFSET
;
510 omap
->irq0_offset
= USBOTGSS_IRQ0_OFFSET
;
511 omap
->irqmisc_offset
= USBOTGSS_IRQMISC_OFFSET
;
512 omap
->utmi_otg_offset
= USBOTGSS_UTMI_OTG_OFFSET
;
513 omap
->debug_offset
= USBOTGSS_DEBUG_OFFSET
;
517 /* For OMAP5(ES2.0) and AM437x x_major is 2 even though there are
518 * changes in wrapper registers, Using dt compatible for aegis
521 if (of_device_is_compatible(node
, "ti,am437x-dwc3")) {
522 omap
->irq_eoi_offset
= USBOTGSS_EOI_OFFSET
;
523 omap
->irq0_offset
= USBOTGSS_IRQ0_OFFSET
;
524 omap
->irqmisc_offset
= USBOTGSS_IRQMISC_OFFSET
;
525 omap
->utmi_otg_offset
= USBOTGSS_UTMI_OTG_OFFSET
;
526 omap
->debug_offset
= USBOTGSS_DEBUG_OFFSET
;
529 reg
= dwc3_omap_read_utmi_status(omap
);
531 of_property_read_u32(node
, "utmi-mode", &utmi_mode
);
534 case DWC3_OMAP_UTMI_MODE_SW
:
535 reg
|= USBOTGSS_UTMI_OTG_STATUS_SW_MODE
;
537 case DWC3_OMAP_UTMI_MODE_HW
:
538 reg
&= ~USBOTGSS_UTMI_OTG_STATUS_SW_MODE
;
541 dev_dbg(dev
, "UNKNOWN utmi mode %d\n", utmi_mode
);
544 dwc3_omap_write_utmi_status(omap
, reg
);
546 /* check the DMA Status */
547 reg
= dwc3_omap_readl(omap
->base
, USBOTGSS_SYSCONFIG
);
548 omap
->dma_status
= !!(reg
& USBOTGSS_SYSCONFIG_DMADISABLE
);
550 ret
= devm_request_irq(dev
, omap
->irq
, dwc3_omap_interrupt
, 0,
553 dev_err(dev
, "failed to request IRQ #%d --> %d\n",
558 dwc3_omap_enable_irqs(omap
);
560 if (of_property_read_bool(node
, "extcon")) {
561 edev
= of_extcon_get_extcon_dev(dev
, 0);
563 dev_vdbg(dev
, "couldn't get extcon device\n");
568 omap
->vbus_nb
.notifier_call
= dwc3_omap_vbus_notifier
;
569 ret
= extcon_register_interest(&omap
->extcon_vbus_dev
,
570 edev
->name
, "USB", &omap
->vbus_nb
);
572 dev_vdbg(dev
, "failed to register notifier for USB\n");
573 omap
->id_nb
.notifier_call
= dwc3_omap_id_notifier
;
574 ret
= extcon_register_interest(&omap
->extcon_id_dev
, edev
->name
,
575 "USB-HOST", &omap
->id_nb
);
578 "failed to register notifier for USB-HOST\n");
580 if (extcon_get_cable_state(edev
, "USB") == true)
581 dwc3_omap_set_mailbox(omap
, OMAP_DWC3_VBUS_VALID
);
582 if (extcon_get_cable_state(edev
, "USB-HOST") == true)
583 dwc3_omap_set_mailbox(omap
, OMAP_DWC3_ID_GROUND
);
586 ret
= of_platform_populate(node
, NULL
, NULL
, dev
);
588 dev_err(&pdev
->dev
, "failed to create dwc3 core\n");
595 if (omap
->extcon_vbus_dev
.edev
)
596 extcon_unregister_interest(&omap
->extcon_vbus_dev
);
597 if (omap
->extcon_id_dev
.edev
)
598 extcon_unregister_interest(&omap
->extcon_id_dev
);
601 dwc3_omap_disable_irqs(omap
);
604 pm_runtime_put_sync(dev
);
607 pm_runtime_disable(dev
);
612 static int dwc3_omap_remove(struct platform_device
*pdev
)
614 struct dwc3_omap
*omap
= platform_get_drvdata(pdev
);
616 if (omap
->extcon_vbus_dev
.edev
)
617 extcon_unregister_interest(&omap
->extcon_vbus_dev
);
618 if (omap
->extcon_id_dev
.edev
)
619 extcon_unregister_interest(&omap
->extcon_id_dev
);
620 dwc3_omap_disable_irqs(omap
);
621 device_for_each_child(&pdev
->dev
, NULL
, dwc3_omap_remove_core
);
622 pm_runtime_put_sync(&pdev
->dev
);
623 pm_runtime_disable(&pdev
->dev
);
628 static const struct of_device_id of_dwc3_match
[] = {
630 .compatible
= "ti,dwc3"
633 .compatible
= "ti,am437x-dwc3"
637 MODULE_DEVICE_TABLE(of
, of_dwc3_match
);
639 #ifdef CONFIG_PM_SLEEP
640 static int dwc3_omap_prepare(struct device
*dev
)
642 struct dwc3_omap
*omap
= dev_get_drvdata(dev
);
644 dwc3_omap_disable_irqs(omap
);
649 static void dwc3_omap_complete(struct device
*dev
)
651 struct dwc3_omap
*omap
= dev_get_drvdata(dev
);
653 dwc3_omap_enable_irqs(omap
);
656 static int dwc3_omap_suspend(struct device
*dev
)
658 struct dwc3_omap
*omap
= dev_get_drvdata(dev
);
660 omap
->utmi_otg_status
= dwc3_omap_read_utmi_status(omap
);
665 static int dwc3_omap_resume(struct device
*dev
)
667 struct dwc3_omap
*omap
= dev_get_drvdata(dev
);
669 dwc3_omap_write_utmi_status(omap
, omap
->utmi_otg_status
);
671 pm_runtime_disable(dev
);
672 pm_runtime_set_active(dev
);
673 pm_runtime_enable(dev
);
678 static const struct dev_pm_ops dwc3_omap_dev_pm_ops
= {
679 .prepare
= dwc3_omap_prepare
,
680 .complete
= dwc3_omap_complete
,
682 SET_SYSTEM_SLEEP_PM_OPS(dwc3_omap_suspend
, dwc3_omap_resume
)
685 #define DEV_PM_OPS (&dwc3_omap_dev_pm_ops)
687 #define DEV_PM_OPS NULL
688 #endif /* CONFIG_PM_SLEEP */
690 static struct platform_driver dwc3_omap_driver
= {
691 .probe
= dwc3_omap_probe
,
692 .remove
= dwc3_omap_remove
,
695 .of_match_table
= of_dwc3_match
,
700 module_platform_driver(dwc3_omap_driver
);
702 MODULE_ALIAS("platform:omap-dwc3");
703 MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
704 MODULE_LICENSE("GPL v2");
705 MODULE_DESCRIPTION("DesignWare USB3 OMAP Glue Layer");