aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2014-08-19 17:37:22 -0400
committerFelipe Balbi <balbi@ti.com>2014-09-05 10:53:51 -0400
commit80977dc99be5d874d10716594e716ef317c1723c (patch)
tree8db9eeaa48b1431e6b3c3629d328d95b6096b334 /drivers/usb/dwc3
parent9bb87f168931cf55738ed2fbda3639575cede886 (diff)
usb: dwc3: move all string helper functions to debug.h
Those functions are only using within debugging messages, grouping them into debug.h makes sense. While at that, also add missing multiple inclusion guard. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3')
-rw-r--r--drivers/usb/dwc3/debug.h164
-rw-r--r--drivers/usb/dwc3/ep0.c1
-rw-r--r--drivers/usb/dwc3/gadget.c89
-rw-r--r--drivers/usb/dwc3/gadget.h56
4 files changed, 165 insertions, 145 deletions
diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h
index fceb39dc4bba..e35a3d103d7f 100644
--- a/drivers/usb/dwc3/debug.h
+++ b/drivers/usb/dwc3/debug.h
@@ -16,8 +16,170 @@
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 */ 17 */
18 18
19#ifndef __DWC3_DEBUG_H
20#define __DWC3_DEBUG_H
21
19#include "core.h" 22#include "core.h"
20 23
24/**
25 * dwc3_gadget_ep_cmd_string - returns endpoint command string
26 * @cmd: command code
27 */
28static inline const char *
29dwc3_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 */
59static inline const char *
60dwc3_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 */
90static inline const char *
91dwc3_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 */
131static 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 */
163static 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
21#ifdef CONFIG_DEBUG_FS 183#ifdef CONFIG_DEBUG_FS
22extern int dwc3_debugfs_init(struct dwc3 *); 184extern int dwc3_debugfs_init(struct dwc3 *);
23extern void dwc3_debugfs_exit(struct dwc3 *); 185extern void dwc3_debugfs_exit(struct dwc3 *);
@@ -27,4 +189,4 @@ static inline int dwc3_debugfs_init(struct dwc3 *d)
27static inline void dwc3_debugfs_exit(struct dwc3 *d) 189static inline void dwc3_debugfs_exit(struct dwc3 *d)
28{ } 190{ }
29#endif 191#endif
30 192#endif /* __DWC3_DEBUG_H */
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 21a352079bc2..994e1d864679 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -31,6 +31,7 @@
31#include <linux/usb/composite.h> 31#include <linux/usb/composite.h>
32 32
33#include "core.h" 33#include "core.h"
34#include "debug.h"
34#include "gadget.h" 35#include "gadget.h"
35#include "io.h" 36#include "io.h"
36 37
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 307b5139faf3..77c49a60a297 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -30,6 +30,7 @@
30#include <linux/usb/ch9.h> 30#include <linux/usb/ch9.h>
31#include <linux/usb/gadget.h> 31#include <linux/usb/gadget.h>
32 32
33#include "debug.h"
33#include "core.h" 34#include "core.h"
34#include "gadget.h" 35#include "gadget.h"
35#include "io.h" 36#include "io.h"
@@ -272,94 +273,6 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
272 spin_lock(&dwc->lock); 273 spin_lock(&dwc->lock);
273} 274}
274 275
275static const char *dwc3_gadget_ep_cmd_string(u8 cmd)
276{
277 switch (cmd) {
278 case DWC3_DEPCMD_DEPSTARTCFG:
279 return "Start New Configuration";
280 case DWC3_DEPCMD_ENDTRANSFER:
281 return "End Transfer";
282 case DWC3_DEPCMD_UPDATETRANSFER:
283 return "Update Transfer";
284 case DWC3_DEPCMD_STARTTRANSFER:
285 return "Start Transfer";
286 case DWC3_DEPCMD_CLEARSTALL:
287 return "Clear Stall";
288 case DWC3_DEPCMD_SETSTALL:
289 return "Set Stall";
290 case DWC3_DEPCMD_GETEPSTATE:
291 return "Get Endpoint State";
292 case DWC3_DEPCMD_SETTRANSFRESOURCE:
293 return "Set Endpoint Transfer Resource";
294 case DWC3_DEPCMD_SETEPCONFIG:
295 return "Set Endpoint Configuration";
296 default:
297 return "UNKNOWN command";
298 }
299}
300
301static const char *dwc3_gadget_generic_cmd_string(u8 cmd)
302{
303 switch (cmd) {
304 case DWC3_DGCMD_SET_LMP:
305 return "Set LMP";
306 case DWC3_DGCMD_SET_PERIODIC_PAR:
307 return "Set Periodic Parameters";
308 case DWC3_DGCMD_XMIT_FUNCTION:
309 return "Transmit Function Wake Device Notification";
310 case DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO:
311 return "Set Scratchpad Buffer Array Address Lo";
312 case DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI:
313 return "Set Scratchpad Buffer Array Address Hi";
314 case DWC3_DGCMD_SELECTED_FIFO_FLUSH:
315 return "Selected FIFO Flush";
316 case DWC3_DGCMD_ALL_FIFO_FLUSH:
317 return "All FIFO Flush";
318 case DWC3_DGCMD_SET_ENDPOINT_NRDY:
319 return "Set Endpoint NRDY";
320 case DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK:
321 return "Run SoC Bus Loopback Test";
322 default:
323 return "UNKNOWN";
324 }
325}
326
327static const char *dwc3_gadget_link_string(enum dwc3_link_state link_state)
328{
329 switch (link_state) {
330 case DWC3_LINK_STATE_U0:
331 return "U0";
332 case DWC3_LINK_STATE_U1:
333 return "U1";
334 case DWC3_LINK_STATE_U2:
335 return "U2";
336 case DWC3_LINK_STATE_U3:
337 return "U3";
338 case DWC3_LINK_STATE_SS_DIS:
339 return "SS.Disabled";
340 case DWC3_LINK_STATE_RX_DET:
341 return "RX.Detect";
342 case DWC3_LINK_STATE_SS_INACT:
343 return "SS.Inactive";
344 case DWC3_LINK_STATE_POLL:
345 return "Polling";
346 case DWC3_LINK_STATE_RECOV:
347 return "Recovery";
348 case DWC3_LINK_STATE_HRESET:
349 return "Hot Reset";
350 case DWC3_LINK_STATE_CMPLY:
351 return "Compliance";
352 case DWC3_LINK_STATE_LPBK:
353 return "Loopback";
354 case DWC3_LINK_STATE_RESET:
355 return "Reset";
356 case DWC3_LINK_STATE_RESUME:
357 return "Resume";
358 default:
359 return "UNKNOWN link state\n";
360 }
361}
362
363int dwc3_send_gadget_generic_command(struct dwc3 *dwc, int cmd, u32 param) 276int dwc3_send_gadget_generic_command(struct dwc3 *dwc, int cmd, u32 param)
364{ 277{
365 u32 timeout = 500; 278 u32 timeout = 500;
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h
index a0ee75b68a80..178ad8982206 100644
--- a/drivers/usb/dwc3/gadget.h
+++ b/drivers/usb/dwc3/gadget.h
@@ -103,60 +103,4 @@ static inline u32 dwc3_gadget_ep_get_transfer_index(struct dwc3 *dwc, u8 number)
103 return DWC3_DEPCMD_GET_RSC_IDX(res_id); 103 return DWC3_DEPCMD_GET_RSC_IDX(res_id);
104} 104}
105 105
106/**
107 * dwc3_gadget_event_string - returns event name
108 * @event: the event code
109 */
110static inline const char *dwc3_gadget_event_string(u8 event)
111{
112 switch (event) {
113 case DWC3_DEVICE_EVENT_DISCONNECT:
114 return "Disconnect";
115 case DWC3_DEVICE_EVENT_RESET:
116 return "Reset";
117 case DWC3_DEVICE_EVENT_CONNECT_DONE:
118 return "Connection Done";
119 case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE:
120 return "Link Status Change";
121 case DWC3_DEVICE_EVENT_WAKEUP:
122 return "WakeUp";
123 case DWC3_DEVICE_EVENT_EOPF:
124 return "End-Of-Frame";
125 case DWC3_DEVICE_EVENT_SOF:
126 return "Start-Of-Frame";
127 case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
128 return "Erratic Error";
129 case DWC3_DEVICE_EVENT_CMD_CMPL:
130 return "Command Complete";
131 case DWC3_DEVICE_EVENT_OVERFLOW:
132 return "Overflow";
133 }
134
135 return "UNKNOWN";
136}
137
138/**
139 * dwc3_ep_event_string - returns event name
140 * @event: then event code
141 */
142static inline const char *dwc3_ep_event_string(u8 event)
143{
144 switch (event) {
145 case DWC3_DEPEVT_XFERCOMPLETE:
146 return "Transfer Complete";
147 case DWC3_DEPEVT_XFERINPROGRESS:
148 return "Transfer In-Progress";
149 case DWC3_DEPEVT_XFERNOTREADY:
150 return "Transfer Not Ready";
151 case DWC3_DEPEVT_RXTXFIFOEVT:
152 return "FIFO";
153 case DWC3_DEPEVT_STREAMEVT:
154 return "Stream";
155 case DWC3_DEPEVT_EPCMDCMPLT:
156 return "Endpoint Command Complete";
157 }
158
159 return "UNKNOWN";
160}
161
162#endif /* __DRIVERS_USB_DWC3_GADGET_H */ 106#endif /* __DRIVERS_USB_DWC3_GADGET_H */