xref: /openbmc/linux/drivers/usb/musb/musb_trace.h (revision 3ca3af7d)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * musb_trace.h - MUSB Controller Trace Support
4  *
5  * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
6  *
7  * Author: Bin Liu <b-liu@ti.com>
8  */
9 
10 #undef TRACE_SYSTEM
11 #define TRACE_SYSTEM musb
12 
13 #if !defined(__MUSB_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
14 #define __MUSB_TRACE_H
15 
16 #include <linux/types.h>
17 #include <linux/tracepoint.h>
18 #include <linux/usb.h>
19 #include "musb_core.h"
20 #ifdef CONFIG_USB_TI_CPPI41_DMA
21 #include "cppi_dma.h"
22 #endif
23 
24 #define MUSB_MSG_MAX   500
25 
26 TRACE_EVENT(musb_log,
27 	TP_PROTO(struct musb *musb, struct va_format *vaf),
28 	TP_ARGS(musb, vaf),
29 	TP_STRUCT__entry(
30 		__string(name, dev_name(musb->controller))
31 		__dynamic_array(char, msg, MUSB_MSG_MAX)
32 	),
33 	TP_fast_assign(
34 		__assign_str(name, dev_name(musb->controller));
35 		vsnprintf(__get_str(msg), MUSB_MSG_MAX, vaf->fmt, *vaf->va);
36 	),
37 	TP_printk("%s: %s", __get_str(name), __get_str(msg))
38 );
39 
40 TRACE_EVENT(musb_state,
41 	TP_PROTO(struct musb *musb, u8 devctl, const char *desc),
42 	TP_ARGS(musb, devctl, desc),
43 	TP_STRUCT__entry(
44 		__string(name, dev_name(musb->controller))
45 		__field(u8, devctl)
46 		__string(desc, desc)
47 	),
48 	TP_fast_assign(
49 		__assign_str(name, dev_name(musb->controller));
50 		__entry->devctl = devctl;
51 		__assign_str(desc, desc);
52 	),
53 	TP_printk("%s: devctl: %02x %s", __get_str(name), __entry->devctl,
54 		  __get_str(desc))
55 );
56 
57 DECLARE_EVENT_CLASS(musb_regb,
58 	TP_PROTO(void *caller, const void  __iomem *addr,
59 		 unsigned int offset, u8 data),
60 	TP_ARGS(caller, addr, offset, data),
61 	TP_STRUCT__entry(
62 		__field(void *, caller)
63 		__field(const void __iomem *, addr)
64 		__field(unsigned int, offset)
65 		__field(u8, data)
66 	),
67 	TP_fast_assign(
68 		__entry->caller = caller;
69 		__entry->addr = addr;
70 		__entry->offset = offset;
71 		__entry->data = data;
72 	),
73 	TP_printk("%pS: %p + %04x: %02x",
74 		__entry->caller, __entry->addr, __entry->offset, __entry->data)
75 );
76 
77 DEFINE_EVENT(musb_regb, musb_readb,
78 	TP_PROTO(void *caller, const void __iomem *addr,
79 		 unsigned int offset, u8 data),
80 	TP_ARGS(caller, addr, offset, data)
81 );
82 
83 DEFINE_EVENT(musb_regb, musb_writeb,
84 	TP_PROTO(void *caller, const void __iomem *addr,
85 		 unsigned int offset, u8 data),
86 	TP_ARGS(caller, addr, offset, data)
87 );
88 
89 DECLARE_EVENT_CLASS(musb_regw,
90 	TP_PROTO(void *caller, const void __iomem *addr,
91 		 unsigned int offset, u16 data),
92 	TP_ARGS(caller, addr, offset, data),
93 	TP_STRUCT__entry(
94 		__field(void *, caller)
95 		__field(const void __iomem *, addr)
96 		__field(unsigned int, offset)
97 		__field(u16, data)
98 	),
99 	TP_fast_assign(
100 		__entry->caller = caller;
101 		__entry->addr = addr;
102 		__entry->offset = offset;
103 		__entry->data = data;
104 	),
105 	TP_printk("%pS: %p + %04x: %04x",
106 		__entry->caller, __entry->addr, __entry->offset, __entry->data)
107 );
108 
109 DEFINE_EVENT(musb_regw, musb_readw,
110 	TP_PROTO(void *caller, const void __iomem *addr,
111 		 unsigned int offset, u16 data),
112 	TP_ARGS(caller, addr, offset, data)
113 );
114 
115 DEFINE_EVENT(musb_regw, musb_writew,
116 	TP_PROTO(void *caller, const void __iomem *addr,
117 		 unsigned int offset, u16 data),
118 	TP_ARGS(caller, addr, offset, data)
119 );
120 
121 DECLARE_EVENT_CLASS(musb_regl,
122 	TP_PROTO(void *caller, const void __iomem *addr,
123 		 unsigned int offset, u32 data),
124 	TP_ARGS(caller, addr, offset, data),
125 	TP_STRUCT__entry(
126 		__field(void *, caller)
127 		__field(const void __iomem *, addr)
128 		__field(unsigned int, offset)
129 		__field(u32, data)
130 	),
131 	TP_fast_assign(
132 		__entry->caller = caller;
133 		__entry->addr = addr;
134 		__entry->offset = offset;
135 		__entry->data = data;
136 	),
137 	TP_printk("%pS: %p + %04x: %08x",
138 		__entry->caller, __entry->addr, __entry->offset, __entry->data)
139 );
140 
141 DEFINE_EVENT(musb_regl, musb_readl,
142 	TP_PROTO(void *caller, const void __iomem *addr,
143 		 unsigned int offset, u32 data),
144 	TP_ARGS(caller, addr, offset, data)
145 );
146 
147 DEFINE_EVENT(musb_regl, musb_writel,
148 	TP_PROTO(void *caller, const void __iomem *addr,
149 		 unsigned int offset, u32 data),
150 	TP_ARGS(caller, addr, offset, data)
151 );
152 
153 TRACE_EVENT(musb_isr,
154 	TP_PROTO(struct musb *musb),
155 	TP_ARGS(musb),
156 	TP_STRUCT__entry(
157 		__string(name, dev_name(musb->controller))
158 		__field(u8, int_usb)
159 		__field(u16, int_tx)
160 		__field(u16, int_rx)
161 	),
162 	TP_fast_assign(
163 		__assign_str(name, dev_name(musb->controller));
164 		__entry->int_usb = musb->int_usb;
165 		__entry->int_tx = musb->int_tx;
166 		__entry->int_rx = musb->int_rx;
167 	),
168 	TP_printk("%s: usb %02x, tx %04x, rx %04x",
169 		__get_str(name), __entry->int_usb,
170 		__entry->int_tx, __entry->int_rx
171 	)
172 );
173 
174 DECLARE_EVENT_CLASS(musb_urb,
175 	TP_PROTO(struct musb *musb, struct urb *urb),
176 	TP_ARGS(musb, urb),
177 	TP_STRUCT__entry(
178 		__string(name, dev_name(musb->controller))
179 		__field(struct urb *, urb)
180 		__field(unsigned int, pipe)
181 		__field(int, status)
182 		__field(unsigned int, flag)
183 		__field(u32, buf_len)
184 		__field(u32, actual_len)
185 	),
186 	TP_fast_assign(
187 		__assign_str(name, dev_name(musb->controller));
188 		__entry->urb = urb;
189 		__entry->pipe = urb->pipe;
190 		__entry->status = urb->status;
191 		__entry->flag = urb->transfer_flags;
192 		__entry->buf_len = urb->transfer_buffer_length;
193 		__entry->actual_len = urb->actual_length;
194 	),
195 	TP_printk("%s: %p, dev%d ep%d%s, flag 0x%x, len %d/%d, status %d",
196 			__get_str(name), __entry->urb,
197 			usb_pipedevice(__entry->pipe),
198 			usb_pipeendpoint(__entry->pipe),
199 			usb_pipein(__entry->pipe) ? "in" : "out",
200 			__entry->flag,
201 			__entry->actual_len, __entry->buf_len,
202 			__entry->status
203 	)
204 );
205 
206 DEFINE_EVENT(musb_urb, musb_urb_start,
207 	TP_PROTO(struct musb *musb, struct urb *urb),
208 	TP_ARGS(musb, urb)
209 );
210 
211 DEFINE_EVENT(musb_urb, musb_urb_gb,
212 	TP_PROTO(struct musb *musb, struct urb *urb),
213 	TP_ARGS(musb, urb)
214 );
215 
216 DEFINE_EVENT(musb_urb, musb_urb_rx,
217 	TP_PROTO(struct musb *musb, struct urb *urb),
218 	TP_ARGS(musb, urb)
219 );
220 
221 DEFINE_EVENT(musb_urb, musb_urb_tx,
222 	TP_PROTO(struct musb *musb, struct urb *urb),
223 	TP_ARGS(musb, urb)
224 );
225 
226 DEFINE_EVENT(musb_urb, musb_urb_enq,
227 	TP_PROTO(struct musb *musb, struct urb *urb),
228 	TP_ARGS(musb, urb)
229 );
230 
231 DEFINE_EVENT(musb_urb, musb_urb_deq,
232 	TP_PROTO(struct musb *musb, struct urb *urb),
233 	TP_ARGS(musb, urb)
234 );
235 
236 DECLARE_EVENT_CLASS(musb_req,
237 	TP_PROTO(struct musb_request *req),
238 	TP_ARGS(req),
239 	TP_STRUCT__entry(
240 		__field(struct usb_request *, req)
241 		__field(u8, is_tx)
242 		__field(u8, epnum)
243 		__field(int, status)
244 		__field(unsigned int, buf_len)
245 		__field(unsigned int, actual_len)
246 		__field(unsigned int, zero)
247 		__field(unsigned int, short_not_ok)
248 		__field(unsigned int, no_interrupt)
249 	),
250 	TP_fast_assign(
251 		__entry->req = &req->request;
252 		__entry->is_tx = req->tx;
253 		__entry->epnum = req->epnum;
254 		__entry->status = req->request.status;
255 		__entry->buf_len = req->request.length;
256 		__entry->actual_len = req->request.actual;
257 		__entry->zero = req->request.zero;
258 		__entry->short_not_ok = req->request.short_not_ok;
259 		__entry->no_interrupt = req->request.no_interrupt;
260 	),
261 	TP_printk("%p, ep%d %s, %s%s%s, len %d/%d, status %d",
262 			__entry->req, __entry->epnum,
263 			__entry->is_tx ? "tx/IN" : "rx/OUT",
264 			__entry->zero ? "Z" : "z",
265 			__entry->short_not_ok ? "S" : "s",
266 			__entry->no_interrupt ? "I" : "i",
267 			__entry->actual_len, __entry->buf_len,
268 			__entry->status
269 	)
270 );
271 
272 DEFINE_EVENT(musb_req, musb_req_gb,
273 	TP_PROTO(struct musb_request *req),
274 	TP_ARGS(req)
275 );
276 
277 DEFINE_EVENT(musb_req, musb_req_tx,
278 	TP_PROTO(struct musb_request *req),
279 	TP_ARGS(req)
280 );
281 
282 DEFINE_EVENT(musb_req, musb_req_rx,
283 	TP_PROTO(struct musb_request *req),
284 	TP_ARGS(req)
285 );
286 
287 DEFINE_EVENT(musb_req, musb_req_alloc,
288 	TP_PROTO(struct musb_request *req),
289 	TP_ARGS(req)
290 );
291 
292 DEFINE_EVENT(musb_req, musb_req_free,
293 	TP_PROTO(struct musb_request *req),
294 	TP_ARGS(req)
295 );
296 
297 DEFINE_EVENT(musb_req, musb_req_start,
298 	TP_PROTO(struct musb_request *req),
299 	TP_ARGS(req)
300 );
301 
302 DEFINE_EVENT(musb_req, musb_req_enq,
303 	TP_PROTO(struct musb_request *req),
304 	TP_ARGS(req)
305 );
306 
307 DEFINE_EVENT(musb_req, musb_req_deq,
308 	TP_PROTO(struct musb_request *req),
309 	TP_ARGS(req)
310 );
311 
312 #ifdef CONFIG_USB_TI_CPPI41_DMA
313 DECLARE_EVENT_CLASS(musb_cppi41,
314 	TP_PROTO(struct cppi41_dma_channel *ch),
315 	TP_ARGS(ch),
316 	TP_STRUCT__entry(
317 		__field(struct cppi41_dma_channel *, ch)
318 		__string(name, dev_name(ch->hw_ep->musb->controller))
319 		__field(u8, hwep)
320 		__field(u8, port)
321 		__field(u8, is_tx)
322 		__field(u32, len)
323 		__field(u32, prog_len)
324 		__field(u32, xferred)
325 	),
326 	TP_fast_assign(
327 		__entry->ch = ch;
328 		__assign_str(name, dev_name(ch->hw_ep->musb->controller));
329 		__entry->hwep = ch->hw_ep->epnum;
330 		__entry->port = ch->port_num;
331 		__entry->is_tx = ch->is_tx;
332 		__entry->len = ch->total_len;
333 		__entry->prog_len = ch->prog_len;
334 		__entry->xferred = ch->transferred;
335 	),
336 	TP_printk("%s: %p, hwep%d ch%d%s, prog_len %d, len %d/%d",
337 			__get_str(name), __entry->ch, __entry->hwep,
338 			__entry->port, __entry->is_tx ? "tx" : "rx",
339 			__entry->prog_len, __entry->xferred, __entry->len
340 	)
341 );
342 
343 DEFINE_EVENT(musb_cppi41, musb_cppi41_done,
344 	TP_PROTO(struct cppi41_dma_channel *ch),
345 	TP_ARGS(ch)
346 );
347 
348 DEFINE_EVENT(musb_cppi41, musb_cppi41_gb,
349 	TP_PROTO(struct cppi41_dma_channel *ch),
350 	TP_ARGS(ch)
351 );
352 
353 DEFINE_EVENT(musb_cppi41, musb_cppi41_config,
354 	TP_PROTO(struct cppi41_dma_channel *ch),
355 	TP_ARGS(ch)
356 );
357 
358 DEFINE_EVENT(musb_cppi41, musb_cppi41_cont,
359 	TP_PROTO(struct cppi41_dma_channel *ch),
360 	TP_ARGS(ch)
361 );
362 
363 DEFINE_EVENT(musb_cppi41, musb_cppi41_alloc,
364 	TP_PROTO(struct cppi41_dma_channel *ch),
365 	TP_ARGS(ch)
366 );
367 
368 DEFINE_EVENT(musb_cppi41, musb_cppi41_abort,
369 	TP_PROTO(struct cppi41_dma_channel *ch),
370 	TP_ARGS(ch)
371 );
372 
373 DEFINE_EVENT(musb_cppi41, musb_cppi41_free,
374 	TP_PROTO(struct cppi41_dma_channel *ch),
375 	TP_ARGS(ch)
376 );
377 #endif /* CONFIG_USB_TI_CPPI41_DMA */
378 
379 #endif /* __MUSB_TRACE_H */
380 
381 /* this part has to be here */
382 
383 #undef TRACE_INCLUDE_PATH
384 #define TRACE_INCLUDE_PATH .
385 
386 #undef TRACE_INCLUDE_FILE
387 #define TRACE_INCLUDE_FILE musb_trace
388 
389 #include <trace/define_trace.h>
390