1 // SPDX-License-Identifier: GPL-2.0
3 * mtu3_trace.h - trace support
5 * Copyright (C) 2019 MediaTek Inc.
7 * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
11 #define TRACE_SYSTEM mtu3
13 #if !defined(__MTU3_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
14 #define __MTU3_TRACE_H__
16 #include <linux/types.h>
17 #include <linux/tracepoint.h>
21 #define MTU3_MSG_MAX 256
24 TP_PROTO(struct device
*dev
, struct va_format
*vaf
),
27 __string(name
, dev_name(dev
))
28 __dynamic_array(char, msg
, MTU3_MSG_MAX
)
31 __assign_str(name
, dev_name(dev
));
32 vsnprintf(__get_str(msg
), MTU3_MSG_MAX
, vaf
->fmt
, *vaf
->va
);
34 TP_printk("%s: %s", __get_str(name
), __get_str(msg
))
37 TRACE_EVENT(mtu3_u3_ltssm_isr
,
46 TP_printk("(%08x) %s %s %s %s %s %s", __entry
->intr
,
47 __entry
->intr
& HOT_RST_INTR
? "HOT_RST" : "",
48 __entry
->intr
& WARM_RST_INTR
? "WARM_RST" : "",
49 __entry
->intr
& ENTER_U3_INTR
? "ENT_U3" : "",
50 __entry
->intr
& EXIT_U3_INTR
? "EXIT_U3" : "",
51 __entry
->intr
& VBUS_RISE_INTR
? "VBUS_RISE" : "",
52 __entry
->intr
& VBUS_FALL_INTR
? "VBUS_FALL" : ""
56 TRACE_EVENT(mtu3_u2_common_isr
,
65 TP_printk("(%08x) %s %s %s", __entry
->intr
,
66 __entry
->intr
& SUSPEND_INTR
? "SUSPEND" : "",
67 __entry
->intr
& RESUME_INTR
? "RESUME" : "",
68 __entry
->intr
& RESET_INTR
? "RESET" : ""
72 TRACE_EVENT(mtu3_qmu_isr
,
73 TP_PROTO(u32 done_intr
, u32 exp_intr
),
74 TP_ARGS(done_intr
, exp_intr
),
76 __field(u32
, done_intr
)
77 __field(u32
, exp_intr
)
80 __entry
->done_intr
= done_intr
;
81 __entry
->exp_intr
= exp_intr
;
83 TP_printk("done (tx %04x, rx %04x), exp (%08x)",
84 __entry
->done_intr
& 0xffff,
85 __entry
->done_intr
>> 16,
90 DECLARE_EVENT_CLASS(mtu3_log_setup
,
91 TP_PROTO(struct usb_ctrlrequest
*setup
),
94 __field(__u8
, bRequestType
)
95 __field(__u8
, bRequest
)
96 __field(__u16
, wValue
)
97 __field(__u16
, wIndex
)
98 __field(__u16
, wLength
)
101 __entry
->bRequestType
= setup
->bRequestType
;
102 __entry
->bRequest
= setup
->bRequest
;
103 __entry
->wValue
= le16_to_cpu(setup
->wValue
);
104 __entry
->wIndex
= le16_to_cpu(setup
->wIndex
);
105 __entry
->wLength
= le16_to_cpu(setup
->wLength
);
107 TP_printk("setup - %02x %02x %04x %04x %04x",
108 __entry
->bRequestType
, __entry
->bRequest
,
109 __entry
->wValue
, __entry
->wIndex
, __entry
->wLength
113 DEFINE_EVENT(mtu3_log_setup
, mtu3_handle_setup
,
114 TP_PROTO(struct usb_ctrlrequest
*setup
),
118 DECLARE_EVENT_CLASS(mtu3_log_request
,
119 TP_PROTO(struct mtu3_request
*mreq
),
122 __string(name
, mreq
->mep
->name
)
123 __field(struct mtu3_request
*, mreq
)
124 __field(struct qmu_gpd
*, gpd
)
125 __field(unsigned int, actual
)
126 __field(unsigned int, length
)
129 __field(int, no_interrupt
)
132 __assign_str(name
, mreq
->mep
->name
);
133 __entry
->mreq
= mreq
;
134 __entry
->gpd
= mreq
->gpd
;
135 __entry
->actual
= mreq
->request
.actual
;
136 __entry
->length
= mreq
->request
.length
;
137 __entry
->status
= mreq
->request
.status
;
138 __entry
->zero
= mreq
->request
.zero
;
139 __entry
->no_interrupt
= mreq
->request
.no_interrupt
;
141 TP_printk("%s: req %p gpd %p len %u/%u %s%s --> %d",
142 __get_str(name
), __entry
->mreq
, __entry
->gpd
,
143 __entry
->actual
, __entry
->length
,
144 __entry
->zero
? "Z" : "z",
145 __entry
->no_interrupt
? "i" : "I",
150 DEFINE_EVENT(mtu3_log_request
, mtu3_alloc_request
,
151 TP_PROTO(struct mtu3_request
*req
),
155 DEFINE_EVENT(mtu3_log_request
, mtu3_free_request
,
156 TP_PROTO(struct mtu3_request
*req
),
160 DEFINE_EVENT(mtu3_log_request
, mtu3_gadget_queue
,
161 TP_PROTO(struct mtu3_request
*req
),
165 DEFINE_EVENT(mtu3_log_request
, mtu3_gadget_dequeue
,
166 TP_PROTO(struct mtu3_request
*req
),
170 DEFINE_EVENT(mtu3_log_request
, mtu3_req_complete
,
171 TP_PROTO(struct mtu3_request
*req
),
175 DECLARE_EVENT_CLASS(mtu3_log_gpd
,
176 TP_PROTO(struct mtu3_ep
*mep
, struct qmu_gpd
*gpd
),
179 __string(name
, mep
->name
)
180 __field(struct qmu_gpd
*, gpd
)
187 __assign_str(name
, mep
->name
);
189 __entry
->dw0
= le32_to_cpu(gpd
->dw0_info
);
190 __entry
->dw1
= le32_to_cpu(gpd
->next_gpd
);
191 __entry
->dw2
= le32_to_cpu(gpd
->buffer
);
192 __entry
->dw3
= le32_to_cpu(gpd
->dw3_info
);
194 TP_printk("%s: gpd %p - %08x %08x %08x %08x",
195 __get_str(name
), __entry
->gpd
,
196 __entry
->dw0
, __entry
->dw1
,
197 __entry
->dw2
, __entry
->dw3
201 DEFINE_EVENT(mtu3_log_gpd
, mtu3_prepare_gpd
,
202 TP_PROTO(struct mtu3_ep
*mep
, struct qmu_gpd
*gpd
),
206 DEFINE_EVENT(mtu3_log_gpd
, mtu3_complete_gpd
,
207 TP_PROTO(struct mtu3_ep
*mep
, struct qmu_gpd
*gpd
),
211 DEFINE_EVENT(mtu3_log_gpd
, mtu3_zlp_exp_gpd
,
212 TP_PROTO(struct mtu3_ep
*mep
, struct qmu_gpd
*gpd
),
216 DECLARE_EVENT_CLASS(mtu3_log_ep
,
217 TP_PROTO(struct mtu3_ep
*mep
),
220 __string(name
, mep
->name
)
221 __field(unsigned int, type
)
222 __field(unsigned int, slot
)
223 __field(unsigned int, maxp
)
224 __field(unsigned int, mult
)
225 __field(unsigned int, maxburst
)
226 __field(unsigned int, flags
)
227 __field(unsigned int, direction
)
228 __field(struct mtu3_gpd_ring
*, gpd_ring
)
231 __assign_str(name
, mep
->name
);
232 __entry
->type
= mep
->type
;
233 __entry
->slot
= mep
->slot
;
234 __entry
->maxp
= mep
->ep
.maxpacket
;
235 __entry
->mult
= mep
->ep
.mult
;
236 __entry
->maxburst
= mep
->ep
.maxburst
;
237 __entry
->flags
= mep
->flags
;
238 __entry
->direction
= mep
->is_in
;
239 __entry
->gpd_ring
= &mep
->gpd_ring
;
241 TP_printk("%s: type %d maxp %d slot %d mult %d burst %d ring %p/%pad flags %c:%c%c%c:%c",
242 __get_str(name
), __entry
->type
,
243 __entry
->maxp
, __entry
->slot
,
244 __entry
->mult
, __entry
->maxburst
,
245 __entry
->gpd_ring
, &__entry
->gpd_ring
->dma
,
246 __entry
->flags
& MTU3_EP_ENABLED
? 'E' : 'e',
247 __entry
->flags
& MTU3_EP_STALL
? 'S' : 's',
248 __entry
->flags
& MTU3_EP_WEDGE
? 'W' : 'w',
249 __entry
->flags
& MTU3_EP_BUSY
? 'B' : 'b',
250 __entry
->direction
? '<' : '>'
254 DEFINE_EVENT(mtu3_log_ep
, mtu3_gadget_ep_enable
,
255 TP_PROTO(struct mtu3_ep
*mep
),
259 DEFINE_EVENT(mtu3_log_ep
, mtu3_gadget_ep_disable
,
260 TP_PROTO(struct mtu3_ep
*mep
),
264 DEFINE_EVENT(mtu3_log_ep
, mtu3_gadget_ep_set_halt
,
265 TP_PROTO(struct mtu3_ep
*mep
),
269 #endif /* __MTU3_TRACE_H__ */
271 /* this part has to be here */
273 #undef TRACE_INCLUDE_PATH
274 #define TRACE_INCLUDE_PATH .
276 #undef TRACE_INCLUDE_FILE
277 #define TRACE_INCLUDE_FILE mtu3_trace
279 #include <trace/define_trace.h>