debug.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /**
  2. * debug.h - DesignWare USB3 DRD Controller Debug Header
  3. *
  4. * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
  5. *
  6. * Authors: Felipe Balbi <balbi@ti.com>,
  7. * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 of
  11. * the License as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #ifndef __DWC3_DEBUG_H
  19. #define __DWC3_DEBUG_H
  20. #include "core.h"
  21. /**
  22. * dwc3_gadget_ep_cmd_string - returns endpoint command string
  23. * @cmd: command code
  24. */
  25. static inline const char *
  26. dwc3_gadget_ep_cmd_string(u8 cmd)
  27. {
  28. switch (cmd) {
  29. case DWC3_DEPCMD_DEPSTARTCFG:
  30. return "Start New Configuration";
  31. case DWC3_DEPCMD_ENDTRANSFER:
  32. return "End Transfer";
  33. case DWC3_DEPCMD_UPDATETRANSFER:
  34. return "Update Transfer";
  35. case DWC3_DEPCMD_STARTTRANSFER:
  36. return "Start Transfer";
  37. case DWC3_DEPCMD_CLEARSTALL:
  38. return "Clear Stall";
  39. case DWC3_DEPCMD_SETSTALL:
  40. return "Set Stall";
  41. case DWC3_DEPCMD_GETEPSTATE:
  42. return "Get Endpoint State";
  43. case DWC3_DEPCMD_SETTRANSFRESOURCE:
  44. return "Set Endpoint Transfer Resource";
  45. case DWC3_DEPCMD_SETEPCONFIG:
  46. return "Set Endpoint Configuration";
  47. default:
  48. return "UNKNOWN command";
  49. }
  50. }
  51. /**
  52. * dwc3_gadget_generic_cmd_string - returns generic command string
  53. * @cmd: command code
  54. */
  55. static inline const char *
  56. dwc3_gadget_generic_cmd_string(u8 cmd)
  57. {
  58. switch (cmd) {
  59. case DWC3_DGCMD_SET_LMP:
  60. return "Set LMP";
  61. case DWC3_DGCMD_SET_PERIODIC_PAR:
  62. return "Set Periodic Parameters";
  63. case DWC3_DGCMD_XMIT_FUNCTION:
  64. return "Transmit Function Wake Device Notification";
  65. case DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO:
  66. return "Set Scratchpad Buffer Array Address Lo";
  67. case DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI:
  68. return "Set Scratchpad Buffer Array Address Hi";
  69. case DWC3_DGCMD_SELECTED_FIFO_FLUSH:
  70. return "Selected FIFO Flush";
  71. case DWC3_DGCMD_ALL_FIFO_FLUSH:
  72. return "All FIFO Flush";
  73. case DWC3_DGCMD_SET_ENDPOINT_NRDY:
  74. return "Set Endpoint NRDY";
  75. case DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK:
  76. return "Run SoC Bus Loopback Test";
  77. default:
  78. return "UNKNOWN";
  79. }
  80. }
  81. /**
  82. * dwc3_gadget_link_string - returns link name
  83. * @link_state: link state code
  84. */
  85. static inline const char *
  86. dwc3_gadget_link_string(enum dwc3_link_state link_state)
  87. {
  88. switch (link_state) {
  89. case DWC3_LINK_STATE_U0:
  90. return "U0";
  91. case DWC3_LINK_STATE_U1:
  92. return "U1";
  93. case DWC3_LINK_STATE_U2:
  94. return "U2";
  95. case DWC3_LINK_STATE_U3:
  96. return "U3";
  97. case DWC3_LINK_STATE_SS_DIS:
  98. return "SS.Disabled";
  99. case DWC3_LINK_STATE_RX_DET:
  100. return "RX.Detect";
  101. case DWC3_LINK_STATE_SS_INACT:
  102. return "SS.Inactive";
  103. case DWC3_LINK_STATE_POLL:
  104. return "Polling";
  105. case DWC3_LINK_STATE_RECOV:
  106. return "Recovery";
  107. case DWC3_LINK_STATE_HRESET:
  108. return "Hot Reset";
  109. case DWC3_LINK_STATE_CMPLY:
  110. return "Compliance";
  111. case DWC3_LINK_STATE_LPBK:
  112. return "Loopback";
  113. case DWC3_LINK_STATE_RESET:
  114. return "Reset";
  115. case DWC3_LINK_STATE_RESUME:
  116. return "Resume";
  117. default:
  118. return "UNKNOWN link state\n";
  119. }
  120. }
  121. /**
  122. * dwc3_gadget_event_string - returns event name
  123. * @event: the event code
  124. */
  125. static inline const char *dwc3_gadget_event_string(u8 event)
  126. {
  127. switch (event) {
  128. case DWC3_DEVICE_EVENT_DISCONNECT:
  129. return "Disconnect";
  130. case DWC3_DEVICE_EVENT_RESET:
  131. return "Reset";
  132. case DWC3_DEVICE_EVENT_CONNECT_DONE:
  133. return "Connection Done";
  134. case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE:
  135. return "Link Status Change";
  136. case DWC3_DEVICE_EVENT_WAKEUP:
  137. return "WakeUp";
  138. case DWC3_DEVICE_EVENT_EOPF:
  139. return "End-Of-Frame";
  140. case DWC3_DEVICE_EVENT_SOF:
  141. return "Start-Of-Frame";
  142. case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
  143. return "Erratic Error";
  144. case DWC3_DEVICE_EVENT_CMD_CMPL:
  145. return "Command Complete";
  146. case DWC3_DEVICE_EVENT_OVERFLOW:
  147. return "Overflow";
  148. }
  149. return "UNKNOWN";
  150. }
  151. /**
  152. * dwc3_ep_event_string - returns event name
  153. * @event: then event code
  154. */
  155. static inline const char *dwc3_ep_event_string(u8 event)
  156. {
  157. switch (event) {
  158. case DWC3_DEPEVT_XFERCOMPLETE:
  159. return "Transfer Complete";
  160. case DWC3_DEPEVT_XFERINPROGRESS:
  161. return "Transfer In-Progress";
  162. case DWC3_DEPEVT_XFERNOTREADY:
  163. return "Transfer Not Ready";
  164. case DWC3_DEPEVT_RXTXFIFOEVT:
  165. return "FIFO";
  166. case DWC3_DEPEVT_STREAMEVT:
  167. return "Stream";
  168. case DWC3_DEPEVT_EPCMDCMPLT:
  169. return "Endpoint Command Complete";
  170. }
  171. return "UNKNOWN";
  172. }
  173. /**
  174. * dwc3_gadget_event_type_string - return event name
  175. * @event: the event code
  176. */
  177. static inline const char *dwc3_gadget_event_type_string(u8 event)
  178. {
  179. switch (event) {
  180. case DWC3_DEVICE_EVENT_DISCONNECT:
  181. return "Disconnect";
  182. case DWC3_DEVICE_EVENT_RESET:
  183. return "Reset";
  184. case DWC3_DEVICE_EVENT_CONNECT_DONE:
  185. return "Connect Done";
  186. case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE:
  187. return "Link Status Change";
  188. case DWC3_DEVICE_EVENT_WAKEUP:
  189. return "Wake-Up";
  190. case DWC3_DEVICE_EVENT_HIBER_REQ:
  191. return "Hibernation";
  192. case DWC3_DEVICE_EVENT_EOPF:
  193. return "End of Periodic Frame";
  194. case DWC3_DEVICE_EVENT_SOF:
  195. return "Start of Frame";
  196. case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
  197. return "Erratic Error";
  198. case DWC3_DEVICE_EVENT_CMD_CMPL:
  199. return "Command Complete";
  200. case DWC3_DEVICE_EVENT_OVERFLOW:
  201. return "Overflow";
  202. default:
  203. return "UNKNOWN";
  204. }
  205. }
  206. void dwc3_trace(void (*trace)(struct va_format *), const char *fmt, ...);
  207. #ifdef CONFIG_DEBUG_FS
  208. extern int dwc3_debugfs_init(struct dwc3 *);
  209. extern void dwc3_debugfs_exit(struct dwc3 *);
  210. #else
  211. static inline int dwc3_debugfs_init(struct dwc3 *d)
  212. { return 0; }
  213. static inline void dwc3_debugfs_exit(struct dwc3 *d)
  214. { }
  215. #endif
  216. #endif /* __DWC3_DEBUG_H */