blob: 77c555e769240c2c4a0dfded17393aecb94781c9 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +05302/**
3 * core.c - DesignWare USB3 DRD Controller Core file
4 *
Kishon Vijay Abraham Id1e431a2015-02-23 18:39:52 +05305 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +05306 *
7 * Authors: Felipe Balbi <balbi@ti.com>,
8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
9 *
Kishon Vijay Abraham Id1e431a2015-02-23 18:39:52 +053010 * Taken from Linux Kernel v3.19-rc1 (drivers/usb/dwc3/core.c) and ported
11 * to uboot.
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053012 *
Kishon Vijay Abraham Id1e431a2015-02-23 18:39:52 +053013 * commit cd72f890d2 : usb: dwc3: core: enable phy suspend quirk on non-FPGA
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053014 */
15
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +053016#include <common.h>
Simon Glass63334482019-11-14 12:57:39 -070017#include <cpu_func.h>
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +053018#include <malloc.h>
Kishon Vijay Abraham Ibfbf05d2015-02-23 18:40:04 +053019#include <dwc3-uboot.h>
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +053020#include <asm/dma-mapping.h>
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053021#include <linux/ioport.h>
Mugunthan V N121f93c2018-05-18 13:10:27 +020022#include <dm.h>
Jean-Jacques Hiblot3de978a2018-11-29 10:52:45 +010023#include <generic-phy.h>
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053024#include <linux/usb/ch9.h>
25#include <linux/usb/gadget.h>
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053026
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053027#include "core.h"
28#include "gadget.h"
29#include "io.h"
30
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +053031#include "linux-compat.h"
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053032
Kishon Vijay Abraham Idc5c6532015-02-23 18:40:05 +053033static LIST_HEAD(dwc3_list);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053034/* -------------------------------------------------------------------------- */
35
Joonyoung Shimbf35c602015-03-03 17:32:09 +010036static void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053037{
38 u32 reg;
39
40 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
41 reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG));
42 reg |= DWC3_GCTL_PRTCAPDIR(mode);
43 dwc3_writel(dwc->regs, DWC3_GCTL, reg);
44}
45
46/**
47 * dwc3_core_soft_reset - Issues core soft reset and PHY reset
48 * @dwc: pointer to our context structure
49 */
50static int dwc3_core_soft_reset(struct dwc3 *dwc)
51{
52 u32 reg;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053053
54 /* Before Resetting PHY, put Core in Reset */
55 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
56 reg |= DWC3_GCTL_CORESOFTRESET;
57 dwc3_writel(dwc->regs, DWC3_GCTL, reg);
58
59 /* Assert USB3 PHY reset */
60 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
61 reg |= DWC3_GUSB3PIPECTL_PHYSOFTRST;
62 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
63
64 /* Assert USB2 PHY reset */
65 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
66 reg |= DWC3_GUSB2PHYCFG_PHYSOFTRST;
67 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
68
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053069 mdelay(100);
70
71 /* Clear USB3 PHY reset */
72 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
73 reg &= ~DWC3_GUSB3PIPECTL_PHYSOFTRST;
74 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
75
76 /* Clear USB2 PHY reset */
77 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
78 reg &= ~DWC3_GUSB2PHYCFG_PHYSOFTRST;
79 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
80
81 mdelay(100);
82
83 /* After PHYs are stable we can take Core out of reset state */
84 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
85 reg &= ~DWC3_GCTL_CORESOFTRESET;
86 dwc3_writel(dwc->regs, DWC3_GCTL, reg);
87
88 return 0;
89}
90
91/**
92 * dwc3_free_one_event_buffer - Frees one event buffer
93 * @dwc: Pointer to our controller context structure
94 * @evt: Pointer to event buffer to be freed
95 */
96static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
97 struct dwc3_event_buffer *evt)
98{
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +053099 dma_free_coherent(evt->buf);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530100}
101
102/**
103 * dwc3_alloc_one_event_buffer - Allocates one event buffer structure
104 * @dwc: Pointer to our controller context structure
105 * @length: size of the event buffer
106 *
107 * Returns a pointer to the allocated event buffer structure on success
108 * otherwise ERR_PTR(errno).
109 */
110static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc,
111 unsigned length)
112{
113 struct dwc3_event_buffer *evt;
114
Mugunthan V N121f93c2018-05-18 13:10:27 +0200115 evt = devm_kzalloc((struct udevice *)dwc->dev, sizeof(*evt),
116 GFP_KERNEL);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530117 if (!evt)
118 return ERR_PTR(-ENOMEM);
119
120 evt->dwc = dwc;
121 evt->length = length;
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530122 evt->buf = dma_alloc_coherent(length,
123 (unsigned long *)&evt->dma);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530124 if (!evt->buf)
125 return ERR_PTR(-ENOMEM);
126
Philipp Tomsich8e17c162017-04-06 16:58:53 +0200127 dwc3_flush_cache((uintptr_t)evt->buf, evt->length);
128
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530129 return evt;
130}
131
132/**
133 * dwc3_free_event_buffers - frees all allocated event buffers
134 * @dwc: Pointer to our controller context structure
135 */
136static void dwc3_free_event_buffers(struct dwc3 *dwc)
137{
138 struct dwc3_event_buffer *evt;
139 int i;
140
141 for (i = 0; i < dwc->num_event_buffers; i++) {
142 evt = dwc->ev_buffs[i];
143 if (evt)
144 dwc3_free_one_event_buffer(dwc, evt);
145 }
146}
147
148/**
149 * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length
150 * @dwc: pointer to our controller context structure
151 * @length: size of event buffer
152 *
153 * Returns 0 on success otherwise negative errno. In the error case, dwc
154 * may contain some buffers allocated but not all which were requested.
155 */
156static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
157{
158 int num;
159 int i;
160
161 num = DWC3_NUM_INT(dwc->hwparams.hwparams1);
162 dwc->num_event_buffers = num;
163
Kishon Vijay Abraham Ic7bdfe32015-02-23 18:40:13 +0530164 dwc->ev_buffs = memalign(CONFIG_SYS_CACHELINE_SIZE,
165 sizeof(*dwc->ev_buffs) * num);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530166 if (!dwc->ev_buffs)
167 return -ENOMEM;
168
169 for (i = 0; i < num; i++) {
170 struct dwc3_event_buffer *evt;
171
172 evt = dwc3_alloc_one_event_buffer(dwc, length);
173 if (IS_ERR(evt)) {
174 dev_err(dwc->dev, "can't allocate event buffer\n");
175 return PTR_ERR(evt);
176 }
177 dwc->ev_buffs[i] = evt;
178 }
179
180 return 0;
181}
182
183/**
184 * dwc3_event_buffers_setup - setup our allocated event buffers
185 * @dwc: pointer to our controller context structure
186 *
187 * Returns 0 on success otherwise negative errno.
188 */
189static int dwc3_event_buffers_setup(struct dwc3 *dwc)
190{
191 struct dwc3_event_buffer *evt;
192 int n;
193
194 for (n = 0; n < dwc->num_event_buffers; n++) {
195 evt = dwc->ev_buffs[n];
196 dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n",
197 evt->buf, (unsigned long long) evt->dma,
198 evt->length);
199
200 evt->lpos = 0;
201
202 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n),
203 lower_32_bits(evt->dma));
204 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n),
205 upper_32_bits(evt->dma));
206 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n),
207 DWC3_GEVNTSIZ_SIZE(evt->length));
208 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
209 }
210
211 return 0;
212}
213
214static void dwc3_event_buffers_cleanup(struct dwc3 *dwc)
215{
216 struct dwc3_event_buffer *evt;
217 int n;
218
219 for (n = 0; n < dwc->num_event_buffers; n++) {
220 evt = dwc->ev_buffs[n];
221
222 evt->lpos = 0;
223
224 dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0);
225 dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0);
226 dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), DWC3_GEVNTSIZ_INTMASK
227 | DWC3_GEVNTSIZ_SIZE(0));
228 dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
229 }
230}
231
232static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc)
233{
234 if (!dwc->has_hibernation)
235 return 0;
236
237 if (!dwc->nr_scratch)
238 return 0;
239
240 dwc->scratchbuf = kmalloc_array(dwc->nr_scratch,
241 DWC3_SCRATCHBUF_SIZE, GFP_KERNEL);
242 if (!dwc->scratchbuf)
243 return -ENOMEM;
244
245 return 0;
246}
247
248static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)
249{
250 dma_addr_t scratch_addr;
251 u32 param;
252 int ret;
253
254 if (!dwc->has_hibernation)
255 return 0;
256
257 if (!dwc->nr_scratch)
258 return 0;
259
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530260 scratch_addr = dma_map_single(dwc->scratchbuf,
261 dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE,
262 DMA_BIDIRECTIONAL);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530263 if (dma_mapping_error(dwc->dev, scratch_addr)) {
264 dev_err(dwc->dev, "failed to map scratch buffer\n");
265 ret = -EFAULT;
266 goto err0;
267 }
268
269 dwc->scratch_addr = scratch_addr;
270
271 param = lower_32_bits(scratch_addr);
272
273 ret = dwc3_send_gadget_generic_command(dwc,
274 DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO, param);
275 if (ret < 0)
276 goto err1;
277
278 param = upper_32_bits(scratch_addr);
279
280 ret = dwc3_send_gadget_generic_command(dwc,
281 DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI, param);
282 if (ret < 0)
283 goto err1;
284
285 return 0;
286
287err1:
Michal Simek698cd6f2015-10-30 16:24:06 +0100288 dma_unmap_single((void *)(uintptr_t)dwc->scratch_addr, dwc->nr_scratch *
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530289 DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530290
291err0:
292 return ret;
293}
294
295static void dwc3_free_scratch_buffers(struct dwc3 *dwc)
296{
297 if (!dwc->has_hibernation)
298 return;
299
300 if (!dwc->nr_scratch)
301 return;
302
Michal Simek698cd6f2015-10-30 16:24:06 +0100303 dma_unmap_single((void *)(uintptr_t)dwc->scratch_addr, dwc->nr_scratch *
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530304 DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530305 kfree(dwc->scratchbuf);
306}
307
308static void dwc3_core_num_eps(struct dwc3 *dwc)
309{
310 struct dwc3_hwparams *parms = &dwc->hwparams;
311
312 dwc->num_in_eps = DWC3_NUM_IN_EPS(parms);
313 dwc->num_out_eps = DWC3_NUM_EPS(parms) - dwc->num_in_eps;
314
315 dev_vdbg(dwc->dev, "found %d IN and %d OUT endpoints\n",
316 dwc->num_in_eps, dwc->num_out_eps);
317}
318
319static void dwc3_cache_hwparams(struct dwc3 *dwc)
320{
321 struct dwc3_hwparams *parms = &dwc->hwparams;
322
323 parms->hwparams0 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS0);
324 parms->hwparams1 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS1);
325 parms->hwparams2 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS2);
326 parms->hwparams3 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS3);
327 parms->hwparams4 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS4);
328 parms->hwparams5 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS5);
329 parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6);
330 parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7);
331 parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8);
332}
333
334/**
335 * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core
336 * @dwc: Pointer to our controller context structure
337 */
338static void dwc3_phy_setup(struct dwc3 *dwc)
339{
340 u32 reg;
341
342 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
343
344 /*
345 * Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY
346 * to '0' during coreConsultant configuration. So default value
347 * will be '0' when the core is reset. Application needs to set it
348 * to '1' after the core initialization is completed.
349 */
350 if (dwc->revision > DWC3_REVISION_194A)
351 reg |= DWC3_GUSB3PIPECTL_SUSPHY;
352
353 if (dwc->u2ss_inp3_quirk)
354 reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
355
356 if (dwc->req_p1p2p3_quirk)
357 reg |= DWC3_GUSB3PIPECTL_REQP1P2P3;
358
359 if (dwc->del_p1p2p3_quirk)
360 reg |= DWC3_GUSB3PIPECTL_DEP1P2P3_EN;
361
362 if (dwc->del_phy_power_chg_quirk)
363 reg |= DWC3_GUSB3PIPECTL_DEPOCHANGE;
364
365 if (dwc->lfps_filter_quirk)
366 reg |= DWC3_GUSB3PIPECTL_LFPSFILT;
367
368 if (dwc->rx_detect_poll_quirk)
369 reg |= DWC3_GUSB3PIPECTL_RX_DETOPOLL;
370
371 if (dwc->tx_de_emphasis_quirk)
372 reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis);
373
374 if (dwc->dis_u3_susphy_quirk)
375 reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
376
377 dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
378
379 mdelay(100);
380
381 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
382
383 /*
384 * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to
385 * '0' during coreConsultant configuration. So default value will
386 * be '0' when the core is reset. Application needs to set it to
387 * '1' after the core initialization is completed.
388 */
389 if (dwc->revision > DWC3_REVISION_194A)
390 reg |= DWC3_GUSB2PHYCFG_SUSPHY;
391
392 if (dwc->dis_u2_susphy_quirk)
393 reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
394
395 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
396
397 mdelay(100);
398}
399
400/**
401 * dwc3_core_init - Low-level initialization of DWC3 Core
402 * @dwc: Pointer to our controller context structure
403 *
404 * Returns 0 on success otherwise negative errno.
405 */
406static int dwc3_core_init(struct dwc3 *dwc)
407{
408 unsigned long timeout;
409 u32 hwparams4 = dwc->hwparams.hwparams4;
410 u32 reg;
411 int ret;
412
413 reg = dwc3_readl(dwc->regs, DWC3_GSNPSID);
414 /* This should read as U3 followed by revision number */
415 if ((reg & DWC3_GSNPSID_MASK) != 0x55330000) {
416 dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n");
417 ret = -ENODEV;
418 goto err0;
419 }
420 dwc->revision = reg;
421
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530422 /* Handle USB2.0-only core configuration */
423 if (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
424 DWC3_GHWPARAMS3_SSPHY_IFC_DIS) {
425 if (dwc->maximum_speed == USB_SPEED_SUPER)
426 dwc->maximum_speed = USB_SPEED_HIGH;
427 }
428
429 /* issue device SoftReset too */
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530430 timeout = 5000;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530431 dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530432 while (timeout--) {
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530433 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
434 if (!(reg & DWC3_DCTL_CSFTRST))
435 break;
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530436 };
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530437
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530438 if (!timeout) {
439 dev_err(dwc->dev, "Reset Timed Out\n");
440 ret = -ETIMEDOUT;
441 goto err0;
442 }
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530443
T Karthik Reddy7bb245a2019-05-01 10:14:49 +0530444 dwc3_phy_setup(dwc);
445
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530446 ret = dwc3_core_soft_reset(dwc);
447 if (ret)
448 goto err0;
449
450 reg = dwc3_readl(dwc->regs, DWC3_GCTL);
451 reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
452
453 switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) {
454 case DWC3_GHWPARAMS1_EN_PWROPT_CLK:
455 /**
456 * WORKAROUND: DWC3 revisions between 2.10a and 2.50a have an
457 * issue which would cause xHCI compliance tests to fail.
458 *
459 * Because of that we cannot enable clock gating on such
460 * configurations.
461 *
462 * Refers to:
463 *
464 * STAR#9000588375: Clock Gating, SOF Issues when ref_clk-Based
465 * SOF/ITP Mode Used
466 */
467 if ((dwc->dr_mode == USB_DR_MODE_HOST ||
468 dwc->dr_mode == USB_DR_MODE_OTG) &&
469 (dwc->revision >= DWC3_REVISION_210A &&
470 dwc->revision <= DWC3_REVISION_250A))
471 reg |= DWC3_GCTL_DSBLCLKGTNG | DWC3_GCTL_SOFITPSYNC;
472 else
473 reg &= ~DWC3_GCTL_DSBLCLKGTNG;
474 break;
475 case DWC3_GHWPARAMS1_EN_PWROPT_HIB:
476 /* enable hibernation here */
477 dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4);
478
479 /*
480 * REVISIT Enabling this bit so that host-mode hibernation
481 * will work. Device-mode hibernation is not yet implemented.
482 */
483 reg |= DWC3_GCTL_GBLHIBERNATIONEN;
484 break;
485 default:
486 dev_dbg(dwc->dev, "No power optimization available\n");
487 }
488
489 /* check if current dwc3 is on simulation board */
490 if (dwc->hwparams.hwparams6 & DWC3_GHWPARAMS6_EN_FPGA) {
491 dev_dbg(dwc->dev, "it is on FPGA board\n");
492 dwc->is_fpga = true;
493 }
494
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530495 if(dwc->disable_scramble_quirk && !dwc->is_fpga)
496 WARN(true,
497 "disable_scramble cannot be used on non-FPGA builds\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530498
499 if (dwc->disable_scramble_quirk && dwc->is_fpga)
500 reg |= DWC3_GCTL_DISSCRAMBLE;
501 else
502 reg &= ~DWC3_GCTL_DISSCRAMBLE;
503
504 if (dwc->u2exit_lfps_quirk)
505 reg |= DWC3_GCTL_U2EXIT_LFPS;
506
507 /*
508 * WORKAROUND: DWC3 revisions <1.90a have a bug
509 * where the device can fail to connect at SuperSpeed
510 * and falls back to high-speed mode which causes
511 * the device to enter a Connect/Disconnect loop
512 */
513 if (dwc->revision < DWC3_REVISION_190A)
514 reg |= DWC3_GCTL_U2RSTECN;
515
516 dwc3_core_num_eps(dwc);
517
518 dwc3_writel(dwc->regs, DWC3_GCTL, reg);
519
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530520 ret = dwc3_alloc_scratch_buffers(dwc);
521 if (ret)
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530522 goto err0;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530523
524 ret = dwc3_setup_scratch_buffers(dwc);
525 if (ret)
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530526 goto err1;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530527
528 return 0;
529
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530530err1:
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530531 dwc3_free_scratch_buffers(dwc);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530532
533err0:
534 return ret;
535}
536
537static void dwc3_core_exit(struct dwc3 *dwc)
538{
539 dwc3_free_scratch_buffers(dwc);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530540}
541
542static int dwc3_core_init_mode(struct dwc3 *dwc)
543{
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530544 int ret;
545
546 switch (dwc->dr_mode) {
547 case USB_DR_MODE_PERIPHERAL:
548 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
549 ret = dwc3_gadget_init(dwc);
550 if (ret) {
551 dev_err(dev, "failed to initialize gadget\n");
552 return ret;
553 }
554 break;
555 case USB_DR_MODE_HOST:
556 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
557 ret = dwc3_host_init(dwc);
558 if (ret) {
559 dev_err(dev, "failed to initialize host\n");
560 return ret;
561 }
562 break;
563 case USB_DR_MODE_OTG:
564 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
565 ret = dwc3_host_init(dwc);
566 if (ret) {
567 dev_err(dev, "failed to initialize host\n");
568 return ret;
569 }
570
571 ret = dwc3_gadget_init(dwc);
572 if (ret) {
573 dev_err(dev, "failed to initialize gadget\n");
574 return ret;
575 }
576 break;
577 default:
578 dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode);
579 return -EINVAL;
580 }
581
582 return 0;
583}
584
Jean-Jacques Hiblot73a1b8b2019-09-11 11:33:45 +0200585static void dwc3_gadget_run(struct dwc3 *dwc)
586{
587 dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_RUN_STOP);
588 mdelay(100);
589}
590
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530591static void dwc3_core_exit_mode(struct dwc3 *dwc)
592{
593 switch (dwc->dr_mode) {
594 case USB_DR_MODE_PERIPHERAL:
595 dwc3_gadget_exit(dwc);
596 break;
597 case USB_DR_MODE_HOST:
598 dwc3_host_exit(dwc);
599 break;
600 case USB_DR_MODE_OTG:
601 dwc3_host_exit(dwc);
602 dwc3_gadget_exit(dwc);
603 break;
604 default:
605 /* do nothing */
606 break;
607 }
Jean-Jacques Hiblot73a1b8b2019-09-11 11:33:45 +0200608
609 /*
610 * switch back to peripheral mode
611 * This enables the phy to enter idle and then, if enabled, suspend.
612 */
613 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
614 dwc3_gadget_run(dwc);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530615}
616
Jagan Teki106c71f2019-11-19 13:56:20 +0530617static void dwc3_uboot_hsphy_mode(struct dwc3_device *dwc3_dev,
618 struct dwc3 *dwc)
619{
620 enum usb_phy_interface hsphy_mode = dwc3_dev->hsphy_mode;
621 u32 reg;
622
623 /* Set dwc3 usb2 phy config */
624 reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
Jagan Teki106c71f2019-11-19 13:56:20 +0530625
626 switch (hsphy_mode) {
627 case USBPHY_INTERFACE_MODE_UTMI:
Jagan Teki5abcf942019-12-18 13:00:02 +0530628 reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK |
629 DWC3_GUSB2PHYCFG_USBTRDTIM_MASK);
630 reg |= DWC3_GUSB2PHYCFG_PHYIF(UTMI_PHYIF_8_BIT) |
631 DWC3_GUSB2PHYCFG_USBTRDTIM(USBTRDTIM_UTMI_8_BIT);
Jagan Teki106c71f2019-11-19 13:56:20 +0530632 break;
633 case USBPHY_INTERFACE_MODE_UTMIW:
Jagan Teki5abcf942019-12-18 13:00:02 +0530634 reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK |
635 DWC3_GUSB2PHYCFG_USBTRDTIM_MASK);
636 reg |= DWC3_GUSB2PHYCFG_PHYIF(UTMI_PHYIF_16_BIT) |
637 DWC3_GUSB2PHYCFG_USBTRDTIM(USBTRDTIM_UTMI_16_BIT);
Jagan Teki106c71f2019-11-19 13:56:20 +0530638 break;
639 default:
640 break;
641 }
642
643 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
644}
645
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530646#define DWC3_ALIGN_MASK (16 - 1)
647
Kishon Vijay Abraham Ibfbf05d2015-02-23 18:40:04 +0530648/**
649 * dwc3_uboot_init - dwc3 core uboot initialization code
650 * @dwc3_dev: struct dwc3_device containing initialization data
651 *
652 * Entry point for dwc3 driver (equivalent to dwc3_probe in linux
653 * kernel driver). Pointer to dwc3_device should be passed containing
654 * base address and other initialization data. Returns '0' on success and
655 * a negative value on failure.
656 *
657 * Generally called from board_usb_init() implemented in board file.
658 */
659int dwc3_uboot_init(struct dwc3_device *dwc3_dev)
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530660{
Kishon Vijay Abraham Idc5c6532015-02-23 18:40:05 +0530661 struct dwc3 *dwc;
Felipe Balbi424305f2015-10-01 14:22:18 -0500662 struct device *dev = NULL;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530663 u8 lpm_nyet_threshold;
664 u8 tx_de_emphasis;
665 u8 hird_threshold;
666
667 int ret;
668
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530669 void *mem;
670
Mugunthan V N121f93c2018-05-18 13:10:27 +0200671 mem = devm_kzalloc((struct udevice *)dev,
672 sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530673 if (!mem)
674 return -ENOMEM;
675
676 dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1);
677 dwc->mem = mem;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530678
Michal Simek698cd6f2015-10-30 16:24:06 +0100679 dwc->regs = (void *)(uintptr_t)(dwc3_dev->base +
680 DWC3_GLOBALS_REGS_START);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530681
682 /* default to highest possible threshold */
683 lpm_nyet_threshold = 0xff;
684
685 /* default to -3.5dB de-emphasis */
686 tx_de_emphasis = 1;
687
688 /*
689 * default to assert utmi_sleep_n and use maximum allowed HIRD
690 * threshold value of 0b1100
691 */
692 hird_threshold = 12;
693
Kishon Vijay Abraham Ibfbf05d2015-02-23 18:40:04 +0530694 dwc->maximum_speed = dwc3_dev->maximum_speed;
695 dwc->has_lpm_erratum = dwc3_dev->has_lpm_erratum;
696 if (dwc3_dev->lpm_nyet_threshold)
697 lpm_nyet_threshold = dwc3_dev->lpm_nyet_threshold;
698 dwc->is_utmi_l1_suspend = dwc3_dev->is_utmi_l1_suspend;
699 if (dwc3_dev->hird_threshold)
700 hird_threshold = dwc3_dev->hird_threshold;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530701
Kishon Vijay Abraham Ibfbf05d2015-02-23 18:40:04 +0530702 dwc->needs_fifo_resize = dwc3_dev->tx_fifo_resize;
703 dwc->dr_mode = dwc3_dev->dr_mode;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530704
Kishon Vijay Abraham Ibfbf05d2015-02-23 18:40:04 +0530705 dwc->disable_scramble_quirk = dwc3_dev->disable_scramble_quirk;
706 dwc->u2exit_lfps_quirk = dwc3_dev->u2exit_lfps_quirk;
707 dwc->u2ss_inp3_quirk = dwc3_dev->u2ss_inp3_quirk;
708 dwc->req_p1p2p3_quirk = dwc3_dev->req_p1p2p3_quirk;
709 dwc->del_p1p2p3_quirk = dwc3_dev->del_p1p2p3_quirk;
710 dwc->del_phy_power_chg_quirk = dwc3_dev->del_phy_power_chg_quirk;
711 dwc->lfps_filter_quirk = dwc3_dev->lfps_filter_quirk;
712 dwc->rx_detect_poll_quirk = dwc3_dev->rx_detect_poll_quirk;
713 dwc->dis_u3_susphy_quirk = dwc3_dev->dis_u3_susphy_quirk;
714 dwc->dis_u2_susphy_quirk = dwc3_dev->dis_u2_susphy_quirk;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530715
Kishon Vijay Abraham Ibfbf05d2015-02-23 18:40:04 +0530716 dwc->tx_de_emphasis_quirk = dwc3_dev->tx_de_emphasis_quirk;
717 if (dwc3_dev->tx_de_emphasis)
718 tx_de_emphasis = dwc3_dev->tx_de_emphasis;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530719
720 /* default to superspeed if no maximum_speed passed */
721 if (dwc->maximum_speed == USB_SPEED_UNKNOWN)
722 dwc->maximum_speed = USB_SPEED_SUPER;
723
724 dwc->lpm_nyet_threshold = lpm_nyet_threshold;
725 dwc->tx_de_emphasis = tx_de_emphasis;
726
727 dwc->hird_threshold = hird_threshold
728 | (dwc->is_utmi_l1_suspend << 4);
729
Kishon Vijay Abraham Idc5c6532015-02-23 18:40:05 +0530730 dwc->index = dwc3_dev->index;
731
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530732 dwc3_cache_hwparams(dwc);
733
734 ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
735 if (ret) {
736 dev_err(dwc->dev, "failed to allocate event buffers\n");
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530737 return -ENOMEM;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530738 }
739
Jean-Jacques Hiblot731a2a32019-09-11 11:33:53 +0200740 if (!IS_ENABLED(CONFIG_USB_DWC3_GADGET))
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530741 dwc->dr_mode = USB_DR_MODE_HOST;
Jean-Jacques Hiblot731a2a32019-09-11 11:33:53 +0200742 else if (!IS_ENABLED(CONFIG_USB_HOST))
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530743 dwc->dr_mode = USB_DR_MODE_PERIPHERAL;
744
745 if (dwc->dr_mode == USB_DR_MODE_UNKNOWN)
746 dwc->dr_mode = USB_DR_MODE_OTG;
747
748 ret = dwc3_core_init(dwc);
749 if (ret) {
750 dev_err(dev, "failed to initialize core\n");
751 goto err0;
752 }
753
Jagan Teki106c71f2019-11-19 13:56:20 +0530754 dwc3_uboot_hsphy_mode(dwc3_dev, dwc);
755
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530756 ret = dwc3_event_buffers_setup(dwc);
757 if (ret) {
758 dev_err(dwc->dev, "failed to setup event buffers\n");
Kishon Vijay Abraham I99030d72015-02-23 18:40:02 +0530759 goto err1;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530760 }
761
762 ret = dwc3_core_init_mode(dwc);
763 if (ret)
764 goto err2;
765
Kishon Vijay Abraham Idc5c6532015-02-23 18:40:05 +0530766 list_add_tail(&dwc->list, &dwc3_list);
767
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530768 return 0;
769
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530770err2:
771 dwc3_event_buffers_cleanup(dwc);
772
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530773err1:
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530774 dwc3_core_exit(dwc);
775
776err0:
777 dwc3_free_event_buffers(dwc);
778
779 return ret;
780}
781
Kishon Vijay Abraham Ibfbf05d2015-02-23 18:40:04 +0530782/**
783 * dwc3_uboot_exit - dwc3 core uboot cleanup code
784 * @index: index of this controller
785 *
786 * Performs cleanup of memory allocated in dwc3_uboot_init and other misc
Kishon Vijay Abraham Idc5c6532015-02-23 18:40:05 +0530787 * cleanups (equivalent to dwc3_remove in linux). index of _this_ controller
788 * should be passed and should match with the index passed in
789 * dwc3_device during init.
Kishon Vijay Abraham Ibfbf05d2015-02-23 18:40:04 +0530790 *
791 * Generally called from board file.
792 */
Kishon Vijay Abraham Idc5c6532015-02-23 18:40:05 +0530793void dwc3_uboot_exit(int index)
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530794{
Kishon Vijay Abraham Idc5c6532015-02-23 18:40:05 +0530795 struct dwc3 *dwc;
796
797 list_for_each_entry(dwc, &dwc3_list, list) {
798 if (dwc->index != index)
799 continue;
800
801 dwc3_core_exit_mode(dwc);
802 dwc3_event_buffers_cleanup(dwc);
803 dwc3_free_event_buffers(dwc);
804 dwc3_core_exit(dwc);
805 list_del(&dwc->list);
806 kfree(dwc->mem);
807 break;
808 }
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530809}
810
Kishon Vijay Abraham I1cee7b12015-02-23 18:40:06 +0530811/**
812 * dwc3_uboot_handle_interrupt - handle dwc3 core interrupt
813 * @index: index of this controller
814 *
815 * Invokes dwc3 gadget interrupts.
816 *
817 * Generally called from board file.
818 */
819void dwc3_uboot_handle_interrupt(int index)
820{
821 struct dwc3 *dwc = NULL;
822
823 list_for_each_entry(dwc, &dwc3_list, list) {
824 if (dwc->index != index)
825 continue;
826
827 dwc3_gadget_uboot_handle_interrupt(dwc);
828 break;
829 }
830}
831
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530832MODULE_ALIAS("platform:dwc3");
833MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
834MODULE_LICENSE("GPL v2");
835MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");
Mugunthan V N5f7ff712018-05-18 13:15:04 +0200836
Jean-Jacques Hiblot3de978a2018-11-29 10:52:45 +0100837#if CONFIG_IS_ENABLED(PHY) && CONFIG_IS_ENABLED(DM_USB)
838int dwc3_setup_phy(struct udevice *dev, struct phy **array, int *num_phys)
839{
840 int i, ret, count;
841 struct phy *usb_phys;
842
843 /* Return if no phy declared */
844 if (!dev_read_prop(dev, "phys", NULL))
845 return 0;
846 count = dev_count_phandle_with_args(dev, "phys", "#phy-cells");
847 if (count <= 0)
848 return count;
849
850 usb_phys = devm_kcalloc(dev, count, sizeof(struct phy),
851 GFP_KERNEL);
852 if (!usb_phys)
853 return -ENOMEM;
854
855 for (i = 0; i < count; i++) {
856 ret = generic_phy_get_by_index(dev, i, &usb_phys[i]);
857 if (ret && ret != -ENOENT) {
858 pr_err("Failed to get USB PHY%d for %s\n",
859 i, dev->name);
860 return ret;
861 }
862 }
863
864 for (i = 0; i < count; i++) {
865 ret = generic_phy_init(&usb_phys[i]);
866 if (ret) {
867 pr_err("Can't init USB PHY%d for %s\n",
868 i, dev->name);
869 goto phys_init_err;
870 }
871 }
872
873 for (i = 0; i < count; i++) {
874 ret = generic_phy_power_on(&usb_phys[i]);
875 if (ret) {
876 pr_err("Can't power USB PHY%d for %s\n",
877 i, dev->name);
878 goto phys_poweron_err;
879 }
880 }
881
882 *array = usb_phys;
883 *num_phys = count;
884 return 0;
885
886phys_poweron_err:
887 for (i = count - 1; i >= 0; i--)
888 generic_phy_power_off(&usb_phys[i]);
889
890 for (i = 0; i < count; i++)
891 generic_phy_exit(&usb_phys[i]);
892
893 return ret;
894
895phys_init_err:
896 for (; i >= 0; i--)
897 generic_phy_exit(&usb_phys[i]);
898
899 return ret;
900}
901
902int dwc3_shutdown_phy(struct udevice *dev, struct phy *usb_phys, int num_phys)
903{
904 int i, ret;
905
906 for (i = 0; i < num_phys; i++) {
907 if (!generic_phy_valid(&usb_phys[i]))
908 continue;
909
910 ret = generic_phy_power_off(&usb_phys[i]);
911 ret |= generic_phy_exit(&usb_phys[i]);
912 if (ret) {
913 pr_err("Can't shutdown USB PHY%d for %s\n",
914 i, dev->name);
915 }
916 }
917
918 return 0;
919}
920#endif
921
Jean-Jacques Hiblot175cd7c2019-09-11 11:33:50 +0200922#if CONFIG_IS_ENABLED(DM_USB)
Jean-Jacques Hiblotce868d02019-09-11 11:33:52 +0200923void dwc3_of_parse(struct dwc3 *dwc)
924{
925 const u8 *tmp;
926 struct udevice *dev = dwc->dev;
927 u8 lpm_nyet_threshold;
928 u8 tx_de_emphasis;
929 u8 hird_threshold;
930
931 /* default to highest possible threshold */
932 lpm_nyet_threshold = 0xff;
933
934 /* default to -3.5dB de-emphasis */
935 tx_de_emphasis = 1;
936
937 /*
938 * default to assert utmi_sleep_n and use maximum allowed HIRD
939 * threshold value of 0b1100
940 */
941 hird_threshold = 12;
942
943 dwc->has_lpm_erratum = dev_read_bool(dev,
944 "snps,has-lpm-erratum");
945 tmp = dev_read_u8_array_ptr(dev, "snps,lpm-nyet-threshold", 1);
946 if (tmp)
947 lpm_nyet_threshold = *tmp;
948
949 dwc->is_utmi_l1_suspend = dev_read_bool(dev,
950 "snps,is-utmi-l1-suspend");
951 tmp = dev_read_u8_array_ptr(dev, "snps,hird-threshold", 1);
952 if (tmp)
953 hird_threshold = *tmp;
954
955 dwc->disable_scramble_quirk = dev_read_bool(dev,
956 "snps,disable_scramble_quirk");
957 dwc->u2exit_lfps_quirk = dev_read_bool(dev,
958 "snps,u2exit_lfps_quirk");
959 dwc->u2ss_inp3_quirk = dev_read_bool(dev,
960 "snps,u2ss_inp3_quirk");
961 dwc->req_p1p2p3_quirk = dev_read_bool(dev,
962 "snps,req_p1p2p3_quirk");
963 dwc->del_p1p2p3_quirk = dev_read_bool(dev,
964 "snps,del_p1p2p3_quirk");
965 dwc->del_phy_power_chg_quirk = dev_read_bool(dev,
966 "snps,del_phy_power_chg_quirk");
967 dwc->lfps_filter_quirk = dev_read_bool(dev,
968 "snps,lfps_filter_quirk");
969 dwc->rx_detect_poll_quirk = dev_read_bool(dev,
970 "snps,rx_detect_poll_quirk");
971 dwc->dis_u3_susphy_quirk = dev_read_bool(dev,
972 "snps,dis_u3_susphy_quirk");
973 dwc->dis_u2_susphy_quirk = dev_read_bool(dev,
974 "snps,dis_u2_susphy_quirk");
975 dwc->tx_de_emphasis_quirk = dev_read_bool(dev,
976 "snps,tx_de_emphasis_quirk");
977 tmp = dev_read_u8_array_ptr(dev, "snps,tx_de_emphasis", 1);
978 if (tmp)
979 tx_de_emphasis = *tmp;
980
981 dwc->lpm_nyet_threshold = lpm_nyet_threshold;
982 dwc->tx_de_emphasis = tx_de_emphasis;
983
984 dwc->hird_threshold = hird_threshold
985 | (dwc->is_utmi_l1_suspend << 4);
986}
987
Mugunthan V N5f7ff712018-05-18 13:15:04 +0200988int dwc3_init(struct dwc3 *dwc)
989{
990 int ret;
991
992 dwc3_cache_hwparams(dwc);
993
994 ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
995 if (ret) {
996 dev_err(dwc->dev, "failed to allocate event buffers\n");
997 return -ENOMEM;
998 }
999
1000 ret = dwc3_core_init(dwc);
1001 if (ret) {
1002 dev_err(dev, "failed to initialize core\n");
1003 goto core_fail;
1004 }
1005
1006 ret = dwc3_event_buffers_setup(dwc);
1007 if (ret) {
1008 dev_err(dwc->dev, "failed to setup event buffers\n");
1009 goto event_fail;
1010 }
1011
1012 ret = dwc3_core_init_mode(dwc);
1013 if (ret)
1014 goto mode_fail;
1015
1016 return 0;
1017
1018mode_fail:
1019 dwc3_event_buffers_cleanup(dwc);
1020
1021event_fail:
1022 dwc3_core_exit(dwc);
1023
1024core_fail:
1025 dwc3_free_event_buffers(dwc);
1026
1027 return ret;
1028}
1029
1030void dwc3_remove(struct dwc3 *dwc)
1031{
1032 dwc3_core_exit_mode(dwc);
1033 dwc3_event_buffers_cleanup(dwc);
1034 dwc3_free_event_buffers(dwc);
1035 dwc3_core_exit(dwc);
1036 kfree(dwc->mem);
1037}
Mugunthan V N5f7ff712018-05-18 13:15:04 +02001038#endif