xref: /linux/drivers/platform/chrome/cros_ec_sensorhub_trace.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1*eabd9a38SGwendal Grignou /* SPDX-License-Identifier: GPL-2.0 */
2*eabd9a38SGwendal Grignou /*
3*eabd9a38SGwendal Grignou  * Trace events for the ChromeOS Sensorhub kernel module
4*eabd9a38SGwendal Grignou  *
5*eabd9a38SGwendal Grignou  * Copyright 2021 Google LLC.
6*eabd9a38SGwendal Grignou  */
7*eabd9a38SGwendal Grignou 
8*eabd9a38SGwendal Grignou #undef TRACE_SYSTEM
9*eabd9a38SGwendal Grignou #define TRACE_SYSTEM cros_ec
10*eabd9a38SGwendal Grignou 
11*eabd9a38SGwendal Grignou #if !defined(_CROS_EC_SENSORHUB_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
12*eabd9a38SGwendal Grignou #define _CROS_EC_SENSORHUB_TRACE_H_
13*eabd9a38SGwendal Grignou 
14*eabd9a38SGwendal Grignou #include <linux/types.h>
15*eabd9a38SGwendal Grignou #include <linux/platform_data/cros_ec_sensorhub.h>
16*eabd9a38SGwendal Grignou 
17*eabd9a38SGwendal Grignou #include <linux/tracepoint.h>
18*eabd9a38SGwendal Grignou 
19*eabd9a38SGwendal Grignou TRACE_EVENT(cros_ec_sensorhub_timestamp,
20*eabd9a38SGwendal Grignou 	    TP_PROTO(u32 ec_sample_timestamp, u32 ec_fifo_timestamp, s64 fifo_timestamp,
21*eabd9a38SGwendal Grignou 		     s64 current_timestamp, s64 current_time),
22*eabd9a38SGwendal Grignou 	TP_ARGS(ec_sample_timestamp, ec_fifo_timestamp, fifo_timestamp, current_timestamp,
23*eabd9a38SGwendal Grignou 		current_time),
24*eabd9a38SGwendal Grignou 	TP_STRUCT__entry(
25*eabd9a38SGwendal Grignou 		__field(u32, ec_sample_timestamp)
26*eabd9a38SGwendal Grignou 		__field(u32, ec_fifo_timestamp)
27*eabd9a38SGwendal Grignou 		__field(s64, fifo_timestamp)
28*eabd9a38SGwendal Grignou 		__field(s64, current_timestamp)
29*eabd9a38SGwendal Grignou 		__field(s64, current_time)
30*eabd9a38SGwendal Grignou 		__field(s64, delta)
31*eabd9a38SGwendal Grignou 	),
32*eabd9a38SGwendal Grignou 	TP_fast_assign(
33*eabd9a38SGwendal Grignou 		__entry->ec_sample_timestamp = ec_sample_timestamp;
34*eabd9a38SGwendal Grignou 		__entry->ec_fifo_timestamp = ec_fifo_timestamp;
35*eabd9a38SGwendal Grignou 		__entry->fifo_timestamp = fifo_timestamp;
36*eabd9a38SGwendal Grignou 		__entry->current_timestamp = current_timestamp;
37*eabd9a38SGwendal Grignou 		__entry->current_time = current_time;
38*eabd9a38SGwendal Grignou 		__entry->delta = current_timestamp - current_time;
39*eabd9a38SGwendal Grignou 	),
40*eabd9a38SGwendal Grignou 	TP_printk("ec_ts: %9u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
41*eabd9a38SGwendal Grignou 		  __entry->ec_sample_timestamp,
42*eabd9a38SGwendal Grignou 		__entry->ec_fifo_timestamp,
43*eabd9a38SGwendal Grignou 		__entry->fifo_timestamp,
44*eabd9a38SGwendal Grignou 		__entry->current_timestamp,
45*eabd9a38SGwendal Grignou 		__entry->current_time,
46*eabd9a38SGwendal Grignou 		__entry->delta
47*eabd9a38SGwendal Grignou 	)
48*eabd9a38SGwendal Grignou );
49*eabd9a38SGwendal Grignou 
50*eabd9a38SGwendal Grignou TRACE_EVENT(cros_ec_sensorhub_data,
51*eabd9a38SGwendal Grignou 	    TP_PROTO(u32 ec_sensor_num, u32 ec_fifo_timestamp, s64 fifo_timestamp,
52*eabd9a38SGwendal Grignou 		     s64 current_timestamp, s64 current_time),
53*eabd9a38SGwendal Grignou 	TP_ARGS(ec_sensor_num, ec_fifo_timestamp, fifo_timestamp, current_timestamp, current_time),
54*eabd9a38SGwendal Grignou 	TP_STRUCT__entry(
55*eabd9a38SGwendal Grignou 		__field(u32, ec_sensor_num)
56*eabd9a38SGwendal Grignou 		__field(u32, ec_fifo_timestamp)
57*eabd9a38SGwendal Grignou 		__field(s64, fifo_timestamp)
58*eabd9a38SGwendal Grignou 		__field(s64, current_timestamp)
59*eabd9a38SGwendal Grignou 		__field(s64, current_time)
60*eabd9a38SGwendal Grignou 		__field(s64, delta)
61*eabd9a38SGwendal Grignou 	),
62*eabd9a38SGwendal Grignou 	TP_fast_assign(
63*eabd9a38SGwendal Grignou 		__entry->ec_sensor_num = ec_sensor_num;
64*eabd9a38SGwendal Grignou 		__entry->ec_fifo_timestamp = ec_fifo_timestamp;
65*eabd9a38SGwendal Grignou 		__entry->fifo_timestamp = fifo_timestamp;
66*eabd9a38SGwendal Grignou 		__entry->current_timestamp = current_timestamp;
67*eabd9a38SGwendal Grignou 		__entry->current_time = current_time;
68*eabd9a38SGwendal Grignou 		__entry->delta = current_timestamp - current_time;
69*eabd9a38SGwendal Grignou 	),
70*eabd9a38SGwendal Grignou 	TP_printk("ec_num: %4u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
71*eabd9a38SGwendal Grignou 		  __entry->ec_sensor_num,
72*eabd9a38SGwendal Grignou 		__entry->ec_fifo_timestamp,
73*eabd9a38SGwendal Grignou 		__entry->fifo_timestamp,
74*eabd9a38SGwendal Grignou 		__entry->current_timestamp,
75*eabd9a38SGwendal Grignou 		__entry->current_time,
76*eabd9a38SGwendal Grignou 		__entry->delta
77*eabd9a38SGwendal Grignou 	)
78*eabd9a38SGwendal Grignou );
79*eabd9a38SGwendal Grignou 
80*eabd9a38SGwendal Grignou TRACE_EVENT(cros_ec_sensorhub_filter,
81*eabd9a38SGwendal Grignou 	    TP_PROTO(struct cros_ec_sensors_ts_filter_state *state, s64 dx, s64 dy),
82*eabd9a38SGwendal Grignou 	TP_ARGS(state, dx, dy),
83*eabd9a38SGwendal Grignou 	TP_STRUCT__entry(
84*eabd9a38SGwendal Grignou 		__field(s64, dx)
85*eabd9a38SGwendal Grignou 		__field(s64, dy)
86*eabd9a38SGwendal Grignou 		__field(s64, median_m)
87*eabd9a38SGwendal Grignou 		__field(s64, median_error)
88*eabd9a38SGwendal Grignou 		__field(s64, history_len)
89*eabd9a38SGwendal Grignou 		__field(s64, x)
90*eabd9a38SGwendal Grignou 		__field(s64, y)
91*eabd9a38SGwendal Grignou 	),
92*eabd9a38SGwendal Grignou 	TP_fast_assign(
93*eabd9a38SGwendal Grignou 		__entry->dx = dx;
94*eabd9a38SGwendal Grignou 		__entry->dy = dy;
95*eabd9a38SGwendal Grignou 		__entry->median_m = state->median_m;
96*eabd9a38SGwendal Grignou 		__entry->median_error = state->median_error;
97*eabd9a38SGwendal Grignou 		__entry->history_len = state->history_len;
98*eabd9a38SGwendal Grignou 		__entry->x = state->x_offset;
99*eabd9a38SGwendal Grignou 		__entry->y = state->y_offset;
100*eabd9a38SGwendal Grignou 	),
101*eabd9a38SGwendal Grignou 	TP_printk("dx: %12lld. dy: %12lld median_m: %12lld median_error: %12lld len: %lld x: %12lld y: %12lld",
102*eabd9a38SGwendal Grignou 		  __entry->dx,
103*eabd9a38SGwendal Grignou 		__entry->dy,
104*eabd9a38SGwendal Grignou 		__entry->median_m,
105*eabd9a38SGwendal Grignou 		__entry->median_error,
106*eabd9a38SGwendal Grignou 		__entry->history_len,
107*eabd9a38SGwendal Grignou 		__entry->x,
108*eabd9a38SGwendal Grignou 		__entry->y
109*eabd9a38SGwendal Grignou 	)
110*eabd9a38SGwendal Grignou );
111*eabd9a38SGwendal Grignou 
112*eabd9a38SGwendal Grignou 
113*eabd9a38SGwendal Grignou #endif /* _CROS_EC_SENSORHUB_TRACE_H_ */
114*eabd9a38SGwendal Grignou 
115*eabd9a38SGwendal Grignou /* this part must be outside header guard */
116*eabd9a38SGwendal Grignou 
117*eabd9a38SGwendal Grignou #undef TRACE_INCLUDE_PATH
118*eabd9a38SGwendal Grignou #define TRACE_INCLUDE_PATH .
119*eabd9a38SGwendal Grignou 
120*eabd9a38SGwendal Grignou #undef TRACE_INCLUDE_FILE
121*eabd9a38SGwendal Grignou #define TRACE_INCLUDE_FILE cros_ec_sensorhub_trace
122*eabd9a38SGwendal Grignou 
123*eabd9a38SGwendal Grignou #include <trace/define_trace.h>
124