blob: 9e5c57c7943d208e862bfbf1dfee695e93721e98 [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;
Felipe Balbif59dcab2016-03-11 10:51:52 +020070 int retries = 1000;
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +053071 int ret;
Felipe Balbi72246da2011-08-19 18:10:58 +030072
Felipe Balbi51e1e7b2012-07-19 14:09:48 +030073 usb_phy_init(dwc->usb2_phy);
74 usb_phy_init(dwc->usb3_phy);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +053075 ret = phy_init(dwc->usb2_generic_phy);
76 if (ret < 0)
77 return ret;
78
79 ret = phy_init(dwc->usb3_generic_phy);
80 if (ret < 0) {
81 phy_exit(dwc->usb2_generic_phy);
82 return ret;
83 }
Felipe Balbi72246da2011-08-19 18:10:58 +030084
Felipe Balbif59dcab2016-03-11 10:51:52 +020085 /*
86 * We're resetting only the device side because, if we're in host mode,
87 * XHCI driver will reset the host block. If dwc3 was configured for
88 * host-only mode, then we can return early.
89 */
90 if (dwc->dr_mode == USB_DR_MODE_HOST)
91 return 0;
Felipe Balbi72246da2011-08-19 18:10:58 +030092
Felipe Balbif59dcab2016-03-11 10:51:52 +020093 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
94 reg |= DWC3_DCTL_CSFTRST;
95 dwc3_writel(dwc->regs, DWC3_DCTL, reg);
Felipe Balbi72246da2011-08-19 18:10:58 +030096
Felipe Balbif59dcab2016-03-11 10:51:52 +020097 do {
98 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
99 if (!(reg & DWC3_DCTL_CSFTRST))
100 return 0;
Pratyush Anand45627ac2012-06-21 17:44:28 +0530101
Felipe Balbif59dcab2016-03-11 10:51:52 +0200102 udelay(1);
103 } while (--retries);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +0530104
Felipe Balbif59dcab2016-03-11 10:51:52 +0200105 return -ETIMEDOUT;
Felipe Balbi72246da2011-08-19 18:10:58 +0300106}
107
108/**
Heikki Krogerusc5cc74e2015-05-13 15:26:47 +0300109 * dwc3_soft_reset - Issue soft reset
110 * @dwc: Pointer to our controller context structure
111 */
112static int dwc3_soft_reset(struct dwc3 *dwc)
113{
114 unsigned long timeout;
115 u32 reg;
116
117 timeout = jiffies + msecs_to_jiffies(500);
118 dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
119 do {
120 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
121 if (!(reg & DWC3_DCTL_CSFTRST))
122 break;
123
124 if (time_after(jiffies, timeout)) {
125 dev_err(dwc->dev, "Reset Timed Out\n");
126 return -ETIMEDOUT;
127 }
128
129 cpu_relax();
130 } while (true);
131
132 return 0;
133}
134
Nikhil Badoladb2be4e2015-09-04 10:15:58 +0530135/*
136 * dwc3_frame_length_adjustment - Adjusts frame length if required
137 * @dwc3: Pointer to our controller context structure
138 * @fladj: Value of GFLADJ_30MHZ to adjust frame length
139 */
140static void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj)
141{
142 u32 reg;
143 u32 dft;
144
145 if (dwc->revision < DWC3_REVISION_250A)
146 return;
147
148 if (fladj == 0)
149 return;
150
151 reg = dwc3_readl(dwc->regs, DWC3_GFLADJ);
152 dft = reg & DWC3_GFLADJ_30MHZ_MASK;
153 if (!dev_WARN_ONCE(dwc->dev, dft == fladj,
154 "request value same as default, ignoring\n")) {
155 reg &= ~DWC3_GFLADJ_30MHZ_MASK;
156 reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | fladj;
157 dwc3_writel(dwc->regs, DWC3_GFLADJ, reg);
158 }
159}
160
Heikki Krogerusc5cc74e2015-05-13 15:26:47 +0300161/**
Felipe Balbi72246da2011-08-19 18:10:58 +0300162 * dwc3_free_one_event_buffer - Frees one event buffer
163 * @dwc: Pointer to our controller context structure
164 * @evt: Pointer to event buffer to be freed
165 */
166static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
167 struct dwc3_event_buffer *evt)
168{
169 dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma);
Felipe Balbi72246da2011-08-19 18:10:58 +0300170}
171
172/**
Paul Zimmerman1d046792012-02-15 18:56:56 -0800173 * dwc3_alloc_one_event_buffer - Allocates one event buffer structure
Felipe Balbi72246da2011-08-19 18:10:58 +0300174 * @dwc: Pointer to our controller context structure
175 * @length: size of the event buffer
176 *
Paul Zimmerman1d046792012-02-15 18:56:56 -0800177 * Returns a pointer to the allocated event buffer structure on success
Felipe Balbi72246da2011-08-19 18:10:58 +0300178 * otherwise ERR_PTR(errno).
179 */
Felipe Balbi67d0b502013-02-22 16:31:07 +0200180static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc,
181 unsigned length)
Felipe Balbi72246da2011-08-19 18:10:58 +0300182{
183 struct dwc3_event_buffer *evt;
184
Felipe Balbi380f0d22012-10-11 13:48:36 +0300185 evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL);
Felipe Balbi72246da2011-08-19 18:10:58 +0300186 if (!evt)
187 return ERR_PTR(-ENOMEM);
188
189 evt->dwc = dwc;
190 evt->length = length;
191 evt->buf = dma_alloc_coherent(dwc->dev, length,
192 &evt->dma, GFP_KERNEL);
Felipe Balbie32672f2012-11-08 15:26:41 +0200193 if (!evt->buf)
Felipe Balbi72246da2011-08-19 18:10:58 +0300194 return ERR_PTR(-ENOMEM);
Felipe Balbi72246da2011-08-19 18:10:58 +0300195
196 return evt;
197}
198
199/**
200 * dwc3_free_event_buffers - frees all allocated event buffers
201 * @dwc: Pointer to our controller context structure
202 */
203static void dwc3_free_event_buffers(struct dwc3 *dwc)
204{
205 struct dwc3_event_buffer *evt;
Felipe Balbi72246da2011-08-19 18:10:58 +0300206
Felipe Balbi660e9bd2016-03-30 09:26:24 +0300207 evt = dwc->ev_buffs[0];
208 if (evt)
209 dwc3_free_one_event_buffer(dwc, evt);
Felipe Balbi72246da2011-08-19 18:10:58 +0300210}
211
212/**
213 * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length
Paul Zimmerman1d046792012-02-15 18:56:56 -0800214 * @dwc: pointer to our controller context structure
Felipe Balbi72246da2011-08-19 18:10:58 +0300215 * @length: size of event buffer
216 *
Paul Zimmerman1d046792012-02-15 18:56:56 -0800217 * Returns 0 on success otherwise negative errno. In the error case, dwc
Felipe Balbi72246da2011-08-19 18:10:58 +0300218 * may contain some buffers allocated but not all which were requested.
219 */
Bill Pemberton41ac7b32012-11-19 13:21:48 -0500220static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
Felipe Balbi72246da2011-08-19 18:10:58 +0300221{
Felipe Balbi660e9bd2016-03-30 09:26:24 +0300222 struct dwc3_event_buffer *evt;
Felipe Balbi72246da2011-08-19 18:10:58 +0300223
Felipe Balbi660e9bd2016-03-30 09:26:24 +0300224 dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs),
Felipe Balbi380f0d22012-10-11 13:48:36 +0300225 GFP_KERNEL);
Jingoo Han734d5a52014-07-17 12:45:11 +0900226 if (!dwc->ev_buffs)
Felipe Balbi457d3f22011-10-24 12:03:13 +0300227 return -ENOMEM;
Felipe Balbi457d3f22011-10-24 12:03:13 +0300228
Felipe Balbi660e9bd2016-03-30 09:26:24 +0300229 evt = dwc3_alloc_one_event_buffer(dwc, length);
230 if (IS_ERR(evt)) {
231 dev_err(dwc->dev, "can't allocate event buffer\n");
232 return PTR_ERR(evt);
Felipe Balbi72246da2011-08-19 18:10:58 +0300233 }
Felipe Balbi660e9bd2016-03-30 09:26:24 +0300234 dwc->ev_buffs[0] = evt;
Felipe Balbi72246da2011-08-19 18:10:58 +0300235
236 return 0;
237}
238
239/**
240 * dwc3_event_buffers_setup - setup our allocated event buffers
Paul Zimmerman1d046792012-02-15 18:56:56 -0800241 * @dwc: pointer to our controller context structure
Felipe Balbi72246da2011-08-19 18:10:58 +0300242 *
243 * Returns 0 on success otherwise negative errno.
244 */
Paul Zimmerman7acd85e2012-04-27 14:28:02 +0300245static int dwc3_event_buffers_setup(struct dwc3 *dwc)
Felipe Balbi72246da2011-08-19 18:10:58 +0300246{
247 struct dwc3_event_buffer *evt;
Felipe Balbi72246da2011-08-19 18:10:58 +0300248
Felipe Balbi660e9bd2016-03-30 09:26:24 +0300249 evt = dwc->ev_buffs[0];
250 dwc3_trace(trace_dwc3_core,
251 "Event buf %p dma %08llx length %d\n",
252 evt->buf, (unsigned long long) evt->dma,
253 evt->length);
Felipe Balbi72246da2011-08-19 18:10:58 +0300254
Felipe Balbi660e9bd2016-03-30 09:26:24 +0300255 evt->lpos = 0;
Paul Zimmerman7acd85e2012-04-27 14:28:02 +0300256
Felipe Balbi660e9bd2016-03-30 09:26:24 +0300257 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0),
258 lower_32_bits(evt->dma));
259 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0),
260 upper_32_bits(evt->dma));
261 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0),
262 DWC3_GEVNTSIZ_SIZE(evt->length));
263 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
Felipe Balbi72246da2011-08-19 18:10:58 +0300264
265 return 0;
266}
267
268static void dwc3_event_buffers_cleanup(struct dwc3 *dwc)
269{
270 struct dwc3_event_buffer *evt;
Felipe Balbi72246da2011-08-19 18:10:58 +0300271
Felipe Balbi660e9bd2016-03-30 09:26:24 +0300272 evt = dwc->ev_buffs[0];
Paul Zimmerman7acd85e2012-04-27 14:28:02 +0300273
Felipe Balbi660e9bd2016-03-30 09:26:24 +0300274 evt->lpos = 0;
Paul Zimmerman7acd85e2012-04-27 14:28:02 +0300275
Felipe Balbi660e9bd2016-03-30 09:26:24 +0300276 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0), 0);
277 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0), 0);
278 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), DWC3_GEVNTSIZ_INTMASK
279 | DWC3_GEVNTSIZ_SIZE(0));
280 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
Felipe Balbi72246da2011-08-19 18:10:58 +0300281}
282
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600283static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc)
284{
285 if (!dwc->has_hibernation)
286 return 0;
287
288 if (!dwc->nr_scratch)
289 return 0;
290
291 dwc->scratchbuf = kmalloc_array(dwc->nr_scratch,
292 DWC3_SCRATCHBUF_SIZE, GFP_KERNEL);
293 if (!dwc->scratchbuf)
294 return -ENOMEM;
295
296 return 0;
297}
298
299static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)
300{
301 dma_addr_t scratch_addr;
302 u32 param;
303 int ret;
304
305 if (!dwc->has_hibernation)
306 return 0;
307
308 if (!dwc->nr_scratch)
309 return 0;
310
311 /* should never fall here */
312 if (!WARN_ON(dwc->scratchbuf))
313 return 0;
314
315 scratch_addr = dma_map_single(dwc->dev, dwc->scratchbuf,
316 dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE,
317 DMA_BIDIRECTIONAL);
318 if (dma_mapping_error(dwc->dev, scratch_addr)) {
319 dev_err(dwc->dev, "failed to map scratch buffer\n");
320 ret = -EFAULT;
321 goto err0;
322 }
323
324 dwc->scratch_addr = scratch_addr;
325
326 param = lower_32_bits(scratch_addr);
327
328 ret = dwc3_send_gadget_generic_command(dwc,
329 DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO, param);
330 if (ret < 0)
331 goto err1;
332
333 param = upper_32_bits(scratch_addr);
334
335 ret = dwc3_send_gadget_generic_command(dwc,
336 DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI, param);
337 if (ret < 0)
338 goto err1;
339
340 return 0;
341
342err1:
343 dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
344 DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
345
346err0:
347 return ret;
348}
349
350static void dwc3_free_scratch_buffers(struct dwc3 *dwc)
351{
352 if (!dwc->has_hibernation)
353 return;
354
355 if (!dwc->nr_scratch)
356 return;
357
358 /* should never fall here */
359 if (!WARN_ON(dwc->scratchbuf))
360 return;
361
362 dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
363 DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
364 kfree(dwc->scratchbuf);
365}
366
Felipe Balbi789451f62011-05-05 15:53:10 +0300367static void dwc3_core_num_eps(struct dwc3 *dwc)
368{
369 struct dwc3_hwparams *parms = &dwc->hwparams;
370
371 dwc->num_in_eps = DWC3_NUM_IN_EPS(parms);
372 dwc->num_out_eps = DWC3_NUM_EPS(parms) - dwc->num_in_eps;
373
Felipe Balbi73815282015-01-27 13:48:14 -0600374 dwc3_trace(trace_dwc3_core, "found %d IN and %d OUT endpoints",
Felipe Balbi789451f62011-05-05 15:53:10 +0300375 dwc->num_in_eps, dwc->num_out_eps);
376}
377
Bill Pemberton41ac7b32012-11-19 13:21:48 -0500378static void dwc3_cache_hwparams(struct dwc3 *dwc)
Felipe Balbi26ceca92011-09-30 10:58:49 +0300379{
380 struct dwc3_hwparams *parms = &dwc->hwparams;
381
382 parms->hwparams0 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS0);
383 parms->hwparams1 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS1);
384 parms->hwparams2 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS2);
385 parms->hwparams3 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS3);
386 parms->hwparams4 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS4);
387 parms->hwparams5 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS5);
388 parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6);
389 parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7);
390 parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8);
391}
392
Felipe Balbi72246da2011-08-19 18:10:58 +0300393/**
Huang Ruib5a65c42014-10-28 19:54:28 +0800394 * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core
395 * @dwc: Pointer to our controller context structure
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300396 *
397 * Returns 0 on success. The USB PHY interfaces are configured but not
398 * initialized. The PHY interfaces and the PHYs get initialized together with
399 * the core in dwc3_core_init.
Huang Ruib5a65c42014-10-28 19:54:28 +0800400 */
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300401static int dwc3_phy_setup(struct dwc3 *dwc)
Huang Ruib5a65c42014-10-28 19:54:28 +0800402{
403 u32 reg;
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300404 int ret;
Huang Ruib5a65c42014-10-28 19:54:28 +0800405
406 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
407
Huang Rui2164a472014-10-28 19:54:35 +0800408 /*
409 * Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY
410 * to '0' during coreConsultant configuration. So default value
411 * will be '0' when the core is reset. Application needs to set it
412 * to '1' after the core initialization is completed.
413 */
414 if (dwc->revision > DWC3_REVISION_194A)
415 reg |= DWC3_GUSB3PIPECTL_SUSPHY;
416
Huang Ruib5a65c42014-10-28 19:54:28 +0800417 if (dwc->u2ss_inp3_quirk)
418 reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
419
Huang Ruidf31f5b2014-10-28 19:54:29 +0800420 if (dwc->req_p1p2p3_quirk)
421 reg |= DWC3_GUSB3PIPECTL_REQP1P2P3;
422
Huang Ruia2a1d0f2014-10-28 19:54:30 +0800423 if (dwc->del_p1p2p3_quirk)
424 reg |= DWC3_GUSB3PIPECTL_DEP1P2P3_EN;
425
Huang Rui41c06ff2014-10-28 19:54:31 +0800426 if (dwc->del_phy_power_chg_quirk)
427 reg |= DWC3_GUSB3PIPECTL_DEPOCHANGE;
428
Huang Ruifb67afc2014-10-28 19:54:32 +0800429 if (dwc->lfps_filter_quirk)
430 reg |= DWC3_GUSB3PIPECTL_LFPSFILT;
431
Huang Rui14f4ac52014-10-28 19:54:33 +0800432 if (dwc->rx_detect_poll_quirk)
433 reg |= DWC3_GUSB3PIPECTL_RX_DETOPOLL;
434
Huang Rui6b6a0c92014-10-31 11:11:12 +0800435 if (dwc->tx_de_emphasis_quirk)
436 reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis);
437
Felipe Balbicd72f892014-11-06 11:31:00 -0600438 if (dwc->dis_u3_susphy_quirk)
Huang Rui59acfa22014-10-31 11:11:13 +0800439 reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
440
Huang Ruib5a65c42014-10-28 19:54:28 +0800441 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
442
Huang Rui2164a472014-10-28 19:54:35 +0800443 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
444
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300445 /* Select the HS PHY interface */
446 switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) {
447 case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
Felipe Balbi43cacb02015-07-01 22:03:09 -0500448 if (dwc->hsphy_interface &&
449 !strncmp(dwc->hsphy_interface, "utmi", 4)) {
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300450 reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300451 break;
Felipe Balbi43cacb02015-07-01 22:03:09 -0500452 } else if (dwc->hsphy_interface &&
453 !strncmp(dwc->hsphy_interface, "ulpi", 4)) {
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300454 reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300455 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300456 } else {
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300457 /* Relying on default value. */
458 if (!(reg & DWC3_GUSB2PHYCFG_ULPI_UTMI))
459 break;
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300460 }
461 /* FALLTHROUGH */
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300462 case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI:
463 /* Making sure the interface and PHY are operational */
464 ret = dwc3_soft_reset(dwc);
465 if (ret)
466 return ret;
467
468 udelay(1);
469
470 ret = dwc3_ulpi_init(dwc);
471 if (ret)
472 return ret;
473 /* FALLTHROUGH */
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300474 default:
475 break;
476 }
477
Huang Rui2164a472014-10-28 19:54:35 +0800478 /*
479 * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to
480 * '0' during coreConsultant configuration. So default value will
481 * be '0' when the core is reset. Application needs to set it to
482 * '1' after the core initialization is completed.
483 */
484 if (dwc->revision > DWC3_REVISION_194A)
485 reg |= DWC3_GUSB2PHYCFG_SUSPHY;
486
Felipe Balbicd72f892014-11-06 11:31:00 -0600487 if (dwc->dis_u2_susphy_quirk)
Huang Rui0effe0a2014-10-31 11:11:14 +0800488 reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
489
John Younec791d12015-10-02 20:30:57 -0700490 if (dwc->dis_enblslpm_quirk)
491 reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
492
Huang Rui2164a472014-10-28 19:54:35 +0800493 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300494
495 return 0;
Huang Ruib5a65c42014-10-28 19:54:28 +0800496}
497
498/**
Felipe Balbi72246da2011-08-19 18:10:58 +0300499 * dwc3_core_init - Low-level initialization of DWC3 Core
500 * @dwc: Pointer to our controller context structure
501 *
502 * Returns 0 on success otherwise negative errno.
503 */
Bill Pemberton41ac7b32012-11-19 13:21:48 -0500504static int dwc3_core_init(struct dwc3 *dwc)
Felipe Balbi72246da2011-08-19 18:10:58 +0300505{
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600506 u32 hwparams4 = dwc->hwparams.hwparams4;
Felipe Balbi72246da2011-08-19 18:10:58 +0300507 u32 reg;
508 int ret;
509
Sebastian Andrzej Siewior7650bd72011-08-29 13:56:36 +0200510 reg = dwc3_readl(dwc->regs, DWC3_GSNPSID);
511 /* This should read as U3 followed by revision number */
John Youn690fb372015-09-04 19:15:10 -0700512 if ((reg & DWC3_GSNPSID_MASK) == 0x55330000) {
513 /* Detected DWC_usb3 IP */
514 dwc->revision = reg;
515 } else if ((reg & DWC3_GSNPSID_MASK) == 0x33310000) {
516 /* Detected DWC_usb31 IP */
517 dwc->revision = dwc3_readl(dwc->regs, DWC3_VER_NUMBER);
518 dwc->revision |= DWC3_REVISION_IS_DWC31;
519 } else {
Sebastian Andrzej Siewior7650bd72011-08-29 13:56:36 +0200520 dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n");
521 ret = -ENODEV;
522 goto err0;
523 }
Sebastian Andrzej Siewior7650bd72011-08-29 13:56:36 +0200524
Felipe Balbifa0ea132014-09-19 15:51:11 -0500525 /*
526 * Write Linux Version Code to our GUID register so it's easy to figure
527 * out which kernel version a bug was found.
528 */
529 dwc3_writel(dwc->regs, DWC3_GUID, LINUX_VERSION_CODE);
530
Paul Zimmerman0e1e5c42014-05-23 11:39:24 -0700531 /* Handle USB2.0-only core configuration */
532 if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
533 DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
534 if (dwc->maximum_speed == USB_SPEED_SUPER)
535 dwc->maximum_speed = USB_SPEED_HIGH;
536 }
537
Felipe Balbi72246da2011-08-19 18:10:58 +0300538 /* issue device SoftReset too */
Heikki Krogerusc5cc74e2015-05-13 15:26:47 +0300539 ret = dwc3_soft_reset(dwc);
540 if (ret)
541 goto err0;
Felipe Balbi72246da2011-08-19 18:10:58 +0300542
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +0530543 ret = dwc3_core_soft_reset(dwc);
544 if (ret)
545 goto err0;
Pratyush Anand58a0f232012-06-21 17:44:29 +0530546
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100547 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
Paul Zimmerman3e87c422012-02-24 17:32:13 -0800548 reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100549
Sebastian Andrzej Siewior164d7732011-11-24 11:22:05 +0100550 switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100551 case DWC3_GHWPARAMS1_EN_PWROPT_CLK:
Felipe Balbi32a4a132014-02-25 14:00:13 -0600552 /**
553 * WORKAROUND: DWC3 revisions between 2.10a and 2.50a have an
554 * issue which would cause xHCI compliance tests to fail.
555 *
556 * Because of that we cannot enable clock gating on such
557 * configurations.
558 *
559 * Refers to:
560 *
561 * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based
562 * SOF/ITP Mode Used
563 */
564 if ((dwc->dr_mode == USB_DR_MODE_HOST ||
565 dwc->dr_mode == USB_DR_MODE_OTG) &&
566 (dwc->revision >= DWC3_REVISION_210A &&
567 dwc->revision <= DWC3_REVISION_250A))
568 reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
569 else
570 reg &= ~DWC3_GCTL_DSBLCLKGTNG;
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100571 break;
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600572 case DWC3_GHWPARAMS1_EN_PWROPT_HIB:
573 /* enable hibernation here */
574 dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4);
Huang Rui2eac3992014-10-28 19:54:22 +0800575
576 /*
577 * REVISIT Enabling this bit so that host-mode hibernation
578 * will work. Device-mode hibernation is not yet implemented.
579 */
580 reg |= DWC3_GCTL_GBLHIBERNATIONEN;
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600581 break;
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100582 default:
Felipe Balbi1407bf12015-11-16 16:06:37 -0600583 dwc3_trace(trace_dwc3_core, "No power optimization available\n");
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100584 }
585
Huang Rui946bd572014-10-28 19:54:23 +0800586 /* check if current dwc3 is on simulation board */
587 if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) {
Felipe Balbi1407bf12015-11-16 16:06:37 -0600588 dwc3_trace(trace_dwc3_core,
589 "running on FPGA platform\n");
Huang Rui946bd572014-10-28 19:54:23 +0800590 dwc->is_fpga = true;
591 }
592
Huang Rui3b812212014-10-28 19:54:25 +0800593 WARN_ONCE(dwc->disable_scramble_quirk && !dwc->is_fpga,
594 "disable_scramble cannot be used on non-FPGA builds\n");
595
596 if (dwc->disable_scramble_quirk && dwc->is_fpga)
597 reg |= DWC3_GCTL_DISSCRAMBLE;
598 else
599 reg &= ~DWC3_GCTL_DISSCRAMBLE;
600
Huang Rui9a5b2f32014-10-28 19:54:27 +0800601 if (dwc->u2exit_lfps_quirk)
602 reg |= DWC3_GCTL_U2EXIT_LFPS;
603
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100604 /*
605 * WORKAROUND: DWC3 revisions <1.90a have a bug
Paul Zimmerman1d046792012-02-15 18:56:56 -0800606 * where the device can fail to connect at SuperSpeed
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100607 * and falls back to high-speed mode which causes
Paul Zimmerman1d046792012-02-15 18:56:56 -0800608 * the device to enter a Connect/Disconnect loop
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100609 */
610 if (dwc->revision < DWC3_REVISION_190A)
611 reg |= DWC3_GCTL_U2RSTECN;
612
Felipe Balbi789451f62011-05-05 15:53:10 +0300613 dwc3_core_num_eps(dwc);
614
Sebastian Andrzej Siewior4878a022011-10-31 22:25:41 +0100615 dwc3_writel(dwc->regs, DWC3_GCTL, reg);
616
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600617 ret = dwc3_alloc_scratch_buffers(dwc);
618 if (ret)
619 goto err1;
620
621 ret = dwc3_setup_scratch_buffers(dwc);
622 if (ret)
623 goto err2;
624
Felipe Balbi72246da2011-08-19 18:10:58 +0300625 return 0;
626
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600627err2:
628 dwc3_free_scratch_buffers(dwc);
629
630err1:
631 usb_phy_shutdown(dwc->usb2_phy);
632 usb_phy_shutdown(dwc->usb3_phy);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +0530633 phy_exit(dwc->usb2_generic_phy);
634 phy_exit(dwc->usb3_generic_phy);
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600635
Felipe Balbi72246da2011-08-19 18:10:58 +0300636err0:
637 return ret;
638}
639
640static void dwc3_core_exit(struct dwc3 *dwc)
641{
Felipe Balbi0ffcaf32013-12-19 13:04:28 -0600642 dwc3_free_scratch_buffers(dwc);
Vivek Gautam01b8daf2012-10-13 19:20:18 +0530643 usb_phy_shutdown(dwc->usb2_phy);
644 usb_phy_shutdown(dwc->usb3_phy);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +0530645 phy_exit(dwc->usb2_generic_phy);
646 phy_exit(dwc->usb3_generic_phy);
Felipe Balbi72246da2011-08-19 18:10:58 +0300647}
648
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500649static int dwc3_core_get_phy(struct dwc3 *dwc)
Felipe Balbi72246da2011-08-19 18:10:58 +0300650{
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500651 struct device *dev = dwc->dev;
Felipe Balbi941ea362013-07-31 09:21:25 +0300652 struct device_node *node = dev->of_node;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500653 int ret;
Felipe Balbi72246da2011-08-19 18:10:58 +0300654
Kishon Vijay Abraham I5088b6f2013-01-25 16:36:53 +0530655 if (node) {
656 dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0);
657 dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1);
Felipe Balbibb674902013-08-14 13:21:23 -0500658 } else {
659 dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
660 dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
Kishon Vijay Abraham I5088b6f2013-01-25 16:36:53 +0530661 }
662
Felipe Balbid105e7f2013-03-15 10:52:08 +0200663 if (IS_ERR(dwc->usb2_phy)) {
664 ret = PTR_ERR(dwc->usb2_phy);
Kishon Vijay Abraham I122f06e2014-03-03 17:08:10 +0530665 if (ret == -ENXIO || ret == -ENODEV) {
666 dwc->usb2_phy = NULL;
667 } else if (ret == -EPROBE_DEFER) {
Felipe Balbid105e7f2013-03-15 10:52:08 +0200668 return ret;
Kishon Vijay Abraham I122f06e2014-03-03 17:08:10 +0530669 } else {
670 dev_err(dev, "no usb2 phy configured\n");
671 return ret;
672 }
Felipe Balbi51e1e7b2012-07-19 14:09:48 +0300673 }
674
Felipe Balbid105e7f2013-03-15 10:52:08 +0200675 if (IS_ERR(dwc->usb3_phy)) {
Ruchika Kharwar315955d72013-07-04 00:59:34 -0500676 ret = PTR_ERR(dwc->usb3_phy);
Kishon Vijay Abraham I122f06e2014-03-03 17:08:10 +0530677 if (ret == -ENXIO || ret == -ENODEV) {
678 dwc->usb3_phy = NULL;
679 } else if (ret == -EPROBE_DEFER) {
Felipe Balbid105e7f2013-03-15 10:52:08 +0200680 return ret;
Kishon Vijay Abraham I122f06e2014-03-03 17:08:10 +0530681 } else {
682 dev_err(dev, "no usb3 phy configured\n");
683 return ret;
684 }
Felipe Balbi51e1e7b2012-07-19 14:09:48 +0300685 }
686
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +0530687 dwc->usb2_generic_phy = devm_phy_get(dev, "usb2-phy");
688 if (IS_ERR(dwc->usb2_generic_phy)) {
689 ret = PTR_ERR(dwc->usb2_generic_phy);
690 if (ret == -ENOSYS || ret == -ENODEV) {
691 dwc->usb2_generic_phy = NULL;
692 } else if (ret == -EPROBE_DEFER) {
693 return ret;
694 } else {
695 dev_err(dev, "no usb2 phy configured\n");
696 return ret;
697 }
698 }
699
700 dwc->usb3_generic_phy = devm_phy_get(dev, "usb3-phy");
701 if (IS_ERR(dwc->usb3_generic_phy)) {
702 ret = PTR_ERR(dwc->usb3_generic_phy);
703 if (ret == -ENOSYS || ret == -ENODEV) {
704 dwc->usb3_generic_phy = NULL;
705 } else if (ret == -EPROBE_DEFER) {
706 return ret;
707 } else {
708 dev_err(dev, "no usb3 phy configured\n");
709 return ret;
710 }
711 }
712
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500713 return 0;
714}
715
Felipe Balbi5f94adf2014-04-16 15:13:45 -0500716static int dwc3_core_init_mode(struct dwc3 *dwc)
717{
718 struct device *dev = dwc->dev;
719 int ret;
720
721 switch (dwc->dr_mode) {
722 case USB_DR_MODE_PERIPHERAL:
723 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
724 ret = dwc3_gadget_init(dwc);
725 if (ret) {
726 dev_err(dev, "failed to initialize gadget\n");
727 return ret;
728 }
729 break;
730 case USB_DR_MODE_HOST:
731 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
732 ret = dwc3_host_init(dwc);
733 if (ret) {
734 dev_err(dev, "failed to initialize host\n");
735 return ret;
736 }
737 break;
738 case USB_DR_MODE_OTG:
739 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
740 ret = dwc3_host_init(dwc);
741 if (ret) {
742 dev_err(dev, "failed to initialize host\n");
743 return ret;
744 }
745
746 ret = dwc3_gadget_init(dwc);
747 if (ret) {
748 dev_err(dev, "failed to initialize gadget\n");
749 return ret;
750 }
751 break;
752 default:
753 dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode);
754 return -EINVAL;
755 }
756
757 return 0;
758}
759
760static void dwc3_core_exit_mode(struct dwc3 *dwc)
761{
762 switch (dwc->dr_mode) {
763 case USB_DR_MODE_PERIPHERAL:
764 dwc3_gadget_exit(dwc);
765 break;
766 case USB_DR_MODE_HOST:
767 dwc3_host_exit(dwc);
768 break;
769 case USB_DR_MODE_OTG:
770 dwc3_host_exit(dwc);
771 dwc3_gadget_exit(dwc);
772 break;
773 default:
774 /* do nothing */
775 break;
776 }
777}
778
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500779#define DWC3_ALIGN_MASK (16 - 1)
780
781static int dwc3_probe(struct platform_device *pdev)
782{
783 struct device *dev = &pdev->dev;
784 struct dwc3_platform_data *pdata = dev_get_platdata(dev);
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500785 struct resource *res;
786 struct dwc3 *dwc;
Huang Rui80caf7d2014-10-28 19:54:26 +0800787 u8 lpm_nyet_threshold;
Huang Rui6b6a0c92014-10-31 11:11:12 +0800788 u8 tx_de_emphasis;
Huang Rui460d0982014-10-31 11:11:18 +0800789 u8 hird_threshold;
Nikhil Badoladb2be4e2015-09-04 10:15:58 +0530790 u32 fladj = 0;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500791
Andy Shevchenkob09e99e2014-05-15 15:53:32 +0300792 int ret;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500793
794 void __iomem *regs;
795 void *mem;
796
797 mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL);
Jingoo Han734d5a52014-07-17 12:45:11 +0900798 if (!mem)
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500799 return -ENOMEM;
Jingoo Han734d5a52014-07-17 12:45:11 +0900800
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500801 dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1);
802 dwc->mem = mem;
803 dwc->dev = dev;
804
805 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
806 if (!res) {
807 dev_err(dev, "missing IRQ\n");
808 return -ENODEV;
809 }
810 dwc->xhci_resources[1].start = res->start;
811 dwc->xhci_resources[1].end = res->end;
812 dwc->xhci_resources[1].flags = res->flags;
813 dwc->xhci_resources[1].name = res->name;
814
815 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
816 if (!res) {
817 dev_err(dev, "missing memory resource\n");
818 return -ENODEV;
819 }
820
Vivek Gautamf32a5e22014-06-04 14:34:52 +0530821 dwc->xhci_resources[0].start = res->start;
822 dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
823 DWC3_XHCI_REGS_END;
824 dwc->xhci_resources[0].flags = res->flags;
825 dwc->xhci_resources[0].name = res->name;
826
827 res->start += DWC3_GLOBALS_REGS_START;
828
829 /*
830 * Request memory region but exclude xHCI regs,
831 * since it will be requested by the xhci-plat driver.
832 */
833 regs = devm_ioremap_resource(dev, res);
Felipe Balbi3da1f6e2014-09-02 15:19:43 -0500834 if (IS_ERR(regs)) {
835 ret = PTR_ERR(regs);
836 goto err0;
837 }
Vivek Gautamf32a5e22014-06-04 14:34:52 +0530838
839 dwc->regs = regs;
840 dwc->regs_size = resource_size(res);
Vivek Gautamf32a5e22014-06-04 14:34:52 +0530841
Huang Rui80caf7d2014-10-28 19:54:26 +0800842 /* default to highest possible threshold */
843 lpm_nyet_threshold = 0xff;
844
Huang Rui6b6a0c92014-10-31 11:11:12 +0800845 /* default to -3.5dB de-emphasis */
846 tx_de_emphasis = 1;
847
Huang Rui460d0982014-10-31 11:11:18 +0800848 /*
849 * default to assert utmi_sleep_n and use maximum allowed HIRD
850 * threshold value of 0b1100
851 */
852 hird_threshold = 12;
853
Heikki Krogerus63863b92015-09-21 11:14:32 +0300854 dwc->maximum_speed = usb_get_maximum_speed(dev);
Heikki Krogerus06e71142015-09-21 11:14:34 +0300855 dwc->dr_mode = usb_get_dr_mode(dev);
Heikki Krogerus63863b92015-09-21 11:14:32 +0300856
Heikki Krogerus3d128912015-09-21 11:14:35 +0300857 dwc->has_lpm_erratum = device_property_read_bool(dev,
Huang Rui80caf7d2014-10-28 19:54:26 +0800858 "snps,has-lpm-erratum");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300859 device_property_read_u8(dev, "snps,lpm-nyet-threshold",
Huang Rui80caf7d2014-10-28 19:54:26 +0800860 &lpm_nyet_threshold);
Heikki Krogerus3d128912015-09-21 11:14:35 +0300861 dwc->is_utmi_l1_suspend = device_property_read_bool(dev,
Huang Rui460d0982014-10-31 11:11:18 +0800862 "snps,is-utmi-l1-suspend");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300863 device_property_read_u8(dev, "snps,hird-threshold",
Huang Rui460d0982014-10-31 11:11:18 +0800864 &hird_threshold);
Heikki Krogerus3d128912015-09-21 11:14:35 +0300865 dwc->usb3_lpm_capable = device_property_read_bool(dev,
Robert Baldygaeac68e82015-03-09 15:06:12 +0100866 "snps,usb3_lpm_capable");
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500867
Heikki Krogerus3d128912015-09-21 11:14:35 +0300868 dwc->disable_scramble_quirk = device_property_read_bool(dev,
Huang Rui3b812212014-10-28 19:54:25 +0800869 "snps,disable_scramble_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300870 dwc->u2exit_lfps_quirk = device_property_read_bool(dev,
Huang Rui9a5b2f32014-10-28 19:54:27 +0800871 "snps,u2exit_lfps_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300872 dwc->u2ss_inp3_quirk = device_property_read_bool(dev,
Huang Ruib5a65c42014-10-28 19:54:28 +0800873 "snps,u2ss_inp3_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300874 dwc->req_p1p2p3_quirk = device_property_read_bool(dev,
Huang Ruidf31f5b2014-10-28 19:54:29 +0800875 "snps,req_p1p2p3_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300876 dwc->del_p1p2p3_quirk = device_property_read_bool(dev,
Huang Ruia2a1d0f2014-10-28 19:54:30 +0800877 "snps,del_p1p2p3_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300878 dwc->del_phy_power_chg_quirk = device_property_read_bool(dev,
Huang Rui41c06ff2014-10-28 19:54:31 +0800879 "snps,del_phy_power_chg_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300880 dwc->lfps_filter_quirk = device_property_read_bool(dev,
Huang Ruifb67afc2014-10-28 19:54:32 +0800881 "snps,lfps_filter_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300882 dwc->rx_detect_poll_quirk = device_property_read_bool(dev,
Huang Rui14f4ac52014-10-28 19:54:33 +0800883 "snps,rx_detect_poll_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300884 dwc->dis_u3_susphy_quirk = device_property_read_bool(dev,
Huang Rui59acfa22014-10-31 11:11:13 +0800885 "snps,dis_u3_susphy_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300886 dwc->dis_u2_susphy_quirk = device_property_read_bool(dev,
Huang Rui0effe0a2014-10-31 11:11:14 +0800887 "snps,dis_u2_susphy_quirk");
John Younec791d12015-10-02 20:30:57 -0700888 dwc->dis_enblslpm_quirk = device_property_read_bool(dev,
889 "snps,dis_enblslpm_quirk");
Huang Rui6b6a0c92014-10-31 11:11:12 +0800890
Heikki Krogerus3d128912015-09-21 11:14:35 +0300891 dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
Huang Rui6b6a0c92014-10-31 11:11:12 +0800892 "snps,tx_de_emphasis_quirk");
Heikki Krogerus3d128912015-09-21 11:14:35 +0300893 device_property_read_u8(dev, "snps,tx_de_emphasis",
Huang Rui6b6a0c92014-10-31 11:11:12 +0800894 &tx_de_emphasis);
Heikki Krogerus3d128912015-09-21 11:14:35 +0300895 device_property_read_string(dev, "snps,hsphy_interface",
896 &dwc->hsphy_interface);
897 device_property_read_u32(dev, "snps,quirk-frame-length-adjustment",
898 &fladj);
899
900 if (pdata) {
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500901 dwc->maximum_speed = pdata->maximum_speed;
Huang Rui80caf7d2014-10-28 19:54:26 +0800902 dwc->has_lpm_erratum = pdata->has_lpm_erratum;
903 if (pdata->lpm_nyet_threshold)
904 lpm_nyet_threshold = pdata->lpm_nyet_threshold;
Huang Rui460d0982014-10-31 11:11:18 +0800905 dwc->is_utmi_l1_suspend = pdata->is_utmi_l1_suspend;
906 if (pdata->hird_threshold)
907 hird_threshold = pdata->hird_threshold;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500908
Robert Baldygaeac68e82015-03-09 15:06:12 +0100909 dwc->usb3_lpm_capable = pdata->usb3_lpm_capable;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500910 dwc->dr_mode = pdata->dr_mode;
Huang Rui3b812212014-10-28 19:54:25 +0800911
912 dwc->disable_scramble_quirk = pdata->disable_scramble_quirk;
Huang Rui9a5b2f32014-10-28 19:54:27 +0800913 dwc->u2exit_lfps_quirk = pdata->u2exit_lfps_quirk;
Huang Ruib5a65c42014-10-28 19:54:28 +0800914 dwc->u2ss_inp3_quirk = pdata->u2ss_inp3_quirk;
Huang Ruidf31f5b2014-10-28 19:54:29 +0800915 dwc->req_p1p2p3_quirk = pdata->req_p1p2p3_quirk;
Huang Ruia2a1d0f2014-10-28 19:54:30 +0800916 dwc->del_p1p2p3_quirk = pdata->del_p1p2p3_quirk;
Huang Rui41c06ff2014-10-28 19:54:31 +0800917 dwc->del_phy_power_chg_quirk = pdata->del_phy_power_chg_quirk;
Huang Ruifb67afc2014-10-28 19:54:32 +0800918 dwc->lfps_filter_quirk = pdata->lfps_filter_quirk;
Huang Rui14f4ac52014-10-28 19:54:33 +0800919 dwc->rx_detect_poll_quirk = pdata->rx_detect_poll_quirk;
Huang Rui59acfa22014-10-31 11:11:13 +0800920 dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk;
Huang Rui0effe0a2014-10-31 11:11:14 +0800921 dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk;
John Younec791d12015-10-02 20:30:57 -0700922 dwc->dis_enblslpm_quirk = pdata->dis_enblslpm_quirk;
Huang Rui6b6a0c92014-10-31 11:11:12 +0800923
924 dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;
925 if (pdata->tx_de_emphasis)
926 tx_de_emphasis = pdata->tx_de_emphasis;
Heikki Krogerus3e10a2c2015-05-13 15:26:49 +0300927
928 dwc->hsphy_interface = pdata->hsphy_interface;
Nikhil Badoladb2be4e2015-09-04 10:15:58 +0530929 fladj = pdata->fladj_value;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500930 }
931
Huang Rui80caf7d2014-10-28 19:54:26 +0800932 dwc->lpm_nyet_threshold = lpm_nyet_threshold;
Huang Rui6b6a0c92014-10-31 11:11:12 +0800933 dwc->tx_de_emphasis = tx_de_emphasis;
Huang Rui80caf7d2014-10-28 19:54:26 +0800934
Huang Rui460d0982014-10-31 11:11:18 +0800935 dwc->hird_threshold = hird_threshold
936 | (dwc->is_utmi_l1_suspend << 4);
937
Heikki Krogerus6c89cce02015-05-13 15:26:45 +0300938 platform_set_drvdata(pdev, dwc);
Heikki Krogerus2917e712015-05-13 15:26:46 +0300939 dwc3_cache_hwparams(dwc);
Heikki Krogerus6c89cce02015-05-13 15:26:45 +0300940
Heikki Krogerus88bc9d12015-05-13 15:26:51 +0300941 ret = dwc3_phy_setup(dwc);
942 if (ret)
943 goto err0;
Heikki Krogerus45bb7de2015-05-13 15:26:48 +0300944
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500945 ret = dwc3_core_get_phy(dwc);
946 if (ret)
Felipe Balbi3da1f6e2014-09-02 15:19:43 -0500947 goto err0;
Felipe Balbi3c9f94a2014-04-16 15:08:29 -0500948
Felipe Balbi72246da2011-08-19 18:10:58 +0300949 spin_lock_init(&dwc->lock);
Felipe Balbi72246da2011-08-19 18:10:58 +0300950
Heikki Krogerus19bacdc2014-09-24 11:00:38 +0300951 if (!dev->dma_mask) {
952 dev->dma_mask = dev->parent->dma_mask;
953 dev->dma_parms = dev->parent->dma_parms;
954 dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask);
955 }
Kishon Vijay Abraham Iddff14f2013-03-07 18:51:43 +0530956
Chanho Park802ca852012-02-15 18:27:55 +0900957 pm_runtime_enable(dev);
958 pm_runtime_get_sync(dev);
959 pm_runtime_forbid(dev);
Felipe Balbi72246da2011-08-19 18:10:58 +0300960
Felipe Balbi39214262012-10-11 13:54:36 +0300961 ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
962 if (ret) {
963 dev_err(dwc->dev, "failed to allocate event buffers\n");
964 ret = -ENOMEM;
Felipe Balbi3da1f6e2014-09-02 15:19:43 -0500965 goto err1;
Felipe Balbi39214262012-10-11 13:54:36 +0300966 }
967
Felipe Balbi32a4a132014-02-25 14:00:13 -0600968 if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
969 dwc->dr_mode = USB_DR_MODE_HOST;
970 else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
971 dwc->dr_mode = USB_DR_MODE_PERIPHERAL;
972
973 if (dwc->dr_mode == USB_DR_MODE_UNKNOWN)
974 dwc->dr_mode = USB_DR_MODE_OTG;
975
Felipe Balbi72246da2011-08-19 18:10:58 +0300976 ret = dwc3_core_init(dwc);
977 if (ret) {
Chanho Park802ca852012-02-15 18:27:55 +0900978 dev_err(dev, "failed to initialize core\n");
Felipe Balbi3da1f6e2014-09-02 15:19:43 -0500979 goto err1;
Felipe Balbi72246da2011-08-19 18:10:58 +0300980 }
981
John Youn77966eb2016-02-19 17:31:01 -0800982 /* Check the maximum_speed parameter */
983 switch (dwc->maximum_speed) {
984 case USB_SPEED_LOW:
985 case USB_SPEED_FULL:
986 case USB_SPEED_HIGH:
987 case USB_SPEED_SUPER:
988 case USB_SPEED_SUPER_PLUS:
989 break;
990 default:
991 dev_err(dev, "invalid maximum_speed parameter %d\n",
992 dwc->maximum_speed);
993 /* fall through */
994 case USB_SPEED_UNKNOWN:
995 /* default to superspeed */
John Youn2c7f1bd2016-02-05 17:08:59 -0800996 dwc->maximum_speed = USB_SPEED_SUPER;
997
998 /*
999 * default to superspeed plus if we are capable.
1000 */
1001 if (dwc3_is_usb31(dwc) &&
1002 (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
1003 DWC3_GHWPARAMS3_SSPHY_IFC_GEN2))
1004 dwc->maximum_speed = USB_SPEED_SUPER_PLUS;
John Youn77966eb2016-02-19 17:31:01 -08001005
1006 break;
John Youn2c7f1bd2016-02-05 17:08:59 -08001007 }
1008
Nikhil Badoladb2be4e2015-09-04 10:15:58 +05301009 /* Adjust Frame Length */
1010 dwc3_frame_length_adjustment(dwc, fladj);
1011
Kishon Vijay Abraham I3088f102013-11-25 15:31:21 +05301012 usb_phy_set_suspend(dwc->usb2_phy, 0);
1013 usb_phy_set_suspend(dwc->usb3_phy, 0);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301014 ret = phy_power_on(dwc->usb2_generic_phy);
1015 if (ret < 0)
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001016 goto err2;
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301017
1018 ret = phy_power_on(dwc->usb3_generic_phy);
1019 if (ret < 0)
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001020 goto err3;
Kishon Vijay Abraham I3088f102013-11-25 15:31:21 +05301021
Felipe Balbif122d332013-02-08 15:15:11 +02001022 ret = dwc3_event_buffers_setup(dwc);
1023 if (ret) {
1024 dev_err(dwc->dev, "failed to setup event buffers\n");
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001025 goto err4;
Felipe Balbif122d332013-02-08 15:15:11 +02001026 }
1027
Felipe Balbi5f94adf2014-04-16 15:13:45 -05001028 ret = dwc3_core_init_mode(dwc);
1029 if (ret)
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001030 goto err5;
Felipe Balbi72246da2011-08-19 18:10:58 +03001031
1032 ret = dwc3_debugfs_init(dwc);
1033 if (ret) {
Chanho Park802ca852012-02-15 18:27:55 +09001034 dev_err(dev, "failed to initialize debugfs\n");
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001035 goto err6;
Felipe Balbi72246da2011-08-19 18:10:58 +03001036 }
1037
Chanho Park802ca852012-02-15 18:27:55 +09001038 pm_runtime_allow(dev);
Felipe Balbi72246da2011-08-19 18:10:58 +03001039
1040 return 0;
1041
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001042err6:
Felipe Balbi5f94adf2014-04-16 15:13:45 -05001043 dwc3_core_exit_mode(dwc);
Felipe Balbi72246da2011-08-19 18:10:58 +03001044
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001045err5:
Felipe Balbif122d332013-02-08 15:15:11 +02001046 dwc3_event_buffers_cleanup(dwc);
1047
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001048err4:
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301049 phy_power_off(dwc->usb3_generic_phy);
1050
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001051err3:
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301052 phy_power_off(dwc->usb2_generic_phy);
1053
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001054err2:
Kishon Vijay Abraham I501fae52013-11-25 15:31:22 +05301055 usb_phy_set_suspend(dwc->usb2_phy, 1);
1056 usb_phy_set_suspend(dwc->usb3_phy, 1);
Felipe Balbi72246da2011-08-19 18:10:58 +03001057 dwc3_core_exit(dwc);
1058
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001059err1:
Felipe Balbi39214262012-10-11 13:54:36 +03001060 dwc3_free_event_buffers(dwc);
Heikki Krogerus88bc9d12015-05-13 15:26:51 +03001061 dwc3_ulpi_exit(dwc);
Felipe Balbi39214262012-10-11 13:54:36 +03001062
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001063err0:
1064 /*
1065 * restore res->start back to its original value so that, in case the
1066 * probe is deferred, we don't end up getting error in request the
1067 * memory region the next time probe is called.
1068 */
1069 res->start -= DWC3_GLOBALS_REGS_START;
1070
Felipe Balbi72246da2011-08-19 18:10:58 +03001071 return ret;
1072}
1073
Bill Pembertonfb4e98a2012-11-19 13:26:20 -05001074static int dwc3_remove(struct platform_device *pdev)
Felipe Balbi72246da2011-08-19 18:10:58 +03001075{
Felipe Balbi72246da2011-08-19 18:10:58 +03001076 struct dwc3 *dwc = platform_get_drvdata(pdev);
Felipe Balbi3da1f6e2014-09-02 15:19:43 -05001077 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1078
1079 /*
1080 * restore res->start back to its original value so that, in case the
1081 * probe is deferred, we don't end up getting error in request the
1082 * memory region the next time probe is called.
1083 */
1084 res->start -= DWC3_GLOBALS_REGS_START;
Felipe Balbi72246da2011-08-19 18:10:58 +03001085
Felipe Balbidc99f162014-09-03 16:13:37 -05001086 dwc3_debugfs_exit(dwc);
1087 dwc3_core_exit_mode(dwc);
1088 dwc3_event_buffers_cleanup(dwc);
1089 dwc3_free_event_buffers(dwc);
1090
Kishon Vijay Abraham I8ba007a2013-01-25 08:30:54 +05301091 usb_phy_set_suspend(dwc->usb2_phy, 1);
1092 usb_phy_set_suspend(dwc->usb3_phy, 1);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301093 phy_power_off(dwc->usb2_generic_phy);
1094 phy_power_off(dwc->usb3_generic_phy);
Kishon Vijay Abraham I8ba007a2013-01-25 08:30:54 +05301095
Felipe Balbi72246da2011-08-19 18:10:58 +03001096 dwc3_core_exit(dwc);
Heikki Krogerus88bc9d12015-05-13 15:26:51 +03001097 dwc3_ulpi_exit(dwc);
Felipe Balbi72246da2011-08-19 18:10:58 +03001098
Felipe Balbi7415f172012-04-30 14:56:33 +03001099 pm_runtime_put_sync(&pdev->dev);
1100 pm_runtime_disable(&pdev->dev);
1101
Felipe Balbi72246da2011-08-19 18:10:58 +03001102 return 0;
1103}
1104
Felipe Balbi7415f172012-04-30 14:56:33 +03001105#ifdef CONFIG_PM_SLEEP
Felipe Balbi7415f172012-04-30 14:56:33 +03001106static int dwc3_suspend(struct device *dev)
1107{
1108 struct dwc3 *dwc = dev_get_drvdata(dev);
1109 unsigned long flags;
1110
1111 spin_lock_irqsave(&dwc->lock, flags);
1112
Ruchika Kharwara45c82b82013-07-06 07:52:49 -05001113 switch (dwc->dr_mode) {
1114 case USB_DR_MODE_PERIPHERAL:
1115 case USB_DR_MODE_OTG:
Felipe Balbi7415f172012-04-30 14:56:33 +03001116 dwc3_gadget_suspend(dwc);
1117 /* FALLTHROUGH */
Ruchika Kharwara45c82b82013-07-06 07:52:49 -05001118 case USB_DR_MODE_HOST:
Felipe Balbi7415f172012-04-30 14:56:33 +03001119 default:
Felipe Balbi0b0231a2014-10-07 10:19:23 -05001120 dwc3_event_buffers_cleanup(dwc);
Felipe Balbi7415f172012-04-30 14:56:33 +03001121 break;
1122 }
1123
1124 dwc->gctl = dwc3_readl(dwc->regs, DWC3_GCTL);
1125 spin_unlock_irqrestore(&dwc->lock, flags);
1126
1127 usb_phy_shutdown(dwc->usb3_phy);
1128 usb_phy_shutdown(dwc->usb2_phy);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301129 phy_exit(dwc->usb2_generic_phy);
1130 phy_exit(dwc->usb3_generic_phy);
Felipe Balbi7415f172012-04-30 14:56:33 +03001131
Sekhar Nori63444752015-08-31 21:09:08 +05301132 pinctrl_pm_select_sleep_state(dev);
1133
Felipe Balbi7415f172012-04-30 14:56:33 +03001134 return 0;
1135}
1136
1137static int dwc3_resume(struct device *dev)
1138{
1139 struct dwc3 *dwc = dev_get_drvdata(dev);
1140 unsigned long flags;
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301141 int ret;
Felipe Balbi7415f172012-04-30 14:56:33 +03001142
Sekhar Nori63444752015-08-31 21:09:08 +05301143 pinctrl_pm_select_default_state(dev);
1144
Felipe Balbi7415f172012-04-30 14:56:33 +03001145 usb_phy_init(dwc->usb3_phy);
1146 usb_phy_init(dwc->usb2_phy);
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301147 ret = phy_init(dwc->usb2_generic_phy);
1148 if (ret < 0)
1149 return ret;
1150
1151 ret = phy_init(dwc->usb3_generic_phy);
1152 if (ret < 0)
1153 goto err_usb2phy_init;
Felipe Balbi7415f172012-04-30 14:56:33 +03001154
1155 spin_lock_irqsave(&dwc->lock, flags);
1156
Felipe Balbi0b0231a2014-10-07 10:19:23 -05001157 dwc3_event_buffers_setup(dwc);
Felipe Balbi7415f172012-04-30 14:56:33 +03001158 dwc3_writel(dwc->regs, DWC3_GCTL, dwc->gctl);
1159
Ruchika Kharwara45c82b82013-07-06 07:52:49 -05001160 switch (dwc->dr_mode) {
1161 case USB_DR_MODE_PERIPHERAL:
1162 case USB_DR_MODE_OTG:
Felipe Balbi7415f172012-04-30 14:56:33 +03001163 dwc3_gadget_resume(dwc);
1164 /* FALLTHROUGH */
Ruchika Kharwara45c82b82013-07-06 07:52:49 -05001165 case USB_DR_MODE_HOST:
Felipe Balbi7415f172012-04-30 14:56:33 +03001166 default:
1167 /* do nothing */
1168 break;
1169 }
1170
1171 spin_unlock_irqrestore(&dwc->lock, flags);
1172
1173 pm_runtime_disable(dev);
1174 pm_runtime_set_active(dev);
1175 pm_runtime_enable(dev);
1176
1177 return 0;
Kishon Vijay Abraham I57303482014-03-03 17:08:11 +05301178
1179err_usb2phy_init:
1180 phy_exit(dwc->usb2_generic_phy);
1181
1182 return ret;
Felipe Balbi7415f172012-04-30 14:56:33 +03001183}
1184
1185static const struct dev_pm_ops dwc3_dev_pm_ops = {
Felipe Balbi7415f172012-04-30 14:56:33 +03001186 SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume)
1187};
1188
1189#define DWC3_PM_OPS &(dwc3_dev_pm_ops)
1190#else
1191#define DWC3_PM_OPS NULL
1192#endif
1193
Kishon Vijay Abraham I5088b6f2013-01-25 16:36:53 +05301194#ifdef CONFIG_OF
1195static const struct of_device_id of_dwc3_match[] = {
1196 {
Felipe Balbi22a5aa12013-07-02 21:20:24 +03001197 .compatible = "snps,dwc3"
1198 },
1199 {
Kishon Vijay Abraham I5088b6f2013-01-25 16:36:53 +05301200 .compatible = "synopsys,dwc3"
1201 },
1202 { },
1203};
1204MODULE_DEVICE_TABLE(of, of_dwc3_match);
1205#endif
1206
Heikki Krogerus404905a2014-09-25 10:57:02 +03001207#ifdef CONFIG_ACPI
1208
1209#define ACPI_ID_INTEL_BSW "808622B7"
1210
1211static const struct acpi_device_id dwc3_acpi_match[] = {
1212 { ACPI_ID_INTEL_BSW, 0 },
1213 { },
1214};
1215MODULE_DEVICE_TABLE(acpi, dwc3_acpi_match);
1216#endif
1217
Felipe Balbi72246da2011-08-19 18:10:58 +03001218static struct platform_driver dwc3_driver = {
1219 .probe = dwc3_probe,
Bill Pemberton76904172012-11-19 13:21:08 -05001220 .remove = dwc3_remove,
Felipe Balbi72246da2011-08-19 18:10:58 +03001221 .driver = {
1222 .name = "dwc3",
Kishon Vijay Abraham I5088b6f2013-01-25 16:36:53 +05301223 .of_match_table = of_match_ptr(of_dwc3_match),
Heikki Krogerus404905a2014-09-25 10:57:02 +03001224 .acpi_match_table = ACPI_PTR(dwc3_acpi_match),
Felipe Balbi7415f172012-04-30 14:56:33 +03001225 .pm = DWC3_PM_OPS,
Felipe Balbi72246da2011-08-19 18:10:58 +03001226 },
Felipe Balbi72246da2011-08-19 18:10:58 +03001227};
1228
Tobias Klauserb1116dc2012-02-28 12:57:20 +01001229module_platform_driver(dwc3_driver);
1230
Sebastian Andrzej Siewior7ae4fc42011-10-19 19:39:50 +02001231MODULE_ALIAS("platform:dwc3");
Felipe Balbi72246da2011-08-19 18:10:58 +03001232MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
Felipe Balbi5945f782013-06-30 14:15:11 +03001233MODULE_LICENSE("GPL v2");
Felipe Balbi72246da2011-08-19 18:10:58 +03001234MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");