1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Trace events for the ChromeOS Embedded Controller
4  *
5  * Copyright 2019 Google LLC.
6  */
7 
8 #undef TRACE_SYSTEM
9 #define TRACE_SYSTEM cros_ec
10 
11 #if !defined(_CROS_EC_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
12 #define _CROS_EC_TRACE_H_
13 
14 #include <linux/bits.h>
15 #include <linux/types.h>
16 #include <linux/platform_data/cros_ec_commands.h>
17 #include <linux/platform_data/cros_ec_proto.h>
18 #include <linux/platform_data/cros_ec_sensorhub.h>
19 
20 #include <linux/tracepoint.h>
21 
22 TRACE_EVENT(cros_ec_request_start,
23 	TP_PROTO(struct cros_ec_command *cmd),
24 	TP_ARGS(cmd),
25 	TP_STRUCT__entry(
26 		__field(uint32_t, version)
27 		__field(uint32_t, offset)
28 		__field(uint32_t, command)
29 		__field(uint32_t, outsize)
30 		__field(uint32_t, insize)
31 	),
32 	TP_fast_assign(
33 		__entry->version = cmd->version;
34 		__entry->offset = cmd->command / EC_CMD_PASSTHRU_OFFSET(1);
35 		__entry->command = cmd->command % EC_CMD_PASSTHRU_OFFSET(1);
36 		__entry->outsize = cmd->outsize;
37 		__entry->insize = cmd->insize;
38 	),
39 	TP_printk("version: %u, offset: %d, command: %s, outsize: %u, insize: %u",
40 		  __entry->version, __entry->offset,
41 		  __print_symbolic(__entry->command, EC_CMDS),
42 		  __entry->outsize, __entry->insize)
43 );
44 
45 TRACE_EVENT(cros_ec_request_done,
46 	TP_PROTO(struct cros_ec_command *cmd, int retval),
47 	TP_ARGS(cmd, retval),
48 	TP_STRUCT__entry(
49 		__field(uint32_t, version)
50 		__field(uint32_t, offset)
51 		__field(uint32_t, command)
52 		__field(uint32_t, outsize)
53 		__field(uint32_t, insize)
54 		__field(uint32_t, result)
55 		__field(int, retval)
56 	),
57 	TP_fast_assign(
58 		__entry->version = cmd->version;
59 		__entry->offset = cmd->command / EC_CMD_PASSTHRU_OFFSET(1);
60 		__entry->command = cmd->command % EC_CMD_PASSTHRU_OFFSET(1);
61 		__entry->outsize = cmd->outsize;
62 		__entry->insize = cmd->insize;
63 		__entry->result = cmd->result;
64 		__entry->retval = retval;
65 	),
66 	TP_printk("version: %u, offset: %d, command: %s, outsize: %u, insize: %u, ec result: %s, retval: %u",
67 		  __entry->version, __entry->offset,
68 		  __print_symbolic(__entry->command, EC_CMDS),
69 		  __entry->outsize, __entry->insize,
70 		  __print_symbolic(__entry->result, EC_RESULT),
71 		  __entry->retval)
72 );
73 
74 TRACE_EVENT(cros_ec_sensorhub_timestamp,
75 	    TP_PROTO(u32 ec_sample_timestamp, u32 ec_fifo_timestamp, s64 fifo_timestamp,
76 		     s64 current_timestamp, s64 current_time),
77 	TP_ARGS(ec_sample_timestamp, ec_fifo_timestamp, fifo_timestamp, current_timestamp,
78 		current_time),
79 	TP_STRUCT__entry(
80 		__field(u32, ec_sample_timestamp)
81 		__field(u32, ec_fifo_timestamp)
82 		__field(s64, fifo_timestamp)
83 		__field(s64, current_timestamp)
84 		__field(s64, current_time)
85 		__field(s64, delta)
86 	),
87 	TP_fast_assign(
88 		__entry->ec_sample_timestamp = ec_sample_timestamp;
89 		__entry->ec_fifo_timestamp = ec_fifo_timestamp;
90 		__entry->fifo_timestamp = fifo_timestamp;
91 		__entry->current_timestamp = current_timestamp;
92 		__entry->current_time = current_time;
93 		__entry->delta = current_timestamp - current_time;
94 	),
95 	TP_printk("ec_ts: %9u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
96 		  __entry->ec_sample_timestamp,
97 		__entry->ec_fifo_timestamp,
98 		__entry->fifo_timestamp,
99 		__entry->current_timestamp,
100 		__entry->current_time,
101 		__entry->delta
102 	)
103 );
104 
105 TRACE_EVENT(cros_ec_sensorhub_data,
106 	    TP_PROTO(u32 ec_sensor_num, u32 ec_fifo_timestamp, s64 fifo_timestamp,
107 		     s64 current_timestamp, s64 current_time),
108 	TP_ARGS(ec_sensor_num, ec_fifo_timestamp, fifo_timestamp, current_timestamp, current_time),
109 	TP_STRUCT__entry(
110 		__field(u32, ec_sensor_num)
111 		__field(u32, ec_fifo_timestamp)
112 		__field(s64, fifo_timestamp)
113 		__field(s64, current_timestamp)
114 		__field(s64, current_time)
115 		__field(s64, delta)
116 	),
117 	TP_fast_assign(
118 		__entry->ec_sensor_num = ec_sensor_num;
119 		__entry->ec_fifo_timestamp = ec_fifo_timestamp;
120 		__entry->fifo_timestamp = fifo_timestamp;
121 		__entry->current_timestamp = current_timestamp;
122 		__entry->current_time = current_time;
123 		__entry->delta = current_timestamp - current_time;
124 	),
125 	TP_printk("ec_num: %4u, ec_fifo_ts: %9u, fifo_ts: %12lld, curr_ts: %12lld, curr_time: %12lld, delta %12lld",
126 		  __entry->ec_sensor_num,
127 		__entry->ec_fifo_timestamp,
128 		__entry->fifo_timestamp,
129 		__entry->current_timestamp,
130 		__entry->current_time,
131 		__entry->delta
132 	)
133 );
134 
135 TRACE_EVENT(cros_ec_sensorhub_filter,
136 	    TP_PROTO(struct cros_ec_sensors_ts_filter_state *state, s64 dx, s64 dy),
137 	TP_ARGS(state, dx, dy),
138 	TP_STRUCT__entry(
139 		__field(s64, dx)
140 		__field(s64, dy)
141 		__field(s64, median_m)
142 		__field(s64, median_error)
143 		__field(s64, history_len)
144 		__field(s64, x)
145 		__field(s64, y)
146 	),
147 	TP_fast_assign(
148 		__entry->dx = dx;
149 		__entry->dy = dy;
150 		__entry->median_m = state->median_m;
151 		__entry->median_error = state->median_error;
152 		__entry->history_len = state->history_len;
153 		__entry->x = state->x_offset;
154 		__entry->y = state->y_offset;
155 	),
156 	TP_printk("dx: %12lld. dy: %12lld median_m: %12lld median_error: %12lld len: %lld x: %12lld y: %12lld",
157 		  __entry->dx,
158 		__entry->dy,
159 		__entry->median_m,
160 		__entry->median_error,
161 		__entry->history_len,
162 		__entry->x,
163 		__entry->y
164 	)
165 );
166 
167 
168 #endif /* _CROS_EC_TRACE_H_ */
169 
170 /* this part must be outside header guard */
171 
172 #undef TRACE_INCLUDE_PATH
173 #define TRACE_INCLUDE_PATH .
174 
175 #undef TRACE_INCLUDE_FILE
176 #define TRACE_INCLUDE_FILE cros_ec_trace
177 
178 #include <trace/define_trace.h>
179