blob: 531f0b522af71b38acd8e7f727d86fded57443b7 [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 * ep0.c - DesignWare USB3 DRD Controller Endpoint 0 Handling
4 *
Nishanth Menoneaa39c62023-11-01 15:56:03 -05005 * Copyright (C) 2015 Texas Instruments Incorporated - https://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/ep0.c) and ported
11 * to uboot.
12 *
13 * commit c00552ebaf : Merge 3.18-rc7 into usb-next
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053014 */
Simon Glass63334482019-11-14 12:57:39 -070015#include <cpu_func.h>
Sean Anderson2789ce82020-09-15 10:45:16 -040016#include <dm.h>
Simon Glass9bc15642020-02-03 07:36:16 -070017#include <dm/device_compat.h>
Simon Glassc06c1be2020-05-10 11:40:08 -060018#include <linux/bug.h>
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053019#include <linux/kernel.h>
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053020#include <linux/list.h>
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053021
22#include <linux/usb/ch9.h>
23#include <linux/usb/gadget.h>
24#include <linux/usb/composite.h>
25
26#include "core.h"
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053027#include "gadget.h"
28#include "io.h"
29
Kishon Vijay Abraham I9c38ca42015-02-23 18:40:00 +053030#include "linux-compat.h"
31
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053032static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep);
33static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
34 struct dwc3_ep *dep, struct dwc3_request *req);
35
36static const char *dwc3_ep0_state_string(enum dwc3_ep0_state state)
37{
38 switch (state) {
39 case EP0_UNCONNECTED:
40 return "Unconnected";
41 case EP0_SETUP_PHASE:
42 return "Setup Phase";
43 case EP0_DATA_PHASE:
44 return "Data Phase";
45 case EP0_STATUS_PHASE:
46 return "Status Phase";
47 default:
48 return "UNKNOWN";
49 }
50}
51
52static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma,
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +053053 u32 len, u32 type, unsigned chain)
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053054{
55 struct dwc3_gadget_ep_cmd_params params;
56 struct dwc3_trb *trb;
57 struct dwc3_ep *dep;
58
59 int ret;
60
61 dep = dwc->eps[epnum];
62 if (dep->flags & DWC3_EP_BUSY) {
Caleb Connolly61c7d822024-06-18 17:03:43 +020063 dev_vdbg(dwc->dev, "%s still busy\n", dep->name);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053064 return 0;
65 }
66
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +053067 trb = &dwc->ep0_trb[dep->free_slot];
68
69 if (chain)
70 dep->free_slot++;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053071
72 trb->bpl = lower_32_bits(buf_dma);
73 trb->bph = upper_32_bits(buf_dma);
74 trb->size = len;
75 trb->ctrl = type;
76
77 trb->ctrl |= (DWC3_TRB_CTRL_HWO
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053078 | DWC3_TRB_CTRL_ISP_IMI);
79
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +053080 if (chain)
81 trb->ctrl |= DWC3_TRB_CTRL_CHN;
82 else
83 trb->ctrl |= (DWC3_TRB_CTRL_IOC
84 | DWC3_TRB_CTRL_LST);
85
Philipp Tomsiched121672017-04-06 16:58:52 +020086 dwc3_flush_cache((uintptr_t)buf_dma, len);
87 dwc3_flush_cache((uintptr_t)trb, sizeof(*trb));
Kishon Vijay Abraham Ic7bdfe32015-02-23 18:40:13 +053088
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +053089 if (chain)
90 return 0;
91
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053092 memset(&params, 0, sizeof(params));
93 params.param0 = upper_32_bits(dwc->ep0_trb_addr);
94 params.param1 = lower_32_bits(dwc->ep0_trb_addr);
95
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +053096 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number,
97 DWC3_DEPCMD_STARTTRANSFER, &params);
98 if (ret < 0) {
Kishon Vijay Abraham I389f6d42015-02-23 18:39:53 +053099 dev_dbg(dwc->dev, "%s STARTTRANSFER failed", dep->name);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530100 return ret;
101 }
102
103 dep->flags |= DWC3_EP_BUSY;
104 dep->resource_index = dwc3_gadget_ep_get_transfer_index(dwc,
105 dep->number);
106
107 dwc->ep0_next_event = DWC3_EP0_COMPLETE;
108
109 return 0;
110}
111
112static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
113 struct dwc3_request *req)
114{
115 struct dwc3 *dwc = dep->dwc;
116
117 req->request.actual = 0;
118 req->request.status = -EINPROGRESS;
119 req->epnum = dep->number;
120
121 list_add_tail(&req->list, &dep->request_list);
122
123 /*
124 * Gadget driver might not be quick enough to queue a request
125 * before we get a Transfer Not Ready event on this endpoint.
126 *
127 * In that case, we will set DWC3_EP_PENDING_REQUEST. When that
128 * flag is set, it's telling us that as soon as Gadget queues the
129 * required request, we should kick the transfer here because the
130 * IRQ we were waiting for is long gone.
131 */
132 if (dep->flags & DWC3_EP_PENDING_REQUEST) {
133 unsigned direction;
134
135 direction = !!(dep->flags & DWC3_EP0_DIR_IN);
136
137 if (dwc->ep0state != EP0_DATA_PHASE) {
138 dev_WARN(dwc->dev, "Unexpected pending request\n");
139 return 0;
140 }
141
142 __dwc3_ep0_do_control_data(dwc, dwc->eps[direction], req);
143
144 dep->flags &= ~(DWC3_EP_PENDING_REQUEST |
145 DWC3_EP0_DIR_IN);
146
147 return 0;
148 }
149
150 /*
151 * In case gadget driver asked us to delay the STATUS phase,
152 * handle it here.
153 */
154 if (dwc->delayed_status) {
155 unsigned direction;
156
157 direction = !dwc->ep0_expect_in;
158 dwc->delayed_status = false;
159 usb_gadget_set_state(&dwc->gadget, USB_STATE_CONFIGURED);
160
161 if (dwc->ep0state == EP0_STATUS_PHASE)
162 __dwc3_ep0_do_control_status(dwc, dwc->eps[direction]);
163 else
Kishon Vijay Abraham I389f6d42015-02-23 18:39:53 +0530164 dev_dbg(dwc->dev, "too early for delayed status");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530165
166 return 0;
167 }
168
169 /*
170 * Unfortunately we have uncovered a limitation wrt the Data Phase.
171 *
172 * Section 9.4 says we can wait for the XferNotReady(DATA) event to
173 * come before issueing Start Transfer command, but if we do, we will
174 * miss situations where the host starts another SETUP phase instead of
175 * the DATA phase. Such cases happen at least on TD.7.6 of the Link
176 * Layer Compliance Suite.
177 *
178 * The problem surfaces due to the fact that in case of back-to-back
179 * SETUP packets there will be no XferNotReady(DATA) generated and we
180 * will be stuck waiting for XferNotReady(DATA) forever.
181 *
182 * By looking at tables 9-13 and 9-14 of the Databook, we can see that
183 * it tells us to start Data Phase right away. It also mentions that if
184 * we receive a SETUP phase instead of the DATA phase, core will issue
185 * XferComplete for the DATA phase, before actually initiating it in
186 * the wire, with the TRB's status set to "SETUP_PENDING". Such status
187 * can only be used to print some debugging logs, as the core expects
188 * us to go through to the STATUS phase and start a CONTROL_STATUS TRB,
189 * just so it completes right away, without transferring anything and,
190 * only then, we can go back to the SETUP phase.
191 *
192 * Because of this scenario, SNPS decided to change the programming
193 * model of control transfers and support on-demand transfers only for
194 * the STATUS phase. To fix the issue we have now, we will always wait
195 * for gadget driver to queue the DATA phase's struct usb_request, then
196 * start it right away.
197 *
198 * If we're actually in a 2-stage transfer, we will wait for
199 * XferNotReady(STATUS).
200 */
201 if (dwc->three_stage_setup) {
202 unsigned direction;
203
204 direction = dwc->ep0_expect_in;
205 dwc->ep0state = EP0_DATA_PHASE;
206
207 __dwc3_ep0_do_control_data(dwc, dwc->eps[direction], req);
208
209 dep->flags &= ~DWC3_EP0_DIR_IN;
210 }
211
212 return 0;
213}
214
215int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,
216 gfp_t gfp_flags)
217{
218 struct dwc3_request *req = to_dwc3_request(request);
219 struct dwc3_ep *dep = to_dwc3_ep(ep);
220 struct dwc3 *dwc = dep->dwc;
221
222 unsigned long flags;
223
224 int ret;
225
226 spin_lock_irqsave(&dwc->lock, flags);
227 if (!dep->endpoint.desc) {
Kishon Vijay Abraham I389f6d42015-02-23 18:39:53 +0530228 dev_dbg(dwc->dev, "trying to queue request %p to disabled %s",
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530229 request, dep->name);
230 ret = -ESHUTDOWN;
231 goto out;
232 }
233
234 /* we share one TRB for ep0/1 */
235 if (!list_empty(&dep->request_list)) {
236 ret = -EBUSY;
237 goto out;
238 }
239
Caleb Connolly61c7d822024-06-18 17:03:43 +0200240 dev_vdbg(dwc->dev, "queueing request %p to %s length %d state '%s\n'",
241 request, dep->name, request->length,
242 dwc3_ep0_state_string(dwc->ep0state));
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530243
244 ret = __dwc3_gadget_ep0_queue(dep, req);
245
246out:
247 spin_unlock_irqrestore(&dwc->lock, flags);
248
249 return ret;
250}
251
252static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc)
253{
254 struct dwc3_ep *dep;
255
256 /* reinitialize physical ep1 */
257 dep = dwc->eps[1];
258 dep->flags = DWC3_EP_ENABLED;
259
260 /* stall is always issued on EP0 */
261 dep = dwc->eps[0];
262 __dwc3_gadget_ep_set_halt(dep, 1, false);
263 dep->flags = DWC3_EP_ENABLED;
264 dwc->delayed_status = false;
265
266 if (!list_empty(&dep->request_list)) {
267 struct dwc3_request *req;
268
269 req = next_request(&dep->request_list);
270 dwc3_gadget_giveback(dep, req, -ECONNRESET);
271 }
272
273 dwc->ep0state = EP0_SETUP_PHASE;
274 dwc3_ep0_out_start(dwc);
275}
276
277int __dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value)
278{
279 struct dwc3_ep *dep = to_dwc3_ep(ep);
280 struct dwc3 *dwc = dep->dwc;
281
282 dwc3_ep0_stall_and_restart(dwc);
283
284 return 0;
285}
286
287int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value)
288{
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530289 unsigned long flags;
290 int ret;
291
292 spin_lock_irqsave(&dwc->lock, flags);
293 ret = __dwc3_gadget_ep0_set_halt(ep, value);
294 spin_unlock_irqrestore(&dwc->lock, flags);
295
296 return ret;
297}
298
299void dwc3_ep0_out_start(struct dwc3 *dwc)
300{
301 int ret;
302
303 ret = dwc3_ep0_start_trans(dwc, 0, dwc->ctrl_req_addr, 8,
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +0530304 DWC3_TRBCTL_CONTROL_SETUP, 0);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530305 WARN_ON(ret < 0);
306}
307
308static struct dwc3_ep *dwc3_wIndex_to_dep(struct dwc3 *dwc, __le16 wIndex_le)
309{
310 struct dwc3_ep *dep;
311 u32 windex = le16_to_cpu(wIndex_le);
312 u32 epnum;
313
314 epnum = (windex & USB_ENDPOINT_NUMBER_MASK) << 1;
315 if ((windex & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)
316 epnum |= 1;
317
318 dep = dwc->eps[epnum];
319 if (dep->flags & DWC3_EP_ENABLED)
320 return dep;
321
322 return NULL;
323}
324
325static void dwc3_ep0_status_cmpl(struct usb_ep *ep, struct usb_request *req)
326{
327}
328/*
329 * ch 9.4.5
330 */
331static int dwc3_ep0_handle_status(struct dwc3 *dwc,
332 struct usb_ctrlrequest *ctrl)
333{
334 struct dwc3_ep *dep;
335 u32 recip;
336 u32 reg;
337 u16 usb_status = 0;
338 __le16 *response_pkt;
339
340 recip = ctrl->bRequestType & USB_RECIP_MASK;
341 switch (recip) {
342 case USB_RECIP_DEVICE:
343 /*
344 * LTM will be set once we know how to set this in HW.
345 */
346 usb_status |= dwc->is_selfpowered << USB_DEVICE_SELF_POWERED;
347
348 if (dwc->speed == DWC3_DSTS_SUPERSPEED) {
349 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
350 if (reg & DWC3_DCTL_INITU1ENA)
351 usb_status |= 1 << USB_DEV_STAT_U1_ENABLED;
352 if (reg & DWC3_DCTL_INITU2ENA)
353 usb_status |= 1 << USB_DEV_STAT_U2_ENABLED;
354 }
355
356 break;
357
358 case USB_RECIP_INTERFACE:
359 /*
360 * Function Remote Wake Capable D0
361 * Function Remote Wakeup D1
362 */
363 break;
364
365 case USB_RECIP_ENDPOINT:
366 dep = dwc3_wIndex_to_dep(dwc, ctrl->wIndex);
367 if (!dep)
368 return -EINVAL;
369
370 if (dep->flags & DWC3_EP_STALL)
371 usb_status = 1 << USB_ENDPOINT_HALT;
372 break;
373 default:
374 return -EINVAL;
375 }
376
377 response_pkt = (__le16 *) dwc->setup_buf;
378 *response_pkt = cpu_to_le16(usb_status);
379
380 dep = dwc->eps[0];
381 dwc->ep0_usb_req.dep = dep;
382 dwc->ep0_usb_req.request.length = sizeof(*response_pkt);
Neil Armstrongec21f2f2024-10-11 16:38:24 +0200383 dwc->ep0_usb_req.request.buf = (void *)dwc->setup_buf_addr;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530384 dwc->ep0_usb_req.request.complete = dwc3_ep0_status_cmpl;
385
386 return __dwc3_gadget_ep0_queue(dep, &dwc->ep0_usb_req);
387}
388
389static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
390 struct usb_ctrlrequest *ctrl, int set)
391{
392 struct dwc3_ep *dep;
393 u32 recip;
394 u32 wValue;
395 u32 wIndex;
396 u32 reg;
397 int ret;
398 enum usb_device_state state;
399
400 wValue = le16_to_cpu(ctrl->wValue);
401 wIndex = le16_to_cpu(ctrl->wIndex);
402 recip = ctrl->bRequestType & USB_RECIP_MASK;
403 state = dwc->gadget.state;
404
405 switch (recip) {
406 case USB_RECIP_DEVICE:
407
408 switch (wValue) {
409 case USB_DEVICE_REMOTE_WAKEUP:
410 break;
411 /*
412 * 9.4.1 says only only for SS, in AddressState only for
413 * default control pipe
414 */
415 case USB_DEVICE_U1_ENABLE:
416 if (state != USB_STATE_CONFIGURED)
417 return -EINVAL;
418 if (dwc->speed != DWC3_DSTS_SUPERSPEED)
419 return -EINVAL;
420
421 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
422 if (set)
423 reg |= DWC3_DCTL_INITU1ENA;
424 else
425 reg &= ~DWC3_DCTL_INITU1ENA;
426 dwc3_writel(dwc->regs, DWC3_DCTL, reg);
427 break;
428
429 case USB_DEVICE_U2_ENABLE:
430 if (state != USB_STATE_CONFIGURED)
431 return -EINVAL;
432 if (dwc->speed != DWC3_DSTS_SUPERSPEED)
433 return -EINVAL;
434
435 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
436 if (set)
437 reg |= DWC3_DCTL_INITU2ENA;
438 else
439 reg &= ~DWC3_DCTL_INITU2ENA;
440 dwc3_writel(dwc->regs, DWC3_DCTL, reg);
441 break;
442
443 case USB_DEVICE_LTM_ENABLE:
444 return -EINVAL;
445
446 case USB_DEVICE_TEST_MODE:
447 if ((wIndex & 0xff) != 0)
448 return -EINVAL;
449 if (!set)
450 return -EINVAL;
451
452 dwc->test_mode_nr = wIndex >> 8;
453 dwc->test_mode = true;
454 break;
455 default:
456 return -EINVAL;
457 }
458 break;
459
460 case USB_RECIP_INTERFACE:
461 switch (wValue) {
462 case USB_INTRF_FUNC_SUSPEND:
463 if (wIndex & USB_INTRF_FUNC_SUSPEND_LP)
464 /* XXX enable Low power suspend */
465 ;
466 if (wIndex & USB_INTRF_FUNC_SUSPEND_RW)
467 /* XXX enable remote wakeup */
468 ;
469 break;
470 default:
471 return -EINVAL;
472 }
473 break;
474
475 case USB_RECIP_ENDPOINT:
476 switch (wValue) {
477 case USB_ENDPOINT_HALT:
478 dep = dwc3_wIndex_to_dep(dwc, wIndex);
479 if (!dep)
480 return -EINVAL;
481 if (set == 0 && (dep->flags & DWC3_EP_WEDGE))
482 break;
483 ret = __dwc3_gadget_ep_set_halt(dep, set, true);
484 if (ret)
485 return -EINVAL;
486 break;
487 default:
488 return -EINVAL;
489 }
490 break;
491
492 default:
493 return -EINVAL;
494 }
495
496 return 0;
497}
498
499static int dwc3_ep0_set_address(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
500{
501 enum usb_device_state state = dwc->gadget.state;
502 u32 addr;
503 u32 reg;
504
505 addr = le16_to_cpu(ctrl->wValue);
506 if (addr > 127) {
Kishon Vijay Abraham I389f6d42015-02-23 18:39:53 +0530507 dev_dbg(dwc->dev, "invalid device address %d", addr);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530508 return -EINVAL;
509 }
510
511 if (state == USB_STATE_CONFIGURED) {
Kishon Vijay Abraham I389f6d42015-02-23 18:39:53 +0530512 dev_dbg(dwc->dev, "trying to set address when configured");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530513 return -EINVAL;
514 }
515
516 reg = dwc3_readl(dwc->regs, DWC3_DCFG);
517 reg &= ~(DWC3_DCFG_DEVADDR_MASK);
518 reg |= DWC3_DCFG_DEVADDR(addr);
519 dwc3_writel(dwc->regs, DWC3_DCFG, reg);
520
521 if (addr)
522 usb_gadget_set_state(&dwc->gadget, USB_STATE_ADDRESS);
523 else
524 usb_gadget_set_state(&dwc->gadget, USB_STATE_DEFAULT);
525
526 return 0;
527}
528
529static int dwc3_ep0_delegate_req(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
530{
531 int ret;
532
533 spin_unlock(&dwc->lock);
534 ret = dwc->gadget_driver->setup(&dwc->gadget, ctrl);
535 spin_lock(&dwc->lock);
536 return ret;
537}
538
539static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
540{
541 enum usb_device_state state = dwc->gadget.state;
542 u32 cfg;
543 int ret;
544 u32 reg;
545
546 dwc->start_config_issued = false;
547 cfg = le16_to_cpu(ctrl->wValue);
548
549 switch (state) {
550 case USB_STATE_DEFAULT:
551 return -EINVAL;
552
553 case USB_STATE_ADDRESS:
554 ret = dwc3_ep0_delegate_req(dwc, ctrl);
555 /* if the cfg matches and the cfg is non zero */
556 if (cfg && (!ret || (ret == USB_GADGET_DELAYED_STATUS))) {
557
558 /*
559 * only change state if set_config has already
560 * been processed. If gadget driver returns
561 * USB_GADGET_DELAYED_STATUS, we will wait
562 * to change the state on the next usb_ep_queue()
563 */
564 if (ret == 0)
565 usb_gadget_set_state(&dwc->gadget,
566 USB_STATE_CONFIGURED);
567
568 /*
569 * Enable transition to U1/U2 state when
570 * nothing is pending from application.
571 */
572 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
573 reg |= (DWC3_DCTL_ACCEPTU1ENA | DWC3_DCTL_ACCEPTU2ENA);
574 dwc3_writel(dwc->regs, DWC3_DCTL, reg);
575
576 dwc->resize_fifos = true;
Kishon Vijay Abraham I389f6d42015-02-23 18:39:53 +0530577 dev_dbg(dwc->dev, "resize FIFOs flag SET");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530578 }
579 break;
580
581 case USB_STATE_CONFIGURED:
582 ret = dwc3_ep0_delegate_req(dwc, ctrl);
583 if (!cfg && !ret)
584 usb_gadget_set_state(&dwc->gadget,
585 USB_STATE_ADDRESS);
586 break;
587 default:
588 ret = -EINVAL;
589 }
590 return ret;
591}
592
593static void dwc3_ep0_set_sel_cmpl(struct usb_ep *ep, struct usb_request *req)
594{
595 struct dwc3_ep *dep = to_dwc3_ep(ep);
596 struct dwc3 *dwc = dep->dwc;
597
598 u32 param = 0;
599 u32 reg;
600
601 struct timing {
602 u8 u1sel;
603 u8 u1pel;
604 u16 u2sel;
605 u16 u2pel;
606 } __packed timing;
607
608 int ret;
609
610 memcpy(&timing, req->buf, sizeof(timing));
611
612 dwc->u1sel = timing.u1sel;
613 dwc->u1pel = timing.u1pel;
614 dwc->u2sel = le16_to_cpu(timing.u2sel);
615 dwc->u2pel = le16_to_cpu(timing.u2pel);
616
617 reg = dwc3_readl(dwc->regs, DWC3_DCTL);
618 if (reg & DWC3_DCTL_INITU2ENA)
619 param = dwc->u2pel;
620 if (reg & DWC3_DCTL_INITU1ENA)
621 param = dwc->u1pel;
622
623 /*
624 * According to Synopsys Databook, if parameter is
625 * greater than 125, a value of zero should be
626 * programmed in the register.
627 */
628 if (param > 125)
629 param = 0;
630
631 /* now that we have the time, issue DGCMD Set Sel */
632 ret = dwc3_send_gadget_generic_command(dwc,
633 DWC3_DGCMD_SET_PERIODIC_PAR, param);
634 WARN_ON(ret < 0);
635}
636
637static int dwc3_ep0_set_sel(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
638{
639 struct dwc3_ep *dep;
640 enum usb_device_state state = dwc->gadget.state;
641 u16 wLength;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530642
643 if (state == USB_STATE_DEFAULT)
644 return -EINVAL;
645
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530646 wLength = le16_to_cpu(ctrl->wLength);
647
648 if (wLength != 6) {
649 dev_err(dwc->dev, "Set SEL should be 6 bytes, got %d\n",
650 wLength);
651 return -EINVAL;
652 }
653
654 /*
655 * To handle Set SEL we need to receive 6 bytes from Host. So let's
656 * queue a usb_request for 6 bytes.
657 *
658 * Remember, though, this controller can't handle non-wMaxPacketSize
659 * aligned transfers on the OUT direction, so we queue a request for
660 * wMaxPacketSize instead.
661 */
662 dep = dwc->eps[0];
663 dwc->ep0_usb_req.dep = dep;
664 dwc->ep0_usb_req.request.length = dep->endpoint.maxpacket;
Neil Armstrongec21f2f2024-10-11 16:38:24 +0200665 dwc->ep0_usb_req.request.buf = (void *)dwc->setup_buf_addr;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530666 dwc->ep0_usb_req.request.complete = dwc3_ep0_set_sel_cmpl;
667
668 return __dwc3_gadget_ep0_queue(dep, &dwc->ep0_usb_req);
669}
670
671static int dwc3_ep0_set_isoch_delay(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
672{
673 u16 wLength;
674 u16 wValue;
675 u16 wIndex;
676
677 wValue = le16_to_cpu(ctrl->wValue);
678 wLength = le16_to_cpu(ctrl->wLength);
679 wIndex = le16_to_cpu(ctrl->wIndex);
680
681 if (wIndex || wLength)
682 return -EINVAL;
683
684 /*
685 * REVISIT It's unclear from Databook what to do with this
686 * value. For now, just cache it.
687 */
688 dwc->isoch_delay = wValue;
689
690 return 0;
691}
692
693static int dwc3_ep0_std_request(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
694{
695 int ret;
696
697 switch (ctrl->bRequest) {
698 case USB_REQ_GET_STATUS:
Caleb Connolly61c7d822024-06-18 17:03:43 +0200699 dev_vdbg(dwc->dev, "USB_REQ_GET_STATUS\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530700 ret = dwc3_ep0_handle_status(dwc, ctrl);
701 break;
702 case USB_REQ_CLEAR_FEATURE:
Caleb Connolly61c7d822024-06-18 17:03:43 +0200703 dev_vdbg(dwc->dev, "USB_REQ_CLEAR_FEATURE\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530704 ret = dwc3_ep0_handle_feature(dwc, ctrl, 0);
705 break;
706 case USB_REQ_SET_FEATURE:
Caleb Connolly61c7d822024-06-18 17:03:43 +0200707 dev_vdbg(dwc->dev, "USB_REQ_SET_FEATURE\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530708 ret = dwc3_ep0_handle_feature(dwc, ctrl, 1);
709 break;
710 case USB_REQ_SET_ADDRESS:
Caleb Connolly61c7d822024-06-18 17:03:43 +0200711 dev_vdbg(dwc->dev, "USB_REQ_SET_ADDRESS\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530712 ret = dwc3_ep0_set_address(dwc, ctrl);
713 break;
714 case USB_REQ_SET_CONFIGURATION:
Caleb Connolly61c7d822024-06-18 17:03:43 +0200715 dev_vdbg(dwc->dev, "USB_REQ_SET_CONFIGURATION\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530716 ret = dwc3_ep0_set_config(dwc, ctrl);
717 break;
718 case USB_REQ_SET_SEL:
Caleb Connolly61c7d822024-06-18 17:03:43 +0200719 dev_vdbg(dwc->dev, "USB_REQ_SET_SEL\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530720 ret = dwc3_ep0_set_sel(dwc, ctrl);
721 break;
722 case USB_REQ_SET_ISOCH_DELAY:
Caleb Connolly61c7d822024-06-18 17:03:43 +0200723 dev_vdbg(dwc->dev, "USB_REQ_SET_ISOCH_DELAY\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530724 ret = dwc3_ep0_set_isoch_delay(dwc, ctrl);
725 break;
726 default:
Caleb Connolly61c7d822024-06-18 17:03:43 +0200727 dev_vdbg(dwc->dev, "Forwarding to gadget driver\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530728 ret = dwc3_ep0_delegate_req(dwc, ctrl);
729 break;
730 }
731
732 return ret;
733}
734
735static void dwc3_ep0_inspect_setup(struct dwc3 *dwc,
736 const struct dwc3_event_depevt *event)
737{
738 struct usb_ctrlrequest *ctrl = dwc->ctrl_req;
739 int ret = -EINVAL;
740 u32 len;
741
742 if (!dwc->gadget_driver)
743 goto out;
744
Neil Armstrongc6a57f72024-10-11 16:38:26 +0200745 dwc3_invalidate_cache((uintptr_t)ctrl, sizeof(*ctrl));
746
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530747 len = le16_to_cpu(ctrl->wLength);
748 if (!len) {
749 dwc->three_stage_setup = false;
750 dwc->ep0_expect_in = false;
751 dwc->ep0_next_event = DWC3_EP0_NRDY_STATUS;
752 } else {
753 dwc->three_stage_setup = true;
754 dwc->ep0_expect_in = !!(ctrl->bRequestType & USB_DIR_IN);
755 dwc->ep0_next_event = DWC3_EP0_NRDY_DATA;
756 }
757
758 if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD)
759 ret = dwc3_ep0_std_request(dwc, ctrl);
760 else
761 ret = dwc3_ep0_delegate_req(dwc, ctrl);
762
763 if (ret == USB_GADGET_DELAYED_STATUS)
764 dwc->delayed_status = true;
765
766out:
767 if (ret < 0)
768 dwc3_ep0_stall_and_restart(dwc);
769}
770
771static void dwc3_ep0_complete_data(struct dwc3 *dwc,
772 const struct dwc3_event_depevt *event)
773{
774 struct dwc3_request *r = NULL;
775 struct usb_request *ur;
776 struct dwc3_trb *trb;
777 struct dwc3_ep *ep0;
Kishon Vijay Abraham Ie1d80c92015-02-23 18:40:14 +0530778 unsigned transfer_size = 0;
779 unsigned maxp;
780 void *buf;
781 u32 transferred = 0;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530782 u32 status;
783 u32 length;
784 u8 epnum;
785
786 epnum = event->endpoint_number;
787 ep0 = dwc->eps[0];
788
789 dwc->ep0_next_event = DWC3_EP0_NRDY_STATUS;
790
791 trb = dwc->ep0_trb;
792
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530793 r = next_request(&ep0->request_list);
794 if (!r)
795 return;
796
Philipp Tomsiched121672017-04-06 16:58:52 +0200797 dwc3_flush_cache((uintptr_t)trb, sizeof(*trb));
Kishon Vijay Abraham Ic7bdfe32015-02-23 18:40:13 +0530798
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530799 status = DWC3_TRB_SIZE_TRBSTS(trb->size);
800 if (status == DWC3_TRBSTS_SETUP_PENDING) {
Kishon Vijay Abraham I389f6d42015-02-23 18:39:53 +0530801 dev_dbg(dwc->dev, "Setup Pending received");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530802
803 if (r)
804 dwc3_gadget_giveback(ep0, r, -ECONNRESET);
805
806 return;
807 }
808
809 ur = &r->request;
Kishon Vijay Abraham Ie1d80c92015-02-23 18:40:14 +0530810 buf = ur->buf;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530811
812 length = trb->size & DWC3_TRB_SIZE_MASK;
813
Kishon Vijay Abraham Ie1d80c92015-02-23 18:40:14 +0530814 maxp = ep0->endpoint.maxpacket;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530815
Kishon Vijay Abraham Ie1d80c92015-02-23 18:40:14 +0530816 if (dwc->ep0_bounced) {
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +0530817 /*
818 * Handle the first TRB before handling the bounce buffer if
819 * the request length is greater than the bounce buffer size.
820 */
821 if (ur->length > DWC3_EP0_BOUNCE_SIZE) {
822 transfer_size = (ur->length / maxp) * maxp;
823 transferred = transfer_size - length;
824 buf = (u8 *)buf + transferred;
825 ur->actual += transferred;
826
827 trb++;
Philipp Tomsiched121672017-04-06 16:58:52 +0200828 dwc3_flush_cache((uintptr_t)trb, sizeof(*trb));
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +0530829 length = trb->size & DWC3_TRB_SIZE_MASK;
830
831 ep0->free_slot = 0;
832 }
833
Kishon Vijay Abraham Ie1d80c92015-02-23 18:40:14 +0530834 transfer_size = roundup((ur->length - transfer_size),
835 maxp);
836 transferred = min_t(u32, ur->length - transferred,
837 transfer_size - length);
Philipp Tomsiched121672017-04-06 16:58:52 +0200838 dwc3_flush_cache((uintptr_t)dwc->ep0_bounce, DWC3_EP0_BOUNCE_SIZE);
Kishon Vijay Abraham Ie1d80c92015-02-23 18:40:14 +0530839 memcpy(buf, dwc->ep0_bounce, transferred);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530840 } else {
841 transferred = ur->length - length;
842 }
843
844 ur->actual += transferred;
845
846 if ((epnum & 1) && ur->actual < ur->length) {
847 /* for some reason we did not get everything out */
848
849 dwc3_ep0_stall_and_restart(dwc);
850 } else {
851 dwc3_gadget_giveback(ep0, r, 0);
852
853 if (IS_ALIGNED(ur->length, ep0->endpoint.maxpacket) &&
854 ur->length && ur->zero) {
855 int ret;
856
857 dwc->ep0_next_event = DWC3_EP0_COMPLETE;
858
859 ret = dwc3_ep0_start_trans(dwc, epnum,
860 dwc->ctrl_req_addr, 0,
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +0530861 DWC3_TRBCTL_CONTROL_DATA, 0);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530862 WARN_ON(ret < 0);
863 }
864 }
865}
866
867static void dwc3_ep0_complete_status(struct dwc3 *dwc,
868 const struct dwc3_event_depevt *event)
869{
870 struct dwc3_request *r;
871 struct dwc3_ep *dep;
872 struct dwc3_trb *trb;
873 u32 status;
874
875 dep = dwc->eps[0];
876 trb = dwc->ep0_trb;
877
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530878 if (!list_empty(&dep->request_list)) {
879 r = next_request(&dep->request_list);
880
881 dwc3_gadget_giveback(dep, r, 0);
882 }
883
884 if (dwc->test_mode) {
885 int ret;
886
887 ret = dwc3_gadget_set_test_mode(dwc, dwc->test_mode_nr);
888 if (ret < 0) {
Kishon Vijay Abraham I389f6d42015-02-23 18:39:53 +0530889 dev_dbg(dwc->dev, "Invalid Test #%d",
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530890 dwc->test_mode_nr);
891 dwc3_ep0_stall_and_restart(dwc);
892 return;
893 }
894 }
895
896 status = DWC3_TRB_SIZE_TRBSTS(trb->size);
897 if (status == DWC3_TRBSTS_SETUP_PENDING)
Kishon Vijay Abraham I389f6d42015-02-23 18:39:53 +0530898 dev_dbg(dwc->dev, "Setup Pending received");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530899
900 dwc->ep0state = EP0_SETUP_PHASE;
901 dwc3_ep0_out_start(dwc);
902}
903
904static void dwc3_ep0_xfer_complete(struct dwc3 *dwc,
905 const struct dwc3_event_depevt *event)
906{
907 struct dwc3_ep *dep = dwc->eps[event->endpoint_number];
908
909 dep->flags &= ~DWC3_EP_BUSY;
910 dep->resource_index = 0;
911 dwc->setup_packet_pending = false;
912
913 switch (dwc->ep0state) {
914 case EP0_SETUP_PHASE:
Caleb Connolly61c7d822024-06-18 17:03:43 +0200915 dev_vdbg(dwc->dev, "Setup Phase\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530916 dwc3_ep0_inspect_setup(dwc, event);
917 break;
918
919 case EP0_DATA_PHASE:
Caleb Connolly61c7d822024-06-18 17:03:43 +0200920 dev_vdbg(dwc->dev, "Data Phase\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530921 dwc3_ep0_complete_data(dwc, event);
922 break;
923
924 case EP0_STATUS_PHASE:
Caleb Connolly61c7d822024-06-18 17:03:43 +0200925 dev_vdbg(dwc->dev, "Status Phase\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530926 dwc3_ep0_complete_status(dwc, event);
927 break;
928 default:
929 WARN(true, "UNKNOWN ep0state %d\n", dwc->ep0state);
930 }
931}
932
933static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
934 struct dwc3_ep *dep, struct dwc3_request *req)
935{
936 int ret;
937
938 req->direction = !!dep->number;
939
940 if (req->request.length == 0) {
941 ret = dwc3_ep0_start_trans(dwc, dep->number,
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +0530942 dwc->ctrl_req_addr, 0,
943 DWC3_TRBCTL_CONTROL_DATA, 0);
944 } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) &&
945 (dep->number == 0)) {
946 u32 transfer_size = 0;
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530947 u32 maxpacket;
948
949 ret = usb_gadget_map_request(&dwc->gadget, &req->request,
950 dep->number);
951 if (ret) {
952 dev_dbg(dwc->dev, "failed to map request\n");
953 return;
954 }
955
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530956 maxpacket = dep->endpoint.maxpacket;
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +0530957 if (req->request.length > DWC3_EP0_BOUNCE_SIZE) {
958 transfer_size = (req->request.length / maxpacket) *
959 maxpacket;
960 ret = dwc3_ep0_start_trans(dwc, dep->number,
961 req->request.dma,
962 transfer_size,
963 DWC3_TRBCTL_CONTROL_DATA, 1);
964 }
965
966 transfer_size = roundup((req->request.length - transfer_size),
967 maxpacket);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530968
969 dwc->ep0_bounced = true;
970
971 /*
972 * REVISIT in case request length is bigger than
973 * DWC3_EP0_BOUNCE_SIZE we will need two chained
974 * TRBs to handle the transfer.
975 */
976 ret = dwc3_ep0_start_trans(dwc, dep->number,
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +0530977 dwc->ep0_bounce_addr, transfer_size,
978 DWC3_TRBCTL_CONTROL_DATA, 0);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530979 } else {
980 ret = usb_gadget_map_request(&dwc->gadget, &req->request,
981 dep->number);
982 if (ret) {
983 dev_dbg(dwc->dev, "failed to map request\n");
984 return;
985 }
986
987 ret = dwc3_ep0_start_trans(dwc, dep->number, req->request.dma,
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +0530988 req->request.length,
989 DWC3_TRBCTL_CONTROL_DATA, 0);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +0530990 }
991
992 WARN_ON(ret < 0);
993}
994
995static int dwc3_ep0_start_control_status(struct dwc3_ep *dep)
996{
997 struct dwc3 *dwc = dep->dwc;
998 u32 type;
999
1000 type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3
1001 : DWC3_TRBCTL_CONTROL_STATUS2;
1002
1003 return dwc3_ep0_start_trans(dwc, dep->number,
Kishon Vijay Abraham If18ed9a2015-02-23 18:40:15 +05301004 dwc->ctrl_req_addr, 0, type, 0);
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +05301005}
1006
1007static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)
1008{
1009 if (dwc->resize_fifos) {
Kishon Vijay Abraham I389f6d42015-02-23 18:39:53 +05301010 dev_dbg(dwc->dev, "Resizing FIFOs");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +05301011 dwc3_gadget_resize_tx_fifos(dwc);
1012 dwc->resize_fifos = 0;
1013 }
1014
1015 WARN_ON(dwc3_ep0_start_control_status(dep));
1016}
1017
1018static void dwc3_ep0_do_control_status(struct dwc3 *dwc,
1019 const struct dwc3_event_depevt *event)
1020{
1021 struct dwc3_ep *dep = dwc->eps[event->endpoint_number];
1022
1023 __dwc3_ep0_do_control_status(dwc, dep);
1024}
1025
1026static void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep)
1027{
1028 struct dwc3_gadget_ep_cmd_params params;
1029 u32 cmd;
1030 int ret;
1031
1032 if (!dep->resource_index)
1033 return;
1034
1035 cmd = DWC3_DEPCMD_ENDTRANSFER;
1036 cmd |= DWC3_DEPCMD_CMDIOC;
1037 cmd |= DWC3_DEPCMD_PARAM(dep->resource_index);
1038 memset(&params, 0, sizeof(params));
1039 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, &params);
1040 WARN_ON_ONCE(ret);
1041 dep->resource_index = 0;
1042}
1043
1044static void dwc3_ep0_xfernotready(struct dwc3 *dwc,
1045 const struct dwc3_event_depevt *event)
1046{
1047 dwc->setup_packet_pending = true;
1048
1049 switch (event->status) {
1050 case DEPEVT_STATUS_CONTROL_DATA:
Caleb Connolly61c7d822024-06-18 17:03:43 +02001051 dev_vdbg(dwc->dev, "Control Data\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +05301052
1053 /*
1054 * We already have a DATA transfer in the controller's cache,
1055 * if we receive a XferNotReady(DATA) we will ignore it, unless
1056 * it's for the wrong direction.
1057 *
1058 * In that case, we must issue END_TRANSFER command to the Data
1059 * Phase we already have started and issue SetStall on the
1060 * control endpoint.
1061 */
1062 if (dwc->ep0_expect_in != event->endpoint_number) {
1063 struct dwc3_ep *dep = dwc->eps[dwc->ep0_expect_in];
1064
Caleb Connolly61c7d822024-06-18 17:03:43 +02001065 dev_vdbg(dwc->dev, "Wrong direction for Data phase\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +05301066 dwc3_ep0_end_control_data(dwc, dep);
1067 dwc3_ep0_stall_and_restart(dwc);
1068 return;
1069 }
1070
1071 break;
1072
1073 case DEPEVT_STATUS_CONTROL_STATUS:
1074 if (dwc->ep0_next_event != DWC3_EP0_NRDY_STATUS)
1075 return;
1076
Caleb Connolly61c7d822024-06-18 17:03:43 +02001077 dev_vdbg(dwc->dev, "Control Status\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +05301078
1079 dwc->ep0state = EP0_STATUS_PHASE;
1080
1081 if (dwc->delayed_status) {
1082 WARN_ON_ONCE(event->endpoint_number != 1);
Caleb Connolly61c7d822024-06-18 17:03:43 +02001083 dev_vdbg(dwc->dev, "Delayed Status\n");
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +05301084 return;
1085 }
1086
1087 dwc3_ep0_do_control_status(dwc, event);
1088 }
1089}
1090
1091void dwc3_ep0_interrupt(struct dwc3 *dwc,
1092 const struct dwc3_event_depevt *event)
1093{
1094 u8 epnum = event->endpoint_number;
1095
Caleb Connolly61c7d822024-06-18 17:03:43 +02001096 dev_dbg(dwc->dev, "%s while ep%d%s in state '%s'\n",
1097 dwc3_ep_event_string(event->endpoint_event),
1098 epnum >> 1, (epnum & 1) ? "in" : "out",
1099 dwc3_ep0_state_string(dwc->ep0state));
Kishon Vijay Abraham I1530fe32015-02-23 18:39:50 +05301100
1101 switch (event->endpoint_event) {
1102 case DWC3_DEPEVT_XFERCOMPLETE:
1103 dwc3_ep0_xfer_complete(dwc, event);
1104 break;
1105
1106 case DWC3_DEPEVT_XFERNOTREADY:
1107 dwc3_ep0_xfernotready(dwc, event);
1108 break;
1109
1110 case DWC3_DEPEVT_XFERINPROGRESS:
1111 case DWC3_DEPEVT_RXTXFIFOEVT:
1112 case DWC3_DEPEVT_STREAMEVT:
1113 case DWC3_DEPEVT_EPCMDCMPLT:
1114 break;
1115 }
1116}