1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * MacBook (Pro) SPI keyboard and touchpad driver
4  *
5  * Copyright (c) 2015-2019 Federico Lorenzi
6  * Copyright (c) 2017-2019 Ronald Tschalär
7  */
8 
9 #undef TRACE_SYSTEM
10 #define TRACE_SYSTEM applespi
11 
12 #if !defined(_APPLESPI_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
13 #define _APPLESPI_TRACE_H_
14 
15 #include <linux/types.h>
16 #include <linux/tracepoint.h>
17 
18 #include "applespi.h"
19 
20 DECLARE_EVENT_CLASS(dump_message_template,
21 	TP_PROTO(enum applespi_evt_type evt_type,
22 		 enum applespi_pkt_type pkt_type,
23 		 u8 *buf,
24 		 size_t len),
25 
26 	TP_ARGS(evt_type, pkt_type, buf, len),
27 
28 	TP_STRUCT__entry(
29 		__field(enum applespi_evt_type, evt_type)
30 		__field(enum applespi_pkt_type, pkt_type)
31 		__field(size_t, len)
32 		__dynamic_array(u8, buf, len)
33 	),
34 
35 	TP_fast_assign(
36 		__entry->evt_type = evt_type;
37 		__entry->pkt_type = pkt_type;
38 		__entry->len = len;
39 		memcpy(__get_dynamic_array(buf), buf, len);
40 	),
41 
42 	TP_printk("%-6s: %s",
43 		  __print_symbolic(__entry->pkt_type,
44 				   { PT_READ, "read" },
45 				   { PT_WRITE, "write" },
46 				   { PT_STATUS, "status" }
47 		  ),
48 		  __print_hex(__get_dynamic_array(buf), __entry->len))
49 );
50 
51 #define DEFINE_DUMP_MESSAGE_EVENT(name)			\
52 DEFINE_EVENT(dump_message_template, name,		\
53 	TP_PROTO(enum applespi_evt_type evt_type,	\
54 		 enum applespi_pkt_type pkt_type,	\
55 		 u8 *buf,				\
56 		 size_t len),				\
57 	TP_ARGS(evt_type, pkt_type, buf, len)		\
58 )
59 
60 DEFINE_DUMP_MESSAGE_EVENT(applespi_tp_ini_cmd);
61 DEFINE_DUMP_MESSAGE_EVENT(applespi_backlight_cmd);
62 DEFINE_DUMP_MESSAGE_EVENT(applespi_caps_lock_cmd);
63 DEFINE_DUMP_MESSAGE_EVENT(applespi_keyboard_data);
64 DEFINE_DUMP_MESSAGE_EVENT(applespi_touchpad_data);
65 DEFINE_DUMP_MESSAGE_EVENT(applespi_unknown_data);
66 DEFINE_DUMP_MESSAGE_EVENT(applespi_bad_crc);
67 
68 TRACE_EVENT(applespi_irq_received,
69 	TP_PROTO(enum applespi_evt_type evt_type,
70 		 enum applespi_pkt_type pkt_type),
71 
72 	TP_ARGS(evt_type, pkt_type),
73 
74 	TP_STRUCT__entry(
75 		__field(enum applespi_evt_type, evt_type)
76 		__field(enum applespi_pkt_type, pkt_type)
77 	),
78 
79 	TP_fast_assign(
80 		__entry->evt_type = evt_type;
81 		__entry->pkt_type = pkt_type;
82 	),
83 
84 	"\n"
85 );
86 
87 #endif /* _APPLESPI_TRACE_H_ */
88 
89 /* This part must be outside protection */
90 #undef TRACE_INCLUDE_PATH
91 #define TRACE_INCLUDE_PATH ../../drivers/input/keyboard
92 #define TRACE_INCLUDE_FILE applespi_trace
93 #include <trace/define_trace.h>
94