xref: /linux/include/trace/events/pwm.h (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM pwm
4 
5 #if !defined(_TRACE_PWM_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_PWM_H
7 
8 #include <linux/pwm.h>
9 #include <linux/tracepoint.h>
10 
11 #define TP_PROTO_pwm(args...)							\
12 	TP_PROTO(struct pwm_device *pwm, args)
13 
14 #define TP_ARGS_pwm(args...)							\
15 	TP_ARGS(pwm, args)
16 
17 #define TP_STRUCT__entry_pwm(args...)						\
18 	TP_STRUCT__entry(							\
19 		__field(unsigned int, chipid)					\
20 		__field(unsigned int, hwpwm)					\
21 		args)
22 
23 #define TP_fast_assign_pwm(args...)						\
24 	TP_fast_assign(								\
25 		__entry->chipid = pwm->chip->id;				\
26 		__entry->hwpwm = pwm->hwpwm;					\
27 		args)
28 
29 #define TP_printk_pwm(fmt, args...)						\
30 	TP_printk("pwmchip%u.%u: " fmt, __entry->chipid, __entry->hwpwm, args)
31 
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)					\
36 
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
41 
42 #define printk_pwmwf_format(wf)							\
43 	"%lld/%lld [+%lld]"
44 
45 #define printk_pwmwf_formatargs(wf)						\
46 	__entry->wf ## _duty_length_ns, __entry->wf ## _period_length_ns, __entry->wf ## _duty_offset_ns
47 
48 TRACE_EVENT(pwm_round_waveform_tohw,
49 
50 	TP_PROTO_pwm(const struct pwm_waveform *wf, void *wfhw, int err),
51 
52 	TP_ARGS_pwm(wf, wfhw, err),
53 
54 	TP_STRUCT__entry_pwm(
55 		__field_pwmwf(wf)
56 		__field(void *, wfhw)
57 		__field(int, err)
58 	),
59 
60 	TP_fast_assign_pwm(
61 		fast_assign_pwmwf(wf);
62 		__entry->wfhw = wfhw;
63 		__entry->err = err;
64 	),
65 
66 	TP_printk_pwm(printk_pwmwf_format(wf) " > %p err=%d",
67 		printk_pwmwf_formatargs(wf), __entry->wfhw, __entry->err)
68 );
69 
70 TRACE_EVENT(pwm_round_waveform_fromhw,
71 
72 	TP_PROTO_pwm(const void *wfhw, struct pwm_waveform *wf, int err),
73 
74 	TP_ARGS_pwm(wfhw, wf, err),
75 
76 	TP_STRUCT__entry_pwm(
77 		__field(const void *, wfhw)
78 		__field_pwmwf(wf)
79 		__field(int, err)
80 	),
81 
82 	TP_fast_assign_pwm(
83 		__entry->wfhw = wfhw;
84 		fast_assign_pwmwf(wf);
85 		__entry->err = err;
86 	),
87 
88 	TP_printk_pwm("%p > " printk_pwmwf_format(wf) " err=%d",
89 		__entry->wfhw, printk_pwmwf_formatargs(wf), __entry->err)
90 );
91 
92 TRACE_EVENT(pwm_read_waveform,
93 
94 	TP_PROTO_pwm(void *wfhw, int err),
95 
96 	TP_ARGS_pwm(wfhw, err),
97 
98 	TP_STRUCT__entry_pwm(
99 		__field(void *, wfhw)
100 		__field(int, err)
101 	),
102 
103 	TP_fast_assign_pwm(
104 		__entry->wfhw = wfhw;
105 		__entry->err = err;
106 	),
107 
108 	TP_printk_pwm("%p err=%d",
109 		__entry->wfhw, __entry->err)
110 );
111 
112 TRACE_EVENT(pwm_write_waveform,
113 
114 	TP_PROTO_pwm(const void *wfhw, int err),
115 
116 	TP_ARGS_pwm(wfhw, err),
117 
118 	TP_STRUCT__entry_pwm(
119 		__field(const void *, wfhw)
120 		__field(int, err)
121 	),
122 
123 	TP_fast_assign_pwm(
124 		__entry->wfhw = wfhw;
125 		__entry->err = err;
126 	),
127 
128 	TP_printk_pwm("%p err=%d",
129 		__entry->wfhw, __entry->err)
130 );
131 
132 
133 DECLARE_EVENT_CLASS(pwm,
134 
135 	TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state, int err),
136 
137 	TP_ARGS(pwm, state, err),
138 
139 	TP_STRUCT__entry_pwm(
140 		__field(u64, period)
141 		__field(u64, duty_cycle)
142 		__field(enum pwm_polarity, polarity)
143 		__field(bool, enabled)
144 		__field(int, err)
145 	),
146 
147 	TP_fast_assign_pwm(
148 		__entry->period = state->period;
149 		__entry->duty_cycle = state->duty_cycle;
150 		__entry->polarity = state->polarity;
151 		__entry->enabled = state->enabled;
152 		__entry->err = err;
153 	),
154 
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)
158 
159 );
160 
161 DEFINE_EVENT(pwm, pwm_apply,
162 
163 	TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state, int err),
164 
165 	TP_ARGS(pwm, state, err)
166 );
167 
168 DEFINE_EVENT(pwm, pwm_get,
169 
170 	TP_PROTO(struct pwm_device *pwm, const struct pwm_state *state, int err),
171 
172 	TP_ARGS(pwm, state, err)
173 );
174 
175 #endif /* _TRACE_PWM_H */
176 
177 /* This part must be outside protection */
178 #include <trace/define_trace.h>
179