debug.h 16 KB

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