blob: 22b4797383cd0021953b58e1f8d60178eeb89389 [file] [log] [blame]
Felipe Balbi72246da2011-08-19 18:10:58 +03001/**
2 * core.c - DesignWare USB3 DRD Controller Core file
3 *
4 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
Felipe Balbi72246da2011-08-19 18:10:58 +03005 *
6 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *
Felipe Balbi5945f782013-06-30 14:15:11 +03009 * 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 Balbi72246da2011-08-19 18:10:58 +030012 *
Felipe Balbi5945f782013-06-30 14:15:11 +030013 * 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 Balbi72246da2011-08-19 18:10:58 +030017 *
Felipe Balbi5945f782013-06-30 14:15:11 +030018 * 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 Balbi72246da2011-08-19 18:10:58 +030020 */
21
Felipe Balbifa0ea132014-09-19 15:51:11 -050022#include <linux/version.h>
Felipe Balbia72e6582011-09-05 13:37:28 +030023#include <linux/module.h>
Felipe Balbi72246da2011-08-19 18:10:58 +030024#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 Balbi457e84b2012-01-18 18:04:09 +020035#include <linux/of.h>
Heikki Krogerus404905a2014-09-25 10:57:02 +030036#include <linux/acpi.h>
Sekhar Nori63444752015-08-31 21:09:08 +053037#include <linux/pinctrl/consumer.h>
Felipe Balbi72246da2011-08-19 18:10:58 +030038
39#include <linux/usb/ch9.h>
40#include <linux/usb/gadget.h>
Felipe Balbif7e846f2013-06-30 14:29:51 +030041#include <linux/usb/of.h>
Ruchika Kharwara45c82b82013-07-06 07:52:49 -050042#include <linux/usb/otg.h>
Felipe Balbi72246da2011-08-19 18:10:58 +030043
Felipe Balbi6462cbd2013-06-30 14:19:33 +030044#include "platform_data.h"
Felipe Balbi72246da2011-08-19 18:10:58 +030045#include "core.h"
46#include "gadget.h"
47#include "io.h"
48
49#include "debug.h"
50
Felipe Balbi8300dd22011-10-18 13:54:01 +030051/* -------------------------------------------------------------------------- */
52
Sebastian Andrzej Siewior3140e8c2011-10-31 22:25:40 +010053void 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}
Felipe Balbi8300dd22011-10-18 13:54:01 +030062
Felipe Balbi72246da2011-08-19 18:10:58 +030063/**
64 * dwc3_core_soft_reset - Issues core soft reset and PHY reset
65 * @dwc: pointer to our context structure
66 */
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +053067static int dwc3_core_soft_reset(struct dwc3 *dwc)
Felipe Balbi72246da2011-08-19 18:10:58 +030068{
69 u32 reg;
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +053070 int ret;
Felipe Balbi72246da2011-08-19 18:10:58 +030071
72 /* Before Resetting PHY, put Core in Reset */
73 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
74 reg |= DWC3_GCTL_CORESOFTRESET;
75 dwc3_writel(dwc->regs, DWC3_GCTL, reg);
76
77 /* Assert USB3 PHY reset */
78 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
79 reg |= DWC3_GUSB3PIPECTL_PHYSOFTRST;
80 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
81
82 /* Assert USB2 PHY reset */
83 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
84 reg |= DWC3_GUSB2PHYCFG_PHYSOFTRST;
85 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
86
Felipe Balbi51e1e7b2012-07-19 14:09:48 +030087 usb_phy_init(dwc->usb2_phy);
88 usb_phy_init(dwc->usb3_phy);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +053089 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 }
Felipe Balbi72246da2011-08-19 18:10:58 +030098 mdelay(100);
99
100 /* Clear USB3 PHY reset */
101 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
102 reg &= ~DWC3_GUSB3PIPECTL_PHYSOFTRST;
103 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
104
105 /* Clear USB2 PHY reset */
106 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
107 reg &= ~DWC3_GUSB2PHYCFG_PHYSOFTRST;
108 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
109
Pratyush Anand45627ac2012-06-21 17:44:28 +0530110 mdelay(100);
111
Felipe Balbi72246da2011-08-19 18:10:58 +0300112 /* After PHYs are stable we can take Core out of reset state */
113 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
114 reg &= ~DWC3_GCTL_CORESOFTRESET;
115 dwc3_writel(dwc->regs, DWC3_GCTL, reg);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +0530116
117 return 0;
Felipe Balbi72246da2011-08-19 18:10:58 +0300118}
119
120/**
Heikki Krogerusc5cc74e2015-05-13 15:26:47 +0300121 * dwc3_soft_reset - Issue soft reset
122 * @dwc: Pointer to our controller context structure
123 */
124static int dwc3_soft_reset(struct dwc3 *dwc)
125{
126 unsigned long timeout;
127 u32 reg;
128
129 timeout = jiffies + msecs_to_jiffies(500);
130 dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
131 do {
132 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
133 if (!(reg & DWC3_DCTL_CSFTRST))
134 break;
135
136 if (time_after(jiffies, timeout)) {
137 dev_err(dwc->dev, "Reset Timed Out\n");
138 return -ETIMEDOUT;
139 }
140
141 cpu_relax();
142 } while (true);
143
144 return 0;
145}
146
Nikhil Badoladb2be4e2015-09-04 10:15:58 +0530147/*
148 * dwc3_frame_length_adjustment - Adjusts frame length if required
149 * @dwc3: Pointer to our controller context structure
150 * @fladj: Value of GFLADJ_30MHZ to adjust frame length
151 */
152static void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj)
153{
154 u32 reg;
155 u32 dft;
156
157 if (dwc->revision < DWC3_REVISION_250A)
158 return;
159
160 if (fladj == 0)
161 return;
162
163 reg = dwc3_readl(dwc->regs, DWC3_GFLADJ);
164 dft = reg & DWC3_GFLADJ_30MHZ_MASK;
165 if (!dev_WARN_ONCE(dwc->dev, dft == fladj,
166 "request value same as default, ignoring\n")) {
167 reg &= ~DWC3_GFLADJ_30MHZ_MASK;
168 reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | fladj;
169 dwc3_writel(dwc->regs, DWC3_GFLADJ, reg);
170 }
171}
172
Heikki Krogerusc5cc74e2015-05-13 15:26:47 +0300173/**
Felipe Balbi72246da2011-08-19 18:10:58 +0300174 * dwc3_free_one_event_buffer - Frees one event buffer
175 * @dwc: Pointer to our controller context structure
176 * @evt: Pointer to event buffer to be freed
177 */
178static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
179 struct dwc3_event_buffer *evt)
180{
181 dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma);
Felipe Balbi72246da2011-08-19 18:10:58 +0300182}
183
184/**
Paul Zimmerman1d046792012-02-15 18:56:56 -0800185 * dwc3_alloc_one_event_buffer - Allocates one event buffer structure
Felipe Balbi72246da2011-08-19 18:10:58 +0300186 * @dwc: Pointer to our controller context structure
187 * @length: size of the event buffer
188 *
Paul Zimmerman1d046792012-02-15 18:56:56 -0800189 * Returns a pointer to the allocated event buffer structure on success
Felipe Balbi72246da2011-08-19 18:10:58 +0300190 * otherwise ERR_PTR(errno).
191 */
Felipe Balbi67d0b502013-02-22 16:31:07 +0200192static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc,
193 unsigned length)
Felipe Balbi72246da2011-08-19 18:10:58 +0300194{
195 struct dwc3_event_buffer *evt;
196
Felipe Balbi380f0d22012-10-11 13:48:36 +0300197 evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL);
Felipe Balbi72246da2011-08-19 18:10:58 +0300198 if (!evt)
199 return ERR_PTR(-ENOMEM);
200
201 evt->dwc = dwc;
202 evt->length = length;
203 evt->buf = dma_alloc_coherent(dwc->dev, length,
204 &evt->dma, GFP_KERNEL);
Felipe Balbie32672f2012-11-08 15:26:41 +0200205 if (!evt->buf)
Felipe Balbi72246da2011-08-19 18:10:58 +0300206 return ERR_PTR(-ENOMEM);
Felipe Balbi72246da2011-08-19 18:10:58 +0300207
208 return evt;
209}
210
211/**
212 * dwc3_free_event_buffers - frees all allocated event buffers
213 * @dwc: Pointer to our controller context structure
214 */
215static void dwc3_free_event_buffers(struct dwc3 *dwc)
216{
217 struct dwc3_event_buffer *evt;
218 int i;
219
Felipe Balbi9f622b22011-10-12 10:31:04 +0300220 for (i = 0; i < dwc->num_event_buffers; i++) {
Felipe Balbi72246da2011-08-19 18:10:58 +0300221 evt = dwc->ev_buffs[i];
Anton Tikhomirov64b6c8a2012-03-06 17:05:15 +0900222 if (evt)
Felipe Balbi72246da2011-08-19 18:10:58 +0300223 dwc3_free_one_event_buffer(dwc, evt);
Felipe Balbi72246da2011-08-19 18:10:58 +0300224 }
225}
226
227/**
228 * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length
Paul Zimmerman1d046792012-02-15 18:56:56 -0800229 * @dwc: pointer to our controller context structure
Felipe Balbi72246da2011-08-19 18:10:58 +0300230 * @length: size of event buffer
231 *
Paul Zimmerman1d046792012-02-15 18:56:56 -0800232 * Returns 0 on success otherwise negative errno. In the error case, dwc
Felipe Balbi72246da2011-08-19 18:10:58 +0300233 * may contain some buffers allocated but not all which were requested.
234 */
Bill Pemberton41ac7b32012-11-19 13:21:48 -0500235static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
Felipe Balbi72246da2011-08-19 18:10:58 +0300236{
Felipe Balbi9f622b22011-10-12 10:31:04 +0300237 int num;
Felipe Balbi72246da2011-08-19 18:10:58 +0300238 int i;
239
Felipe Balbi9f622b22011-10-12 10:31:04 +0300240 num = DWC3_NUM_INT(dwc->hwparams.hwparams1);
241 dwc->num_event_buffers = num;
242
Felipe Balbi380f0d22012-10-11 13:48:36 +0300243 dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num,
244 GFP_KERNEL);
Jingoo Han734d5a52014-07-17 12:45:11 +0900245 if (!dwc->ev_buffs)
Felipe Balbi457d3f22011-10-24 12:03:13 +0300246 return -ENOMEM;
Felipe Balbi457d3f22011-10-24 12:03:13 +0300247
Felipe Balbi72246da2011-08-19 18:10:58 +0300248 for (i = 0; i < num; i++) {
249 struct dwc3_event_buffer *evt;
250
251 evt = dwc3_alloc_one_event_buffer(dwc, length);
252 if (IS_ERR(evt)) {
253 dev_err(dwc->dev, "can't allocate event buffer\n");
254 return PTR_ERR(evt);
255 }
256 dwc->ev_buffs[i] = evt;
257 }
258
259 return 0;
260}
261
262/**
263 * dwc3_event_buffers_setup - setup our allocated event buffers
Paul Zimmerman1d046792012-02-15 18:56:56 -0800264 * @dwc: pointer to our controller context structure
Felipe Balbi72246da2011-08-19 18:10:58 +0300265 *
266 * Returns 0 on success otherwise negative errno.
267 */
Paul Zimmerman7acd85e2012-04-27 14:28:02 +0300268static int dwc3_event_buffers_setup(struct dwc3 *dwc)
Felipe Balbi72246da2011-08-19 18:10:58 +0300269{
270 struct dwc3_event_buffer *evt;
271 int n;
272
Felipe Balbi9f622b22011-10-12 10:31:04 +0300273 for (n = 0; n < dwc->num_event_buffers; n++) {
Felipe Balbi72246da2011-08-19 18:10:58 +0300274 evt = dwc->ev_buffs[n];
275 dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n",
276 evt->buf, (unsigned long long) evt->dma,
277 evt->length);
278
Paul Zimmerman7acd85e2012-04-27 14:28:02 +0300279 evt->lpos = 0;
280
Felipe Balbi72246da2011-08-19 18:10:58 +0300281 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n),
282 lower_32_bits(evt->dma));
283 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n),
284 upper_32_bits(evt->dma));
285 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n),
Felipe Balbi68d6a012013-06-12 21:09:26 +0300286 DWC3_GEVNTSIZ_SIZE(evt->length));
Felipe Balbi72246da2011-08-19 18:10:58 +0300287 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
288 }
289
290 return 0;
291}
292
293static void dwc3_event_buffers_cleanup(struct dwc3 *dwc)
294{
295 struct dwc3_event_buffer *evt;
296 int n;
297
Felipe Balbi9f622b22011-10-12 10:31:04 +0300298 for (n = 0; n < dwc->num_event_buffers; n++) {
Felipe Balbi72246da2011-08-19 18:10:58 +0300299 evt = dwc->ev_buffs[n];
Paul Zimmerman7acd85e2012-04-27 14:28:02 +0300300
301 evt->lpos = 0;
302
Felipe Balbi72246da2011-08-19 18:10:58 +0300303 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0);
304 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0);
Felipe Balbi68d6a012013-06-12 21:09:26 +0300305 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), DWC3_GEVNTSIZ_INTMASK
306 | DWC3_GEVNTSIZ_SIZE(0));
Felipe Balbi72246da2011-08-19 18:10:58 +0300307 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
308 }
309}
310
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600311static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc)
312{
313 if (!dwc->has_hibernation)
314 return 0;
315
316 if (!dwc->nr_scratch)
317 return 0;
318
319 dwc->scratchbuf = kmalloc_array(dwc->nr_scratch,
320 DWC3_SCRATCHBUF_SIZE, GFP_KERNEL);
321 if (!dwc->scratchbuf)
322 return -ENOMEM;
323
324 return 0;
325}
326
327static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)
328{
329 dma_addr_t scratch_addr;
330 u32 param;
331 int ret;
332
333 if (!dwc->has_hibernation)
334 return 0;
335
336 if (!dwc->nr_scratch)
337 return 0;
338
339 /* should never fall here */
340 if (!WARN_ON(dwc->scratchbuf))
341 return 0;
342
343 scratch_addr = dma_map_single(dwc->dev, dwc->scratchbuf,
344 dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE,
345 DMA_BIDIRECTIONAL);
346 if (dma_mapping_error(dwc->dev, scratch_addr)) {
347 dev_err(dwc->dev, "failed to map scratch buffer\n");
348 ret = -EFAULT;
349 goto err0;
350 }
351
352 dwc->scratch_addr = scratch_addr;
353
354 param = lower_32_bits(scratch_addr);
355
356 ret = dwc3_send_gadget_generic_command(dwc,
357 DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO, param);
358 if (ret < 0)
359 goto err1;
360
361 param = upper_32_bits(scratch_addr);
362
363 ret = dwc3_send_gadget_generic_command(dwc,
364 DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI, param);
365 if (ret < 0)
366 goto err1;
367
368 return 0;
369
370err1:
371 dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
372 DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
373
374err0:
375 return ret;
376}
377
378static void dwc3_free_scratch_buffers(struct dwc3 *dwc)
379{
380 if (!dwc->has_hibernation)
381 return;
382
383 if (!dwc->nr_scratch)
384 return;
385
386 /* should never fall here */
387 if (!WARN_ON(dwc->scratchbuf))
388 return;
389
390 dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
391 DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
392 kfree(dwc->scratchbuf);
393}
394
Felipe Balbi789451f62011-05-05 15:53:10 +0300395static void dwc3_core_num_eps(struct dwc3 *dwc)
396{
397 struct dwc3_hwparams *parms = &dwc->hwparams;
398
399 dwc->num_in_eps = DWC3_NUM_IN_EPS(parms);
400 dwc->num_out_eps = DWC3_NUM_EPS(parms) - dwc->num_in_eps;
401
Felipe Balbi73815282015-01-27 13:48:14 -0600402 dwc3_trace(trace_dwc3_core, "found %d IN and %d OUT endpoints",
Felipe Balbi789451f62011-05-05 15:53:10 +0300403 dwc->num_in_eps, dwc->num_out_eps);
404}
405
Bill Pemberton41ac7b32012-11-19 13:21:48 -0500406static void dwc3_cache_hwparams(struct dwc3 *dwc)
Felipe Balbi26ceca92011-09-30 10:58:49 +0300407{
408 struct dwc3_hwparams *parms = &dwc->hwparams;
409
410 parms->hwparams0 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS0);
411 parms->hwparams1 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS1);
412 parms->hwparams2 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS2);
413 parms->hwparams3 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS3);
414 parms->hwparams4 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS4);
415 parms->hwparams5 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS5);
416 parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6);
417 parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7);
418 parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8);
419}
420
Felipe Balbi72246da2011-08-19 18:10:58 +0300421/**
Huang Ruib5a65c42014-10-28 19:54:28 +0800422 * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core
423 * @dwc: Pointer to our controller context structure
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300424 *
425 * Returns 0 on success. The USB PHY interfaces are configured but not
426 * initialized. The PHY interfaces and the PHYs get initialized together with
427 * the core in dwc3_core_init.
Huang Ruib5a65c42014-10-28 19:54:28 +0800428 */
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300429static int dwc3_phy_setup(struct dwc3 *dwc)
Huang Ruib5a65c42014-10-28 19:54:28 +0800430{
431 u32 reg;
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300432 int ret;
Huang Ruib5a65c42014-10-28 19:54:28 +0800433
434 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
435
Huang Rui2164a472014-10-28 19:54:35 +0800436 /*
437 * Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY
438 * to '0' during coreConsultant configuration. So default value
439 * will be '0' when the core is reset. Application needs to set it
440 * to '1' after the core initialization is completed.
441 */
442 if (dwc->revision > DWC3_REVISION_194A)
443 reg |= DWC3_GUSB3PIPECTL_SUSPHY;
444
Huang Ruib5a65c42014-10-28 19:54:28 +0800445 if (dwc->u2ss_inp3_quirk)
446 reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
447
Huang Ruidf31f5b2014-10-28 19:54:29 +0800448 if (dwc->req_p1p2p3_quirk)
449 reg |= DWC3_GUSB3PIPECTL_REQP1P2P3;
450
Huang Ruia2a1d0f2014-10-28 19:54:30 +0800451 if (dwc->del_p1p2p3_quirk)
452 reg |= DWC3_GUSB3PIPECTL_DEP1P2P3_EN;
453
Huang Rui41c06ff2014-10-28 19:54:31 +0800454 if (dwc->del_phy_power_chg_quirk)
455 reg |= DWC3_GUSB3PIPECTL_DEPOCHANGE;
456
Huang Ruifb67afc2014-10-28 19:54:32 +0800457 if (dwc->lfps_filter_quirk)
458 reg |= DWC3_GUSB3PIPECTL_LFPSFILT;
459
Huang Rui14f4ac52014-10-28 19:54:33 +0800460 if (dwc->rx_detect_poll_quirk)
461 reg |= DWC3_GUSB3PIPECTL_RX_DETOPOLL;
462
Huang Rui6b6a0c92014-10-31 11:11:12 +0800463 if (dwc->tx_de_emphasis_quirk)
464 reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis);
465
Felipe Balbicd72f892014-11-06 11:31:00 -0600466 if (dwc->dis_u3_susphy_quirk)
Huang Rui59acfa22014-10-31 11:11:13 +0800467 reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
468
Huang Ruib5a65c42014-10-28 19:54:28 +0800469 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
470
Huang Rui2164a472014-10-28 19:54:35 +0800471 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
472
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300473 /* Select the HS PHY interface */
474 switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) {
475 case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
Felipe Balbi43cacb02015-07-01 22:03:09 -0500476 if (dwc->hsphy_interface &&
477 !strncmp(dwc->hsphy_interface, "utmi", 4)) {
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300478 reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300479 break;
Felipe Balbi43cacb02015-07-01 22:03:09 -0500480 } else if (dwc->hsphy_interface &&
481 !strncmp(dwc->hsphy_interface, "ulpi", 4)) {
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300482 reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300483 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300484 } else {
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300485 /* Relying on default value. */
486 if (!(reg & DWC3_GUSB2PHYCFG_ULPI_UTMI))
487 break;
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300488 }
489 /* FALLTHROUGH */
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300490 case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI:
491 /* Making sure the interface and PHY are operational */
492 ret = dwc3_soft_reset(dwc);
493 if (ret)
494 return ret;
495
496 udelay(1);
497
498 ret = dwc3_ulpi_init(dwc);
499 if (ret)
500 return ret;
501 /* FALLTHROUGH */
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300502 default:
503 break;
504 }
505
Huang Rui2164a472014-10-28 19:54:35 +0800506 /*
507 * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to
508 * '0' during coreConsultant configuration. So default value will
509 * be '0' when the core is reset. Application needs to set it to
510 * '1' after the core initialization is completed.
511 */
512 if (dwc->revision > DWC3_REVISION_194A)
513 reg |= DWC3_GUSB2PHYCFG_SUSPHY;
514
Felipe Balbicd72f892014-11-06 11:31:00 -0600515 if (dwc->dis_u2_susphy_quirk)
Huang Rui0effe0a2014-10-31 11:11:14 +0800516 reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
517
John Younec791d12015-10-02 20:30:57 -0700518 if (dwc->dis_enblslpm_quirk)
519 reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
520
Huang Rui2164a472014-10-28 19:54:35 +0800521 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300522
523 return 0;
Huang Ruib5a65c42014-10-28 19:54:28 +0800524}
525
526/**
Felipe Balbi72246da2011-08-19 18:10:58 +0300527 * dwc3_core_init - Low-level initialization of DWC3 Core
528 * @dwc: Pointer to our controller context structure
529 *
530 * Returns 0 on success otherwise negative errno.
531 */
Bill Pemberton41ac7b32012-11-19 13:21:48 -0500532static int dwc3_core_init(struct dwc3 *dwc)
Felipe Balbi72246da2011-08-19 18:10:58 +0300533{
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600534 u32 hwparams4 = dwc->hwparams.hwparams4;
Felipe Balbi72246da2011-08-19 18:10:58 +0300535 u32 reg;
536 int ret;
537
Sebastian Andrzej Siewior7650bd72011-08-29 13:56:36 +0200538 reg = dwc3_readl(dwc->regs, DWC3_GSNPSID);
539 /* This should read as U3 followed by revision number */
John Youn690fb372015-09-04 19:15:10 -0700540 if ((reg & DWC3_GSNPSID_MASK) == 0x55330000) {
541 /* Detected DWC_usb3 IP */
542 dwc->revision = reg;
543 } else if ((reg & DWC3_GSNPSID_MASK) == 0x33310000) {
544 /* Detected DWC_usb31 IP */
545 dwc->revision = dwc3_readl(dwc->regs, DWC3_VER_NUMBER);
546 dwc->revision |= DWC3_REVISION_IS_DWC31;
547 } else {
Sebastian Andrzej Siewior7650bd72011-08-29 13:56:36 +0200548 dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n");
549 ret = -ENODEV;
550 goto err0;
551 }
Sebastian Andrzej Siewior7650bd72011-08-29 13:56:36 +0200552
Felipe Balbifa0ea132014-09-19 15:51:11 -0500553 /*
554 * Write Linux Version Code to our GUID register so it's easy to figure
555 * out which kernel version a bug was found.
556 */
557 dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE);
558
Paul Zimmerman0e1e5c42014-05-23 11:39:24 -0700559 /* Handle USB2.0-only core configuration */
560 if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
561 DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
562 if (dwc->maximum_speed == USB_SPEED_SUPER)
563 dwc->maximum_speed = USB_SPEED_HIGH;
564 }
565
Felipe Balbi72246da2011-08-19 18:10:58 +0300566 /* issue device SoftReset too */
Heikki Krogerusc5cc74e2015-05-13 15:26:47 +0300567 ret = dwc3_soft_reset(dwc);
568 if (ret)
569 goto err0;
Felipe Balbi72246da2011-08-19 18:10:58 +0300570
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +0530571 ret = dwc3_core_soft_reset(dwc);
572 if (ret)
573 goto err0;
Pratyush Anand58a0f232012-06-21 17:44:29 +0530574
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100575 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
Paul Zimmerman3e87c422012-02-24 17:32:13 -0800576 reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100577
Sebastian Andrzej Siewior164d7732011-11-24 11:22:05 +0100578 switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100579 case DWC3_GHWPARAMS1_EN_PWROPT_CLK:
Felipe Balbi32a4a132014-02-25 14:00:13 -0600580 /**
581 * WORKAROUND: DWC3 revisions between 2.10a and 2.50a have an
582 * issue which would cause xHCI compliance tests to fail.
583 *
584 * Because of that we cannot enable clock gating on such
585 * configurations.
586 *
587 * Refers to:
588 *
589 * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based
590 * SOF/ITP Mode Used
591 */
592 if ((dwc->dr_mode == USB_DR_MODE_HOST ||
593 dwc->dr_mode == USB_DR_MODE_OTG) &&
594 (dwc->revision >= DWC3_REVISION_210A &&
595 dwc->revision <= DWC3_REVISION_250A))
596 reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
597 else
598 reg &= ~DWC3_GCTL_DSBLCLKGTNG;
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100599 break;
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600600 case DWC3_GHWPARAMS1_EN_PWROPT_HIB:
601 /* enable hibernation here */
602 dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4);
Huang Rui2eac3992014-10-28 19:54:22 +0800603
604 /*
605 * REVISIT Enabling this bit so that host-mode hibernation
606 * will work. Device-mode hibernation is not yet implemented.
607 */
608 reg |= DWC3_GCTL_GBLHIBERNATIONEN;
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600609 break;
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100610 default:
611 dev_dbg(dwc->dev, "No power optimization available\n");
612 }
613
Huang Rui946bd572014-10-28 19:54:23 +0800614 /* check if current dwc3 is on simulation board */
615 if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) {
616 dev_dbg(dwc->dev, "it is on FPGA board\n");
617 dwc->is_fpga = true;
618 }
619
Huang Rui3b812212014-10-28 19:54:25 +0800620 WARN_ONCE(dwc->disable_scramble_quirk && !dwc->is_fpga,
621 "disable_scramble cannot be used on non-FPGA builds\n");
622
623 if (dwc->disable_scramble_quirk && dwc->is_fpga)
624 reg |= DWC3_GCTL_DISSCRAMBLE;
625 else
626 reg &= ~DWC3_GCTL_DISSCRAMBLE;
627
Huang Rui9a5b2f32014-10-28 19:54:27 +0800628 if (dwc->u2exit_lfps_quirk)
629 reg |= DWC3_GCTL_U2EXIT_LFPS;
630
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100631 /*
632 * WORKAROUND: DWC3 revisions <1.90a have a bug
Paul Zimmerman1d046792012-02-15 18:56:56 -0800633 * where the device can fail to connect at SuperSpeed
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100634 * and falls back to high-speed mode which causes
Paul Zimmerman1d046792012-02-15 18:56:56 -0800635 * the device to enter a Connect/Disconnect loop
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100636 */
637 if (dwc->revision < DWC3_REVISION_190A)
638 reg |= DWC3_GCTL_U2RSTECN;
639
Felipe Balbi789451f62011-05-05 15:53:10 +0300640 dwc3_core_num_eps(dwc);
641
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100642 dwc3_writel(dwc->regs, DWC3_GCTL, reg);
643
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600644 ret = dwc3_alloc_scratch_buffers(dwc);
645 if (ret)
646 goto err1;
647
648 ret = dwc3_setup_scratch_buffers(dwc);
649 if (ret)
650 goto err2;
651
Felipe Balbi72246da2011-08-19 18:10:58 +0300652 return 0;
653
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600654err2:
655 dwc3_free_scratch_buffers(dwc);
656
657err1:
658 usb_phy_shutdown(dwc->usb2_phy);
659 usb_phy_shutdown(dwc->usb3_phy);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +0530660 phy_exit(dwc->usb2_generic_phy);
661 phy_exit(dwc->usb3_generic_phy);
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600662
Felipe Balbi72246da2011-08-19 18:10:58 +0300663err0:
664 return ret;
665}
666
667static void dwc3_core_exit(struct dwc3 *dwc)
668{
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600669 dwc3_free_scratch_buffers(dwc);
Vivek Gautam01b8daf2012-10-13 19:20:18 +0530670 usb_phy_shutdown(dwc->usb2_phy);
671 usb_phy_shutdown(dwc->usb3_phy);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +0530672 phy_exit(dwc->usb2_generic_phy);
673 phy_exit(dwc->usb3_generic_phy);
Felipe Balbi72246da2011-08-19 18:10:58 +0300674}
675
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500676static int dwc3_core_get_phy(struct dwc3 *dwc)
Felipe Balbi72246da2011-08-19 18:10:58 +0300677{
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500678 struct device *dev = dwc->dev;
Felipe Balbi941ea362013-07-31 09:21:25 +0300679 struct device_node *node = dev->of_node;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500680 int ret;
Felipe Balbi72246da2011-08-19 18:10:58 +0300681
Kishon Vijay Abraham I5088b6f2013-01-25 16:36:53 +0530682 if (node) {
683 dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0);
684 dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1);
Felipe Balbibb674902013-08-14 13:21:23 -0500685 } else {
686 dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
687 dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
Kishon Vijay Abraham I5088b6f2013-01-25 16:36:53 +0530688 }
689
Felipe Balbid105e7f2013-03-15 10:52:08 +0200690 if (IS_ERR(dwc->usb2_phy)) {
691 ret = PTR_ERR(dwc->usb2_phy);
Kishon Vijay Abraham I122f06e2014-03-03 17:08:10 +0530692 if (ret == -ENXIO || ret == -ENODEV) {
693 dwc->usb2_phy = NULL;
694 } else if (ret == -EPROBE_DEFER) {
Felipe Balbid105e7f2013-03-15 10:52:08 +0200695 return ret;
Kishon Vijay Abraham I122f06e2014-03-03 17:08:10 +0530696 } else {
697 dev_err(dev, "no usb2 phy configured\n");
698 return ret;
699 }
Felipe Balbi51e1e7b2012-07-19 14:09:48 +0300700 }
701
Felipe Balbid105e7f2013-03-15 10:52:08 +0200702 if (IS_ERR(dwc->usb3_phy)) {
Ruchika Kharwar315955d72013-07-04 00:59:34 -0500703 ret = PTR_ERR(dwc->usb3_phy);
Kishon Vijay Abraham I122f06e2014-03-03 17:08:10 +0530704 if (ret == -ENXIO || ret == -ENODEV) {
705 dwc->usb3_phy = NULL;
706 } else if (ret == -EPROBE_DEFER) {
Felipe Balbid105e7f2013-03-15 10:52:08 +0200707 return ret;
Kishon Vijay Abraham I122f06e2014-03-03 17:08:10 +0530708 } else {
709 dev_err(dev, "no usb3 phy configured\n");
710 return ret;
711 }
Felipe Balbi51e1e7b2012-07-19 14:09:48 +0300712 }
713
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +0530714 dwc->usb2_generic_phy = devm_phy_get(dev, "usb2-phy");
715 if (IS_ERR(dwc->usb2_generic_phy)) {
716 ret = PTR_ERR(dwc->usb2_generic_phy);
717 if (ret == -ENOSYS || ret == -ENODEV) {
718 dwc->usb2_generic_phy = NULL;
719 } else if (ret == -EPROBE_DEFER) {
720 return ret;
721 } else {
722 dev_err(dev, "no usb2 phy configured\n");
723 return ret;
724 }
725 }
726
727 dwc->usb3_generic_phy = devm_phy_get(dev, "usb3-phy");
728 if (IS_ERR(dwc->usb3_generic_phy)) {
729 ret = PTR_ERR(dwc->usb3_generic_phy);
730 if (ret == -ENOSYS || ret == -ENODEV) {
731 dwc->usb3_generic_phy = NULL;
732 } else if (ret == -EPROBE_DEFER) {
733 return ret;
734 } else {
735 dev_err(dev, "no usb3 phy configured\n");
736 return ret;
737 }
738 }
739
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500740 return 0;
741}
742
Felipe Balbi5f94adf2014-04-16 15:13:45 -0500743static int dwc3_core_init_mode(struct dwc3 *dwc)
744{
745 struct device *dev = dwc->dev;
746 int ret;
747
748 switch (dwc->dr_mode) {
749 case USB_DR_MODE_PERIPHERAL:
750 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
751 ret = dwc3_gadget_init(dwc);
752 if (ret) {
753 dev_err(dev, "failed to initialize gadget\n");
754 return ret;
755 }
756 break;
757 case USB_DR_MODE_HOST:
758 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
759 ret = dwc3_host_init(dwc);
760 if (ret) {
761 dev_err(dev, "failed to initialize host\n");
762 return ret;
763 }
764 break;
765 case USB_DR_MODE_OTG:
766 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
767 ret = dwc3_host_init(dwc);
768 if (ret) {
769 dev_err(dev, "failed to initialize host\n");
770 return ret;
771 }
772
773 ret = dwc3_gadget_init(dwc);
774 if (ret) {
775 dev_err(dev, "failed to initialize gadget\n");
776 return ret;
777 }
778 break;
779 default:
780 dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode);
781 return -EINVAL;
782 }
783
784 return 0;
785}
786
787static void dwc3_core_exit_mode(struct dwc3 *dwc)
788{
789 switch (dwc->dr_mode) {
790 case USB_DR_MODE_PERIPHERAL:
791 dwc3_gadget_exit(dwc);
792 break;
793 case USB_DR_MODE_HOST:
794 dwc3_host_exit(dwc);
795 break;
796 case USB_DR_MODE_OTG:
797 dwc3_host_exit(dwc);
798 dwc3_gadget_exit(dwc);
799 break;
800 default:
801 /* do nothing */
802 break;
803 }
804}
805
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500806#define DWC3_ALIGN_MASK (16 - 1)
807
808static int dwc3_probe(struct platform_device *pdev)
809{
810 struct device *dev = &pdev->dev;
811 struct dwc3_platform_data *pdata = dev_get_platdata(dev);
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500812 struct resource *res;
813 struct dwc3 *dwc;
Huang Rui80caf7d2014-10-28 19:54:26 +0800814 u8 lpm_nyet_threshold;
Huang Rui6b6a0c92014-10-31 11:11:12 +0800815 u8 tx_de_emphasis;
Huang Rui460d0982014-10-31 11:11:18 +0800816 u8 hird_threshold;
Nikhil Badoladb2be4e2015-09-04 10:15:58 +0530817 u32 fladj = 0;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500818
Andy Shevchenkob09e99e2014-05-15 15:53:32 +0300819 int ret;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500820
821 void __iomem *regs;
822 void *mem;
823
824 mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL);
Jingoo Han734d5a52014-07-17 12:45:11 +0900825 if (!mem)
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500826 return -ENOMEM;
Jingoo Han734d5a52014-07-17 12:45:11 +0900827
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500828 dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1);
829 dwc->mem = mem;
830 dwc->dev = dev;
831
832 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
833 if (!res) {
834 dev_err(dev, "missing IRQ\n");
835 return -ENODEV;
836 }
837 dwc->xhci_resources[1].start = res->start;
838 dwc->xhci_resources[1].end = res->end;
839 dwc->xhci_resources[1].flags = res->flags;
840 dwc->xhci_resources[1].name = res->name;
841
842 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
843 if (!res) {
844 dev_err(dev, "missing memory resource\n");
845 return -ENODEV;
846 }
847
Vivek Gautamf32a5e22014-06-04 14:34:52 +0530848 dwc->xhci_resources[0].start = res->start;
849 dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
850 DWC3_XHCI_REGS_END;
851 dwc->xhci_resources[0].flags = res->flags;
852 dwc->xhci_resources[0].name = res->name;
853
854 res->start += DWC3_GLOBALS_REGS_START;
855
856 /*
857 * Request memory region but exclude xHCI regs,
858 * since it will be requested by the xhci-plat driver.
859 */
860 regs = devm_ioremap_resource(dev, res);
Felipe Balbi3da1f6e2014-09-02 15:19:43 -0500861 if (IS_ERR(regs)) {
862 ret = PTR_ERR(regs);
863 goto err0;
864 }
Vivek Gautamf32a5e22014-06-04 14:34:52 +0530865
866 dwc->regs = regs;
867 dwc->regs_size = resource_size(res);
Vivek Gautamf32a5e22014-06-04 14:34:52 +0530868
Huang Rui80caf7d2014-10-28 19:54:26 +0800869 /* default to highest possible threshold */
870 lpm_nyet_threshold = 0xff;
871
Huang Rui6b6a0c92014-10-31 11:11:12 +0800872 /* default to -3.5dB de-emphasis */
873 tx_de_emphasis = 1;
874
Huang Rui460d0982014-10-31 11:11:18 +0800875 /*
876 * default to assert utmi_sleep_n and use maximum allowed HIRD
877 * threshold value of 0b1100
878 */
879 hird_threshold = 12;
880
Heikki Krogerus63863b92015-09-21 11:14:32 +0300881 dwc->maximum_speed = usb_get_maximum_speed(dev);
Heikki Krogerus06e71142015-09-21 11:14:34 +0300882 dwc->dr_mode = usb_get_dr_mode(dev);
Heikki Krogerus63863b92015-09-21 11:14:32 +0300883
Heikki Krogerus3d128912015-09-21 11:14:35 +0300884 dwc->has_lpm_erratum = device_property_read_bool(dev,
Huang Rui80caf7d2014-10-28 19:54:26 +0800885 "snps,has-lpm-erratum");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300886 device_property_read_u8(dev, "snps,lpm-nyet-threshold",
Huang Rui80caf7d2014-10-28 19:54:26 +0800887 &lpm_nyet_threshold);
Heikki Krogerus3d128912015-09-21 11:14:35 +0300888 dwc->is_utmi_l1_suspend = device_property_read_bool(dev,
Huang Rui460d0982014-10-31 11:11:18 +0800889 "snps,is-utmi-l1-suspend");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300890 device_property_read_u8(dev, "snps,hird-threshold",
Huang Rui460d0982014-10-31 11:11:18 +0800891 &hird_threshold);
Heikki Krogerus3d128912015-09-21 11:14:35 +0300892 dwc->usb3_lpm_capable = device_property_read_bool(dev,
Robert Baldygaeac68e82015-03-09 15:06:12 +0100893 "snps,usb3_lpm_capable");
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500894
Heikki Krogerus3d128912015-09-21 11:14:35 +0300895 dwc->needs_fifo_resize = device_property_read_bool(dev,
Huang Rui80caf7d2014-10-28 19:54:26 +0800896 "tx-fifo-resize");
Huang Rui3b812212014-10-28 19:54:25 +0800897
Heikki Krogerus3d128912015-09-21 11:14:35 +0300898 dwc->disable_scramble_quirk = device_property_read_bool(dev,
Huang Rui3b812212014-10-28 19:54:25 +0800899 "snps,disable_scramble_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300900 dwc->u2exit_lfps_quirk = device_property_read_bool(dev,
Huang Rui9a5b2f32014-10-28 19:54:27 +0800901 "snps,u2exit_lfps_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300902 dwc->u2ss_inp3_quirk = device_property_read_bool(dev,
Huang Ruib5a65c42014-10-28 19:54:28 +0800903 "snps,u2ss_inp3_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300904 dwc->req_p1p2p3_quirk = device_property_read_bool(dev,
Huang Ruidf31f5b2014-10-28 19:54:29 +0800905 "snps,req_p1p2p3_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300906 dwc->del_p1p2p3_quirk = device_property_read_bool(dev,
Huang Ruia2a1d0f2014-10-28 19:54:30 +0800907 "snps,del_p1p2p3_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300908 dwc->del_phy_power_chg_quirk = device_property_read_bool(dev,
Huang Rui41c06ff2014-10-28 19:54:31 +0800909 "snps,del_phy_power_chg_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300910 dwc->lfps_filter_quirk = device_property_read_bool(dev,
Huang Ruifb67afc2014-10-28 19:54:32 +0800911 "snps,lfps_filter_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300912 dwc->rx_detect_poll_quirk = device_property_read_bool(dev,
Huang Rui14f4ac52014-10-28 19:54:33 +0800913 "snps,rx_detect_poll_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300914 dwc->dis_u3_susphy_quirk = device_property_read_bool(dev,
Huang Rui59acfa22014-10-31 11:11:13 +0800915 "snps,dis_u3_susphy_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300916 dwc->dis_u2_susphy_quirk = device_property_read_bool(dev,
Huang Rui0effe0a2014-10-31 11:11:14 +0800917 "snps,dis_u2_susphy_quirk");
John Younec791d12015-10-02 20:30:57 -0700918 dwc->dis_enblslpm_quirk = device_property_read_bool(dev,
919 "snps,dis_enblslpm_quirk");
Huang Rui6b6a0c92014-10-31 11:11:12 +0800920
Heikki Krogerus3d128912015-09-21 11:14:35 +0300921 dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
Huang Rui6b6a0c92014-10-31 11:11:12 +0800922 "snps,tx_de_emphasis_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300923 device_property_read_u8(dev, "snps,tx_de_emphasis",
Huang Rui6b6a0c92014-10-31 11:11:12 +0800924 &tx_de_emphasis);
Heikki Krogerus3d128912015-09-21 11:14:35 +0300925 device_property_read_string(dev, "snps,hsphy_interface",
926 &dwc->hsphy_interface);
927 device_property_read_u32(dev, "snps,quirk-frame-length-adjustment",
928 &fladj);
929
930 if (pdata) {
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500931 dwc->maximum_speed = pdata->maximum_speed;
Huang Rui80caf7d2014-10-28 19:54:26 +0800932 dwc->has_lpm_erratum = pdata->has_lpm_erratum;
933 if (pdata->lpm_nyet_threshold)
934 lpm_nyet_threshold = pdata->lpm_nyet_threshold;
Huang Rui460d0982014-10-31 11:11:18 +0800935 dwc->is_utmi_l1_suspend = pdata->is_utmi_l1_suspend;
936 if (pdata->hird_threshold)
937 hird_threshold = pdata->hird_threshold;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500938
939 dwc->needs_fifo_resize = pdata->tx_fifo_resize;
Robert Baldygaeac68e82015-03-09 15:06:12 +0100940 dwc->usb3_lpm_capable = pdata->usb3_lpm_capable;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500941 dwc->dr_mode = pdata->dr_mode;
Huang Rui3b812212014-10-28 19:54:25 +0800942
943 dwc->disable_scramble_quirk = pdata->disable_scramble_quirk;
Huang Rui9a5b2f32014-10-28 19:54:27 +0800944 dwc->u2exit_lfps_quirk = pdata->u2exit_lfps_quirk;
Huang Ruib5a65c42014-10-28 19:54:28 +0800945 dwc->u2ss_inp3_quirk = pdata->u2ss_inp3_quirk;
Huang Ruidf31f5b2014-10-28 19:54:29 +0800946 dwc->req_p1p2p3_quirk = pdata->req_p1p2p3_quirk;
Huang Ruia2a1d0f2014-10-28 19:54:30 +0800947 dwc->del_p1p2p3_quirk = pdata->del_p1p2p3_quirk;
Huang Rui41c06ff2014-10-28 19:54:31 +0800948 dwc->del_phy_power_chg_quirk = pdata->del_phy_power_chg_quirk;
Huang Ruifb67afc2014-10-28 19:54:32 +0800949 dwc->lfps_filter_quirk = pdata->lfps_filter_quirk;
Huang Rui14f4ac52014-10-28 19:54:33 +0800950 dwc->rx_detect_poll_quirk = pdata->rx_detect_poll_quirk;
Huang Rui59acfa22014-10-31 11:11:13 +0800951 dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk;
Huang Rui0effe0a2014-10-31 11:11:14 +0800952 dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk;
John Younec791d12015-10-02 20:30:57 -0700953 dwc->dis_enblslpm_quirk = pdata->dis_enblslpm_quirk;
Huang Rui6b6a0c92014-10-31 11:11:12 +0800954
955 dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;
956 if (pdata->tx_de_emphasis)
957 tx_de_emphasis = pdata->tx_de_emphasis;
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300958
959 dwc->hsphy_interface = pdata->hsphy_interface;
Nikhil Badoladb2be4e2015-09-04 10:15:58 +0530960 fladj = pdata->fladj_value;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500961 }
962
963 /* default to superspeed if no maximum_speed passed */
964 if (dwc->maximum_speed == USB_SPEED_UNKNOWN)
965 dwc->maximum_speed = USB_SPEED_SUPER;
966
Huang Rui80caf7d2014-10-28 19:54:26 +0800967 dwc->lpm_nyet_threshold = lpm_nyet_threshold;
Huang Rui6b6a0c92014-10-31 11:11:12 +0800968 dwc->tx_de_emphasis = tx_de_emphasis;
Huang Rui80caf7d2014-10-28 19:54:26 +0800969
Huang Rui460d0982014-10-31 11:11:18 +0800970 dwc->hird_threshold = hird_threshold
971 | (dwc->is_utmi_l1_suspend << 4);
972
Heikki Krogerus6c89cce02015-05-13 15:26:45 +0300973 platform_set_drvdata(pdev, dwc);
Heikki Krogerus2917e712015-05-13 15:26:46 +0300974 dwc3_cache_hwparams(dwc);
Heikki Krogerus6c89cce02015-05-13 15:26:45 +0300975
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300976 ret = dwc3_phy_setup(dwc);
977 if (ret)
978 goto err0;
Heikki Krogerus45bb7de2015-05-13 15:26:48 +0300979
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500980 ret = dwc3_core_get_phy(dwc);
981 if (ret)
Felipe Balbi3da1f6e2014-09-02 15:19:43 -0500982 goto err0;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500983
Felipe Balbi72246da2011-08-19 18:10:58 +0300984 spin_lock_init(&dwc->lock);
Felipe Balbi72246da2011-08-19 18:10:58 +0300985
Heikki Krogerus19bacdc2014-09-24 11:00:38 +0300986 if (!dev->dma_mask) {
987 dev->dma_mask = dev->parent->dma_mask;
988 dev->dma_parms = dev->parent->dma_parms;
989 dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask);
990 }
Kishon Vijay Abraham Iddff14f2013-03-07 18:51:43 +0530991
Chanho Park802ca852012-02-15 18:27:55 +0900992 pm_runtime_enable(dev);
993 pm_runtime_get_sync(dev);
994 pm_runtime_forbid(dev);
Felipe Balbi72246da2011-08-19 18:10:58 +0300995
Felipe Balbi39214262012-10-11 13:54:36 +0300996 ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
997 if (ret) {
998 dev_err(dwc->dev, "failed to allocate event buffers\n");
999 ret = -ENOMEM;
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001000 goto err1;
Felipe Balbi39214262012-10-11 13:54:36 +03001001 }
1002
Felipe Balbi32a4a132014-02-25 14:00:13 -06001003 if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
1004 dwc->dr_mode = USB_DR_MODE_HOST;
1005 else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
1006 dwc->dr_mode = USB_DR_MODE_PERIPHERAL;
1007
1008 if (dwc->dr_mode == USB_DR_MODE_UNKNOWN)
1009 dwc->dr_mode = USB_DR_MODE_OTG;
1010
Felipe Balbi72246da2011-08-19 18:10:58 +03001011 ret = dwc3_core_init(dwc);
1012 if (ret) {
Chanho Park802ca852012-02-15 18:27:55 +09001013 dev_err(dev, "failed to initialize core\n");
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001014 goto err1;
Felipe Balbi72246da2011-08-19 18:10:58 +03001015 }
1016
Nikhil Badoladb2be4e2015-09-04 10:15:58 +05301017 /* Adjust Frame Length */
1018 dwc3_frame_length_adjustment(dwc, fladj);
1019
Kishon Vijay Abraham I3088f102013-11-25 15:31:21 +05301020 usb_phy_set_suspend(dwc->usb2_phy, 0);
1021 usb_phy_set_suspend(dwc->usb3_phy, 0);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301022 ret = phy_power_on(dwc->usb2_generic_phy);
1023 if (ret < 0)
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001024 goto err2;
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301025
1026 ret = phy_power_on(dwc->usb3_generic_phy);
1027 if (ret < 0)
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001028 goto err3;
Kishon Vijay Abraham I3088f102013-11-25 15:31:21 +05301029
Felipe Balbif122d332013-02-08 15:15:11 +02001030 ret = dwc3_event_buffers_setup(dwc);
1031 if (ret) {
1032 dev_err(dwc->dev, "failed to setup event buffers\n");
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001033 goto err4;
Felipe Balbif122d332013-02-08 15:15:11 +02001034 }
1035
Felipe Balbi5f94adf2014-04-16 15:13:45 -05001036 ret = dwc3_core_init_mode(dwc);
1037 if (ret)
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001038 goto err5;
Felipe Balbi72246da2011-08-19 18:10:58 +03001039
1040 ret = dwc3_debugfs_init(dwc);
1041 if (ret) {
Chanho Park802ca852012-02-15 18:27:55 +09001042 dev_err(dev, "failed to initialize debugfs\n");
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001043 goto err6;
Felipe Balbi72246da2011-08-19 18:10:58 +03001044 }
1045
Chanho Park802ca852012-02-15 18:27:55 +09001046 pm_runtime_allow(dev);
Felipe Balbi72246da2011-08-19 18:10:58 +03001047
1048 return 0;
1049
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001050err6:
Felipe Balbi5f94adf2014-04-16 15:13:45 -05001051 dwc3_core_exit_mode(dwc);
Felipe Balbi72246da2011-08-19 18:10:58 +03001052
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001053err5:
Felipe Balbif122d332013-02-08 15:15:11 +02001054 dwc3_event_buffers_cleanup(dwc);
1055
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001056err4:
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301057 phy_power_off(dwc->usb3_generic_phy);
1058
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001059err3:
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301060 phy_power_off(dwc->usb2_generic_phy);
1061
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001062err2:
Kishon Vijay Abraham I501fae52013-11-25 15:31:22 +05301063 usb_phy_set_suspend(dwc->usb2_phy, 1);
1064 usb_phy_set_suspend(dwc->usb3_phy, 1);
Felipe Balbi72246da2011-08-19 18:10:58 +03001065 dwc3_core_exit(dwc);
1066
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001067err1:
Felipe Balbi39214262012-10-11 13:54:36 +03001068 dwc3_free_event_buffers(dwc);
Heikki Krogerus88bc9d12015-05-13 15:26:51 +03001069 dwc3_ulpi_exit(dwc);
Felipe Balbi39214262012-10-11 13:54:36 +03001070
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001071err0:
1072 /*
1073 * restore res->start back to its original value so that, in case the
1074 * probe is deferred, we don't end up getting error in request the
1075 * memory region the next time probe is called.
1076 */
1077 res->start -= DWC3_GLOBALS_REGS_START;
1078
Felipe Balbi72246da2011-08-19 18:10:58 +03001079 return ret;
1080}
1081
Bill Pembertonfb4e98a2012-11-19 13:26:20 -05001082static int dwc3_remove(struct platform_device *pdev)
Felipe Balbi72246da2011-08-19 18:10:58 +03001083{
Felipe Balbi72246da2011-08-19 18:10:58 +03001084 struct dwc3 *dwc = platform_get_drvdata(pdev);
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001085 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1086
1087 /*
1088 * restore res->start back to its original value so that, in case the
1089 * probe is deferred, we don't end up getting error in request the
1090 * memory region the next time probe is called.
1091 */
1092 res->start -= DWC3_GLOBALS_REGS_START;
Felipe Balbi72246da2011-08-19 18:10:58 +03001093
Felipe Balbidc99f162014-09-03 16:13:37 -05001094 dwc3_debugfs_exit(dwc);
1095 dwc3_core_exit_mode(dwc);
1096 dwc3_event_buffers_cleanup(dwc);
1097 dwc3_free_event_buffers(dwc);
1098
Kishon Vijay Abraham I8ba007a2013-01-25 08:30:54 +05301099 usb_phy_set_suspend(dwc->usb2_phy, 1);
1100 usb_phy_set_suspend(dwc->usb3_phy, 1);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301101 phy_power_off(dwc->usb2_generic_phy);
1102 phy_power_off(dwc->usb3_generic_phy);
Kishon Vijay Abraham I8ba007a2013-01-25 08:30:54 +05301103
Felipe Balbi72246da2011-08-19 18:10:58 +03001104 dwc3_core_exit(dwc);
Heikki Krogerus88bc9d12015-05-13 15:26:51 +03001105 dwc3_ulpi_exit(dwc);
Felipe Balbi72246da2011-08-19 18:10:58 +03001106
Felipe Balbi7415f172012-04-30 14:56:33 +03001107 pm_runtime_put_sync(&pdev->dev);
1108 pm_runtime_disable(&pdev->dev);
1109
Felipe Balbi72246da2011-08-19 18:10:58 +03001110 return 0;
1111}
1112
Felipe Balbi7415f172012-04-30 14:56:33 +03001113#ifdef CONFIG_PM_SLEEP
Felipe Balbi7415f172012-04-30 14:56:33 +03001114static int dwc3_suspend(struct device *dev)
1115{
1116 struct dwc3 *dwc = dev_get_drvdata(dev);
1117 unsigned long flags;
1118
1119 spin_lock_irqsave(&dwc->lock, flags);
1120
Ruchika Kharwara45c82b82013-07-06 07:52:49 -05001121 switch (dwc->dr_mode) {
1122 case USB_DR_MODE_PERIPHERAL:
1123 case USB_DR_MODE_OTG:
Felipe Balbi7415f172012-04-30 14:56:33 +03001124 dwc3_gadget_suspend(dwc);
1125 /* FALLTHROUGH */
Ruchika Kharwara45c82b82013-07-06 07:52:49 -05001126 case USB_DR_MODE_HOST:
Felipe Balbi7415f172012-04-30 14:56:33 +03001127 default:
Felipe Balbi0b0231a2014-10-07 10:19:23 -05001128 dwc3_event_buffers_cleanup(dwc);
Felipe Balbi7415f172012-04-30 14:56:33 +03001129 break;
1130 }
1131
1132 dwc->gctl = dwc3_readl(dwc->regs, DWC3_GCTL);
1133 spin_unlock_irqrestore(&dwc->lock, flags);
1134
1135 usb_phy_shutdown(dwc->usb3_phy);
1136 usb_phy_shutdown(dwc->usb2_phy);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301137 phy_exit(dwc->usb2_generic_phy);
1138 phy_exit(dwc->usb3_generic_phy);
Felipe Balbi7415f172012-04-30 14:56:33 +03001139
Sekhar Nori63444752015-08-31 21:09:08 +05301140 pinctrl_pm_select_sleep_state(dev);
1141
Felipe Balbi7415f172012-04-30 14:56:33 +03001142 return 0;
1143}
1144
1145static int dwc3_resume(struct device *dev)
1146{
1147 struct dwc3 *dwc = dev_get_drvdata(dev);
1148 unsigned long flags;
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301149 int ret;
Felipe Balbi7415f172012-04-30 14:56:33 +03001150
Sekhar Nori63444752015-08-31 21:09:08 +05301151 pinctrl_pm_select_default_state(dev);
1152
Felipe Balbi7415f172012-04-30 14:56:33 +03001153 usb_phy_init(dwc->usb3_phy);
1154 usb_phy_init(dwc->usb2_phy);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301155 ret = phy_init(dwc->usb2_generic_phy);
1156 if (ret < 0)
1157 return ret;
1158
1159 ret = phy_init(dwc->usb3_generic_phy);
1160 if (ret < 0)
1161 goto err_usb2phy_init;
Felipe Balbi7415f172012-04-30 14:56:33 +03001162
1163 spin_lock_irqsave(&dwc->lock, flags);
1164
Felipe Balbi0b0231a2014-10-07 10:19:23 -05001165 dwc3_event_buffers_setup(dwc);
Felipe Balbi7415f172012-04-30 14:56:33 +03001166 dwc3_writel(dwc->regs, DWC3_GCTL, dwc->gctl);
1167
Ruchika Kharwara45c82b82013-07-06 07:52:49 -05001168 switch (dwc->dr_mode) {
1169 case USB_DR_MODE_PERIPHERAL:
1170 case USB_DR_MODE_OTG:
Felipe Balbi7415f172012-04-30 14:56:33 +03001171 dwc3_gadget_resume(dwc);
1172 /* FALLTHROUGH */
Ruchika Kharwara45c82b82013-07-06 07:52:49 -05001173 case USB_DR_MODE_HOST:
Felipe Balbi7415f172012-04-30 14:56:33 +03001174 default:
1175 /* do nothing */
1176 break;
1177 }
1178
1179 spin_unlock_irqrestore(&dwc->lock, flags);
1180
1181 pm_runtime_disable(dev);
1182 pm_runtime_set_active(dev);
1183 pm_runtime_enable(dev);
1184
1185 return 0;
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301186
1187err_usb2phy_init:
1188 phy_exit(dwc->usb2_generic_phy);
1189
1190 return ret;
Felipe Balbi7415f172012-04-30 14:56:33 +03001191}
1192
1193static const struct dev_pm_ops dwc3_dev_pm_ops = {
Felipe Balbi7415f172012-04-30 14:56:33 +03001194 SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume)
1195};
1196
1197#define DWC3_PM_OPS &(dwc3_dev_pm_ops)
1198#else
1199#define DWC3_PM_OPS NULL
1200#endif
1201
Kishon Vijay Abraham I5088b6f2013-01-25 16:36:53 +05301202#ifdef CONFIG_OF
1203static const struct of_device_id of_dwc3_match[] = {
1204 {
Felipe Balbi22a5aa12013-07-02 21:20:24 +03001205 .compatible = "snps,dwc3"
1206 },
1207 {
Kishon Vijay Abraham I5088b6f2013-01-25 16:36:53 +05301208 .compatible = "synopsys,dwc3"
1209 },
1210 { },
1211};
1212MODULE_DEVICE_TABLE(of, of_dwc3_match);
1213#endif
1214
Heikki Krogerus404905a2014-09-25 10:57:02 +03001215#ifdef CONFIG_ACPI
1216
1217#define ACPI_ID_INTEL_BSW "808622B7"
1218
1219static const struct acpi_device_id dwc3_acpi_match[] = {
1220 { ACPI_ID_INTEL_BSW, 0 },
1221 { },
1222};
1223MODULE_DEVICE_TABLE(acpi, dwc3_acpi_match);
1224#endif
1225
Felipe Balbi72246da2011-08-19 18:10:58 +03001226static struct platform_driver dwc3_driver = {
1227 .probe = dwc3_probe,
Bill Pemberton76904172012-11-19 13:21:08 -05001228 .remove = dwc3_remove,
Felipe Balbi72246da2011-08-19 18:10:58 +03001229 .driver = {
1230 .name = "dwc3",
Kishon Vijay Abraham I5088b6f2013-01-25 16:36:53 +05301231 .of_match_table = of_match_ptr(of_dwc3_match),
Heikki Krogerus404905a2014-09-25 10:57:02 +03001232 .acpi_match_table = ACPI_PTR(dwc3_acpi_match),
Felipe Balbi7415f172012-04-30 14:56:33 +03001233 .pm = DWC3_PM_OPS,
Felipe Balbi72246da2011-08-19 18:10:58 +03001234 },
Felipe Balbi72246da2011-08-19 18:10:58 +03001235};
1236
Tobias Klauserb1116dc2012-02-28 12:57:20 +01001237module_platform_driver(dwc3_driver);
1238
Sebastian Andrzej Siewior7ae4fc42011-10-19 19:39:50 +02001239MODULE_ALIAS("platform:dwc3");
Felipe Balbi72246da2011-08-19 18:10:58 +03001240MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
Felipe Balbi5945f782013-06-30 14:15:11 +03001241MODULE_LICENSE("GPL v2");
Felipe Balbi72246da2011-08-19 18:10:58 +03001242MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");