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