| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
|
| 3 |
#undef TRACE_SYSTEM |
| 4 |
#define TRACE_SYSTEM ucsi |
| 5 |
|
| 6 |
#if !defined(__UCSI_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) |
| 7 |
#define __UCSI_TRACE_H |
| 8 |
|
| 9 |
#include <linux/tracepoint.h> |
| 10 |
#include <linux/usb/typec_altmode.h> |
| 11 |
|
| 12 |
const char *ucsi_cmd_str(u64 raw_cmd); |
| 13 |
const char *ucsi_recipient_str(u8 recipient); |
| 14 |
|
| 15 |
DECLARE_EVENT_CLASS(ucsi_log_command, |
| 16 |
TP_PROTO(u64 command, int ret), |
| 17 |
TP_ARGS(command, ret), |
| 18 |
TP_STRUCT__entry( |
| 19 |
__field(u64, ctrl) |
| 20 |
__field(int, ret) |
| 21 |
), |
| 22 |
TP_fast_assign( |
| 23 |
__entry->ctrl = command; |
| 24 |
__entry->ret = ret; |
| 25 |
), |
| 26 |
TP_printk("%s -> %s (err=%d)", ucsi_cmd_str(__entry->ctrl), |
| 27 |
__entry->ret < 0 ? "FAIL" : "OK", |
| 28 |
__entry->ret < 0 ? __entry->ret : 0) |
| 29 |
); |
| 30 |
|
| 31 |
DEFINE_EVENT(ucsi_log_command, ucsi_run_command, |
| 32 |
TP_PROTO(u64 command, int ret), |
| 33 |
TP_ARGS(command, ret) |
| 34 |
); |
| 35 |
|
| 36 |
DEFINE_EVENT(ucsi_log_command, ucsi_reset_ppm, |
| 37 |
TP_PROTO(u64 command, int ret), |
| 38 |
TP_ARGS(command, ret) |
| 39 |
); |
| 40 |
|
| 41 |
DECLARE_EVENT_CLASS(ucsi_log_connector_status, |
| 42 |
TP_PROTO(int port, struct ucsi_connector *con), |
| 43 |
TP_ARGS(port, con), |
| 44 |
TP_STRUCT__entry( |
| 45 |
__field(int, port) |
| 46 |
__field(u16, change) |
| 47 |
__field(u8, opmode) |
| 48 |
__field(u8, connected) |
| 49 |
__field(u8, pwr_dir) |
| 50 |
__field(u8, partner_flags) |
| 51 |
__field(u8, partner_type) |
| 52 |
__field(u32, request_data_obj) |
| 53 |
__field(u8, bc_status) |
| 54 |
), |
| 55 |
TP_fast_assign( |
| 56 |
__entry->port = port - 1; |
| 57 |
__entry->change = UCSI_CONSTAT(con, CHANGE); |
| 58 |
__entry->opmode = UCSI_CONSTAT(con, PWR_OPMODE); |
| 59 |
__entry->connected = UCSI_CONSTAT(con, CONNECTED); |
| 60 |
__entry->pwr_dir = UCSI_CONSTAT(con, PWR_DIR); |
| 61 |
__entry->partner_flags = UCSI_CONSTAT(con, PARTNER_FLAGS); |
| 62 |
__entry->partner_type = UCSI_CONSTAT(con, PARTNER_TYPE); |
| 63 |
__entry->request_data_obj = UCSI_CONSTAT(con, RDO); |
| 64 |
__entry->bc_status = UCSI_CONSTAT(con, BC_STATUS); |
| 65 |
), |
| 66 |
TP_printk("port%d status: change=%04x, opmode=%x, connected=%d, " |
| 67 |
"sourcing=%d, partner_flags=%x, partner_type=%x, " |
| 68 |
"request_data_obj=%08x, BC status=%x", __entry->port, |
| 69 |
__entry->change, __entry->opmode, __entry->connected, |
| 70 |
__entry->pwr_dir, __entry->partner_flags, __entry->partner_type, |
| 71 |
__entry->request_data_obj, __entry->bc_status) |
| 72 |
); |
| 73 |
|
| 74 |
DEFINE_EVENT(ucsi_log_connector_status, ucsi_connector_change, |
| 75 |
TP_PROTO(int port, struct ucsi_connector *con), |
| 76 |
TP_ARGS(port, con) |
| 77 |
); |
| 78 |
|
| 79 |
DEFINE_EVENT(ucsi_log_connector_status, ucsi_register_port, |
| 80 |
TP_PROTO(int port, struct ucsi_connector *con), |
| 81 |
TP_ARGS(port, con) |
| 82 |
); |
| 83 |
|
| 84 |
DECLARE_EVENT_CLASS(ucsi_log_register_altmode, |
| 85 |
TP_PROTO(u8 recipient, struct typec_altmode *alt), |
| 86 |
TP_ARGS(recipient, alt), |
| 87 |
TP_STRUCT__entry( |
| 88 |
__field(u8, recipient) |
| 89 |
__field(u16, svid) |
| 90 |
__field(u8, mode) |
| 91 |
__field(u32, vdo) |
| 92 |
), |
| 93 |
TP_fast_assign( |
| 94 |
__entry->recipient = recipient; |
| 95 |
__entry->svid = alt->svid; |
| 96 |
__entry->mode = alt->mode; |
| 97 |
__entry->vdo = alt->vdo; |
| 98 |
), |
| 99 |
TP_printk("%s alt mode: svid %04x, mode %d vdo %x", |
| 100 |
ucsi_recipient_str(__entry->recipient), __entry->svid, |
| 101 |
__entry->mode, __entry->vdo) |
| 102 |
); |
| 103 |
|
| 104 |
DEFINE_EVENT(ucsi_log_register_altmode, ucsi_register_altmode, |
| 105 |
TP_PROTO(u8 recipient, struct typec_altmode *alt), |
| 106 |
TP_ARGS(recipient, alt) |
| 107 |
); |
| 108 |
|
| 109 |
#endif /* __UCSI_TRACE_H */ |
| 110 |
|
| 111 |
/* This part must be outside protection */ |
| 112 |
|
| 113 |
#undef TRACE_INCLUDE_PATH |
| 114 |
#define TRACE_INCLUDE_PATH . |
| 115 |
|
| 116 |
#undef TRACE_INCLUDE_FILE |
| 117 |
#define TRACE_INCLUDE_FILE trace |
| 118 |
|
| 119 |
#include <trace/define_trace.h> |