Attention is currently required from: Caveh Jalali, Forest Mittelberg.
ChromeOS coreboot bot has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/83742?usp=email )
Change subject: UPSTREAM: ec_commands: Add PDC tracing host commands ......................................................................
UPSTREAM: ec_commands: Add PDC tracing host commands
Add EC_CMD_PDC_TRACE_MSG_ENABLE and EC_CMD_PDC_TRACE_GET_ENTRIES host commands for controlling PDC message tracing and capturing on the EC.
BUG=b:336660528 TEST=tested with ectool patches later in this series
Original-Change-Id: If693006e931149cf3bea44716f56e8a3d9126419 Original-Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/5552811 Original-Code-Coverage: Zoss zoss-cl-coverage@prod.google.com Original-Tested-by: caveh jalali caveh@chromium.org Original-Reviewed-by: Tristan Honscheid honscheid@google.com Original-Commit-Queue: caveh jalali caveh@chromium.org GitOrigin-RevId: f15e662629c1965787c401b7d99d17de1d4235bb Change-Id: I5f87f11100b362070cafb3504abe8f37876a6cfa --- M src/ec/google/chromeec/ec_cmd_api.h M src/ec/google/chromeec/ec_commands.h 2 files changed, 71 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/42/83742/1
diff --git a/src/ec/google/chromeec/ec_cmd_api.h b/src/ec/google/chromeec/ec_cmd_api.h index cab69b7..7bdfe17 100644 --- a/src/ec/google/chromeec/ec_cmd_api.h +++ b/src/ec/google/chromeec/ec_cmd_api.h @@ -373,6 +373,8 @@ _CROS_EC_CV_F_P(EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT, 0, override_dedicated_charger_limit, dedicated_charger_limit); _CROS_EC_C0_F_RF(EC_CMD_PCHG_COUNT, pchg_count); +_CROS_EC_C0_F_PF_RF(EC_CMD_PDC_TRACE_MSG_ENABLE, pdc_trace_msg_enable); +_CROS_EC_C0_F_RF(EC_CMD_PDC_TRACE_MSG_GET_ENTRIES, pdc_trace_msg_get_entries); _CROS_EC_CV_F_P(EC_CMD_PD_CHARGE_PORT_OVERRIDE, 0, pd_charge_port_override, charge_port_override); _CROS_EC_CV_F_P_R(EC_CMD_PD_CHIP_INFO, 2, pd_chip_info_v2, pd_chip_info, diff --git a/src/ec/google/chromeec/ec_commands.h b/src/ec/google/chromeec/ec_commands.h index 71cd287..914f580 100644 --- a/src/ec/google/chromeec/ec_commands.h +++ b/src/ec/google/chromeec/ec_commands.h @@ -8053,6 +8053,75 @@ uint32_t time; } __ec_align2;
+/* + * Control PDC tracing. + * EC_PDC_TRACE_MSG_PORT_NONE disable tracing + * EC_PDC_TRACE_MSG_PORT_ALL enable tracing on all ports + * else, enable tracing on a specific port. + */ + +#define EC_CMD_PDC_TRACE_MSG_ENABLE 0x0143 + +#define EC_PDC_TRACE_MSG_PORT_NONE 0xff +#define EC_PDC_TRACE_MSG_PORT_ALL 0xfe + +struct ec_params_pdc_trace_msg_enable { + uint8_t port; +}; + +struct ec_response_pdc_trace_msg_enable { + /* Previous port value. */ + uint8_t port; + uint8_t reserved; + /* Number of free bytes in FIFO. */ + uint16_t fifo_free; + /* Running total of dropped messages (may wrap). */ + uint32_t dropped_count; +} __ec_align4; + +/* + * Fetch multiple PDC trace entries. + * + * If no entries are available, pl_size is 0. + * At most MAX_HC_PDC_TRACE_MSG_GET_PAYLOAD bytes worth of entries + * are returned. Only whole entries are returned. + */ + +#define EC_CMD_PDC_TRACE_MSG_GET_ENTRIES 0x0144 +#define MAX_HC_PDC_TRACE_MSG_GET_PAYLOAD 240 + +struct ec_response_pdc_trace_msg_get_entries { + /* Total bytes of payload. */ + uint16_t pl_size; + /* Packed array of pdc_trace_msg_entry structs. */ + uint8_t payload[FLEXIBLE_ARRAY_MEMBER_SIZE]; +}; + +enum pdc_trace_msg_direction { + PDC_TRACE_MSG_DIR_IN = 0, + PDC_TRACE_MSG_DIR_OUT = 1, +}; + +struct pdc_trace_msg_entry { + /* + * Timestamp - least significant 32 bits of EC epoch time + * (microseconds, will wrap around). + */ + uint32_t time32_us; + /* Entry sequence number (wraps around). */ + uint16_t seq_num; + /* Port number associated with this entry. */ + uint8_t port_num; + /* Direction of message (enum pdc_trace_msg_direction) */ + uint8_t direction; + /* Format of pdc_data (PDC chip identifier). */ + uint8_t msg_type; + /* Bytes in pdc_data. */ + uint8_t pdc_data_size; + /* Captured PDC message. */ + uint8_t pdc_data[0]; +} __ec_align1; + /*****************************************************************************/ /* The command range 0x200-0x2FF is reserved for Rotor. */