Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1 | /** |
| 2 | * core.c - DesignWare USB3 DRD Controller Core file |
| 3 | * |
| 4 | * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 5 | * |
| 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
| 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
| 8 | * |
Felipe Balbi | 5945f78 | 2013-06-30 14:15:11 +0300 | [diff] [blame] | 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. |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 12 | * |
Felipe Balbi | 5945f78 | 2013-06-30 14:15:11 +0300 | [diff] [blame] | 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. |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 17 | * |
Felipe Balbi | 5945f78 | 2013-06-30 14:15:11 +0300 | [diff] [blame] | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 20 | */ |
| 21 | |
Felipe Balbi | fa0ea13 | 2014-09-19 15:51:11 -0500 | [diff] [blame] | 22 | #include <linux/version.h> |
Felipe Balbi | a72e658 | 2011-09-05 13:37:28 +0300 | [diff] [blame] | 23 | #include <linux/module.h> |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 24 | #include <linux/kernel.h> |
| 25 | #include <linux/slab.h> |
| 26 | #include <linux/spinlock.h> |
| 27 | #include <linux/platform_device.h> |
| 28 | #include <linux/pm_runtime.h> |
| 29 | #include <linux/interrupt.h> |
| 30 | #include <linux/ioport.h> |
| 31 | #include <linux/io.h> |
| 32 | #include <linux/list.h> |
| 33 | #include <linux/delay.h> |
| 34 | #include <linux/dma-mapping.h> |
Felipe Balbi | 457e84b | 2012-01-18 18:04:09 +0200 | [diff] [blame] | 35 | #include <linux/of.h> |
Heikki Krogerus | 404905a | 2014-09-25 10:57:02 +0300 | [diff] [blame] | 36 | #include <linux/acpi.h> |
Sekhar Nori | 6344475 | 2015-08-31 21:09:08 +0530 | [diff] [blame] | 37 | #include <linux/pinctrl/consumer.h> |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 38 | #include <linux/irq.h> |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 39 | |
| 40 | #include <linux/usb/ch9.h> |
| 41 | #include <linux/usb/gadget.h> |
Felipe Balbi | f7e846f | 2013-06-30 14:29:51 +0300 | [diff] [blame] | 42 | #include <linux/usb/of.h> |
Ruchika Kharwar | a45c82b8 | 2013-07-06 07:52:49 -0500 | [diff] [blame] | 43 | #include <linux/usb/otg.h> |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 44 | |
| 45 | #include "core.h" |
| 46 | #include "gadget.h" |
| 47 | #include "io.h" |
| 48 | |
| 49 | #include "debug.h" |
| 50 | |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 51 | #define DWC3_DEFAULT_AUTOSUSPEND_DELAY 5000 /* ms */ |
Felipe Balbi | 8300dd2 | 2011-10-18 13:54:01 +0300 | [diff] [blame] | 52 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 53 | void dwc3_usb3_phy_suspend(struct dwc3 *dwc, int suspend) |
| 54 | { |
| 55 | u32 reg; |
| 56 | |
| 57 | reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); |
| 58 | |
| 59 | if (suspend) |
| 60 | reg |= DWC3_GUSB3PIPECTL_SUSPHY; |
| 61 | else |
| 62 | reg &= ~DWC3_GUSB3PIPECTL_SUSPHY; |
| 63 | |
| 64 | dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); |
| 65 | } |
| 66 | |
Thinh Nguyen | 9d6173e | 2016-09-06 19:22:03 -0700 | [diff] [blame] | 67 | /** |
| 68 | * dwc3_get_dr_mode - Validates and sets dr_mode |
| 69 | * @dwc: pointer to our context structure |
| 70 | */ |
| 71 | static int dwc3_get_dr_mode(struct dwc3 *dwc) |
| 72 | { |
| 73 | enum usb_dr_mode mode; |
| 74 | struct device *dev = dwc->dev; |
| 75 | unsigned int hw_mode; |
| 76 | |
Thinh Nguyen | 9d6173e | 2016-09-06 19:22:03 -0700 | [diff] [blame] | 77 | |
Mayank Rana | fb9cd93 | 2016-11-03 23:26:38 -0700 | [diff] [blame] | 78 | dwc->is_drd = 0; |
Thinh Nguyen | 9d6173e | 2016-09-06 19:22:03 -0700 | [diff] [blame] | 79 | mode = dwc->dr_mode; |
| 80 | hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0); |
| 81 | |
| 82 | switch (hw_mode) { |
| 83 | case DWC3_GHWPARAMS0_MODE_GADGET: |
| 84 | if (IS_ENABLED(CONFIG_USB_DWC3_HOST)) { |
| 85 | dev_err(dev, |
| 86 | "Controller does not support host mode.\n"); |
| 87 | return -EINVAL; |
| 88 | } |
| 89 | mode = USB_DR_MODE_PERIPHERAL; |
| 90 | break; |
| 91 | case DWC3_GHWPARAMS0_MODE_HOST: |
| 92 | if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) { |
| 93 | dev_err(dev, |
| 94 | "Controller does not support device mode.\n"); |
| 95 | return -EINVAL; |
| 96 | } |
| 97 | mode = USB_DR_MODE_HOST; |
| 98 | break; |
| 99 | default: |
| 100 | if (IS_ENABLED(CONFIG_USB_DWC3_HOST)) |
| 101 | mode = USB_DR_MODE_HOST; |
| 102 | else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) |
| 103 | mode = USB_DR_MODE_PERIPHERAL; |
| 104 | } |
| 105 | |
| 106 | if (mode != dwc->dr_mode) { |
| 107 | dev_warn(dev, |
| 108 | "Configuration mismatch. dr_mode forced to %s\n", |
| 109 | mode == USB_DR_MODE_HOST ? "host" : "gadget"); |
| 110 | |
| 111 | dwc->dr_mode = mode; |
| 112 | } |
| 113 | |
Mayank Rana | fb9cd93 | 2016-11-03 23:26:38 -0700 | [diff] [blame] | 114 | if (dwc->dr_mode == USB_DR_MODE_OTG) |
| 115 | dwc->is_drd = 1; |
| 116 | |
Thinh Nguyen | 9d6173e | 2016-09-06 19:22:03 -0700 | [diff] [blame] | 117 | return 0; |
| 118 | } |
| 119 | |
Sebastian Andrzej Siewior | 3140e8c | 2011-10-31 22:25:40 +0100 | [diff] [blame] | 120 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode) |
| 121 | { |
| 122 | u32 reg; |
| 123 | |
| 124 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); |
| 125 | reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG)); |
| 126 | reg |= DWC3_GCTL_PRTCAPDIR(mode); |
| 127 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 128 | |
| 129 | /* |
| 130 | * Set this bit so that device attempts three more times at SS, even |
| 131 | * if it failed previously to operate in SS mode. |
| 132 | */ |
| 133 | reg |= DWC3_GCTL_U2RSTECN; |
| 134 | reg &= ~(DWC3_GCTL_SOFITPSYNC); |
| 135 | reg &= ~(DWC3_GCTL_PWRDNSCALEMASK); |
| 136 | reg |= DWC3_GCTL_PWRDNSCALE(2); |
| 137 | reg |= DWC3_GCTL_U2EXIT_LFPS; |
| 138 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
| 139 | |
| 140 | if (mode == DWC3_GCTL_PRTCAP_OTG || mode == DWC3_GCTL_PRTCAP_HOST) { |
| 141 | /* |
| 142 | * Allow ITP generated off of ref clk based counter instead |
| 143 | * of UTMI/ULPI clk based counter, when superspeed only is |
| 144 | * active so that UTMI/ULPI PHY can be suspened. |
| 145 | * |
| 146 | * Starting with revision 2.50A, GFLADJ_REFCLK_LPM_SEL is used |
| 147 | * instead. |
| 148 | */ |
| 149 | if (dwc->revision < DWC3_REVISION_250A) { |
| 150 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); |
| 151 | reg |= DWC3_GCTL_SOFITPSYNC; |
| 152 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
| 153 | } else { |
| 154 | reg = dwc3_readl(dwc->regs, DWC3_GFLADJ); |
| 155 | reg |= DWC3_GFLADJ_REFCLK_LPM_SEL; |
| 156 | dwc3_writel(dwc->regs, DWC3_GFLADJ, reg); |
| 157 | } |
| 158 | } |
Sebastian Andrzej Siewior | 3140e8c | 2011-10-31 22:25:40 +0100 | [diff] [blame] | 159 | } |
Felipe Balbi | 8300dd2 | 2011-10-18 13:54:01 +0300 | [diff] [blame] | 160 | |
Felipe Balbi | cf6d867 | 2016-04-14 15:03:39 +0300 | [diff] [blame] | 161 | u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type) |
| 162 | { |
| 163 | struct dwc3 *dwc = dep->dwc; |
| 164 | u32 reg; |
| 165 | |
| 166 | dwc3_writel(dwc->regs, DWC3_GDBGFIFOSPACE, |
| 167 | DWC3_GDBGFIFOSPACE_NUM(dep->number) | |
| 168 | DWC3_GDBGFIFOSPACE_TYPE(type)); |
| 169 | |
| 170 | reg = dwc3_readl(dwc->regs, DWC3_GDBGFIFOSPACE); |
| 171 | |
| 172 | return DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE(reg); |
| 173 | } |
| 174 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 175 | /** |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 176 | * Peforms initialization of HS and SS PHYs. |
| 177 | * If used as a part of POR or init sequence it is recommended |
| 178 | * that we should perform hard reset of the PHYs prior to invoking |
| 179 | * this function. |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 180 | * @dwc: pointer to our context structure |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 181 | */ |
| 182 | static int dwc3_init_usb_phys(struct dwc3 *dwc) |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 183 | { |
Kishon Vijay Abraham I | 5730348 | 2014-03-03 17:08:11 +0530 | [diff] [blame] | 184 | int ret; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 185 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 186 | /* Bring up PHYs */ |
| 187 | ret = usb_phy_init(dwc->usb2_phy); |
| 188 | if (ret) { |
| 189 | pr_err("%s: usb_phy_init(dwc->usb2_phy) returned %d\n", |
| 190 | __func__, ret); |
| 191 | return ret; |
| 192 | } |
| 193 | |
Hemant Kumar | de1df69 | 2016-04-26 19:36:48 -0700 | [diff] [blame] | 194 | if (dwc->maximum_speed == USB_SPEED_HIGH) |
| 195 | goto generic_phy_init; |
| 196 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 197 | ret = usb_phy_init(dwc->usb3_phy); |
| 198 | if (ret == -EBUSY) { |
| 199 | /* |
| 200 | * Setting Max speed as high when USB3 PHY initialiation |
| 201 | * is failing and USB superspeed can't be supported. |
| 202 | */ |
| 203 | dwc->maximum_speed = USB_SPEED_HIGH; |
| 204 | } else if (ret) { |
| 205 | pr_err("%s: usb_phy_init(dwc->usb3_phy) returned %d\n", |
| 206 | __func__, ret); |
| 207 | return ret; |
| 208 | } |
Hemant Kumar | de1df69 | 2016-04-26 19:36:48 -0700 | [diff] [blame] | 209 | |
| 210 | generic_phy_init: |
Kishon Vijay Abraham I | 5730348 | 2014-03-03 17:08:11 +0530 | [diff] [blame] | 211 | ret = phy_init(dwc->usb2_generic_phy); |
| 212 | if (ret < 0) |
| 213 | return ret; |
| 214 | |
| 215 | ret = phy_init(dwc->usb3_generic_phy); |
| 216 | if (ret < 0) { |
| 217 | phy_exit(dwc->usb2_generic_phy); |
| 218 | return ret; |
| 219 | } |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 220 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 221 | return 0; |
| 222 | } |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 223 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 224 | /** |
| 225 | * dwc3_core_reset - Issues core soft reset and PHY reset |
| 226 | * @dwc: pointer to our context structure |
| 227 | */ |
| 228 | static int dwc3_core_reset(struct dwc3 *dwc) |
| 229 | { |
| 230 | int ret; |
Mayank Rana | f8ebb7f | 2016-09-08 11:09:37 -0700 | [diff] [blame] | 231 | u32 reg; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 232 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 233 | /* Reset PHYs */ |
| 234 | usb_phy_reset(dwc->usb2_phy); |
Hemant Kumar | de1df69 | 2016-04-26 19:36:48 -0700 | [diff] [blame] | 235 | |
| 236 | if (dwc->maximum_speed == USB_SPEED_SUPER) |
| 237 | usb_phy_reset(dwc->usb3_phy); |
Pratyush Anand | 45627ac | 2012-06-21 17:44:28 +0530 | [diff] [blame] | 238 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 239 | /* Initialize PHYs */ |
| 240 | ret = dwc3_init_usb_phys(dwc); |
| 241 | if (ret) { |
| 242 | pr_err("%s: dwc3_init_phys returned %d\n", |
| 243 | __func__, ret); |
| 244 | return ret; |
| 245 | } |
Kishon Vijay Abraham I | 5730348 | 2014-03-03 17:08:11 +0530 | [diff] [blame] | 246 | |
Mayank Rana | f8ebb7f | 2016-09-08 11:09:37 -0700 | [diff] [blame] | 247 | reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); |
| 248 | reg &= ~DWC3_GUSB3PIPECTL_DELAYP1TRANS; |
| 249 | dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); |
| 250 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 251 | dwc3_notify_event(dwc, DWC3_CONTROLLER_RESET_EVENT); |
| 252 | |
| 253 | dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_RESET_EVENT); |
| 254 | |
| 255 | return 0; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | /** |
Heikki Krogerus | c5cc74e | 2015-05-13 15:26:47 +0300 | [diff] [blame] | 259 | * dwc3_soft_reset - Issue soft reset |
| 260 | * @dwc: Pointer to our controller context structure |
| 261 | */ |
| 262 | static int dwc3_soft_reset(struct dwc3 *dwc) |
| 263 | { |
| 264 | unsigned long timeout; |
| 265 | u32 reg; |
| 266 | |
| 267 | timeout = jiffies + msecs_to_jiffies(500); |
| 268 | dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST); |
| 269 | do { |
| 270 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); |
| 271 | if (!(reg & DWC3_DCTL_CSFTRST)) |
| 272 | break; |
| 273 | |
| 274 | if (time_after(jiffies, timeout)) { |
| 275 | dev_err(dwc->dev, "Reset Timed Out\n"); |
| 276 | return -ETIMEDOUT; |
| 277 | } |
| 278 | |
| 279 | cpu_relax(); |
| 280 | } while (true); |
| 281 | |
| 282 | return 0; |
| 283 | } |
| 284 | |
Nikhil Badola | db2be4e | 2015-09-04 10:15:58 +0530 | [diff] [blame] | 285 | /* |
| 286 | * dwc3_frame_length_adjustment - Adjusts frame length if required |
| 287 | * @dwc3: Pointer to our controller context structure |
Nikhil Badola | db2be4e | 2015-09-04 10:15:58 +0530 | [diff] [blame] | 288 | */ |
Felipe Balbi | bcdb327 | 2016-05-16 10:42:23 +0300 | [diff] [blame] | 289 | static void dwc3_frame_length_adjustment(struct dwc3 *dwc) |
Nikhil Badola | db2be4e | 2015-09-04 10:15:58 +0530 | [diff] [blame] | 290 | { |
| 291 | u32 reg; |
| 292 | u32 dft; |
| 293 | |
| 294 | if (dwc->revision < DWC3_REVISION_250A) |
| 295 | return; |
| 296 | |
Felipe Balbi | bcdb327 | 2016-05-16 10:42:23 +0300 | [diff] [blame] | 297 | if (dwc->fladj == 0) |
Nikhil Badola | db2be4e | 2015-09-04 10:15:58 +0530 | [diff] [blame] | 298 | return; |
| 299 | |
| 300 | reg = dwc3_readl(dwc->regs, DWC3_GFLADJ); |
| 301 | dft = reg & DWC3_GFLADJ_30MHZ_MASK; |
Felipe Balbi | bcdb327 | 2016-05-16 10:42:23 +0300 | [diff] [blame] | 302 | if (!dev_WARN_ONCE(dwc->dev, dft == dwc->fladj, |
Nikhil Badola | db2be4e | 2015-09-04 10:15:58 +0530 | [diff] [blame] | 303 | "request value same as default, ignoring\n")) { |
| 304 | reg &= ~DWC3_GFLADJ_30MHZ_MASK; |
Felipe Balbi | bcdb327 | 2016-05-16 10:42:23 +0300 | [diff] [blame] | 305 | reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | dwc->fladj; |
Nikhil Badola | db2be4e | 2015-09-04 10:15:58 +0530 | [diff] [blame] | 306 | dwc3_writel(dwc->regs, DWC3_GFLADJ, reg); |
| 307 | } |
| 308 | } |
| 309 | |
Heikki Krogerus | c5cc74e | 2015-05-13 15:26:47 +0300 | [diff] [blame] | 310 | /** |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 311 | * dwc3_free_one_event_buffer - Frees one event buffer |
| 312 | * @dwc: Pointer to our controller context structure |
| 313 | * @evt: Pointer to event buffer to be freed |
| 314 | */ |
| 315 | static void dwc3_free_one_event_buffer(struct dwc3 *dwc, |
| 316 | struct dwc3_event_buffer *evt) |
| 317 | { |
| 318 | dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | /** |
Paul Zimmerman | 1d04679 | 2012-02-15 18:56:56 -0800 | [diff] [blame] | 322 | * dwc3_alloc_one_event_buffer - Allocates one event buffer structure |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 323 | * @dwc: Pointer to our controller context structure |
| 324 | * @length: size of the event buffer |
| 325 | * |
Paul Zimmerman | 1d04679 | 2012-02-15 18:56:56 -0800 | [diff] [blame] | 326 | * Returns a pointer to the allocated event buffer structure on success |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 327 | * otherwise ERR_PTR(errno). |
| 328 | */ |
Felipe Balbi | 67d0b50 | 2013-02-22 16:31:07 +0200 | [diff] [blame] | 329 | static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, |
| 330 | unsigned length) |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 331 | { |
| 332 | struct dwc3_event_buffer *evt; |
| 333 | |
Felipe Balbi | 380f0d2 | 2012-10-11 13:48:36 +0300 | [diff] [blame] | 334 | evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 335 | if (!evt) |
| 336 | return ERR_PTR(-ENOMEM); |
| 337 | |
| 338 | evt->dwc = dwc; |
| 339 | evt->length = length; |
| 340 | evt->buf = dma_alloc_coherent(dwc->dev, length, |
| 341 | &evt->dma, GFP_KERNEL); |
Felipe Balbi | e32672f | 2012-11-08 15:26:41 +0200 | [diff] [blame] | 342 | if (!evt->buf) |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 343 | return ERR_PTR(-ENOMEM); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 344 | |
| 345 | return evt; |
| 346 | } |
| 347 | |
| 348 | /** |
| 349 | * dwc3_free_event_buffers - frees all allocated event buffers |
| 350 | * @dwc: Pointer to our controller context structure |
| 351 | */ |
| 352 | static void dwc3_free_event_buffers(struct dwc3 *dwc) |
| 353 | { |
| 354 | struct dwc3_event_buffer *evt; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 355 | |
Felipe Balbi | 696c8b1 | 2016-03-30 09:37:03 +0300 | [diff] [blame] | 356 | evt = dwc->ev_buf; |
Felipe Balbi | 660e9bd | 2016-03-30 09:26:24 +0300 | [diff] [blame] | 357 | if (evt) |
| 358 | dwc3_free_one_event_buffer(dwc, evt); |
Mayank Rana | f4918d3 | 2016-12-15 13:35:55 -0800 | [diff] [blame^] | 359 | |
| 360 | /* free GSI related event buffers */ |
| 361 | dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_FREE); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | /** |
| 365 | * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length |
Paul Zimmerman | 1d04679 | 2012-02-15 18:56:56 -0800 | [diff] [blame] | 366 | * @dwc: pointer to our controller context structure |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 367 | * @length: size of event buffer |
| 368 | * |
Paul Zimmerman | 1d04679 | 2012-02-15 18:56:56 -0800 | [diff] [blame] | 369 | * Returns 0 on success otherwise negative errno. In the error case, dwc |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 370 | * may contain some buffers allocated but not all which were requested. |
| 371 | */ |
Bill Pemberton | 41ac7b3 | 2012-11-19 13:21:48 -0500 | [diff] [blame] | 372 | static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 373 | { |
Felipe Balbi | 660e9bd | 2016-03-30 09:26:24 +0300 | [diff] [blame] | 374 | struct dwc3_event_buffer *evt; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 375 | |
Felipe Balbi | 660e9bd | 2016-03-30 09:26:24 +0300 | [diff] [blame] | 376 | evt = dwc3_alloc_one_event_buffer(dwc, length); |
| 377 | if (IS_ERR(evt)) { |
| 378 | dev_err(dwc->dev, "can't allocate event buffer\n"); |
| 379 | return PTR_ERR(evt); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 380 | } |
Felipe Balbi | 696c8b1 | 2016-03-30 09:37:03 +0300 | [diff] [blame] | 381 | dwc->ev_buf = evt; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 382 | |
Mayank Rana | f4918d3 | 2016-12-15 13:35:55 -0800 | [diff] [blame^] | 383 | /* alloc GSI related event buffers */ |
| 384 | dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_ALLOC); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 385 | return 0; |
| 386 | } |
| 387 | |
| 388 | /** |
| 389 | * dwc3_event_buffers_setup - setup our allocated event buffers |
Paul Zimmerman | 1d04679 | 2012-02-15 18:56:56 -0800 | [diff] [blame] | 390 | * @dwc: pointer to our controller context structure |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 391 | * |
| 392 | * Returns 0 on success otherwise negative errno. |
| 393 | */ |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 394 | int dwc3_event_buffers_setup(struct dwc3 *dwc) |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 395 | { |
| 396 | struct dwc3_event_buffer *evt; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 397 | |
Felipe Balbi | 696c8b1 | 2016-03-30 09:37:03 +0300 | [diff] [blame] | 398 | evt = dwc->ev_buf; |
Felipe Balbi | 660e9bd | 2016-03-30 09:26:24 +0300 | [diff] [blame] | 399 | dwc3_trace(trace_dwc3_core, |
| 400 | "Event buf %p dma %08llx length %d\n", |
| 401 | evt->buf, (unsigned long long) evt->dma, |
| 402 | evt->length); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 403 | |
Felipe Balbi | 660e9bd | 2016-03-30 09:26:24 +0300 | [diff] [blame] | 404 | evt->lpos = 0; |
Paul Zimmerman | 7acd85e | 2012-04-27 14:28:02 +0300 | [diff] [blame] | 405 | |
Felipe Balbi | 660e9bd | 2016-03-30 09:26:24 +0300 | [diff] [blame] | 406 | dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0), |
| 407 | lower_32_bits(evt->dma)); |
| 408 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), |
| 409 | upper_32_bits(evt->dma)); |
| 410 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), |
| 411 | DWC3_GEVNTSIZ_SIZE(evt->length)); |
| 412 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 413 | |
Mayank Rana | f4918d3 | 2016-12-15 13:35:55 -0800 | [diff] [blame^] | 414 | /* setup GSI related event buffers */ |
| 415 | dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_SETUP); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 416 | return 0; |
| 417 | } |
| 418 | |
| 419 | static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) |
| 420 | { |
| 421 | struct dwc3_event_buffer *evt; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 422 | |
Felipe Balbi | 696c8b1 | 2016-03-30 09:37:03 +0300 | [diff] [blame] | 423 | evt = dwc->ev_buf; |
Paul Zimmerman | 7acd85e | 2012-04-27 14:28:02 +0300 | [diff] [blame] | 424 | |
Felipe Balbi | 660e9bd | 2016-03-30 09:26:24 +0300 | [diff] [blame] | 425 | evt->lpos = 0; |
Paul Zimmerman | 7acd85e | 2012-04-27 14:28:02 +0300 | [diff] [blame] | 426 | |
Felipe Balbi | 660e9bd | 2016-03-30 09:26:24 +0300 | [diff] [blame] | 427 | dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0), 0); |
| 428 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), 0); |
| 429 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), DWC3_GEVNTSIZ_INTMASK |
| 430 | | DWC3_GEVNTSIZ_SIZE(0)); |
| 431 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); |
Mayank Rana | f4918d3 | 2016-12-15 13:35:55 -0800 | [diff] [blame^] | 432 | |
| 433 | /* cleanup GSI related event buffers */ |
| 434 | dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_CLEANUP); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 435 | } |
| 436 | |
Felipe Balbi | 0ffcaf3 | 2013-12-19 13:04:28 -0600 | [diff] [blame] | 437 | static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc) |
| 438 | { |
| 439 | if (!dwc->has_hibernation) |
| 440 | return 0; |
| 441 | |
| 442 | if (!dwc->nr_scratch) |
| 443 | return 0; |
| 444 | |
| 445 | dwc->scratchbuf = kmalloc_array(dwc->nr_scratch, |
| 446 | DWC3_SCRATCHBUF_SIZE, GFP_KERNEL); |
| 447 | if (!dwc->scratchbuf) |
| 448 | return -ENOMEM; |
| 449 | |
| 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | static int dwc3_setup_scratch_buffers(struct dwc3 *dwc) |
| 454 | { |
| 455 | dma_addr_t scratch_addr; |
| 456 | u32 param; |
| 457 | int ret; |
| 458 | |
| 459 | if (!dwc->has_hibernation) |
| 460 | return 0; |
| 461 | |
| 462 | if (!dwc->nr_scratch) |
| 463 | return 0; |
| 464 | |
| 465 | /* should never fall here */ |
| 466 | if (!WARN_ON(dwc->scratchbuf)) |
| 467 | return 0; |
| 468 | |
| 469 | scratch_addr = dma_map_single(dwc->dev, dwc->scratchbuf, |
| 470 | dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE, |
| 471 | DMA_BIDIRECTIONAL); |
| 472 | if (dma_mapping_error(dwc->dev, scratch_addr)) { |
| 473 | dev_err(dwc->dev, "failed to map scratch buffer\n"); |
| 474 | ret = -EFAULT; |
| 475 | goto err0; |
| 476 | } |
| 477 | |
| 478 | dwc->scratch_addr = scratch_addr; |
| 479 | |
| 480 | param = lower_32_bits(scratch_addr); |
| 481 | |
| 482 | ret = dwc3_send_gadget_generic_command(dwc, |
| 483 | DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO, param); |
| 484 | if (ret < 0) |
| 485 | goto err1; |
| 486 | |
| 487 | param = upper_32_bits(scratch_addr); |
| 488 | |
| 489 | ret = dwc3_send_gadget_generic_command(dwc, |
| 490 | DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI, param); |
| 491 | if (ret < 0) |
| 492 | goto err1; |
| 493 | |
| 494 | return 0; |
| 495 | |
| 496 | err1: |
| 497 | dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch * |
| 498 | DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL); |
| 499 | |
| 500 | err0: |
| 501 | return ret; |
| 502 | } |
| 503 | |
| 504 | static void dwc3_free_scratch_buffers(struct dwc3 *dwc) |
| 505 | { |
| 506 | if (!dwc->has_hibernation) |
| 507 | return; |
| 508 | |
| 509 | if (!dwc->nr_scratch) |
| 510 | return; |
| 511 | |
| 512 | /* should never fall here */ |
| 513 | if (!WARN_ON(dwc->scratchbuf)) |
| 514 | return; |
| 515 | |
| 516 | dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch * |
| 517 | DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL); |
| 518 | kfree(dwc->scratchbuf); |
| 519 | } |
| 520 | |
Felipe Balbi | 789451f6 | 2011-05-05 15:53:10 +0300 | [diff] [blame] | 521 | static void dwc3_core_num_eps(struct dwc3 *dwc) |
| 522 | { |
| 523 | struct dwc3_hwparams *parms = &dwc->hwparams; |
| 524 | |
| 525 | dwc->num_in_eps = DWC3_NUM_IN_EPS(parms); |
| 526 | dwc->num_out_eps = DWC3_NUM_EPS(parms) - dwc->num_in_eps; |
| 527 | |
Felipe Balbi | 7381528 | 2015-01-27 13:48:14 -0600 | [diff] [blame] | 528 | dwc3_trace(trace_dwc3_core, "found %d IN and %d OUT endpoints", |
Felipe Balbi | 789451f6 | 2011-05-05 15:53:10 +0300 | [diff] [blame] | 529 | dwc->num_in_eps, dwc->num_out_eps); |
| 530 | } |
| 531 | |
Bill Pemberton | 41ac7b3 | 2012-11-19 13:21:48 -0500 | [diff] [blame] | 532 | static void dwc3_cache_hwparams(struct dwc3 *dwc) |
Felipe Balbi | 26ceca9 | 2011-09-30 10:58:49 +0300 | [diff] [blame] | 533 | { |
| 534 | struct dwc3_hwparams *parms = &dwc->hwparams; |
| 535 | |
| 536 | parms->hwparams0 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS0); |
| 537 | parms->hwparams1 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS1); |
| 538 | parms->hwparams2 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS2); |
| 539 | parms->hwparams3 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS3); |
| 540 | parms->hwparams4 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS4); |
| 541 | parms->hwparams5 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS5); |
| 542 | parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6); |
| 543 | parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7); |
| 544 | parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8); |
| 545 | } |
| 546 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 547 | /** |
Huang Rui | b5a65c4 | 2014-10-28 19:54:28 +0800 | [diff] [blame] | 548 | * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core |
| 549 | * @dwc: Pointer to our controller context structure |
Heikki Krogerus | 88bc9d1 | 2015-05-13 15:26:51 +0300 | [diff] [blame] | 550 | * |
| 551 | * Returns 0 on success. The USB PHY interfaces are configured but not |
| 552 | * initialized. The PHY interfaces and the PHYs get initialized together with |
| 553 | * the core in dwc3_core_init. |
Huang Rui | b5a65c4 | 2014-10-28 19:54:28 +0800 | [diff] [blame] | 554 | */ |
Heikki Krogerus | 88bc9d1 | 2015-05-13 15:26:51 +0300 | [diff] [blame] | 555 | static int dwc3_phy_setup(struct dwc3 *dwc) |
Huang Rui | b5a65c4 | 2014-10-28 19:54:28 +0800 | [diff] [blame] | 556 | { |
| 557 | u32 reg; |
Heikki Krogerus | 88bc9d1 | 2015-05-13 15:26:51 +0300 | [diff] [blame] | 558 | int ret; |
Huang Rui | b5a65c4 | 2014-10-28 19:54:28 +0800 | [diff] [blame] | 559 | |
| 560 | reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); |
| 561 | |
Huang Rui | 2164a47 | 2014-10-28 19:54:35 +0800 | [diff] [blame] | 562 | /* |
| 563 | * Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY |
| 564 | * to '0' during coreConsultant configuration. So default value |
| 565 | * will be '0' when the core is reset. Application needs to set it |
| 566 | * to '1' after the core initialization is completed. |
| 567 | */ |
| 568 | if (dwc->revision > DWC3_REVISION_194A) |
| 569 | reg |= DWC3_GUSB3PIPECTL_SUSPHY; |
| 570 | |
Huang Rui | b5a65c4 | 2014-10-28 19:54:28 +0800 | [diff] [blame] | 571 | if (dwc->u2ss_inp3_quirk) |
| 572 | reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK; |
| 573 | |
Rajesh Bhagat | e58dd35 | 2016-03-14 14:40:50 +0530 | [diff] [blame] | 574 | if (dwc->dis_rxdet_inp3_quirk) |
| 575 | reg |= DWC3_GUSB3PIPECTL_DISRXDETINP3; |
| 576 | |
Huang Rui | df31f5b | 2014-10-28 19:54:29 +0800 | [diff] [blame] | 577 | if (dwc->req_p1p2p3_quirk) |
| 578 | reg |= DWC3_GUSB3PIPECTL_REQP1P2P3; |
| 579 | |
Huang Rui | a2a1d0f | 2014-10-28 19:54:30 +0800 | [diff] [blame] | 580 | if (dwc->del_p1p2p3_quirk) |
| 581 | reg |= DWC3_GUSB3PIPECTL_DEP1P2P3_EN; |
| 582 | |
Huang Rui | 41c06ff | 2014-10-28 19:54:31 +0800 | [diff] [blame] | 583 | if (dwc->del_phy_power_chg_quirk) |
| 584 | reg |= DWC3_GUSB3PIPECTL_DEPOCHANGE; |
| 585 | |
Huang Rui | fb67afc | 2014-10-28 19:54:32 +0800 | [diff] [blame] | 586 | if (dwc->lfps_filter_quirk) |
| 587 | reg |= DWC3_GUSB3PIPECTL_LFPSFILT; |
| 588 | |
Huang Rui | 14f4ac5 | 2014-10-28 19:54:33 +0800 | [diff] [blame] | 589 | if (dwc->rx_detect_poll_quirk) |
| 590 | reg |= DWC3_GUSB3PIPECTL_RX_DETOPOLL; |
| 591 | |
Huang Rui | 6b6a0c9 | 2014-10-31 11:11:12 +0800 | [diff] [blame] | 592 | if (dwc->tx_de_emphasis_quirk) |
| 593 | reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis); |
| 594 | |
Felipe Balbi | cd72f89 | 2014-11-06 11:31:00 -0600 | [diff] [blame] | 595 | if (dwc->dis_u3_susphy_quirk) |
Huang Rui | 59acfa2 | 2014-10-31 11:11:13 +0800 | [diff] [blame] | 596 | reg &= ~DWC3_GUSB3PIPECTL_SUSPHY; |
| 597 | |
William Wu | 00fe081 | 2016-08-16 22:44:39 +0800 | [diff] [blame] | 598 | if (dwc->dis_del_phy_power_chg_quirk) |
| 599 | reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE; |
| 600 | |
Huang Rui | b5a65c4 | 2014-10-28 19:54:28 +0800 | [diff] [blame] | 601 | dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); |
| 602 | |
Huang Rui | 2164a47 | 2014-10-28 19:54:35 +0800 | [diff] [blame] | 603 | reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); |
| 604 | |
Heikki Krogerus | 3e10a2c | 2015-05-13 15:26:49 +0300 | [diff] [blame] | 605 | /* Select the HS PHY interface */ |
| 606 | switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) { |
| 607 | case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI: |
Felipe Balbi | 43cacb0 | 2015-07-01 22:03:09 -0500 | [diff] [blame] | 608 | if (dwc->hsphy_interface && |
| 609 | !strncmp(dwc->hsphy_interface, "utmi", 4)) { |
Heikki Krogerus | 3e10a2c | 2015-05-13 15:26:49 +0300 | [diff] [blame] | 610 | reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI; |
Heikki Krogerus | 88bc9d1 | 2015-05-13 15:26:51 +0300 | [diff] [blame] | 611 | break; |
Felipe Balbi | 43cacb0 | 2015-07-01 22:03:09 -0500 | [diff] [blame] | 612 | } else if (dwc->hsphy_interface && |
| 613 | !strncmp(dwc->hsphy_interface, "ulpi", 4)) { |
Heikki Krogerus | 3e10a2c | 2015-05-13 15:26:49 +0300 | [diff] [blame] | 614 | reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI; |
Heikki Krogerus | 88bc9d1 | 2015-05-13 15:26:51 +0300 | [diff] [blame] | 615 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); |
Heikki Krogerus | 3e10a2c | 2015-05-13 15:26:49 +0300 | [diff] [blame] | 616 | } else { |
Heikki Krogerus | 88bc9d1 | 2015-05-13 15:26:51 +0300 | [diff] [blame] | 617 | /* Relying on default value. */ |
| 618 | if (!(reg & DWC3_GUSB2PHYCFG_ULPI_UTMI)) |
| 619 | break; |
Heikki Krogerus | 3e10a2c | 2015-05-13 15:26:49 +0300 | [diff] [blame] | 620 | } |
| 621 | /* FALLTHROUGH */ |
Heikki Krogerus | 88bc9d1 | 2015-05-13 15:26:51 +0300 | [diff] [blame] | 622 | case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI: |
| 623 | /* Making sure the interface and PHY are operational */ |
| 624 | ret = dwc3_soft_reset(dwc); |
| 625 | if (ret) |
| 626 | return ret; |
| 627 | |
| 628 | udelay(1); |
| 629 | |
| 630 | ret = dwc3_ulpi_init(dwc); |
| 631 | if (ret) |
| 632 | return ret; |
| 633 | /* FALLTHROUGH */ |
Heikki Krogerus | 3e10a2c | 2015-05-13 15:26:49 +0300 | [diff] [blame] | 634 | default: |
| 635 | break; |
| 636 | } |
| 637 | |
William Wu | 32f2ed8 | 2016-08-16 22:44:38 +0800 | [diff] [blame] | 638 | switch (dwc->hsphy_mode) { |
| 639 | case USBPHY_INTERFACE_MODE_UTMI: |
| 640 | reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK | |
| 641 | DWC3_GUSB2PHYCFG_USBTRDTIM_MASK); |
| 642 | reg |= DWC3_GUSB2PHYCFG_PHYIF(UTMI_PHYIF_8_BIT) | |
| 643 | DWC3_GUSB2PHYCFG_USBTRDTIM(USBTRDTIM_UTMI_8_BIT); |
| 644 | break; |
| 645 | case USBPHY_INTERFACE_MODE_UTMIW: |
| 646 | reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK | |
| 647 | DWC3_GUSB2PHYCFG_USBTRDTIM_MASK); |
| 648 | reg |= DWC3_GUSB2PHYCFG_PHYIF(UTMI_PHYIF_16_BIT) | |
| 649 | DWC3_GUSB2PHYCFG_USBTRDTIM(USBTRDTIM_UTMI_16_BIT); |
| 650 | break; |
| 651 | default: |
| 652 | break; |
| 653 | } |
| 654 | |
Huang Rui | 2164a47 | 2014-10-28 19:54:35 +0800 | [diff] [blame] | 655 | /* |
| 656 | * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to |
| 657 | * '0' during coreConsultant configuration. So default value will |
| 658 | * be '0' when the core is reset. Application needs to set it to |
| 659 | * '1' after the core initialization is completed. |
| 660 | */ |
| 661 | if (dwc->revision > DWC3_REVISION_194A) |
| 662 | reg |= DWC3_GUSB2PHYCFG_SUSPHY; |
| 663 | |
Felipe Balbi | cd72f89 | 2014-11-06 11:31:00 -0600 | [diff] [blame] | 664 | if (dwc->dis_u2_susphy_quirk) |
Huang Rui | 0effe0a | 2014-10-31 11:11:14 +0800 | [diff] [blame] | 665 | reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; |
| 666 | |
John Youn | ec791d1 | 2015-10-02 20:30:57 -0700 | [diff] [blame] | 667 | if (dwc->dis_enblslpm_quirk) |
| 668 | reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM; |
| 669 | |
William Wu | 16199f3 | 2016-08-16 22:44:37 +0800 | [diff] [blame] | 670 | if (dwc->dis_u2_freeclk_exists_quirk) |
| 671 | reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS; |
| 672 | |
Huang Rui | 2164a47 | 2014-10-28 19:54:35 +0800 | [diff] [blame] | 673 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); |
Heikki Krogerus | 88bc9d1 | 2015-05-13 15:26:51 +0300 | [diff] [blame] | 674 | |
| 675 | return 0; |
Huang Rui | b5a65c4 | 2014-10-28 19:54:28 +0800 | [diff] [blame] | 676 | } |
| 677 | |
Felipe Balbi | c499ff7 | 2016-05-16 10:49:01 +0300 | [diff] [blame] | 678 | static void dwc3_core_exit(struct dwc3 *dwc) |
| 679 | { |
| 680 | dwc3_event_buffers_cleanup(dwc); |
| 681 | |
| 682 | usb_phy_shutdown(dwc->usb2_phy); |
| 683 | usb_phy_shutdown(dwc->usb3_phy); |
| 684 | phy_exit(dwc->usb2_generic_phy); |
| 685 | phy_exit(dwc->usb3_generic_phy); |
| 686 | |
| 687 | usb_phy_set_suspend(dwc->usb2_phy, 1); |
| 688 | usb_phy_set_suspend(dwc->usb3_phy, 1); |
| 689 | phy_power_off(dwc->usb2_generic_phy); |
| 690 | phy_power_off(dwc->usb3_generic_phy); |
| 691 | } |
| 692 | |
Huang Rui | b5a65c4 | 2014-10-28 19:54:28 +0800 | [diff] [blame] | 693 | /** |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 694 | * dwc3_core_init - Low-level initialization of DWC3 Core |
| 695 | * @dwc: Pointer to our controller context structure |
| 696 | * |
| 697 | * Returns 0 on success otherwise negative errno. |
| 698 | */ |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 699 | int dwc3_core_init(struct dwc3 *dwc) |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 700 | { |
Felipe Balbi | 0ffcaf3 | 2013-12-19 13:04:28 -0600 | [diff] [blame] | 701 | u32 hwparams4 = dwc->hwparams.hwparams4; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 702 | u32 reg; |
| 703 | int ret; |
| 704 | |
Sebastian Andrzej Siewior | 7650bd7 | 2011-08-29 13:56:36 +0200 | [diff] [blame] | 705 | reg = dwc3_readl(dwc->regs, DWC3_GSNPSID); |
| 706 | /* This should read as U3 followed by revision number */ |
John Youn | 690fb37 | 2015-09-04 19:15:10 -0700 | [diff] [blame] | 707 | if ((reg & DWC3_GSNPSID_MASK) == 0x55330000) { |
| 708 | /* Detected DWC_usb3 IP */ |
| 709 | dwc->revision = reg; |
| 710 | } else if ((reg & DWC3_GSNPSID_MASK) == 0x33310000) { |
| 711 | /* Detected DWC_usb31 IP */ |
| 712 | dwc->revision = dwc3_readl(dwc->regs, DWC3_VER_NUMBER); |
| 713 | dwc->revision |= DWC3_REVISION_IS_DWC31; |
| 714 | } else { |
Sebastian Andrzej Siewior | 7650bd7 | 2011-08-29 13:56:36 +0200 | [diff] [blame] | 715 | dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n"); |
| 716 | ret = -ENODEV; |
| 717 | goto err0; |
| 718 | } |
Sebastian Andrzej Siewior | 7650bd7 | 2011-08-29 13:56:36 +0200 | [diff] [blame] | 719 | |
Felipe Balbi | fa0ea13 | 2014-09-19 15:51:11 -0500 | [diff] [blame] | 720 | /* |
| 721 | * Write Linux Version Code to our GUID register so it's easy to figure |
| 722 | * out which kernel version a bug was found. |
| 723 | */ |
| 724 | dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE); |
| 725 | |
Paul Zimmerman | 0e1e5c4 | 2014-05-23 11:39:24 -0700 | [diff] [blame] | 726 | /* Handle USB2.0-only core configuration */ |
| 727 | if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) == |
| 728 | DWC3_GHWPARAMS3_SSPHY_IFC_DIS) { |
| 729 | if (dwc->maximum_speed == USB_SPEED_SUPER) |
| 730 | dwc->maximum_speed = USB_SPEED_HIGH; |
| 731 | } |
| 732 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 733 | /* issue device SoftReset too */ |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 734 | ret = dwc3_core_reset(dwc); |
Heikki Krogerus | c5cc74e | 2015-05-13 15:26:47 +0300 | [diff] [blame] | 735 | if (ret) |
| 736 | goto err0; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 737 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 738 | /* issue device SoftReset too */ |
| 739 | ret = dwc3_soft_reset(dwc); |
Kishon Vijay Abraham I | 5730348 | 2014-03-03 17:08:11 +0530 | [diff] [blame] | 740 | if (ret) |
| 741 | goto err0; |
Pratyush Anand | 58a0f23 | 2012-06-21 17:44:29 +0530 | [diff] [blame] | 742 | |
Felipe Balbi | c499ff7 | 2016-05-16 10:49:01 +0300 | [diff] [blame] | 743 | ret = dwc3_phy_setup(dwc); |
| 744 | if (ret) |
| 745 | goto err0; |
| 746 | |
Sebastian Andrzej Siewior | 4878a02 | 2011-10-31 22:25:41 +0100 | [diff] [blame] | 747 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); |
Paul Zimmerman | 3e87c42 | 2012-02-24 17:32:13 -0800 | [diff] [blame] | 748 | reg &= ~DWC3_GCTL_SCALEDOWN_MASK; |
Sebastian Andrzej Siewior | 4878a02 | 2011-10-31 22:25:41 +0100 | [diff] [blame] | 749 | |
Sebastian Andrzej Siewior | 164d773 | 2011-11-24 11:22:05 +0100 | [diff] [blame] | 750 | switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) { |
Sebastian Andrzej Siewior | 4878a02 | 2011-10-31 22:25:41 +0100 | [diff] [blame] | 751 | case DWC3_GHWPARAMS1_EN_PWROPT_CLK: |
Felipe Balbi | 32a4a13 | 2014-02-25 14:00:13 -0600 | [diff] [blame] | 752 | /** |
| 753 | * WORKAROUND: DWC3 revisions between 2.10a and 2.50a have an |
| 754 | * issue which would cause xHCI compliance tests to fail. |
| 755 | * |
| 756 | * Because of that we cannot enable clock gating on such |
| 757 | * configurations. |
| 758 | * |
| 759 | * Refers to: |
| 760 | * |
| 761 | * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based |
| 762 | * SOF/ITP Mode Used |
| 763 | */ |
| 764 | if ((dwc->dr_mode == USB_DR_MODE_HOST || |
| 765 | dwc->dr_mode == USB_DR_MODE_OTG) && |
| 766 | (dwc->revision >= DWC3_REVISION_210A && |
| 767 | dwc->revision <= DWC3_REVISION_250A)) |
| 768 | reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC; |
| 769 | else |
| 770 | reg &= ~DWC3_GCTL_DSBLCLKGTNG; |
Sebastian Andrzej Siewior | 4878a02 | 2011-10-31 22:25:41 +0100 | [diff] [blame] | 771 | break; |
Felipe Balbi | 0ffcaf3 | 2013-12-19 13:04:28 -0600 | [diff] [blame] | 772 | case DWC3_GHWPARAMS1_EN_PWROPT_HIB: |
| 773 | /* enable hibernation here */ |
| 774 | dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4); |
Huang Rui | 2eac399 | 2014-10-28 19:54:22 +0800 | [diff] [blame] | 775 | |
| 776 | /* |
| 777 | * REVISIT Enabling this bit so that host-mode hibernation |
| 778 | * will work. Device-mode hibernation is not yet implemented. |
| 779 | */ |
| 780 | reg |= DWC3_GCTL_GBLHIBERNATIONEN; |
Felipe Balbi | 0ffcaf3 | 2013-12-19 13:04:28 -0600 | [diff] [blame] | 781 | break; |
Sebastian Andrzej Siewior | 4878a02 | 2011-10-31 22:25:41 +0100 | [diff] [blame] | 782 | default: |
Felipe Balbi | 1407bf1 | 2015-11-16 16:06:37 -0600 | [diff] [blame] | 783 | dwc3_trace(trace_dwc3_core, "No power optimization available\n"); |
Sebastian Andrzej Siewior | 4878a02 | 2011-10-31 22:25:41 +0100 | [diff] [blame] | 784 | } |
| 785 | |
Huang Rui | 946bd57 | 2014-10-28 19:54:23 +0800 | [diff] [blame] | 786 | /* check if current dwc3 is on simulation board */ |
| 787 | if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) { |
Felipe Balbi | 1407bf1 | 2015-11-16 16:06:37 -0600 | [diff] [blame] | 788 | dwc3_trace(trace_dwc3_core, |
| 789 | "running on FPGA platform\n"); |
Huang Rui | 946bd57 | 2014-10-28 19:54:23 +0800 | [diff] [blame] | 790 | dwc->is_fpga = true; |
| 791 | } |
| 792 | |
Huang Rui | 3b81221 | 2014-10-28 19:54:25 +0800 | [diff] [blame] | 793 | WARN_ONCE(dwc->disable_scramble_quirk && !dwc->is_fpga, |
| 794 | "disable_scramble cannot be used on non-FPGA builds\n"); |
| 795 | |
| 796 | if (dwc->disable_scramble_quirk && dwc->is_fpga) |
| 797 | reg |= DWC3_GCTL_DISSCRAMBLE; |
| 798 | else |
| 799 | reg &= ~DWC3_GCTL_DISSCRAMBLE; |
| 800 | |
Huang Rui | 9a5b2f3 | 2014-10-28 19:54:27 +0800 | [diff] [blame] | 801 | if (dwc->u2exit_lfps_quirk) |
| 802 | reg |= DWC3_GCTL_U2EXIT_LFPS; |
| 803 | |
Sebastian Andrzej Siewior | 4878a02 | 2011-10-31 22:25:41 +0100 | [diff] [blame] | 804 | /* |
| 805 | * WORKAROUND: DWC3 revisions <1.90a have a bug |
Paul Zimmerman | 1d04679 | 2012-02-15 18:56:56 -0800 | [diff] [blame] | 806 | * where the device can fail to connect at SuperSpeed |
Sebastian Andrzej Siewior | 4878a02 | 2011-10-31 22:25:41 +0100 | [diff] [blame] | 807 | * and falls back to high-speed mode which causes |
Paul Zimmerman | 1d04679 | 2012-02-15 18:56:56 -0800 | [diff] [blame] | 808 | * the device to enter a Connect/Disconnect loop |
Sebastian Andrzej Siewior | 4878a02 | 2011-10-31 22:25:41 +0100 | [diff] [blame] | 809 | */ |
| 810 | if (dwc->revision < DWC3_REVISION_190A) |
| 811 | reg |= DWC3_GCTL_U2RSTECN; |
| 812 | |
Mayank Rana | fb9cd93 | 2016-11-03 23:26:38 -0700 | [diff] [blame] | 813 | ret = dwc3_get_dr_mode(dwc); |
| 814 | if (ret) |
| 815 | goto err0; |
| 816 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 817 | dwc3_core_num_eps(dwc); |
| 818 | |
| 819 | /* |
| 820 | * Disable clock gating to work around a known HW bug that causes the |
| 821 | * internal RAM clock to get stuck when entering low power modes. |
| 822 | */ |
| 823 | if (dwc->disable_clk_gating) { |
| 824 | dev_dbg(dwc->dev, "Disabling controller clock gating.\n"); |
| 825 | reg |= DWC3_GCTL_DSBLCLKGTNG; |
| 826 | } |
| 827 | |
Sebastian Andrzej Siewior | 4878a02 | 2011-10-31 22:25:41 +0100 | [diff] [blame] | 828 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
| 829 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 830 | ret = dwc3_alloc_scratch_buffers(dwc); |
| 831 | if (ret) |
| 832 | goto err1; |
Felipe Balbi | 0ffcaf3 | 2013-12-19 13:04:28 -0600 | [diff] [blame] | 833 | |
| 834 | ret = dwc3_setup_scratch_buffers(dwc); |
| 835 | if (ret) |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 836 | goto err2; |
Felipe Balbi | c499ff7 | 2016-05-16 10:49:01 +0300 | [diff] [blame] | 837 | |
| 838 | /* Adjust Frame Length */ |
| 839 | dwc3_frame_length_adjustment(dwc); |
| 840 | |
| 841 | usb_phy_set_suspend(dwc->usb2_phy, 0); |
| 842 | usb_phy_set_suspend(dwc->usb3_phy, 0); |
| 843 | ret = phy_power_on(dwc->usb2_generic_phy); |
| 844 | if (ret < 0) |
Felipe Balbi | 0ffcaf3 | 2013-12-19 13:04:28 -0600 | [diff] [blame] | 845 | goto err2; |
| 846 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 847 | /* |
| 848 | * clear Elastic buffer mode in GUSBPIPE_CTRL(0) register, otherwise |
| 849 | * it results in high link errors and could cause SS mode transfer |
| 850 | * failure. |
| 851 | */ |
| 852 | if (!dwc->nominal_elastic_buffer) { |
| 853 | reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); |
| 854 | reg &= ~DWC3_GUSB3PIPECTL_ELASTIC_BUF_MODE; |
| 855 | dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); |
Felipe Balbi | c499ff7 | 2016-05-16 10:49:01 +0300 | [diff] [blame] | 856 | } |
| 857 | |
Baolin Wang | 00af623 | 2016-07-15 17:13:27 +0800 | [diff] [blame] | 858 | switch (dwc->dr_mode) { |
| 859 | case USB_DR_MODE_PERIPHERAL: |
| 860 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); |
| 861 | break; |
| 862 | case USB_DR_MODE_HOST: |
| 863 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); |
| 864 | break; |
| 865 | case USB_DR_MODE_OTG: |
| 866 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); |
| 867 | break; |
| 868 | default: |
| 869 | dev_warn(dwc->dev, "Unsupported mode %d\n", dwc->dr_mode); |
| 870 | break; |
| 871 | } |
| 872 | |
John Youn | 06281d4 | 2016-08-22 15:39:13 -0700 | [diff] [blame] | 873 | /* |
| 874 | * ENDXFER polling is available on version 3.10a and later of |
| 875 | * the DWC_usb3 controller. It is NOT available in the |
| 876 | * DWC_usb31 controller. |
| 877 | */ |
| 878 | if (!dwc3_is_usb31(dwc) && dwc->revision >= DWC3_REVISION_310A) { |
| 879 | reg = dwc3_readl(dwc->regs, DWC3_GUCTL2); |
| 880 | reg |= DWC3_GUCTL2_RST_ACTBITLATER; |
| 881 | dwc3_writel(dwc->regs, DWC3_GUCTL2, reg); |
| 882 | } |
| 883 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 884 | return 0; |
| 885 | |
Felipe Balbi | 0ffcaf3 | 2013-12-19 13:04:28 -0600 | [diff] [blame] | 886 | err2: |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 887 | dwc3_free_scratch_buffers(dwc); |
Felipe Balbi | 0ffcaf3 | 2013-12-19 13:04:28 -0600 | [diff] [blame] | 888 | err1: |
| 889 | usb_phy_shutdown(dwc->usb2_phy); |
| 890 | usb_phy_shutdown(dwc->usb3_phy); |
Kishon Vijay Abraham I | 5730348 | 2014-03-03 17:08:11 +0530 | [diff] [blame] | 891 | phy_exit(dwc->usb2_generic_phy); |
| 892 | phy_exit(dwc->usb3_generic_phy); |
Felipe Balbi | 0ffcaf3 | 2013-12-19 13:04:28 -0600 | [diff] [blame] | 893 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 894 | err0: |
| 895 | return ret; |
| 896 | } |
| 897 | |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 898 | static int dwc3_core_get_phy(struct dwc3 *dwc) |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 899 | { |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 900 | struct device *dev = dwc->dev; |
Felipe Balbi | 941ea36 | 2013-07-31 09:21:25 +0300 | [diff] [blame] | 901 | struct device_node *node = dev->of_node; |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 902 | int ret; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 903 | |
Kishon Vijay Abraham I | 5088b6f | 2013-01-25 16:36:53 +0530 | [diff] [blame] | 904 | if (node) { |
| 905 | dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); |
| 906 | dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1); |
Felipe Balbi | bb67490 | 2013-08-14 13:21:23 -0500 | [diff] [blame] | 907 | } else { |
| 908 | dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); |
| 909 | dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); |
Kishon Vijay Abraham I | 5088b6f | 2013-01-25 16:36:53 +0530 | [diff] [blame] | 910 | } |
| 911 | |
Felipe Balbi | d105e7f | 2013-03-15 10:52:08 +0200 | [diff] [blame] | 912 | if (IS_ERR(dwc->usb2_phy)) { |
| 913 | ret = PTR_ERR(dwc->usb2_phy); |
Kishon Vijay Abraham I | 122f06e | 2014-03-03 17:08:10 +0530 | [diff] [blame] | 914 | if (ret == -ENXIO || ret == -ENODEV) { |
| 915 | dwc->usb2_phy = NULL; |
| 916 | } else if (ret == -EPROBE_DEFER) { |
Felipe Balbi | d105e7f | 2013-03-15 10:52:08 +0200 | [diff] [blame] | 917 | return ret; |
Kishon Vijay Abraham I | 122f06e | 2014-03-03 17:08:10 +0530 | [diff] [blame] | 918 | } else { |
| 919 | dev_err(dev, "no usb2 phy configured\n"); |
| 920 | return ret; |
| 921 | } |
Felipe Balbi | 51e1e7b | 2012-07-19 14:09:48 +0300 | [diff] [blame] | 922 | } |
| 923 | |
Felipe Balbi | d105e7f | 2013-03-15 10:52:08 +0200 | [diff] [blame] | 924 | if (IS_ERR(dwc->usb3_phy)) { |
Ruchika Kharwar | 315955d7 | 2013-07-04 00:59:34 -0500 | [diff] [blame] | 925 | ret = PTR_ERR(dwc->usb3_phy); |
Kishon Vijay Abraham I | 122f06e | 2014-03-03 17:08:10 +0530 | [diff] [blame] | 926 | if (ret == -ENXIO || ret == -ENODEV) { |
| 927 | dwc->usb3_phy = NULL; |
| 928 | } else if (ret == -EPROBE_DEFER) { |
Felipe Balbi | d105e7f | 2013-03-15 10:52:08 +0200 | [diff] [blame] | 929 | return ret; |
Kishon Vijay Abraham I | 122f06e | 2014-03-03 17:08:10 +0530 | [diff] [blame] | 930 | } else { |
| 931 | dev_err(dev, "no usb3 phy configured\n"); |
| 932 | return ret; |
| 933 | } |
Felipe Balbi | 51e1e7b | 2012-07-19 14:09:48 +0300 | [diff] [blame] | 934 | } |
| 935 | |
Kishon Vijay Abraham I | 5730348 | 2014-03-03 17:08:11 +0530 | [diff] [blame] | 936 | dwc->usb2_generic_phy = devm_phy_get(dev, "usb2-phy"); |
| 937 | if (IS_ERR(dwc->usb2_generic_phy)) { |
| 938 | ret = PTR_ERR(dwc->usb2_generic_phy); |
| 939 | if (ret == -ENOSYS || ret == -ENODEV) { |
| 940 | dwc->usb2_generic_phy = NULL; |
| 941 | } else if (ret == -EPROBE_DEFER) { |
| 942 | return ret; |
| 943 | } else { |
| 944 | dev_err(dev, "no usb2 phy configured\n"); |
| 945 | return ret; |
| 946 | } |
| 947 | } |
| 948 | |
| 949 | dwc->usb3_generic_phy = devm_phy_get(dev, "usb3-phy"); |
| 950 | if (IS_ERR(dwc->usb3_generic_phy)) { |
| 951 | ret = PTR_ERR(dwc->usb3_generic_phy); |
| 952 | if (ret == -ENOSYS || ret == -ENODEV) { |
| 953 | dwc->usb3_generic_phy = NULL; |
| 954 | } else if (ret == -EPROBE_DEFER) { |
| 955 | return ret; |
| 956 | } else { |
| 957 | dev_err(dev, "no usb3 phy configured\n"); |
| 958 | return ret; |
| 959 | } |
| 960 | } |
| 961 | |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 962 | return 0; |
| 963 | } |
| 964 | |
Felipe Balbi | 5f94adf | 2014-04-16 15:13:45 -0500 | [diff] [blame] | 965 | static int dwc3_core_init_mode(struct dwc3 *dwc) |
| 966 | { |
| 967 | struct device *dev = dwc->dev; |
| 968 | int ret; |
| 969 | |
| 970 | switch (dwc->dr_mode) { |
| 971 | case USB_DR_MODE_PERIPHERAL: |
Felipe Balbi | 5f94adf | 2014-04-16 15:13:45 -0500 | [diff] [blame] | 972 | ret = dwc3_gadget_init(dwc); |
| 973 | if (ret) { |
Roger Quadros | 9522def | 2016-06-10 14:48:38 +0300 | [diff] [blame] | 974 | if (ret != -EPROBE_DEFER) |
| 975 | dev_err(dev, "failed to initialize gadget\n"); |
Felipe Balbi | 5f94adf | 2014-04-16 15:13:45 -0500 | [diff] [blame] | 976 | return ret; |
| 977 | } |
| 978 | break; |
| 979 | case USB_DR_MODE_HOST: |
Felipe Balbi | 5f94adf | 2014-04-16 15:13:45 -0500 | [diff] [blame] | 980 | ret = dwc3_host_init(dwc); |
| 981 | if (ret) { |
Roger Quadros | 9522def | 2016-06-10 14:48:38 +0300 | [diff] [blame] | 982 | if (ret != -EPROBE_DEFER) |
| 983 | dev_err(dev, "failed to initialize host\n"); |
Felipe Balbi | 5f94adf | 2014-04-16 15:13:45 -0500 | [diff] [blame] | 984 | return ret; |
| 985 | } |
| 986 | break; |
| 987 | case USB_DR_MODE_OTG: |
Felipe Balbi | 5f94adf | 2014-04-16 15:13:45 -0500 | [diff] [blame] | 988 | ret = dwc3_host_init(dwc); |
| 989 | if (ret) { |
Roger Quadros | 9522def | 2016-06-10 14:48:38 +0300 | [diff] [blame] | 990 | if (ret != -EPROBE_DEFER) |
| 991 | dev_err(dev, "failed to initialize host\n"); |
Felipe Balbi | 5f94adf | 2014-04-16 15:13:45 -0500 | [diff] [blame] | 992 | return ret; |
| 993 | } |
| 994 | |
| 995 | ret = dwc3_gadget_init(dwc); |
| 996 | if (ret) { |
Roger Quadros | 9522def | 2016-06-10 14:48:38 +0300 | [diff] [blame] | 997 | if (ret != -EPROBE_DEFER) |
| 998 | dev_err(dev, "failed to initialize gadget\n"); |
Felipe Balbi | 5f94adf | 2014-04-16 15:13:45 -0500 | [diff] [blame] | 999 | return ret; |
| 1000 | } |
| 1001 | break; |
| 1002 | default: |
| 1003 | dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode); |
| 1004 | return -EINVAL; |
| 1005 | } |
| 1006 | |
| 1007 | return 0; |
| 1008 | } |
| 1009 | |
| 1010 | static void dwc3_core_exit_mode(struct dwc3 *dwc) |
| 1011 | { |
| 1012 | switch (dwc->dr_mode) { |
| 1013 | case USB_DR_MODE_PERIPHERAL: |
| 1014 | dwc3_gadget_exit(dwc); |
| 1015 | break; |
| 1016 | case USB_DR_MODE_HOST: |
| 1017 | dwc3_host_exit(dwc); |
| 1018 | break; |
| 1019 | case USB_DR_MODE_OTG: |
| 1020 | dwc3_host_exit(dwc); |
| 1021 | dwc3_gadget_exit(dwc); |
| 1022 | break; |
| 1023 | default: |
| 1024 | /* do nothing */ |
| 1025 | break; |
| 1026 | } |
| 1027 | } |
| 1028 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1029 | /* XHCI reset, resets other CORE registers as well, re-init those */ |
| 1030 | void dwc3_post_host_reset_core_init(struct dwc3 *dwc) |
| 1031 | { |
| 1032 | dwc3_core_init(dwc); |
| 1033 | dwc3_gadget_restart(dwc); |
| 1034 | } |
| 1035 | |
| 1036 | static void (*notify_event)(struct dwc3 *, unsigned int); |
| 1037 | void dwc3_set_notifier(void (*notify)(struct dwc3 *, unsigned int)) |
| 1038 | { |
| 1039 | notify_event = notify; |
| 1040 | } |
| 1041 | EXPORT_SYMBOL(dwc3_set_notifier); |
| 1042 | |
| 1043 | int dwc3_notify_event(struct dwc3 *dwc, unsigned int event) |
| 1044 | { |
| 1045 | int ret = 0; |
| 1046 | |
| 1047 | if (dwc->notify_event) |
| 1048 | dwc->notify_event(dwc, event); |
| 1049 | else |
| 1050 | ret = -ENODEV; |
| 1051 | |
| 1052 | return ret; |
| 1053 | } |
| 1054 | EXPORT_SYMBOL(dwc3_notify_event); |
| 1055 | |
| 1056 | int dwc3_core_pre_init(struct dwc3 *dwc) |
| 1057 | { |
| 1058 | int ret; |
| 1059 | |
| 1060 | dwc3_cache_hwparams(dwc); |
| 1061 | |
| 1062 | ret = dwc3_phy_setup(dwc); |
| 1063 | if (ret) |
| 1064 | goto err0; |
| 1065 | |
| 1066 | if (!dwc->ev_buf) { |
| 1067 | ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); |
| 1068 | if (ret) { |
| 1069 | dev_err(dwc->dev, "failed to allocate event buffers\n"); |
| 1070 | ret = -ENOMEM; |
| 1071 | goto err1; |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | ret = dwc3_core_init(dwc); |
| 1076 | if (ret) { |
| 1077 | dev_err(dwc->dev, "failed to initialize core\n"); |
| 1078 | goto err2; |
| 1079 | } |
| 1080 | |
| 1081 | ret = phy_power_on(dwc->usb2_generic_phy); |
| 1082 | if (ret < 0) |
| 1083 | goto err3; |
| 1084 | |
| 1085 | ret = phy_power_on(dwc->usb3_generic_phy); |
| 1086 | if (ret < 0) |
| 1087 | goto err4; |
| 1088 | |
| 1089 | ret = dwc3_event_buffers_setup(dwc); |
| 1090 | if (ret) { |
| 1091 | dev_err(dwc->dev, "failed to setup event buffers\n"); |
| 1092 | goto err5; |
| 1093 | } |
| 1094 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1095 | return ret; |
| 1096 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1097 | err5: |
| 1098 | phy_power_off(dwc->usb3_generic_phy); |
| 1099 | err4: |
| 1100 | phy_power_off(dwc->usb2_generic_phy); |
| 1101 | err3: |
| 1102 | dwc3_core_exit(dwc); |
| 1103 | err2: |
| 1104 | dwc3_free_event_buffers(dwc); |
| 1105 | err1: |
| 1106 | dwc3_ulpi_exit(dwc); |
| 1107 | err0: |
| 1108 | return ret; |
| 1109 | } |
| 1110 | |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 1111 | #define DWC3_ALIGN_MASK (16 - 1) |
| 1112 | |
| 1113 | static int dwc3_probe(struct platform_device *pdev) |
| 1114 | { |
| 1115 | struct device *dev = &pdev->dev; |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 1116 | struct resource *res; |
| 1117 | struct dwc3 *dwc; |
Huang Rui | 80caf7d | 2014-10-28 19:54:26 +0800 | [diff] [blame] | 1118 | u8 lpm_nyet_threshold; |
Huang Rui | 6b6a0c9 | 2014-10-31 11:11:12 +0800 | [diff] [blame] | 1119 | u8 tx_de_emphasis; |
Huang Rui | 460d098 | 2014-10-31 11:11:18 +0800 | [diff] [blame] | 1120 | u8 hird_threshold; |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1121 | int irq; |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 1122 | |
Andy Shevchenko | b09e99e | 2014-05-15 15:53:32 +0300 | [diff] [blame] | 1123 | int ret; |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 1124 | |
| 1125 | void __iomem *regs; |
| 1126 | void *mem; |
| 1127 | |
| 1128 | mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); |
Jingoo Han | 734d5a5 | 2014-07-17 12:45:11 +0900 | [diff] [blame] | 1129 | if (!mem) |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 1130 | return -ENOMEM; |
Jingoo Han | 734d5a5 | 2014-07-17 12:45:11 +0900 | [diff] [blame] | 1131 | |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 1132 | dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); |
| 1133 | dwc->mem = mem; |
| 1134 | dwc->dev = dev; |
| 1135 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1136 | dwc->notify_event = notify_event; |
| 1137 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
| 1138 | if (!res) { |
| 1139 | dev_err(dev, "missing IRQ\n"); |
| 1140 | return -ENODEV; |
| 1141 | } |
| 1142 | dwc->xhci_resources[1].start = res->start; |
| 1143 | dwc->xhci_resources[1].end = res->end; |
| 1144 | dwc->xhci_resources[1].flags = res->flags; |
| 1145 | dwc->xhci_resources[1].name = res->name; |
| 1146 | |
| 1147 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); |
| 1148 | |
| 1149 | /* will be enabled in dwc3_msm_resume() */ |
| 1150 | irq_set_status_flags(irq, IRQ_NOAUTOEN); |
| 1151 | ret = devm_request_threaded_irq(dev, irq, NULL, dwc3_interrupt, |
| 1152 | IRQF_SHARED | IRQF_ONESHOT, "dwc3", dwc); |
| 1153 | if (ret) { |
| 1154 | dev_err(dwc->dev, "failed to request irq #%d --> %d\n", |
| 1155 | irq, ret); |
| 1156 | return -ENODEV; |
| 1157 | } |
| 1158 | |
| 1159 | dwc->irq = irq; |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 1160 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 1161 | if (!res) { |
| 1162 | dev_err(dev, "missing memory resource\n"); |
| 1163 | return -ENODEV; |
| 1164 | } |
| 1165 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1166 | dwc->reg_phys = res->start; |
Vivek Gautam | f32a5e2 | 2014-06-04 14:34:52 +0530 | [diff] [blame] | 1167 | dwc->xhci_resources[0].start = res->start; |
| 1168 | dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + |
| 1169 | DWC3_XHCI_REGS_END; |
| 1170 | dwc->xhci_resources[0].flags = res->flags; |
| 1171 | dwc->xhci_resources[0].name = res->name; |
| 1172 | |
| 1173 | res->start += DWC3_GLOBALS_REGS_START; |
| 1174 | |
| 1175 | /* |
| 1176 | * Request memory region but exclude xHCI regs, |
| 1177 | * since it will be requested by the xhci-plat driver. |
| 1178 | */ |
| 1179 | regs = devm_ioremap_resource(dev, res); |
Felipe Balbi | 3da1f6e | 2014-09-02 15:19:43 -0500 | [diff] [blame] | 1180 | if (IS_ERR(regs)) { |
| 1181 | ret = PTR_ERR(regs); |
| 1182 | goto err0; |
| 1183 | } |
Vivek Gautam | f32a5e2 | 2014-06-04 14:34:52 +0530 | [diff] [blame] | 1184 | |
| 1185 | dwc->regs = regs; |
| 1186 | dwc->regs_size = resource_size(res); |
Vivek Gautam | f32a5e2 | 2014-06-04 14:34:52 +0530 | [diff] [blame] | 1187 | |
Huang Rui | 80caf7d | 2014-10-28 19:54:26 +0800 | [diff] [blame] | 1188 | /* default to highest possible threshold */ |
| 1189 | lpm_nyet_threshold = 0xff; |
| 1190 | |
Huang Rui | 6b6a0c9 | 2014-10-31 11:11:12 +0800 | [diff] [blame] | 1191 | /* default to -3.5dB de-emphasis */ |
| 1192 | tx_de_emphasis = 1; |
| 1193 | |
Huang Rui | 460d098 | 2014-10-31 11:11:18 +0800 | [diff] [blame] | 1194 | /* |
| 1195 | * default to assert utmi_sleep_n and use maximum allowed HIRD |
| 1196 | * threshold value of 0b1100 |
| 1197 | */ |
| 1198 | hird_threshold = 12; |
| 1199 | |
Heikki Krogerus | 63863b9 | 2015-09-21 11:14:32 +0300 | [diff] [blame] | 1200 | dwc->maximum_speed = usb_get_maximum_speed(dev); |
Heikki Krogerus | 06e7114 | 2015-09-21 11:14:34 +0300 | [diff] [blame] | 1201 | dwc->dr_mode = usb_get_dr_mode(dev); |
Mayank Rana | fb9cd93 | 2016-11-03 23:26:38 -0700 | [diff] [blame] | 1202 | |
| 1203 | if (dwc->dr_mode == USB_DR_MODE_UNKNOWN) { |
| 1204 | dwc->dr_mode = USB_DR_MODE_OTG; |
| 1205 | dwc->is_drd = 1; |
| 1206 | } |
| 1207 | |
William Wu | 32f2ed8 | 2016-08-16 22:44:38 +0800 | [diff] [blame] | 1208 | dwc->hsphy_mode = of_usb_get_phy_mode(dev->of_node); |
Heikki Krogerus | 63863b9 | 2015-09-21 11:14:32 +0300 | [diff] [blame] | 1209 | |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1210 | dwc->has_lpm_erratum = device_property_read_bool(dev, |
Huang Rui | 80caf7d | 2014-10-28 19:54:26 +0800 | [diff] [blame] | 1211 | "snps,has-lpm-erratum"); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1212 | device_property_read_u8(dev, "snps,lpm-nyet-threshold", |
Huang Rui | 80caf7d | 2014-10-28 19:54:26 +0800 | [diff] [blame] | 1213 | &lpm_nyet_threshold); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1214 | dwc->is_utmi_l1_suspend = device_property_read_bool(dev, |
Huang Rui | 460d098 | 2014-10-31 11:11:18 +0800 | [diff] [blame] | 1215 | "snps,is-utmi-l1-suspend"); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1216 | device_property_read_u8(dev, "snps,hird-threshold", |
Huang Rui | 460d098 | 2014-10-31 11:11:18 +0800 | [diff] [blame] | 1217 | &hird_threshold); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1218 | dwc->usb3_lpm_capable = device_property_read_bool(dev, |
Robert Baldyga | eac68e8 | 2015-03-09 15:06:12 +0100 | [diff] [blame] | 1219 | "snps,usb3_lpm_capable"); |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 1220 | |
Mayank Rana | a8e4de6 | 2016-12-13 17:11:15 -0800 | [diff] [blame] | 1221 | dwc->needs_fifo_resize = device_property_read_bool(dev, |
| 1222 | "tx-fifo-resize"); |
| 1223 | |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1224 | dwc->disable_scramble_quirk = device_property_read_bool(dev, |
Huang Rui | 3b81221 | 2014-10-28 19:54:25 +0800 | [diff] [blame] | 1225 | "snps,disable_scramble_quirk"); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1226 | dwc->u2exit_lfps_quirk = device_property_read_bool(dev, |
Huang Rui | 9a5b2f3 | 2014-10-28 19:54:27 +0800 | [diff] [blame] | 1227 | "snps,u2exit_lfps_quirk"); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1228 | dwc->u2ss_inp3_quirk = device_property_read_bool(dev, |
Huang Rui | b5a65c4 | 2014-10-28 19:54:28 +0800 | [diff] [blame] | 1229 | "snps,u2ss_inp3_quirk"); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1230 | dwc->req_p1p2p3_quirk = device_property_read_bool(dev, |
Huang Rui | df31f5b | 2014-10-28 19:54:29 +0800 | [diff] [blame] | 1231 | "snps,req_p1p2p3_quirk"); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1232 | dwc->del_p1p2p3_quirk = device_property_read_bool(dev, |
Huang Rui | a2a1d0f | 2014-10-28 19:54:30 +0800 | [diff] [blame] | 1233 | "snps,del_p1p2p3_quirk"); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1234 | dwc->del_phy_power_chg_quirk = device_property_read_bool(dev, |
Huang Rui | 41c06ff | 2014-10-28 19:54:31 +0800 | [diff] [blame] | 1235 | "snps,del_phy_power_chg_quirk"); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1236 | dwc->lfps_filter_quirk = device_property_read_bool(dev, |
Huang Rui | fb67afc | 2014-10-28 19:54:32 +0800 | [diff] [blame] | 1237 | "snps,lfps_filter_quirk"); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1238 | dwc->rx_detect_poll_quirk = device_property_read_bool(dev, |
Huang Rui | 14f4ac5 | 2014-10-28 19:54:33 +0800 | [diff] [blame] | 1239 | "snps,rx_detect_poll_quirk"); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1240 | dwc->dis_u3_susphy_quirk = device_property_read_bool(dev, |
Huang Rui | 59acfa2 | 2014-10-31 11:11:13 +0800 | [diff] [blame] | 1241 | "snps,dis_u3_susphy_quirk"); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1242 | dwc->dis_u2_susphy_quirk = device_property_read_bool(dev, |
Huang Rui | 0effe0a | 2014-10-31 11:11:14 +0800 | [diff] [blame] | 1243 | "snps,dis_u2_susphy_quirk"); |
John Youn | ec791d1 | 2015-10-02 20:30:57 -0700 | [diff] [blame] | 1244 | dwc->dis_enblslpm_quirk = device_property_read_bool(dev, |
| 1245 | "snps,dis_enblslpm_quirk"); |
Rajesh Bhagat | e58dd35 | 2016-03-14 14:40:50 +0530 | [diff] [blame] | 1246 | dwc->dis_rxdet_inp3_quirk = device_property_read_bool(dev, |
| 1247 | "snps,dis_rxdet_inp3_quirk"); |
William Wu | 16199f3 | 2016-08-16 22:44:37 +0800 | [diff] [blame] | 1248 | dwc->dis_u2_freeclk_exists_quirk = device_property_read_bool(dev, |
| 1249 | "snps,dis-u2-freeclk-exists-quirk"); |
William Wu | 00fe081 | 2016-08-16 22:44:39 +0800 | [diff] [blame] | 1250 | dwc->dis_del_phy_power_chg_quirk = device_property_read_bool(dev, |
| 1251 | "snps,dis-del-phy-power-chg-quirk"); |
Huang Rui | 6b6a0c9 | 2014-10-31 11:11:12 +0800 | [diff] [blame] | 1252 | |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1253 | dwc->tx_de_emphasis_quirk = device_property_read_bool(dev, |
Huang Rui | 6b6a0c9 | 2014-10-31 11:11:12 +0800 | [diff] [blame] | 1254 | "snps,tx_de_emphasis_quirk"); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1255 | device_property_read_u8(dev, "snps,tx_de_emphasis", |
Huang Rui | 6b6a0c9 | 2014-10-31 11:11:12 +0800 | [diff] [blame] | 1256 | &tx_de_emphasis); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1257 | device_property_read_string(dev, "snps,hsphy_interface", |
| 1258 | &dwc->hsphy_interface); |
| 1259 | device_property_read_u32(dev, "snps,quirk-frame-length-adjustment", |
Felipe Balbi | bcdb327 | 2016-05-16 10:42:23 +0300 | [diff] [blame] | 1260 | &dwc->fladj); |
Heikki Krogerus | 3d12891 | 2015-09-21 11:14:35 +0300 | [diff] [blame] | 1261 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1262 | if (dwc->enable_bus_suspend) { |
| 1263 | pm_runtime_set_autosuspend_delay(dev, 500); |
| 1264 | pm_runtime_use_autosuspend(dev); |
| 1265 | } |
| 1266 | |
Huang Rui | 80caf7d | 2014-10-28 19:54:26 +0800 | [diff] [blame] | 1267 | dwc->lpm_nyet_threshold = lpm_nyet_threshold; |
Huang Rui | 6b6a0c9 | 2014-10-31 11:11:12 +0800 | [diff] [blame] | 1268 | dwc->tx_de_emphasis = tx_de_emphasis; |
Huang Rui | 80caf7d | 2014-10-28 19:54:26 +0800 | [diff] [blame] | 1269 | |
Huang Rui | 460d098 | 2014-10-31 11:11:18 +0800 | [diff] [blame] | 1270 | dwc->hird_threshold = hird_threshold |
| 1271 | | (dwc->is_utmi_l1_suspend << 4); |
| 1272 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1273 | init_waitqueue_head(&dwc->wait_linkstate); |
Heikki Krogerus | 6c89cce0 | 2015-05-13 15:26:45 +0300 | [diff] [blame] | 1274 | platform_set_drvdata(pdev, dwc); |
| 1275 | |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 1276 | ret = dwc3_core_get_phy(dwc); |
| 1277 | if (ret) |
Felipe Balbi | 3da1f6e | 2014-09-02 15:19:43 -0500 | [diff] [blame] | 1278 | goto err0; |
Felipe Balbi | 3c9f94a | 2014-04-16 15:08:29 -0500 | [diff] [blame] | 1279 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1280 | spin_lock_init(&dwc->lock); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1281 | |
Heikki Krogerus | 19bacdc | 2014-09-24 11:00:38 +0300 | [diff] [blame] | 1282 | if (!dev->dma_mask) { |
| 1283 | dev->dma_mask = dev->parent->dma_mask; |
| 1284 | dev->dma_parms = dev->parent->dma_parms; |
| 1285 | dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask); |
| 1286 | } |
Kishon Vijay Abraham I | ddff14f | 2013-03-07 18:51:43 +0530 | [diff] [blame] | 1287 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1288 | pm_runtime_no_callbacks(dev); |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1289 | pm_runtime_set_active(dev); |
Chanho Park | 802ca85 | 2012-02-15 18:27:55 +0900 | [diff] [blame] | 1290 | pm_runtime_enable(dev); |
Chanho Park | 802ca85 | 2012-02-15 18:27:55 +0900 | [diff] [blame] | 1291 | pm_runtime_forbid(dev); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1292 | |
John Youn | 77966eb | 2016-02-19 17:31:01 -0800 | [diff] [blame] | 1293 | /* Check the maximum_speed parameter */ |
| 1294 | switch (dwc->maximum_speed) { |
| 1295 | case USB_SPEED_LOW: |
| 1296 | case USB_SPEED_FULL: |
| 1297 | case USB_SPEED_HIGH: |
| 1298 | case USB_SPEED_SUPER: |
| 1299 | case USB_SPEED_SUPER_PLUS: |
| 1300 | break; |
| 1301 | default: |
| 1302 | dev_err(dev, "invalid maximum_speed parameter %d\n", |
| 1303 | dwc->maximum_speed); |
| 1304 | /* fall through */ |
| 1305 | case USB_SPEED_UNKNOWN: |
| 1306 | /* default to superspeed */ |
John Youn | 2c7f1bd | 2016-02-05 17:08:59 -0800 | [diff] [blame] | 1307 | dwc->maximum_speed = USB_SPEED_SUPER; |
| 1308 | |
| 1309 | /* |
| 1310 | * default to superspeed plus if we are capable. |
| 1311 | */ |
| 1312 | if (dwc3_is_usb31(dwc) && |
| 1313 | (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) == |
| 1314 | DWC3_GHWPARAMS3_SSPHY_IFC_GEN2)) |
| 1315 | dwc->maximum_speed = USB_SPEED_SUPER_PLUS; |
John Youn | 77966eb | 2016-02-19 17:31:01 -0800 | [diff] [blame] | 1316 | |
| 1317 | break; |
John Youn | 2c7f1bd | 2016-02-05 17:08:59 -0800 | [diff] [blame] | 1318 | } |
| 1319 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1320 | /* Adjust Frame Length */ |
| 1321 | dwc3_frame_length_adjustment(dwc); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1322 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1323 | /* Hardcode number of eps */ |
| 1324 | dwc->num_in_eps = 16; |
| 1325 | dwc->num_out_eps = 16; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1326 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1327 | ret = dwc3_core_init_mode(dwc); |
| 1328 | if (ret) |
Kyle Yan | 65be4a5 | 2016-10-31 15:05:00 -0700 | [diff] [blame] | 1329 | goto err0; |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1330 | |
| 1331 | ret = dwc3_debugfs_init(dwc); |
| 1332 | if (ret) { |
| 1333 | dev_err(dev, "failed to initialize debugfs\n"); |
Kyle Yan | 65be4a5 | 2016-10-31 15:05:00 -0700 | [diff] [blame] | 1334 | goto err_core_init; |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1335 | } |
| 1336 | |
| 1337 | pm_runtime_allow(dev); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1338 | return 0; |
| 1339 | |
Kyle Yan | 65be4a5 | 2016-10-31 15:05:00 -0700 | [diff] [blame] | 1340 | err_core_init: |
| 1341 | dwc3_core_exit_mode(dwc); |
Felipe Balbi | 3da1f6e | 2014-09-02 15:19:43 -0500 | [diff] [blame] | 1342 | err0: |
| 1343 | /* |
| 1344 | * restore res->start back to its original value so that, in case the |
| 1345 | * probe is deferred, we don't end up getting error in request the |
| 1346 | * memory region the next time probe is called. |
| 1347 | */ |
| 1348 | res->start -= DWC3_GLOBALS_REGS_START; |
| 1349 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1350 | return ret; |
| 1351 | } |
| 1352 | |
Bill Pemberton | fb4e98a | 2012-11-19 13:26:20 -0500 | [diff] [blame] | 1353 | static int dwc3_remove(struct platform_device *pdev) |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1354 | { |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1355 | struct dwc3 *dwc = platform_get_drvdata(pdev); |
Felipe Balbi | 3da1f6e | 2014-09-02 15:19:43 -0500 | [diff] [blame] | 1356 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 1357 | |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1358 | pm_runtime_get_sync(&pdev->dev); |
Felipe Balbi | 3da1f6e | 2014-09-02 15:19:43 -0500 | [diff] [blame] | 1359 | /* |
| 1360 | * restore res->start back to its original value so that, in case the |
| 1361 | * probe is deferred, we don't end up getting error in request the |
| 1362 | * memory region the next time probe is called. |
| 1363 | */ |
| 1364 | res->start -= DWC3_GLOBALS_REGS_START; |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1365 | |
Felipe Balbi | dc99f16 | 2014-09-03 16:13:37 -0500 | [diff] [blame] | 1366 | dwc3_debugfs_exit(dwc); |
| 1367 | dwc3_core_exit_mode(dwc); |
Kishon Vijay Abraham I | 8ba007a | 2013-01-25 08:30:54 +0530 | [diff] [blame] | 1368 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1369 | dwc3_core_exit(dwc); |
Heikki Krogerus | 88bc9d1 | 2015-05-13 15:26:51 +0300 | [diff] [blame] | 1370 | dwc3_ulpi_exit(dwc); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1371 | |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1372 | pm_runtime_put_sync(&pdev->dev); |
| 1373 | pm_runtime_allow(&pdev->dev); |
| 1374 | pm_runtime_disable(&pdev->dev); |
| 1375 | |
Felipe Balbi | c499ff7 | 2016-05-16 10:49:01 +0300 | [diff] [blame] | 1376 | dwc3_free_event_buffers(dwc); |
| 1377 | dwc3_free_scratch_buffers(dwc); |
| 1378 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1379 | return 0; |
| 1380 | } |
| 1381 | |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1382 | #ifdef CONFIG_PM |
| 1383 | static int dwc3_suspend_common(struct dwc3 *dwc) |
Felipe Balbi | 7415f17 | 2012-04-30 14:56:33 +0300 | [diff] [blame] | 1384 | { |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1385 | unsigned long flags; |
Felipe Balbi | 7415f17 | 2012-04-30 14:56:33 +0300 | [diff] [blame] | 1386 | |
Ruchika Kharwar | a45c82b8 | 2013-07-06 07:52:49 -0500 | [diff] [blame] | 1387 | switch (dwc->dr_mode) { |
| 1388 | case USB_DR_MODE_PERIPHERAL: |
| 1389 | case USB_DR_MODE_OTG: |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1390 | spin_lock_irqsave(&dwc->lock, flags); |
Felipe Balbi | 7415f17 | 2012-04-30 14:56:33 +0300 | [diff] [blame] | 1391 | dwc3_gadget_suspend(dwc); |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1392 | spin_unlock_irqrestore(&dwc->lock, flags); |
Felipe Balbi | 51f5d49 | 2016-05-16 10:52:58 +0300 | [diff] [blame] | 1393 | break; |
Ruchika Kharwar | a45c82b8 | 2013-07-06 07:52:49 -0500 | [diff] [blame] | 1394 | case USB_DR_MODE_HOST: |
Felipe Balbi | 7415f17 | 2012-04-30 14:56:33 +0300 | [diff] [blame] | 1395 | default: |
Felipe Balbi | 51f5d49 | 2016-05-16 10:52:58 +0300 | [diff] [blame] | 1396 | /* do nothing */ |
Felipe Balbi | 7415f17 | 2012-04-30 14:56:33 +0300 | [diff] [blame] | 1397 | break; |
| 1398 | } |
| 1399 | |
Felipe Balbi | 51f5d49 | 2016-05-16 10:52:58 +0300 | [diff] [blame] | 1400 | dwc3_core_exit(dwc); |
Felipe Balbi | 5c4ad318 | 2016-04-11 17:12:34 +0300 | [diff] [blame] | 1401 | |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1402 | return 0; |
| 1403 | } |
| 1404 | |
| 1405 | static int dwc3_resume_common(struct dwc3 *dwc) |
| 1406 | { |
| 1407 | unsigned long flags; |
| 1408 | int ret; |
| 1409 | |
| 1410 | ret = dwc3_core_init(dwc); |
| 1411 | if (ret) |
| 1412 | return ret; |
| 1413 | |
| 1414 | switch (dwc->dr_mode) { |
| 1415 | case USB_DR_MODE_PERIPHERAL: |
| 1416 | case USB_DR_MODE_OTG: |
| 1417 | spin_lock_irqsave(&dwc->lock, flags); |
| 1418 | dwc3_gadget_resume(dwc); |
| 1419 | spin_unlock_irqrestore(&dwc->lock, flags); |
| 1420 | /* FALLTHROUGH */ |
| 1421 | case USB_DR_MODE_HOST: |
| 1422 | default: |
| 1423 | /* do nothing */ |
| 1424 | break; |
| 1425 | } |
| 1426 | |
| 1427 | return 0; |
| 1428 | } |
| 1429 | |
| 1430 | static int dwc3_runtime_checks(struct dwc3 *dwc) |
| 1431 | { |
| 1432 | switch (dwc->dr_mode) { |
| 1433 | case USB_DR_MODE_PERIPHERAL: |
| 1434 | case USB_DR_MODE_OTG: |
| 1435 | if (dwc->connected) |
| 1436 | return -EBUSY; |
| 1437 | break; |
| 1438 | case USB_DR_MODE_HOST: |
| 1439 | default: |
| 1440 | /* do nothing */ |
| 1441 | break; |
| 1442 | } |
| 1443 | |
| 1444 | return 0; |
| 1445 | } |
| 1446 | |
| 1447 | static int dwc3_runtime_suspend(struct device *dev) |
| 1448 | { |
| 1449 | struct dwc3 *dwc = dev_get_drvdata(dev); |
| 1450 | int ret; |
| 1451 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1452 | /* Check if platform glue driver handling PM, if not then handle here */ |
| 1453 | if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT)) |
| 1454 | return 0; |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1455 | |
| 1456 | ret = dwc3_suspend_common(dwc); |
| 1457 | if (ret) |
| 1458 | return ret; |
| 1459 | |
| 1460 | device_init_wakeup(dev, true); |
| 1461 | |
| 1462 | return 0; |
| 1463 | } |
| 1464 | |
| 1465 | static int dwc3_runtime_resume(struct device *dev) |
| 1466 | { |
| 1467 | struct dwc3 *dwc = dev_get_drvdata(dev); |
| 1468 | int ret; |
| 1469 | |
Mayank Rana | a99689a | 2016-08-10 17:39:47 -0700 | [diff] [blame] | 1470 | /* Check if platform glue driver handling PM, if not then handle here */ |
| 1471 | if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT)) |
| 1472 | return 0; |
| 1473 | |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1474 | device_init_wakeup(dev, false); |
| 1475 | |
| 1476 | ret = dwc3_resume_common(dwc); |
| 1477 | if (ret) |
| 1478 | return ret; |
| 1479 | |
| 1480 | switch (dwc->dr_mode) { |
| 1481 | case USB_DR_MODE_PERIPHERAL: |
| 1482 | case USB_DR_MODE_OTG: |
| 1483 | dwc3_gadget_process_pending_events(dwc); |
| 1484 | break; |
| 1485 | case USB_DR_MODE_HOST: |
| 1486 | default: |
| 1487 | /* do nothing */ |
| 1488 | break; |
| 1489 | } |
| 1490 | |
| 1491 | pm_runtime_mark_last_busy(dev); |
Felipe Balbi | b74c2d8 | 2016-07-28 13:07:07 +0300 | [diff] [blame] | 1492 | pm_runtime_put(dev); |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1493 | |
| 1494 | return 0; |
| 1495 | } |
| 1496 | |
| 1497 | static int dwc3_runtime_idle(struct device *dev) |
| 1498 | { |
| 1499 | struct dwc3 *dwc = dev_get_drvdata(dev); |
| 1500 | |
| 1501 | switch (dwc->dr_mode) { |
| 1502 | case USB_DR_MODE_PERIPHERAL: |
| 1503 | case USB_DR_MODE_OTG: |
| 1504 | if (dwc3_runtime_checks(dwc)) |
| 1505 | return -EBUSY; |
| 1506 | break; |
| 1507 | case USB_DR_MODE_HOST: |
| 1508 | default: |
| 1509 | /* do nothing */ |
| 1510 | break; |
| 1511 | } |
| 1512 | |
| 1513 | pm_runtime_mark_last_busy(dev); |
| 1514 | pm_runtime_autosuspend(dev); |
| 1515 | |
| 1516 | return 0; |
| 1517 | } |
| 1518 | #endif /* CONFIG_PM */ |
| 1519 | |
| 1520 | #ifdef CONFIG_PM_SLEEP |
| 1521 | static int dwc3_suspend(struct device *dev) |
| 1522 | { |
| 1523 | struct dwc3 *dwc = dev_get_drvdata(dev); |
| 1524 | int ret; |
| 1525 | |
| 1526 | ret = dwc3_suspend_common(dwc); |
| 1527 | if (ret) |
| 1528 | return ret; |
| 1529 | |
Sekhar Nori | 6344475 | 2015-08-31 21:09:08 +0530 | [diff] [blame] | 1530 | pinctrl_pm_select_sleep_state(dev); |
| 1531 | |
Felipe Balbi | 7415f17 | 2012-04-30 14:56:33 +0300 | [diff] [blame] | 1532 | return 0; |
| 1533 | } |
| 1534 | |
| 1535 | static int dwc3_resume(struct device *dev) |
| 1536 | { |
| 1537 | struct dwc3 *dwc = dev_get_drvdata(dev); |
Kishon Vijay Abraham I | 5730348 | 2014-03-03 17:08:11 +0530 | [diff] [blame] | 1538 | int ret; |
Felipe Balbi | 7415f17 | 2012-04-30 14:56:33 +0300 | [diff] [blame] | 1539 | |
Sekhar Nori | 6344475 | 2015-08-31 21:09:08 +0530 | [diff] [blame] | 1540 | pinctrl_pm_select_default_state(dev); |
| 1541 | |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1542 | ret = dwc3_resume_common(dwc); |
Felipe Balbi | 51f5d49 | 2016-05-16 10:52:58 +0300 | [diff] [blame] | 1543 | if (ret) |
Felipe Balbi | 5c4ad318 | 2016-04-11 17:12:34 +0300 | [diff] [blame] | 1544 | return ret; |
| 1545 | |
Felipe Balbi | 7415f17 | 2012-04-30 14:56:33 +0300 | [diff] [blame] | 1546 | pm_runtime_disable(dev); |
| 1547 | pm_runtime_set_active(dev); |
| 1548 | pm_runtime_enable(dev); |
| 1549 | |
| 1550 | return 0; |
| 1551 | } |
Felipe Balbi | 7f370ed | 2016-05-09 15:27:01 +0300 | [diff] [blame] | 1552 | #endif /* CONFIG_PM_SLEEP */ |
Felipe Balbi | 7415f17 | 2012-04-30 14:56:33 +0300 | [diff] [blame] | 1553 | |
| 1554 | static const struct dev_pm_ops dwc3_dev_pm_ops = { |
Felipe Balbi | 7415f17 | 2012-04-30 14:56:33 +0300 | [diff] [blame] | 1555 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume) |
Felipe Balbi | fc8bb91 | 2016-05-16 13:14:48 +0300 | [diff] [blame] | 1556 | SET_RUNTIME_PM_OPS(dwc3_runtime_suspend, dwc3_runtime_resume, |
| 1557 | dwc3_runtime_idle) |
Felipe Balbi | 7415f17 | 2012-04-30 14:56:33 +0300 | [diff] [blame] | 1558 | }; |
| 1559 | |
Kishon Vijay Abraham I | 5088b6f | 2013-01-25 16:36:53 +0530 | [diff] [blame] | 1560 | #ifdef CONFIG_OF |
| 1561 | static const struct of_device_id of_dwc3_match[] = { |
| 1562 | { |
Felipe Balbi | 22a5aa1 | 2013-07-02 21:20:24 +0300 | [diff] [blame] | 1563 | .compatible = "snps,dwc3" |
| 1564 | }, |
| 1565 | { |
Kishon Vijay Abraham I | 5088b6f | 2013-01-25 16:36:53 +0530 | [diff] [blame] | 1566 | .compatible = "synopsys,dwc3" |
| 1567 | }, |
| 1568 | { }, |
| 1569 | }; |
| 1570 | MODULE_DEVICE_TABLE(of, of_dwc3_match); |
| 1571 | #endif |
| 1572 | |
Heikki Krogerus | 404905a | 2014-09-25 10:57:02 +0300 | [diff] [blame] | 1573 | #ifdef CONFIG_ACPI |
| 1574 | |
| 1575 | #define ACPI_ID_INTEL_BSW "808622B7" |
| 1576 | |
| 1577 | static const struct acpi_device_id dwc3_acpi_match[] = { |
| 1578 | { ACPI_ID_INTEL_BSW, 0 }, |
| 1579 | { }, |
| 1580 | }; |
| 1581 | MODULE_DEVICE_TABLE(acpi, dwc3_acpi_match); |
| 1582 | #endif |
| 1583 | |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1584 | static struct platform_driver dwc3_driver = { |
| 1585 | .probe = dwc3_probe, |
Bill Pemberton | 7690417 | 2012-11-19 13:21:08 -0500 | [diff] [blame] | 1586 | .remove = dwc3_remove, |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1587 | .driver = { |
| 1588 | .name = "dwc3", |
Kishon Vijay Abraham I | 5088b6f | 2013-01-25 16:36:53 +0530 | [diff] [blame] | 1589 | .of_match_table = of_match_ptr(of_dwc3_match), |
Heikki Krogerus | 404905a | 2014-09-25 10:57:02 +0300 | [diff] [blame] | 1590 | .acpi_match_table = ACPI_PTR(dwc3_acpi_match), |
Felipe Balbi | 7f370ed | 2016-05-09 15:27:01 +0300 | [diff] [blame] | 1591 | .pm = &dwc3_dev_pm_ops, |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1592 | }, |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1593 | }; |
| 1594 | |
Tobias Klauser | b1116dc | 2012-02-28 12:57:20 +0100 | [diff] [blame] | 1595 | module_platform_driver(dwc3_driver); |
| 1596 | |
Sebastian Andrzej Siewior | 7ae4fc4 | 2011-10-19 19:39:50 +0200 | [diff] [blame] | 1597 | MODULE_ALIAS("platform:dwc3"); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1598 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
Felipe Balbi | 5945f78 | 2013-06-30 14:15:11 +0300 | [diff] [blame] | 1599 | MODULE_LICENSE("GPL v2"); |
Felipe Balbi | 72246da | 2011-08-19 18:10:58 +0300 | [diff] [blame] | 1600 | MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver"); |