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