39 #include <linux/module.h>
40 #include <linux/kernel.h>
41 #include <linux/slab.h>
61 #define USBOTGSS_REVISION 0x0000
62 #define USBOTGSS_SYSCONFIG 0x0010
63 #define USBOTGSS_IRQ_EOI 0x0020
64 #define USBOTGSS_IRQSTATUS_RAW_0 0x0024
65 #define USBOTGSS_IRQSTATUS_0 0x0028
66 #define USBOTGSS_IRQENABLE_SET_0 0x002c
67 #define USBOTGSS_IRQENABLE_CLR_0 0x0030
68 #define USBOTGSS_IRQSTATUS_RAW_1 0x0034
69 #define USBOTGSS_IRQSTATUS_1 0x0038
70 #define USBOTGSS_IRQENABLE_SET_1 0x003c
71 #define USBOTGSS_IRQENABLE_CLR_1 0x0040
72 #define USBOTGSS_UTMI_OTG_CTRL 0x0080
73 #define USBOTGSS_UTMI_OTG_STATUS 0x0084
74 #define USBOTGSS_MMRAM_OFFSET 0x0100
75 #define USBOTGSS_FLADJ 0x0104
76 #define USBOTGSS_DEBUG_CFG 0x0108
77 #define USBOTGSS_DEBUG_DATA 0x010c
80 #define USBOTGSS_SYSCONFIG_DMADISABLE (1 << 16)
81 #define USBOTGSS_SYSCONFIG_STANDBYMODE(x) ((x) << 4)
83 #define USBOTGSS_STANDBYMODE_FORCE_STANDBY 0
84 #define USBOTGSS_STANDBYMODE_NO_STANDBY 1
85 #define USBOTGSS_STANDBYMODE_SMART_STANDBY 2
86 #define USBOTGSS_STANDBYMODE_SMART_WAKEUP 3
88 #define USBOTGSS_STANDBYMODE_MASK (0x03 << 4)
90 #define USBOTGSS_SYSCONFIG_IDLEMODE(x) ((x) << 2)
92 #define USBOTGSS_IDLEMODE_FORCE_IDLE 0
93 #define USBOTGSS_IDLEMODE_NO_IDLE 1
94 #define USBOTGSS_IDLEMODE_SMART_IDLE 2
95 #define USBOTGSS_IDLEMODE_SMART_WAKEUP 3
97 #define USBOTGSS_IDLEMODE_MASK (0x03 << 2)
100 #define USBOTGSS_IRQ_EOI_LINE_NUMBER (1 << 0)
103 #define USBOTGSS_IRQO_COREIRQ_ST (1 << 0)
106 #define USBOTGSS_IRQ1_DMADISABLECLR (1 << 17)
107 #define USBOTGSS_IRQ1_OEVT (1 << 16)
108 #define USBOTGSS_IRQ1_DRVVBUS_RISE (1 << 13)
109 #define USBOTGSS_IRQ1_CHRGVBUS_RISE (1 << 12)
110 #define USBOTGSS_IRQ1_DISCHRGVBUS_RISE (1 << 11)
111 #define USBOTGSS_IRQ1_IDPULLUP_RISE (1 << 8)
112 #define USBOTGSS_IRQ1_DRVVBUS_FALL (1 << 5)
113 #define USBOTGSS_IRQ1_CHRGVBUS_FALL (1 << 4)
114 #define USBOTGSS_IRQ1_DISCHRGVBUS_FALL (1 << 3)
115 #define USBOTGSS_IRQ1_IDPULLUP_FALL (1 << 0)
118 #define USBOTGSS_UTMI_OTG_CTRL_DRVVBUS (1 << 5)
119 #define USBOTGSS_UTMI_OTG_CTRL_CHRGVBUS (1 << 4)
120 #define USBOTGSS_UTMI_OTG_CTRL_DISCHRGVBUS (1 << 3)
121 #define USBOTGSS_UTMI_OTG_CTRL_IDPULLUP (1 << 0)
124 #define USBOTGSS_UTMI_OTG_STATUS_SW_MODE (1 << 31)
125 #define USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT (1 << 9)
126 #define USBOTGSS_UTMI_OTG_STATUS_TXBITSTUFFENABLE (1 << 8)
127 #define USBOTGSS_UTMI_OTG_STATUS_IDDIG (1 << 4)
128 #define USBOTGSS_UTMI_OTG_STATUS_SESSEND (1 << 3)
129 #define USBOTGSS_UTMI_OTG_STATUS_SESSVALID (1 << 2)
130 #define USBOTGSS_UTMI_OTG_STATUS_VBUSVALID (1 << 1)
152 return readl(base + offset);
157 writel(value, base + offset);
214 static irqreturn_t dwc3_omap_interrupt(
int irq,
void *_omap)
219 spin_lock(&omap->
lock);
224 dev_dbg(omap->
dev,
"DMA Disable was Cleared\n");
260 spin_unlock(&omap->
lock);
280 const u32 *utmi_mode;
288 dev_err(dev,
"not enough memory\n");
292 platform_set_drvdata(pdev, omap);
296 dev_err(dev,
"missing IRQ resource\n");
302 dev_err(dev,
"missing memory base resource\n");
308 dev_err(dev,
"ioremap failed\n");
312 ret = dwc3_omap_register_phys(omap);
314 dev_err(dev,
"couldn't register PHYs\n");
324 dev_err(dev,
"couldn't allocate dwc3 device\n");
330 dev_err(dev,
"couldn't allocate dwc3 context memory\n");
350 if (utmi_mode && size ==
sizeof(*utmi_mode)) {
354 dev_dbg(dev,
"missing platform data\n");
364 dev_dbg(dev,
"UNKNOWN utmi mode %d\n",
385 ret = devm_request_irq(dev, omap->
irq, dwc3_omap_interrupt, 0,
388 dev_err(dev,
"failed to request IRQ #%d --> %d\n",
397 reg = (USBOTGSS_IRQ1_OEVT |
398 USBOTGSS_IRQ1_DRVVBUS_RISE |
399 USBOTGSS_IRQ1_CHRGVBUS_RISE |
400 USBOTGSS_IRQ1_DISCHRGVBUS_RISE |
401 USBOTGSS_IRQ1_IDPULLUP_RISE |
402 USBOTGSS_IRQ1_DRVVBUS_FALL |
403 USBOTGSS_IRQ1_CHRGVBUS_FALL |
404 USBOTGSS_IRQ1_DISCHRGVBUS_FALL |
412 dev_err(dev,
"couldn't add resources to dwc3 device\n");
418 dev_err(dev,
"failed to register dwc3 device\n");
435 struct dwc3_omap *omap = platform_get_drvdata(pdev);
455 .probe = dwc3_omap_probe,
459 .of_match_table = of_dwc3_matach,