1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #define TRACE_SYSTEM pwm
5 #if !defined(_TRACE_PWM_H) || defined(TRACE_HEADER_MULTI_READ)
9 #include <linux/tracepoint.h>
11 #define TP_PROTO_pwm(args...) \
12 TP_PROTO(struct pwm_device *pwm, args)
14 #define TP_ARGS_pwm(args...) \
17 #define TP_STRUCT__entry_pwm(args...) \
19 __field(unsigned int, chipid) \
20 __field(unsigned int, hwpwm) \
23 #define TP_fast_assign_pwm(args...) \
25 __entry->chipid = pwm->chip->id; \
26 __entry->hwpwm = pwm->hwpwm; \
29 #define TP_printk_pwm(fmt, args...) \
30 TP_printk("pwmchip%u.%u: " fmt, __entry->chipid, __entry->hwpwm, args)
32 #define __field_pwmwf(wf) \
33 __field(u64, wf ## _period_length_ns) \
34 __field(u64, wf ## _duty_length_ns) \
35 __field(u64, wf ## _duty_offset_ns) \
37 #define fast_assign_pwmwf(wf) \
38 __entry->wf ## _period_length_ns = wf->period_length_ns; \
39 __entry->wf ## _duty_length_ns = wf->duty_length_ns; \
40 __entry->wf ## _duty_offset_ns = wf->duty_offset_ns
42 #define printk_pwmwf_format(wf) \
45 #define printk_pwmwf_formatargs(wf) \
46 __entry->wf ## _duty_length_ns, __entry->wf ## _period_length_ns, __entry->wf ## _duty_offset_ns
48 TRACE_EVENT(pwm_round_waveform_tohw
,
50 TP_PROTO_pwm(const struct pwm_waveform
*wf
, void *wfhw
, int err
),
52 TP_ARGS_pwm(wf
, wfhw
, err
),
61 fast_assign_pwmwf(wf
);
66 TP_printk_pwm(printk_pwmwf_format(wf
) " > %p err=%d",
67 printk_pwmwf_formatargs(wf
), __entry
->wfhw
, __entry
->err
)
70 TRACE_EVENT(pwm_round_waveform_fromhw
,
72 TP_PROTO_pwm(const void *wfhw
, struct pwm_waveform
*wf
, int err
),
74 TP_ARGS_pwm(wfhw
, wf
, err
),
77 __field(const void *, wfhw
)
84 fast_assign_pwmwf(wf
);
88 TP_printk_pwm("%p > " printk_pwmwf_format(wf
) " err=%d",
89 __entry
->wfhw
, printk_pwmwf_formatargs(wf
), __entry
->err
)
92 TRACE_EVENT(pwm_read_waveform
,
94 TP_PROTO_pwm(void *wfhw
, int err
),
96 TP_ARGS_pwm(wfhw
, err
),
104 __entry
->wfhw
= wfhw
;
108 TP_printk_pwm("%p err=%d",
109 __entry
->wfhw
, __entry
->err
)
112 TRACE_EVENT(pwm_write_waveform
,
114 TP_PROTO_pwm(const void *wfhw
, int err
),
116 TP_ARGS_pwm(wfhw
, err
),
118 TP_STRUCT__entry_pwm(
119 __field(const void *, wfhw
)
124 __entry
->wfhw
= wfhw
;
128 TP_printk_pwm("%p err=%d",
129 __entry
->wfhw
, __entry
->err
)
133 DECLARE_EVENT_CLASS(pwm
,
135 TP_PROTO(struct pwm_device
*pwm
, const struct pwm_state
*state
, int err
),
137 TP_ARGS(pwm
, state
, err
),
139 TP_STRUCT__entry_pwm(
141 __field(u64
, duty_cycle
)
142 __field(enum pwm_polarity
, polarity
)
143 __field(bool, enabled
)
148 __entry
->period
= state
->period
;
149 __entry
->duty_cycle
= state
->duty_cycle
;
150 __entry
->polarity
= state
->polarity
;
151 __entry
->enabled
= state
->enabled
;
155 TP_printk_pwm("period=%llu duty_cycle=%llu polarity=%d enabled=%d err=%d",
156 __entry
->period
, __entry
->duty_cycle
,
157 __entry
->polarity
, __entry
->enabled
, __entry
->err
)
161 DEFINE_EVENT(pwm
, pwm_apply
,
163 TP_PROTO(struct pwm_device
*pwm
, const struct pwm_state
*state
, int err
),
165 TP_ARGS(pwm
, state
, err
)
168 DEFINE_EVENT(pwm
, pwm_get
,
170 TP_PROTO(struct pwm_device
*pwm
, const struct pwm_state
*state
, int err
),
172 TP_ARGS(pwm
, state
, err
)
175 #endif /* _TRACE_PWM_H */
177 /* This part must be outside protection */
178 #include <trace/define_trace.h>