UPSTREAM: usb: dwc3: core: move fladj to dwc3 structure
[firefly-linux-kernel-4.4.55.git] / drivers / usb / dwc3 / core.c
1 /**
2  * core.c - DesignWare USB3 DRD Controller Core file
3  *
4  * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
5  *
6  * Authors: Felipe Balbi <balbi@ti.com>,
7  *          Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8  *
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.
12  *
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.
17  *
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/>.
20  */
21
22 #include <linux/version.h>
23 #include <linux/module.h>
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>
35 #include <linux/of.h>
36 #include <linux/acpi.h>
37 #include <linux/pinctrl/consumer.h>
38
39 #include <linux/usb/ch9.h>
40 #include <linux/usb/gadget.h>
41 #include <linux/usb/of.h>
42 #include <linux/usb/otg.h>
43
44 #include "platform_data.h"
45 #include "core.h"
46 #include "gadget.h"
47 #include "io.h"
48
49 #include "debug.h"
50
51 /* -------------------------------------------------------------------------- */
52
53 void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
54 {
55         u32 reg;
56
57         reg = dwc3_readl(dwc->regs, DWC3_GCTL);
58         reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG));
59         reg |= DWC3_GCTL_PRTCAPDIR(mode);
60         dwc3_writel(dwc->regs, DWC3_GCTL, reg);
61 }
62
63 u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type)
64 {
65         struct dwc3             *dwc = dep->dwc;
66         u32                     reg;
67
68         dwc3_writel(dwc->regs, DWC3_GDBGFIFOSPACE,
69                         DWC3_GDBGFIFOSPACE_NUM(dep->number) |
70                         DWC3_GDBGFIFOSPACE_TYPE(type));
71
72         reg = dwc3_readl(dwc->regs, DWC3_GDBGFIFOSPACE);
73
74         return DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE(reg);
75 }
76
77 /**
78  * dwc3_core_soft_reset - Issues core soft reset and PHY reset
79  * @dwc: pointer to our context structure
80  */
81 static int dwc3_core_soft_reset(struct dwc3 *dwc)
82 {
83         u32             reg;
84         int             retries = 1000;
85         int             ret;
86
87         usb_phy_init(dwc->usb2_phy);
88         usb_phy_init(dwc->usb3_phy);
89         ret = phy_init(dwc->usb2_generic_phy);
90         if (ret < 0)
91                 return ret;
92
93         ret = phy_init(dwc->usb3_generic_phy);
94         if (ret < 0) {
95                 phy_exit(dwc->usb2_generic_phy);
96                 return ret;
97         }
98
99         /*
100          * We're resetting only the device side because, if we're in host mode,
101          * XHCI driver will reset the host block. If dwc3 was configured for
102          * host-only mode, then we can return early.
103          */
104         if (dwc->dr_mode == USB_DR_MODE_HOST)
105                 return 0;
106
107         reg = dwc3_readl(dwc->regs, DWC3_DCTL);
108         reg |= DWC3_DCTL_CSFTRST;
109         dwc3_writel(dwc->regs, DWC3_DCTL, reg);
110
111         do {
112                 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
113                 if (!(reg & DWC3_DCTL_CSFTRST))
114                         return 0;
115
116                 udelay(1);
117         } while (--retries);
118
119         return -ETIMEDOUT;
120 }
121
122 /**
123  * dwc3_soft_reset - Issue soft reset
124  * @dwc: Pointer to our controller context structure
125  */
126 static int dwc3_soft_reset(struct dwc3 *dwc)
127 {
128         unsigned long timeout;
129         u32 reg;
130
131         timeout = jiffies + msecs_to_jiffies(500);
132         dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
133         do {
134                 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
135                 if (!(reg & DWC3_DCTL_CSFTRST))
136                         break;
137
138                 if (time_after(jiffies, timeout)) {
139                         dev_err(dwc->dev, "Reset Timed Out\n");
140                         return -ETIMEDOUT;
141                 }
142
143                 cpu_relax();
144         } while (true);
145
146         return 0;
147 }
148
149 /*
150  * dwc3_frame_length_adjustment - Adjusts frame length if required
151  * @dwc3: Pointer to our controller context structure
152  */
153 static void dwc3_frame_length_adjustment(struct dwc3 *dwc)
154 {
155         u32 reg;
156         u32 dft;
157
158         if (dwc->revision < DWC3_REVISION_250A)
159                 return;
160
161         if (dwc->fladj == 0)
162                 return;
163
164         reg = dwc3_readl(dwc->regs, DWC3_GFLADJ);
165         dft = reg & DWC3_GFLADJ_30MHZ_MASK;
166         if (!dev_WARN_ONCE(dwc->dev, dft == dwc->fladj,
167             "request value same as default, ignoring\n")) {
168                 reg &= ~DWC3_GFLADJ_30MHZ_MASK;
169                 reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | dwc->fladj;
170                 dwc3_writel(dwc->regs, DWC3_GFLADJ, reg);
171         }
172 }
173
174 /**
175  * dwc3_free_one_event_buffer - Frees one event buffer
176  * @dwc: Pointer to our controller context structure
177  * @evt: Pointer to event buffer to be freed
178  */
179 static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
180                 struct dwc3_event_buffer *evt)
181 {
182         dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma);
183 }
184
185 /**
186  * dwc3_alloc_one_event_buffer - Allocates one event buffer structure
187  * @dwc: Pointer to our controller context structure
188  * @length: size of the event buffer
189  *
190  * Returns a pointer to the allocated event buffer structure on success
191  * otherwise ERR_PTR(errno).
192  */
193 static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc,
194                 unsigned length)
195 {
196         struct dwc3_event_buffer        *evt;
197
198         evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL);
199         if (!evt)
200                 return ERR_PTR(-ENOMEM);
201
202         evt->dwc        = dwc;
203         evt->length     = length;
204         evt->buf        = dma_alloc_coherent(dwc->dev, length,
205                         &evt->dma, GFP_KERNEL);
206         if (!evt->buf)
207                 return ERR_PTR(-ENOMEM);
208
209         return evt;
210 }
211
212 /**
213  * dwc3_free_event_buffers - frees all allocated event buffers
214  * @dwc: Pointer to our controller context structure
215  */
216 static void dwc3_free_event_buffers(struct dwc3 *dwc)
217 {
218         struct dwc3_event_buffer        *evt;
219
220         evt = dwc->ev_buf;
221         if (evt)
222                 dwc3_free_one_event_buffer(dwc, evt);
223 }
224
225 /**
226  * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length
227  * @dwc: pointer to our controller context structure
228  * @length: size of event buffer
229  *
230  * Returns 0 on success otherwise negative errno. In the error case, dwc
231  * may contain some buffers allocated but not all which were requested.
232  */
233 static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
234 {
235         struct dwc3_event_buffer *evt;
236
237         evt = dwc3_alloc_one_event_buffer(dwc, length);
238         if (IS_ERR(evt)) {
239                 dev_err(dwc->dev, "can't allocate event buffer\n");
240                 return PTR_ERR(evt);
241         }
242         dwc->ev_buf = evt;
243
244         return 0;
245 }
246
247 /**
248  * dwc3_event_buffers_setup - setup our allocated event buffers
249  * @dwc: pointer to our controller context structure
250  *
251  * Returns 0 on success otherwise negative errno.
252  */
253 static int dwc3_event_buffers_setup(struct dwc3 *dwc)
254 {
255         struct dwc3_event_buffer        *evt;
256
257         evt = dwc->ev_buf;
258         dwc3_trace(trace_dwc3_core,
259                         "Event buf %p dma %08llx length %d\n",
260                         evt->buf, (unsigned long long) evt->dma,
261                         evt->length);
262
263         evt->lpos = 0;
264
265         dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0),
266                         lower_32_bits(evt->dma));
267         dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0),
268                         upper_32_bits(evt->dma));
269         dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0),
270                         DWC3_GEVNTSIZ_SIZE(evt->length));
271         dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
272
273         return 0;
274 }
275
276 static void dwc3_event_buffers_cleanup(struct dwc3 *dwc)
277 {
278         struct dwc3_event_buffer        *evt;
279
280         evt = dwc->ev_buf;
281
282         evt->lpos = 0;
283
284         dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0), 0);
285         dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), 0);
286         dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), DWC3_GEVNTSIZ_INTMASK
287                         | DWC3_GEVNTSIZ_SIZE(0));
288         dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
289 }
290
291 static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc)
292 {
293         if (!dwc->has_hibernation)
294                 return 0;
295
296         if (!dwc->nr_scratch)
297                 return 0;
298
299         dwc->scratchbuf = kmalloc_array(dwc->nr_scratch,
300                         DWC3_SCRATCHBUF_SIZE, GFP_KERNEL);
301         if (!dwc->scratchbuf)
302                 return -ENOMEM;
303
304         return 0;
305 }
306
307 static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)
308 {
309         dma_addr_t scratch_addr;
310         u32 param;
311         int ret;
312
313         if (!dwc->has_hibernation)
314                 return 0;
315
316         if (!dwc->nr_scratch)
317                 return 0;
318
319          /* should never fall here */
320         if (!WARN_ON(dwc->scratchbuf))
321                 return 0;
322
323         scratch_addr = dma_map_single(dwc->dev, dwc->scratchbuf,
324                         dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE,
325                         DMA_BIDIRECTIONAL);
326         if (dma_mapping_error(dwc->dev, scratch_addr)) {
327                 dev_err(dwc->dev, "failed to map scratch buffer\n");
328                 ret = -EFAULT;
329                 goto err0;
330         }
331
332         dwc->scratch_addr = scratch_addr;
333
334         param = lower_32_bits(scratch_addr);
335
336         ret = dwc3_send_gadget_generic_command(dwc,
337                         DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO, param);
338         if (ret < 0)
339                 goto err1;
340
341         param = upper_32_bits(scratch_addr);
342
343         ret = dwc3_send_gadget_generic_command(dwc,
344                         DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI, param);
345         if (ret < 0)
346                 goto err1;
347
348         return 0;
349
350 err1:
351         dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
352                         DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
353
354 err0:
355         return ret;
356 }
357
358 static void dwc3_free_scratch_buffers(struct dwc3 *dwc)
359 {
360         if (!dwc->has_hibernation)
361                 return;
362
363         if (!dwc->nr_scratch)
364                 return;
365
366          /* should never fall here */
367         if (!WARN_ON(dwc->scratchbuf))
368                 return;
369
370         dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
371                         DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
372         kfree(dwc->scratchbuf);
373 }
374
375 static void dwc3_core_num_eps(struct dwc3 *dwc)
376 {
377         struct dwc3_hwparams    *parms = &dwc->hwparams;
378
379         dwc->num_in_eps = DWC3_NUM_IN_EPS(parms);
380         dwc->num_out_eps = DWC3_NUM_EPS(parms) - dwc->num_in_eps;
381
382         dwc3_trace(trace_dwc3_core, "found %d IN and %d OUT endpoints",
383                         dwc->num_in_eps, dwc->num_out_eps);
384 }
385
386 static void dwc3_cache_hwparams(struct dwc3 *dwc)
387 {
388         struct dwc3_hwparams    *parms = &dwc->hwparams;
389
390         parms->hwparams0 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS0);
391         parms->hwparams1 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS1);
392         parms->hwparams2 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS2);
393         parms->hwparams3 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS3);
394         parms->hwparams4 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS4);
395         parms->hwparams5 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS5);
396         parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6);
397         parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7);
398         parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8);
399 }
400
401 /**
402  * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core
403  * @dwc: Pointer to our controller context structure
404  *
405  * Returns 0 on success. The USB PHY interfaces are configured but not
406  * initialized. The PHY interfaces and the PHYs get initialized together with
407  * the core in dwc3_core_init.
408  */
409 static int dwc3_phy_setup(struct dwc3 *dwc)
410 {
411         u32 reg;
412         int ret;
413
414         reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
415
416         /*
417          * Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY
418          * to '0' during coreConsultant configuration. So default value
419          * will be '0' when the core is reset. Application needs to set it
420          * to '1' after the core initialization is completed.
421          */
422         if (dwc->revision > DWC3_REVISION_194A)
423                 reg |= DWC3_GUSB3PIPECTL_SUSPHY;
424
425         if (dwc->u2ss_inp3_quirk)
426                 reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
427
428         if (dwc->dis_rxdet_inp3_quirk)
429                 reg |= DWC3_GUSB3PIPECTL_DISRXDETINP3;
430
431         if (dwc->req_p1p2p3_quirk)
432                 reg |= DWC3_GUSB3PIPECTL_REQP1P2P3;
433
434         if (dwc->del_p1p2p3_quirk)
435                 reg |= DWC3_GUSB3PIPECTL_DEP1P2P3_EN;
436
437         if (dwc->del_phy_power_chg_quirk)
438                 reg |= DWC3_GUSB3PIPECTL_DEPOCHANGE;
439
440         if (dwc->lfps_filter_quirk)
441                 reg |= DWC3_GUSB3PIPECTL_LFPSFILT;
442
443         if (dwc->rx_detect_poll_quirk)
444                 reg |= DWC3_GUSB3PIPECTL_RX_DETOPOLL;
445
446         if (dwc->tx_de_emphasis_quirk)
447                 reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis);
448
449         if (dwc->dis_u3_susphy_quirk)
450                 reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
451
452         dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
453
454         reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
455
456         /* Select the HS PHY interface */
457         switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) {
458         case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
459                 if (dwc->hsphy_interface &&
460                                 !strncmp(dwc->hsphy_interface, "utmi", 4)) {
461                         reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
462                         break;
463                 } else if (dwc->hsphy_interface &&
464                                 !strncmp(dwc->hsphy_interface, "ulpi", 4)) {
465                         reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
466                         dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
467                 } else {
468                         /* Relying on default value. */
469                         if (!(reg & DWC3_GUSB2PHYCFG_ULPI_UTMI))
470                                 break;
471                 }
472                 /* FALLTHROUGH */
473         case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI:
474                 /* Making sure the interface and PHY are operational */
475                 ret = dwc3_soft_reset(dwc);
476                 if (ret)
477                         return ret;
478
479                 udelay(1);
480
481                 ret = dwc3_ulpi_init(dwc);
482                 if (ret)
483                         return ret;
484                 /* FALLTHROUGH */
485         default:
486                 break;
487         }
488
489         /*
490          * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to
491          * '0' during coreConsultant configuration. So default value will
492          * be '0' when the core is reset. Application needs to set it to
493          * '1' after the core initialization is completed.
494          */
495         if (dwc->revision > DWC3_REVISION_194A)
496                 reg |= DWC3_GUSB2PHYCFG_SUSPHY;
497
498         if (dwc->dis_u2_susphy_quirk)
499                 reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
500
501         if (dwc->dis_enblslpm_quirk)
502                 reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
503
504         dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
505
506         return 0;
507 }
508
509 /**
510  * dwc3_core_init - Low-level initialization of DWC3 Core
511  * @dwc: Pointer to our controller context structure
512  *
513  * Returns 0 on success otherwise negative errno.
514  */
515 static int dwc3_core_init(struct dwc3 *dwc)
516 {
517         u32                     hwparams4 = dwc->hwparams.hwparams4;
518         u32                     reg;
519         int                     ret;
520
521         reg = dwc3_readl(dwc->regs, DWC3_GSNPSID);
522         /* This should read as U3 followed by revision number */
523         if ((reg & DWC3_GSNPSID_MASK) == 0x55330000) {
524                 /* Detected DWC_usb3 IP */
525                 dwc->revision = reg;
526         } else if ((reg & DWC3_GSNPSID_MASK) == 0x33310000) {
527                 /* Detected DWC_usb31 IP */
528                 dwc->revision = dwc3_readl(dwc->regs, DWC3_VER_NUMBER);
529                 dwc->revision |= DWC3_REVISION_IS_DWC31;
530         } else {
531                 dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n");
532                 ret = -ENODEV;
533                 goto err0;
534         }
535
536         /*
537          * Write Linux Version Code to our GUID register so it's easy to figure
538          * out which kernel version a bug was found.
539          */
540         dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE);
541
542         /* Handle USB2.0-only core configuration */
543         if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
544                         DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
545                 if (dwc->maximum_speed == USB_SPEED_SUPER)
546                         dwc->maximum_speed = USB_SPEED_HIGH;
547         }
548
549         /* issue device SoftReset too */
550         ret = dwc3_soft_reset(dwc);
551         if (ret)
552                 goto err0;
553
554         ret = dwc3_core_soft_reset(dwc);
555         if (ret)
556                 goto err0;
557
558         reg = dwc3_readl(dwc->regs, DWC3_GCTL);
559         reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
560
561         switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
562         case DWC3_GHWPARAMS1_EN_PWROPT_CLK:
563                 /**
564                  * WORKAROUND: DWC3 revisions between 2.10a and 2.50a have an
565                  * issue which would cause xHCI compliance tests to fail.
566                  *
567                  * Because of that we cannot enable clock gating on such
568                  * configurations.
569                  *
570                  * Refers to:
571                  *
572                  * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based
573                  * SOF/ITP Mode Used
574                  */
575                 if ((dwc->dr_mode == USB_DR_MODE_HOST ||
576                                 dwc->dr_mode == USB_DR_MODE_OTG) &&
577                                 (dwc->revision >= DWC3_REVISION_210A &&
578                                 dwc->revision <= DWC3_REVISION_250A))
579                         reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
580                 else
581                         reg &= ~DWC3_GCTL_DSBLCLKGTNG;
582                 break;
583         case DWC3_GHWPARAMS1_EN_PWROPT_HIB:
584                 /* enable hibernation here */
585                 dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4);
586
587                 /*
588                  * REVISIT Enabling this bit so that host-mode hibernation
589                  * will work. Device-mode hibernation is not yet implemented.
590                  */
591                 reg |= DWC3_GCTL_GBLHIBERNATIONEN;
592                 break;
593         default:
594                 dwc3_trace(trace_dwc3_core, "No power optimization available\n");
595         }
596
597         /* check if current dwc3 is on simulation board */
598         if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) {
599                 dwc3_trace(trace_dwc3_core,
600                                 "running on FPGA platform\n");
601                 dwc->is_fpga = true;
602         }
603
604         WARN_ONCE(dwc->disable_scramble_quirk && !dwc->is_fpga,
605                         "disable_scramble cannot be used on non-FPGA builds\n");
606
607         if (dwc->disable_scramble_quirk && dwc->is_fpga)
608                 reg |= DWC3_GCTL_DISSCRAMBLE;
609         else
610                 reg &= ~DWC3_GCTL_DISSCRAMBLE;
611
612         if (dwc->u2exit_lfps_quirk)
613                 reg |= DWC3_GCTL_U2EXIT_LFPS;
614
615         /*
616          * WORKAROUND: DWC3 revisions <1.90a have a bug
617          * where the device can fail to connect at SuperSpeed
618          * and falls back to high-speed mode which causes
619          * the device to enter a Connect/Disconnect loop
620          */
621         if (dwc->revision < DWC3_REVISION_190A)
622                 reg |= DWC3_GCTL_U2RSTECN;
623
624         dwc3_core_num_eps(dwc);
625
626         dwc3_writel(dwc->regs, DWC3_GCTL, reg);
627
628         ret = dwc3_alloc_scratch_buffers(dwc);
629         if (ret)
630                 goto err1;
631
632         ret = dwc3_setup_scratch_buffers(dwc);
633         if (ret)
634                 goto err2;
635
636         return 0;
637
638 err2:
639         dwc3_free_scratch_buffers(dwc);
640
641 err1:
642         usb_phy_shutdown(dwc->usb2_phy);
643         usb_phy_shutdown(dwc->usb3_phy);
644         phy_exit(dwc->usb2_generic_phy);
645         phy_exit(dwc->usb3_generic_phy);
646
647 err0:
648         return ret;
649 }
650
651 static void dwc3_core_exit(struct dwc3 *dwc)
652 {
653         dwc3_free_scratch_buffers(dwc);
654         usb_phy_shutdown(dwc->usb2_phy);
655         usb_phy_shutdown(dwc->usb3_phy);
656         phy_exit(dwc->usb2_generic_phy);
657         phy_exit(dwc->usb3_generic_phy);
658 }
659
660 static int dwc3_core_get_phy(struct dwc3 *dwc)
661 {
662         struct device           *dev = dwc->dev;
663         struct device_node      *node = dev->of_node;
664         int ret;
665
666         if (node) {
667                 dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0);
668                 dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1);
669         } else {
670                 dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
671                 dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
672         }
673
674         if (IS_ERR(dwc->usb2_phy)) {
675                 ret = PTR_ERR(dwc->usb2_phy);
676                 if (ret == -ENXIO || ret == -ENODEV) {
677                         dwc->usb2_phy = NULL;
678                 } else if (ret == -EPROBE_DEFER) {
679                         return ret;
680                 } else {
681                         dev_err(dev, "no usb2 phy configured\n");
682                         return ret;
683                 }
684         }
685
686         if (IS_ERR(dwc->usb3_phy)) {
687                 ret = PTR_ERR(dwc->usb3_phy);
688                 if (ret == -ENXIO || ret == -ENODEV) {
689                         dwc->usb3_phy = NULL;
690                 } else if (ret == -EPROBE_DEFER) {
691                         return ret;
692                 } else {
693                         dev_err(dev, "no usb3 phy configured\n");
694                         return ret;
695                 }
696         }
697
698         dwc->usb2_generic_phy = devm_phy_get(dev, "usb2-phy");
699         if (IS_ERR(dwc->usb2_generic_phy)) {
700                 ret = PTR_ERR(dwc->usb2_generic_phy);
701                 if (ret == -ENOSYS || ret == -ENODEV) {
702                         dwc->usb2_generic_phy = NULL;
703                 } else if (ret == -EPROBE_DEFER) {
704                         return ret;
705                 } else {
706                         dev_err(dev, "no usb2 phy configured\n");
707                         return ret;
708                 }
709         }
710
711         dwc->usb3_generic_phy = devm_phy_get(dev, "usb3-phy");
712         if (IS_ERR(dwc->usb3_generic_phy)) {
713                 ret = PTR_ERR(dwc->usb3_generic_phy);
714                 if (ret == -ENOSYS || ret == -ENODEV) {
715                         dwc->usb3_generic_phy = NULL;
716                 } else if (ret == -EPROBE_DEFER) {
717                         return ret;
718                 } else {
719                         dev_err(dev, "no usb3 phy configured\n");
720                         return ret;
721                 }
722         }
723
724         return 0;
725 }
726
727 static int dwc3_core_init_mode(struct dwc3 *dwc)
728 {
729         struct device *dev = dwc->dev;
730         int ret;
731
732         switch (dwc->dr_mode) {
733         case USB_DR_MODE_PERIPHERAL:
734                 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
735                 ret = dwc3_gadget_init(dwc);
736                 if (ret) {
737                         dev_err(dev, "failed to initialize gadget\n");
738                         return ret;
739                 }
740                 break;
741         case USB_DR_MODE_HOST:
742                 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
743                 ret = dwc3_host_init(dwc);
744                 if (ret) {
745                         dev_err(dev, "failed to initialize host\n");
746                         return ret;
747                 }
748                 break;
749         case USB_DR_MODE_OTG:
750                 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
751                 ret = dwc3_host_init(dwc);
752                 if (ret) {
753                         dev_err(dev, "failed to initialize host\n");
754                         return ret;
755                 }
756
757                 ret = dwc3_gadget_init(dwc);
758                 if (ret) {
759                         dev_err(dev, "failed to initialize gadget\n");
760                         return ret;
761                 }
762                 break;
763         default:
764                 dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode);
765                 return -EINVAL;
766         }
767
768         return 0;
769 }
770
771 static void dwc3_core_exit_mode(struct dwc3 *dwc)
772 {
773         switch (dwc->dr_mode) {
774         case USB_DR_MODE_PERIPHERAL:
775                 dwc3_gadget_exit(dwc);
776                 break;
777         case USB_DR_MODE_HOST:
778                 dwc3_host_exit(dwc);
779                 break;
780         case USB_DR_MODE_OTG:
781                 dwc3_host_exit(dwc);
782                 dwc3_gadget_exit(dwc);
783                 break;
784         default:
785                 /* do nothing */
786                 break;
787         }
788 }
789
790 #define DWC3_ALIGN_MASK         (16 - 1)
791
792 static int dwc3_probe(struct platform_device *pdev)
793 {
794         struct device           *dev = &pdev->dev;
795         struct dwc3_platform_data *pdata = dev_get_platdata(dev);
796         struct resource         *res;
797         struct dwc3             *dwc;
798         u8                      lpm_nyet_threshold;
799         u8                      tx_de_emphasis;
800         u8                      hird_threshold;
801
802         int                     ret;
803
804         void __iomem            *regs;
805         void                    *mem;
806
807         mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL);
808         if (!mem)
809                 return -ENOMEM;
810
811         dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1);
812         dwc->mem = mem;
813         dwc->dev = dev;
814
815         /* Try to set 64-bit DMA first */
816         if (!pdev->dev.dma_mask)
817                 /* Platform did not initialize dma_mask */
818                 ret = dma_coerce_mask_and_coherent(&pdev->dev,
819                                                    DMA_BIT_MASK(64));
820         else
821                 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
822
823         /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
824         if (ret) {
825                 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
826                 if (ret)
827                         return ret;
828         }
829
830         res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
831         if (!res) {
832                 dev_err(dev, "missing IRQ\n");
833                 return -ENODEV;
834         }
835         dwc->xhci_resources[1].start = res->start;
836         dwc->xhci_resources[1].end = res->end;
837         dwc->xhci_resources[1].flags = res->flags;
838         dwc->xhci_resources[1].name = res->name;
839
840         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
841         if (!res) {
842                 dev_err(dev, "missing memory resource\n");
843                 return -ENODEV;
844         }
845
846         dwc->xhci_resources[0].start = res->start;
847         dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
848                                         DWC3_XHCI_REGS_END;
849         dwc->xhci_resources[0].flags = res->flags;
850         dwc->xhci_resources[0].name = res->name;
851
852         res->start += DWC3_GLOBALS_REGS_START;
853
854         /*
855          * Request memory region but exclude xHCI regs,
856          * since it will be requested by the xhci-plat driver.
857          */
858         regs = devm_ioremap_resource(dev, res);
859         if (IS_ERR(regs)) {
860                 ret = PTR_ERR(regs);
861                 goto err0;
862         }
863
864         dwc->regs       = regs;
865         dwc->regs_size  = resource_size(res);
866
867         /* default to highest possible threshold */
868         lpm_nyet_threshold = 0xff;
869
870         /* default to -3.5dB de-emphasis */
871         tx_de_emphasis = 1;
872
873         /*
874          * default to assert utmi_sleep_n and use maximum allowed HIRD
875          * threshold value of 0b1100
876          */
877         hird_threshold = 12;
878
879         dwc->maximum_speed = usb_get_maximum_speed(dev);
880         dwc->dr_mode = usb_get_dr_mode(dev);
881
882         dwc->has_lpm_erratum = device_property_read_bool(dev,
883                                 "snps,has-lpm-erratum");
884         device_property_read_u8(dev, "snps,lpm-nyet-threshold",
885                                 &lpm_nyet_threshold);
886         dwc->is_utmi_l1_suspend = device_property_read_bool(dev,
887                                 "snps,is-utmi-l1-suspend");
888         device_property_read_u8(dev, "snps,hird-threshold",
889                                 &hird_threshold);
890         dwc->usb3_lpm_capable = device_property_read_bool(dev,
891                                 "snps,usb3_lpm_capable");
892
893         dwc->disable_scramble_quirk = device_property_read_bool(dev,
894                                 "snps,disable_scramble_quirk");
895         dwc->u2exit_lfps_quirk = device_property_read_bool(dev,
896                                 "snps,u2exit_lfps_quirk");
897         dwc->u2ss_inp3_quirk = device_property_read_bool(dev,
898                                 "snps,u2ss_inp3_quirk");
899         dwc->req_p1p2p3_quirk = device_property_read_bool(dev,
900                                 "snps,req_p1p2p3_quirk");
901         dwc->del_p1p2p3_quirk = device_property_read_bool(dev,
902                                 "snps,del_p1p2p3_quirk");
903         dwc->del_phy_power_chg_quirk = device_property_read_bool(dev,
904                                 "snps,del_phy_power_chg_quirk");
905         dwc->lfps_filter_quirk = device_property_read_bool(dev,
906                                 "snps,lfps_filter_quirk");
907         dwc->rx_detect_poll_quirk = device_property_read_bool(dev,
908                                 "snps,rx_detect_poll_quirk");
909         dwc->dis_u3_susphy_quirk = device_property_read_bool(dev,
910                                 "snps,dis_u3_susphy_quirk");
911         dwc->dis_u2_susphy_quirk = device_property_read_bool(dev,
912                                 "snps,dis_u2_susphy_quirk");
913         dwc->dis_enblslpm_quirk = device_property_read_bool(dev,
914                                 "snps,dis_enblslpm_quirk");
915         dwc->dis_rxdet_inp3_quirk = device_property_read_bool(dev,
916                                 "snps,dis_rxdet_inp3_quirk");
917
918         dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
919                                 "snps,tx_de_emphasis_quirk");
920         device_property_read_u8(dev, "snps,tx_de_emphasis",
921                                 &tx_de_emphasis);
922         device_property_read_string(dev, "snps,hsphy_interface",
923                                     &dwc->hsphy_interface);
924         device_property_read_u32(dev, "snps,quirk-frame-length-adjustment",
925                                  &dwc->fladj);
926
927         if (pdata) {
928                 dwc->maximum_speed = pdata->maximum_speed;
929                 dwc->has_lpm_erratum = pdata->has_lpm_erratum;
930                 if (pdata->lpm_nyet_threshold)
931                         lpm_nyet_threshold = pdata->lpm_nyet_threshold;
932                 dwc->is_utmi_l1_suspend = pdata->is_utmi_l1_suspend;
933                 if (pdata->hird_threshold)
934                         hird_threshold = pdata->hird_threshold;
935
936                 dwc->usb3_lpm_capable = pdata->usb3_lpm_capable;
937                 dwc->dr_mode = pdata->dr_mode;
938
939                 dwc->disable_scramble_quirk = pdata->disable_scramble_quirk;
940                 dwc->u2exit_lfps_quirk = pdata->u2exit_lfps_quirk;
941                 dwc->u2ss_inp3_quirk = pdata->u2ss_inp3_quirk;
942                 dwc->req_p1p2p3_quirk = pdata->req_p1p2p3_quirk;
943                 dwc->del_p1p2p3_quirk = pdata->del_p1p2p3_quirk;
944                 dwc->del_phy_power_chg_quirk = pdata->del_phy_power_chg_quirk;
945                 dwc->lfps_filter_quirk = pdata->lfps_filter_quirk;
946                 dwc->rx_detect_poll_quirk = pdata->rx_detect_poll_quirk;
947                 dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk;
948                 dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk;
949                 dwc->dis_enblslpm_quirk = pdata->dis_enblslpm_quirk;
950                 dwc->dis_rxdet_inp3_quirk = pdata->dis_rxdet_inp3_quirk;
951
952                 dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;
953                 if (pdata->tx_de_emphasis)
954                         tx_de_emphasis = pdata->tx_de_emphasis;
955
956                 dwc->hsphy_interface = pdata->hsphy_interface;
957                 dwc->fladj = pdata->fladj_value;
958         }
959
960         /* default to superspeed if no maximum_speed passed */
961         if (dwc->maximum_speed == USB_SPEED_UNKNOWN)
962                 dwc->maximum_speed = USB_SPEED_SUPER;
963
964         dwc->lpm_nyet_threshold = lpm_nyet_threshold;
965         dwc->tx_de_emphasis = tx_de_emphasis;
966
967         dwc->hird_threshold = hird_threshold
968                 | (dwc->is_utmi_l1_suspend << 4);
969
970         platform_set_drvdata(pdev, dwc);
971         dwc3_cache_hwparams(dwc);
972
973         ret = dwc3_phy_setup(dwc);
974         if (ret)
975                 goto err0;
976
977         ret = dwc3_core_get_phy(dwc);
978         if (ret)
979                 goto err0;
980
981         spin_lock_init(&dwc->lock);
982
983         if (!dev->dma_mask) {
984                 dev->dma_mask = dev->parent->dma_mask;
985                 dev->dma_parms = dev->parent->dma_parms;
986                 dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask);
987         }
988
989         pm_runtime_enable(dev);
990         pm_runtime_get_sync(dev);
991         pm_runtime_forbid(dev);
992
993         ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
994         if (ret) {
995                 dev_err(dwc->dev, "failed to allocate event buffers\n");
996                 ret = -ENOMEM;
997                 goto err1;
998         }
999
1000         if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
1001                 dwc->dr_mode = USB_DR_MODE_HOST;
1002         else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
1003                 dwc->dr_mode = USB_DR_MODE_PERIPHERAL;
1004
1005         if (dwc->dr_mode == USB_DR_MODE_UNKNOWN)
1006                 dwc->dr_mode = USB_DR_MODE_OTG;
1007
1008         ret = dwc3_core_init(dwc);
1009         if (ret) {
1010                 dev_err(dev, "failed to initialize core\n");
1011                 goto err1;
1012         }
1013
1014         /* Adjust Frame Length */
1015         dwc3_frame_length_adjustment(dwc);
1016
1017         usb_phy_set_suspend(dwc->usb2_phy, 0);
1018         usb_phy_set_suspend(dwc->usb3_phy, 0);
1019         ret = phy_power_on(dwc->usb2_generic_phy);
1020         if (ret < 0)
1021                 goto err2;
1022
1023         ret = phy_power_on(dwc->usb3_generic_phy);
1024         if (ret < 0)
1025                 goto err3;
1026
1027         ret = dwc3_event_buffers_setup(dwc);
1028         if (ret) {
1029                 dev_err(dwc->dev, "failed to setup event buffers\n");
1030                 goto err4;
1031         }
1032
1033         ret = dwc3_core_init_mode(dwc);
1034         if (ret)
1035                 goto err5;
1036
1037         dwc3_debugfs_init(dwc);
1038         pm_runtime_allow(dev);
1039
1040         return 0;
1041
1042 err5:
1043         dwc3_event_buffers_cleanup(dwc);
1044
1045 err4:
1046         phy_power_off(dwc->usb3_generic_phy);
1047
1048 err3:
1049         phy_power_off(dwc->usb2_generic_phy);
1050
1051 err2:
1052         usb_phy_set_suspend(dwc->usb2_phy, 1);
1053         usb_phy_set_suspend(dwc->usb3_phy, 1);
1054         dwc3_core_exit(dwc);
1055
1056 err1:
1057         dwc3_free_event_buffers(dwc);
1058         dwc3_ulpi_exit(dwc);
1059
1060 err0:
1061         /*
1062          * restore res->start back to its original value so that, in case the
1063          * probe is deferred, we don't end up getting error in request the
1064          * memory region the next time probe is called.
1065          */
1066         res->start -= DWC3_GLOBALS_REGS_START;
1067
1068         return ret;
1069 }
1070
1071 static int dwc3_remove(struct platform_device *pdev)
1072 {
1073         struct dwc3     *dwc = platform_get_drvdata(pdev);
1074         struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1075
1076         /*
1077          * restore res->start back to its original value so that, in case the
1078          * probe is deferred, we don't end up getting error in request the
1079          * memory region the next time probe is called.
1080          */
1081         res->start -= DWC3_GLOBALS_REGS_START;
1082
1083         dwc3_debugfs_exit(dwc);
1084         dwc3_core_exit_mode(dwc);
1085         dwc3_event_buffers_cleanup(dwc);
1086         dwc3_free_event_buffers(dwc);
1087
1088         usb_phy_set_suspend(dwc->usb2_phy, 1);
1089         usb_phy_set_suspend(dwc->usb3_phy, 1);
1090         phy_power_off(dwc->usb2_generic_phy);
1091         phy_power_off(dwc->usb3_generic_phy);
1092
1093         dwc3_core_exit(dwc);
1094         dwc3_ulpi_exit(dwc);
1095
1096         pm_runtime_put_sync(&pdev->dev);
1097         pm_runtime_disable(&pdev->dev);
1098
1099         return 0;
1100 }
1101
1102 #ifdef CONFIG_PM_SLEEP
1103 static int dwc3_suspend(struct device *dev)
1104 {
1105         struct dwc3     *dwc = dev_get_drvdata(dev);
1106         unsigned long   flags;
1107
1108         spin_lock_irqsave(&dwc->lock, flags);
1109
1110         switch (dwc->dr_mode) {
1111         case USB_DR_MODE_PERIPHERAL:
1112         case USB_DR_MODE_OTG:
1113                 dwc3_gadget_suspend(dwc);
1114                 /* FALLTHROUGH */
1115         case USB_DR_MODE_HOST:
1116         default:
1117                 dwc3_event_buffers_cleanup(dwc);
1118                 break;
1119         }
1120
1121         dwc->gctl = dwc3_readl(dwc->regs, DWC3_GCTL);
1122         spin_unlock_irqrestore(&dwc->lock, flags);
1123
1124         usb_phy_shutdown(dwc->usb3_phy);
1125         usb_phy_shutdown(dwc->usb2_phy);
1126         phy_exit(dwc->usb2_generic_phy);
1127         phy_exit(dwc->usb3_generic_phy);
1128
1129         usb_phy_set_suspend(dwc->usb2_phy, 1);
1130         usb_phy_set_suspend(dwc->usb3_phy, 1);
1131         WARN_ON(phy_power_off(dwc->usb2_generic_phy) < 0);
1132         WARN_ON(phy_power_off(dwc->usb3_generic_phy) < 0);
1133
1134         pinctrl_pm_select_sleep_state(dev);
1135
1136         return 0;
1137 }
1138
1139 static int dwc3_resume(struct device *dev)
1140 {
1141         struct dwc3     *dwc = dev_get_drvdata(dev);
1142         unsigned long   flags;
1143         int             ret;
1144
1145         pinctrl_pm_select_default_state(dev);
1146
1147         usb_phy_set_suspend(dwc->usb2_phy, 0);
1148         usb_phy_set_suspend(dwc->usb3_phy, 0);
1149         ret = phy_power_on(dwc->usb2_generic_phy);
1150         if (ret < 0)
1151                 return ret;
1152
1153         ret = phy_power_on(dwc->usb3_generic_phy);
1154         if (ret < 0)
1155                 goto err_usb2phy_power;
1156
1157         usb_phy_init(dwc->usb3_phy);
1158         usb_phy_init(dwc->usb2_phy);
1159         ret = phy_init(dwc->usb2_generic_phy);
1160         if (ret < 0)
1161                 goto err_usb3phy_power;
1162
1163         ret = phy_init(dwc->usb3_generic_phy);
1164         if (ret < 0)
1165                 goto err_usb2phy_init;
1166
1167         spin_lock_irqsave(&dwc->lock, flags);
1168
1169         dwc3_event_buffers_setup(dwc);
1170         dwc3_writel(dwc->regs, DWC3_GCTL, dwc->gctl);
1171
1172         switch (dwc->dr_mode) {
1173         case USB_DR_MODE_PERIPHERAL:
1174         case USB_DR_MODE_OTG:
1175                 dwc3_gadget_resume(dwc);
1176                 /* FALLTHROUGH */
1177         case USB_DR_MODE_HOST:
1178         default:
1179                 /* do nothing */
1180                 break;
1181         }
1182
1183         spin_unlock_irqrestore(&dwc->lock, flags);
1184
1185         pm_runtime_disable(dev);
1186         pm_runtime_set_active(dev);
1187         pm_runtime_enable(dev);
1188
1189         return 0;
1190
1191 err_usb2phy_init:
1192         phy_exit(dwc->usb2_generic_phy);
1193
1194 err_usb3phy_power:
1195         phy_power_off(dwc->usb3_generic_phy);
1196
1197 err_usb2phy_power:
1198         phy_power_off(dwc->usb2_generic_phy);
1199
1200         return ret;
1201 }
1202 #endif /* CONFIG_PM_SLEEP */
1203
1204 static const struct dev_pm_ops dwc3_dev_pm_ops = {
1205         SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume)
1206 };
1207
1208 #ifdef CONFIG_OF
1209 static const struct of_device_id of_dwc3_match[] = {
1210         {
1211                 .compatible = "snps,dwc3"
1212         },
1213         {
1214                 .compatible = "synopsys,dwc3"
1215         },
1216         { },
1217 };
1218 MODULE_DEVICE_TABLE(of, of_dwc3_match);
1219 #endif
1220
1221 #ifdef CONFIG_ACPI
1222
1223 #define ACPI_ID_INTEL_BSW       "808622B7"
1224
1225 static const struct acpi_device_id dwc3_acpi_match[] = {
1226         { ACPI_ID_INTEL_BSW, 0 },
1227         { },
1228 };
1229 MODULE_DEVICE_TABLE(acpi, dwc3_acpi_match);
1230 #endif
1231
1232 static struct platform_driver dwc3_driver = {
1233         .probe          = dwc3_probe,
1234         .remove         = dwc3_remove,
1235         .driver         = {
1236                 .name   = "dwc3",
1237                 .of_match_table = of_match_ptr(of_dwc3_match),
1238                 .acpi_match_table = ACPI_PTR(dwc3_acpi_match),
1239                 .pm     = &dwc3_dev_pm_ops,
1240         },
1241 };
1242
1243 module_platform_driver(dwc3_driver);
1244
1245 MODULE_ALIAS("platform:dwc3");
1246 MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
1247 MODULE_LICENSE("GPL v2");
1248 MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");