xref: /openbmc/linux/drivers/usb/dwc3/debug.h (revision 9726bfcd)
1 // SPDX-License-Identifier: GPL-2.0
2 /**
3  * debug.h - DesignWare USB3 DRD Controller Debug Header
4  *
5  * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
6  *
7  * Authors: Felipe Balbi <balbi@ti.com>,
8  *	    Sebastian Andrzej Siewior <bigeasy@linutronix.de>
9  */
10 
11 #ifndef __DWC3_DEBUG_H
12 #define __DWC3_DEBUG_H
13 
14 #include "core.h"
15 
16 /**
17  * dwc3_gadget_ep_cmd_string - returns endpoint command string
18  * @cmd: command code
19  */
20 static inline const char *
21 dwc3_gadget_ep_cmd_string(u8 cmd)
22 {
23 	switch (cmd) {
24 	case DWC3_DEPCMD_DEPSTARTCFG:
25 		return "Start New Configuration";
26 	case DWC3_DEPCMD_ENDTRANSFER:
27 		return "End Transfer";
28 	case DWC3_DEPCMD_UPDATETRANSFER:
29 		return "Update Transfer";
30 	case DWC3_DEPCMD_STARTTRANSFER:
31 		return "Start Transfer";
32 	case DWC3_DEPCMD_CLEARSTALL:
33 		return "Clear Stall";
34 	case DWC3_DEPCMD_SETSTALL:
35 		return "Set Stall";
36 	case DWC3_DEPCMD_GETEPSTATE:
37 		return "Get Endpoint State";
38 	case DWC3_DEPCMD_SETTRANSFRESOURCE:
39 		return "Set Endpoint Transfer Resource";
40 	case DWC3_DEPCMD_SETEPCONFIG:
41 		return "Set Endpoint Configuration";
42 	default:
43 		return "UNKNOWN command";
44 	}
45 }
46 
47 /**
48  * dwc3_gadget_generic_cmd_string - returns generic command string
49  * @cmd: command code
50  */
51 static inline const char *
52 dwc3_gadget_generic_cmd_string(u8 cmd)
53 {
54 	switch (cmd) {
55 	case DWC3_DGCMD_SET_LMP:
56 		return "Set LMP";
57 	case DWC3_DGCMD_SET_PERIODIC_PAR:
58 		return "Set Periodic Parameters";
59 	case DWC3_DGCMD_XMIT_FUNCTION:
60 		return "Transmit Function Wake Device Notification";
61 	case DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO:
62 		return "Set Scratchpad Buffer Array Address Lo";
63 	case DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI:
64 		return "Set Scratchpad Buffer Array Address Hi";
65 	case DWC3_DGCMD_SELECTED_FIFO_FLUSH:
66 		return "Selected FIFO Flush";
67 	case DWC3_DGCMD_ALL_FIFO_FLUSH:
68 		return "All FIFO Flush";
69 	case DWC3_DGCMD_SET_ENDPOINT_NRDY:
70 		return "Set Endpoint NRDY";
71 	case DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK:
72 		return "Run SoC Bus Loopback Test";
73 	default:
74 		return "UNKNOWN";
75 	}
76 }
77 
78 /**
79  * dwc3_gadget_link_string - returns link name
80  * @link_state: link state code
81  */
82 static inline const char *
83 dwc3_gadget_link_string(enum dwc3_link_state link_state)
84 {
85 	switch (link_state) {
86 	case DWC3_LINK_STATE_U0:
87 		return "U0";
88 	case DWC3_LINK_STATE_U1:
89 		return "U1";
90 	case DWC3_LINK_STATE_U2:
91 		return "U2";
92 	case DWC3_LINK_STATE_U3:
93 		return "U3";
94 	case DWC3_LINK_STATE_SS_DIS:
95 		return "SS.Disabled";
96 	case DWC3_LINK_STATE_RX_DET:
97 		return "RX.Detect";
98 	case DWC3_LINK_STATE_SS_INACT:
99 		return "SS.Inactive";
100 	case DWC3_LINK_STATE_POLL:
101 		return "Polling";
102 	case DWC3_LINK_STATE_RECOV:
103 		return "Recovery";
104 	case DWC3_LINK_STATE_HRESET:
105 		return "Hot Reset";
106 	case DWC3_LINK_STATE_CMPLY:
107 		return "Compliance";
108 	case DWC3_LINK_STATE_LPBK:
109 		return "Loopback";
110 	case DWC3_LINK_STATE_RESET:
111 		return "Reset";
112 	case DWC3_LINK_STATE_RESUME:
113 		return "Resume";
114 	default:
115 		return "UNKNOWN link state\n";
116 	}
117 }
118 
119 /**
120  * dwc3_gadget_hs_link_string - returns highspeed and below link name
121  * @link_state: link state code
122  */
123 static inline const char *
124 dwc3_gadget_hs_link_string(enum dwc3_link_state link_state)
125 {
126 	switch (link_state) {
127 	case DWC3_LINK_STATE_U0:
128 		return "On";
129 	case DWC3_LINK_STATE_U2:
130 		return "Sleep";
131 	case DWC3_LINK_STATE_U3:
132 		return "Suspend";
133 	case DWC3_LINK_STATE_SS_DIS:
134 		return "Disconnected";
135 	case DWC3_LINK_STATE_RX_DET:
136 		return "Early Suspend";
137 	case DWC3_LINK_STATE_RECOV:
138 		return "Recovery";
139 	case DWC3_LINK_STATE_RESET:
140 		return "Reset";
141 	case DWC3_LINK_STATE_RESUME:
142 		return "Resume";
143 	default:
144 		return "UNKNOWN link state\n";
145 	}
146 }
147 
148 /**
149  * dwc3_trb_type_string - returns TRB type as a string
150  * @type: the type of the TRB
151  */
152 static inline const char *dwc3_trb_type_string(unsigned int type)
153 {
154 	switch (type) {
155 	case DWC3_TRBCTL_NORMAL:
156 		return "normal";
157 	case DWC3_TRBCTL_CONTROL_SETUP:
158 		return "setup";
159 	case DWC3_TRBCTL_CONTROL_STATUS2:
160 		return "status2";
161 	case DWC3_TRBCTL_CONTROL_STATUS3:
162 		return "status3";
163 	case DWC3_TRBCTL_CONTROL_DATA:
164 		return "data";
165 	case DWC3_TRBCTL_ISOCHRONOUS_FIRST:
166 		return "isoc-first";
167 	case DWC3_TRBCTL_ISOCHRONOUS:
168 		return "isoc";
169 	case DWC3_TRBCTL_LINK_TRB:
170 		return "link";
171 	default:
172 		return "UNKNOWN";
173 	}
174 }
175 
176 static inline const char *dwc3_ep0_state_string(enum dwc3_ep0_state state)
177 {
178 	switch (state) {
179 	case EP0_UNCONNECTED:
180 		return "Unconnected";
181 	case EP0_SETUP_PHASE:
182 		return "Setup Phase";
183 	case EP0_DATA_PHASE:
184 		return "Data Phase";
185 	case EP0_STATUS_PHASE:
186 		return "Status Phase";
187 	default:
188 		return "UNKNOWN";
189 	}
190 }
191 
192 /**
193  * dwc3_gadget_event_string - returns event name
194  * @event: the event code
195  */
196 static inline const char *dwc3_gadget_event_string(char *str, size_t size,
197 		const struct dwc3_event_devt *event)
198 {
199 	enum dwc3_link_state state = event->event_info & DWC3_LINK_STATE_MASK;
200 
201 	switch (event->type) {
202 	case DWC3_DEVICE_EVENT_DISCONNECT:
203 		snprintf(str, size, "Disconnect: [%s]",
204 				dwc3_gadget_link_string(state));
205 		break;
206 	case DWC3_DEVICE_EVENT_RESET:
207 		snprintf(str, size, "Reset [%s]",
208 				dwc3_gadget_link_string(state));
209 		break;
210 	case DWC3_DEVICE_EVENT_CONNECT_DONE:
211 		snprintf(str, size, "Connection Done [%s]",
212 				dwc3_gadget_link_string(state));
213 		break;
214 	case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE:
215 		snprintf(str, size, "Link Change [%s]",
216 				dwc3_gadget_link_string(state));
217 		break;
218 	case DWC3_DEVICE_EVENT_WAKEUP:
219 		snprintf(str, size, "WakeUp [%s]",
220 				dwc3_gadget_link_string(state));
221 		break;
222 	case DWC3_DEVICE_EVENT_EOPF:
223 		snprintf(str, size, "End-Of-Frame [%s]",
224 				dwc3_gadget_link_string(state));
225 		break;
226 	case DWC3_DEVICE_EVENT_SOF:
227 		snprintf(str, size, "Start-Of-Frame [%s]",
228 				dwc3_gadget_link_string(state));
229 		break;
230 	case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
231 		snprintf(str, size, "Erratic Error [%s]",
232 				dwc3_gadget_link_string(state));
233 		break;
234 	case DWC3_DEVICE_EVENT_CMD_CMPL:
235 		snprintf(str, size, "Command Complete [%s]",
236 				dwc3_gadget_link_string(state));
237 		break;
238 	case DWC3_DEVICE_EVENT_OVERFLOW:
239 		snprintf(str, size, "Overflow [%s]",
240 				dwc3_gadget_link_string(state));
241 		break;
242 	default:
243 		snprintf(str, size, "UNKNOWN");
244 	}
245 
246 	return str;
247 }
248 
249 static inline void dwc3_decode_get_status(__u8 t, __u16 i, __u16 l, char *str,
250 		size_t size)
251 {
252 	switch (t & USB_RECIP_MASK) {
253 	case USB_RECIP_DEVICE:
254 		snprintf(str, size, "Get Device Status(Length = %d)", l);
255 		break;
256 	case USB_RECIP_INTERFACE:
257 		snprintf(str, size, "Get Interface Status(Intf = %d, Length = %d)",
258 				i, l);
259 		break;
260 	case USB_RECIP_ENDPOINT:
261 		snprintf(str, size, "Get Endpoint Status(ep%d%s)",
262 			i & ~USB_DIR_IN,
263 			i & USB_DIR_IN ? "in" : "out");
264 		break;
265 	}
266 }
267 
268 static inline void dwc3_decode_set_clear_feature(__u8 t, __u8 b, __u16 v,
269 		__u16 i, char *str, size_t size)
270 {
271 	switch (t & USB_RECIP_MASK) {
272 	case USB_RECIP_DEVICE:
273 		snprintf(str, size, "%s Device Feature(%s%s)",
274 			b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
275 			({char *s;
276 				switch (v) {
277 				case USB_DEVICE_SELF_POWERED:
278 					s = "Self Powered";
279 					break;
280 				case USB_DEVICE_REMOTE_WAKEUP:
281 					s = "Remote Wakeup";
282 					break;
283 				case USB_DEVICE_TEST_MODE:
284 					s = "Test Mode";
285 					break;
286 				case USB_DEVICE_U1_ENABLE:
287 					s = "U1 Enable";
288 					break;
289 				case USB_DEVICE_U2_ENABLE:
290 					s = "U2 Enable";
291 					break;
292 				case USB_DEVICE_LTM_ENABLE:
293 					s = "LTM Enable";
294 					break;
295 				default:
296 					s = "UNKNOWN";
297 				} s; }),
298 			v == USB_DEVICE_TEST_MODE ?
299 			({ char *s;
300 				switch (i) {
301 				case TEST_J:
302 					s = ": TEST_J";
303 					break;
304 				case TEST_K:
305 					s = ": TEST_K";
306 					break;
307 				case TEST_SE0_NAK:
308 					s = ": TEST_SE0_NAK";
309 					break;
310 				case TEST_PACKET:
311 					s = ": TEST_PACKET";
312 					break;
313 				case TEST_FORCE_EN:
314 					s = ": TEST_FORCE_EN";
315 					break;
316 				default:
317 					s = ": UNKNOWN";
318 				} s; }) : "");
319 		break;
320 	case USB_RECIP_INTERFACE:
321 		snprintf(str, size, "%s Interface Feature(%s)",
322 			b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
323 			v == USB_INTRF_FUNC_SUSPEND ?
324 			"Function Suspend" : "UNKNOWN");
325 		break;
326 	case USB_RECIP_ENDPOINT:
327 		snprintf(str, size, "%s Endpoint Feature(%s ep%d%s)",
328 			b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
329 			v == USB_ENDPOINT_HALT ? "Halt" : "UNKNOWN",
330 			i & ~USB_DIR_IN,
331 			i & USB_DIR_IN ? "in" : "out");
332 		break;
333 	}
334 }
335 
336 static inline void dwc3_decode_set_address(__u16 v, char *str, size_t size)
337 {
338 	snprintf(str, size, "Set Address(Addr = %02x)", v);
339 }
340 
341 static inline void dwc3_decode_get_set_descriptor(__u8 t, __u8 b, __u16 v,
342 		__u16 i, __u16 l, char *str, size_t size)
343 {
344 	snprintf(str, size, "%s %s Descriptor(Index = %d, Length = %d)",
345 		b == USB_REQ_GET_DESCRIPTOR ? "Get" : "Set",
346 		({ char *s;
347 			switch (v >> 8) {
348 			case USB_DT_DEVICE:
349 				s = "Device";
350 				break;
351 			case USB_DT_CONFIG:
352 				s = "Configuration";
353 				break;
354 			case USB_DT_STRING:
355 				s = "String";
356 				break;
357 			case USB_DT_INTERFACE:
358 				s = "Interface";
359 				break;
360 			case USB_DT_ENDPOINT:
361 				s = "Endpoint";
362 				break;
363 			case USB_DT_DEVICE_QUALIFIER:
364 				s = "Device Qualifier";
365 				break;
366 			case USB_DT_OTHER_SPEED_CONFIG:
367 				s = "Other Speed Config";
368 				break;
369 			case USB_DT_INTERFACE_POWER:
370 				s = "Interface Power";
371 				break;
372 			case USB_DT_OTG:
373 				s = "OTG";
374 				break;
375 			case USB_DT_DEBUG:
376 				s = "Debug";
377 				break;
378 			case USB_DT_INTERFACE_ASSOCIATION:
379 				s = "Interface Association";
380 				break;
381 			case USB_DT_BOS:
382 				s = "BOS";
383 				break;
384 			case USB_DT_DEVICE_CAPABILITY:
385 				s = "Device Capability";
386 				break;
387 			case USB_DT_PIPE_USAGE:
388 				s = "Pipe Usage";
389 				break;
390 			case USB_DT_SS_ENDPOINT_COMP:
391 				s = "SS Endpoint Companion";
392 				break;
393 			case USB_DT_SSP_ISOC_ENDPOINT_COMP:
394 				s = "SSP Isochronous Endpoint Companion";
395 				break;
396 			default:
397 				s = "UNKNOWN";
398 				break;
399 			} s; }), v & 0xff, l);
400 }
401 
402 
403 static inline void dwc3_decode_get_configuration(__u16 l, char *str,
404 		size_t size)
405 {
406 	snprintf(str, size, "Get Configuration(Length = %d)", l);
407 }
408 
409 static inline void dwc3_decode_set_configuration(__u8 v, char *str, size_t size)
410 {
411 	snprintf(str, size, "Set Configuration(Config = %d)", v);
412 }
413 
414 static inline void dwc3_decode_get_intf(__u16 i, __u16 l, char *str,
415 		size_t size)
416 {
417 	snprintf(str, size, "Get Interface(Intf = %d, Length = %d)", i, l);
418 }
419 
420 static inline void dwc3_decode_set_intf(__u8 v, __u16 i, char *str, size_t size)
421 {
422 	snprintf(str, size, "Set Interface(Intf = %d, Alt.Setting = %d)", i, v);
423 }
424 
425 static inline void dwc3_decode_synch_frame(__u16 i, __u16 l, char *str,
426 		size_t size)
427 {
428 	snprintf(str, size, "Synch Frame(Endpoint = %d, Length = %d)", i, l);
429 }
430 
431 static inline void dwc3_decode_set_sel(__u16 l, char *str, size_t size)
432 {
433 	snprintf(str, size, "Set SEL(Length = %d)", l);
434 }
435 
436 static inline void dwc3_decode_set_isoch_delay(__u8 v, char *str, size_t size)
437 {
438 	snprintf(str, size, "Set Isochronous Delay(Delay = %d ns)", v);
439 }
440 
441 /**
442  * dwc3_decode_ctrl - returns a string represetion of ctrl request
443  */
444 static inline const char *dwc3_decode_ctrl(char *str, size_t size,
445 		__u8 bRequestType, __u8 bRequest, __u16 wValue, __u16 wIndex,
446 		__u16 wLength)
447 {
448 	switch (bRequest) {
449 	case USB_REQ_GET_STATUS:
450 		dwc3_decode_get_status(bRequestType, wIndex, wLength, str,
451 				size);
452 		break;
453 	case USB_REQ_CLEAR_FEATURE:
454 	case USB_REQ_SET_FEATURE:
455 		dwc3_decode_set_clear_feature(bRequestType, bRequest, wValue,
456 				wIndex, str, size);
457 		break;
458 	case USB_REQ_SET_ADDRESS:
459 		dwc3_decode_set_address(wValue, str, size);
460 		break;
461 	case USB_REQ_GET_DESCRIPTOR:
462 	case USB_REQ_SET_DESCRIPTOR:
463 		dwc3_decode_get_set_descriptor(bRequestType, bRequest, wValue,
464 				wIndex, wLength, str, size);
465 		break;
466 	case USB_REQ_GET_CONFIGURATION:
467 		dwc3_decode_get_configuration(wLength, str, size);
468 		break;
469 	case USB_REQ_SET_CONFIGURATION:
470 		dwc3_decode_set_configuration(wValue, str, size);
471 		break;
472 	case USB_REQ_GET_INTERFACE:
473 		dwc3_decode_get_intf(wIndex, wLength, str, size);
474 		break;
475 	case USB_REQ_SET_INTERFACE:
476 		dwc3_decode_set_intf(wValue, wIndex, str, size);
477 		break;
478 	case USB_REQ_SYNCH_FRAME:
479 		dwc3_decode_synch_frame(wIndex, wLength, str, size);
480 		break;
481 	case USB_REQ_SET_SEL:
482 		dwc3_decode_set_sel(wLength, str, size);
483 		break;
484 	case USB_REQ_SET_ISOCH_DELAY:
485 		dwc3_decode_set_isoch_delay(wValue, str, size);
486 		break;
487 	default:
488 		snprintf(str, size, "%02x %02x %02x %02x %02x %02x %02x %02x",
489 			bRequestType, bRequest,
490 			cpu_to_le16(wValue) & 0xff,
491 			cpu_to_le16(wValue) >> 8,
492 			cpu_to_le16(wIndex) & 0xff,
493 			cpu_to_le16(wIndex) >> 8,
494 			cpu_to_le16(wLength) & 0xff,
495 			cpu_to_le16(wLength) >> 8);
496 	}
497 
498 	return str;
499 }
500 
501 /**
502  * dwc3_ep_event_string - returns event name
503  * @event: then event code
504  */
505 static inline const char *dwc3_ep_event_string(char *str, size_t size,
506 		const struct dwc3_event_depevt *event, u32 ep0state)
507 {
508 	u8 epnum = event->endpoint_number;
509 	size_t len;
510 	int status;
511 	int ret;
512 
513 	ret = snprintf(str, size, "ep%d%s: ", epnum >> 1,
514 			(epnum & 1) ? "in" : "out");
515 	if (ret < 0)
516 		return "UNKNOWN";
517 
518 	status = event->status;
519 
520 	switch (event->endpoint_event) {
521 	case DWC3_DEPEVT_XFERCOMPLETE:
522 		len = strlen(str);
523 		snprintf(str + len, size - len, "Transfer Complete (%c%c%c)",
524 				status & DEPEVT_STATUS_SHORT ? 'S' : 's',
525 				status & DEPEVT_STATUS_IOC ? 'I' : 'i',
526 				status & DEPEVT_STATUS_LST ? 'L' : 'l');
527 
528 		len = strlen(str);
529 
530 		if (epnum <= 1)
531 			snprintf(str + len, size - len, " [%s]",
532 					dwc3_ep0_state_string(ep0state));
533 		break;
534 	case DWC3_DEPEVT_XFERINPROGRESS:
535 		len = strlen(str);
536 
537 		snprintf(str + len, size - len, "Transfer In Progress [%d] (%c%c%c)",
538 				event->parameters,
539 				status & DEPEVT_STATUS_SHORT ? 'S' : 's',
540 				status & DEPEVT_STATUS_IOC ? 'I' : 'i',
541 				status & DEPEVT_STATUS_LST ? 'M' : 'm');
542 		break;
543 	case DWC3_DEPEVT_XFERNOTREADY:
544 		len = strlen(str);
545 
546 		snprintf(str + len, size - len, "Transfer Not Ready [%d]%s",
547 				event->parameters,
548 				status & DEPEVT_STATUS_TRANSFER_ACTIVE ?
549 				" (Active)" : " (Not Active)");
550 
551 		len = strlen(str);
552 
553 		/* Control Endpoints */
554 		if (epnum <= 1) {
555 			int phase = DEPEVT_STATUS_CONTROL_PHASE(event->status);
556 
557 			switch (phase) {
558 			case DEPEVT_STATUS_CONTROL_DATA:
559 				snprintf(str + ret, size - ret,
560 						" [Data Phase]");
561 				break;
562 			case DEPEVT_STATUS_CONTROL_STATUS:
563 				snprintf(str + ret, size - ret,
564 						" [Status Phase]");
565 			}
566 		}
567 		break;
568 	case DWC3_DEPEVT_RXTXFIFOEVT:
569 		snprintf(str + ret, size - ret, "FIFO");
570 		break;
571 	case DWC3_DEPEVT_STREAMEVT:
572 		status = event->status;
573 
574 		switch (status) {
575 		case DEPEVT_STREAMEVT_FOUND:
576 			snprintf(str + ret, size - ret, " Stream %d Found",
577 					event->parameters);
578 			break;
579 		case DEPEVT_STREAMEVT_NOTFOUND:
580 		default:
581 			snprintf(str + ret, size - ret, " Stream Not Found");
582 			break;
583 		}
584 
585 		break;
586 	case DWC3_DEPEVT_EPCMDCMPLT:
587 		snprintf(str + ret, size - ret, "Endpoint Command Complete");
588 		break;
589 	default:
590 		snprintf(str, size, "UNKNOWN");
591 	}
592 
593 	return str;
594 }
595 
596 /**
597  * dwc3_gadget_event_type_string - return event name
598  * @event: the event code
599  */
600 static inline const char *dwc3_gadget_event_type_string(u8 event)
601 {
602 	switch (event) {
603 	case DWC3_DEVICE_EVENT_DISCONNECT:
604 		return "Disconnect";
605 	case DWC3_DEVICE_EVENT_RESET:
606 		return "Reset";
607 	case DWC3_DEVICE_EVENT_CONNECT_DONE:
608 		return "Connect Done";
609 	case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE:
610 		return "Link Status Change";
611 	case DWC3_DEVICE_EVENT_WAKEUP:
612 		return "Wake-Up";
613 	case DWC3_DEVICE_EVENT_HIBER_REQ:
614 		return "Hibernation";
615 	case DWC3_DEVICE_EVENT_EOPF:
616 		return "End of Periodic Frame";
617 	case DWC3_DEVICE_EVENT_SOF:
618 		return "Start of Frame";
619 	case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
620 		return "Erratic Error";
621 	case DWC3_DEVICE_EVENT_CMD_CMPL:
622 		return "Command Complete";
623 	case DWC3_DEVICE_EVENT_OVERFLOW:
624 		return "Overflow";
625 	default:
626 		return "UNKNOWN";
627 	}
628 }
629 
630 static inline const char *dwc3_decode_event(char *str, size_t size, u32 event,
631 		u32 ep0state)
632 {
633 	const union dwc3_event evt = (union dwc3_event) event;
634 
635 	if (evt.type.is_devspec)
636 		return dwc3_gadget_event_string(str, size, &evt.devt);
637 	else
638 		return dwc3_ep_event_string(str, size, &evt.depevt, ep0state);
639 }
640 
641 static inline const char *dwc3_ep_cmd_status_string(int status)
642 {
643 	switch (status) {
644 	case -ETIMEDOUT:
645 		return "Timed Out";
646 	case 0:
647 		return "Successful";
648 	case DEPEVT_TRANSFER_NO_RESOURCE:
649 		return "No Resource";
650 	case DEPEVT_TRANSFER_BUS_EXPIRY:
651 		return "Bus Expiry";
652 	default:
653 		return "UNKNOWN";
654 	}
655 }
656 
657 static inline const char *dwc3_gadget_generic_cmd_status_string(int status)
658 {
659 	switch (status) {
660 	case -ETIMEDOUT:
661 		return "Timed Out";
662 	case 0:
663 		return "Successful";
664 	case 1:
665 		return "Error";
666 	default:
667 		return "UNKNOWN";
668 	}
669 }
670 
671 
672 #ifdef CONFIG_DEBUG_FS
673 extern void dwc3_debugfs_init(struct dwc3 *);
674 extern void dwc3_debugfs_exit(struct dwc3 *);
675 #else
676 static inline void dwc3_debugfs_init(struct dwc3 *d)
677 {  }
678 static inline void dwc3_debugfs_exit(struct dwc3 *d)
679 {  }
680 #endif
681 #endif /* __DWC3_DEBUG_H */
682