xref: /linux/drivers/platform/chrome/cros_ec_trace.h (revision 9f2c9170934eace462499ba0bfe042cc72900173)
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 
19 #include <linux/tracepoint.h>
20 
21 TRACE_EVENT(cros_ec_request_start,
22 	TP_PROTO(struct cros_ec_command *cmd),
23 	TP_ARGS(cmd),
24 	TP_STRUCT__entry(
25 		__field(uint32_t, version)
26 		__field(uint32_t, offset)
27 		__field(uint32_t, command)
28 		__field(uint32_t, outsize)
29 		__field(uint32_t, insize)
30 	),
31 	TP_fast_assign(
32 		__entry->version = cmd->version;
33 		__entry->offset = cmd->command / EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX);
34 		__entry->command = cmd->command % EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX);
35 		__entry->outsize = cmd->outsize;
36 		__entry->insize = cmd->insize;
37 	),
38 	TP_printk("version: %u, offset: %d, command: %s, outsize: %u, insize: %u",
39 		  __entry->version, __entry->offset,
40 		  __print_symbolic(__entry->command, EC_CMDS),
41 		  __entry->outsize, __entry->insize)
42 );
43 
44 TRACE_EVENT(cros_ec_request_done,
45 	TP_PROTO(struct cros_ec_command *cmd, int retval),
46 	TP_ARGS(cmd, retval),
47 	TP_STRUCT__entry(
48 		__field(uint32_t, version)
49 		__field(uint32_t, offset)
50 		__field(uint32_t, command)
51 		__field(uint32_t, outsize)
52 		__field(uint32_t, insize)
53 		__field(uint32_t, result)
54 		__field(int, retval)
55 	),
56 	TP_fast_assign(
57 		__entry->version = cmd->version;
58 		__entry->offset = cmd->command / EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX);
59 		__entry->command = cmd->command % EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX);
60 		__entry->outsize = cmd->outsize;
61 		__entry->insize = cmd->insize;
62 		__entry->result = cmd->result;
63 		__entry->retval = retval;
64 	),
65 	TP_printk("version: %u, offset: %d, command: %s, outsize: %u, insize: %u, ec result: %s, retval: %u",
66 		  __entry->version, __entry->offset,
67 		  __print_symbolic(__entry->command, EC_CMDS),
68 		  __entry->outsize, __entry->insize,
69 		  __print_symbolic(__entry->result, EC_RESULT),
70 		  __entry->retval)
71 );
72 
73 #endif /* _CROS_EC_TRACE_H_ */
74 
75 /* this part must be outside header guard */
76 
77 #undef TRACE_INCLUDE_PATH
78 #define TRACE_INCLUDE_PATH .
79 
80 #undef TRACE_INCLUDE_FILE
81 #define TRACE_INCLUDE_FILE cros_ec_trace
82 
83 #include <trace/define_trace.h>
84