@@ -3,12 +3,14 @@
obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o
obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o
obj-$(CONFIG_CHROMEOS_TBMC) += chromeos_tbmc.o
+# tell define_trace.h where to find the cros ec trace header
+CFLAGS_cros_ec_trace.o:= -I$(src)
obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o
obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
cros_ec_lpcs-objs := cros_ec_lpc.o cros_ec_lpc_reg.o
cros_ec_lpcs-$(CONFIG_CROS_EC_LPC_MEC) += cros_ec_lpc_mec.o
obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpcs.o
-obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o
+obj-$(CONFIG_CROS_EC_PROTO) += cros_ec_proto.o cros_ec_trace.o
obj-$(CONFIG_CROS_KBD_LED_BACKLIGHT) += cros_kbd_led_backlight.o
obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o
obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o
@@ -10,6 +10,8 @@
#include <linux/slab.h>
#include <asm/unaligned.h>
+#include "cros_ec_trace.h"
+
#define EC_COMMAND_RETRIES 50
static int prepare_packet(struct cros_ec_device *ec_dev,
@@ -51,6 +53,8 @@ static int send_command(struct cros_ec_device *ec_dev,
int ret;
int (*xfer_fxn)(struct cros_ec_device *ec, struct cros_ec_command *msg);
+ trace_cros_ec_cmd(msg);
+
if (ec_dev->proto_version > 2)
xfer_fxn = ec_dev->pkt_xfer;
else
new file mode 100644
@@ -0,0 +1,162 @@
+// SPDX-License-Identifier: GPL-2.0
+// Trace events for the ChromeOS Embedded Controller
+//
+// Copyright 2019 Google LLC.
+
+#define EC_CMD(a) {EC_CMD_##a, #a}
+
+#define ec_cmds \
+ EC_CMD(PROTO_VERSION), \
+ EC_CMD(HELLO), \
+ EC_CMD(GET_VERSION), \
+ EC_CMD(READ_TEST), \
+ EC_CMD(GET_BUILD_INFO), \
+ EC_CMD(GET_CHIP_INFO), \
+ EC_CMD(GET_BOARD_VERSION), \
+ EC_CMD(READ_MEMMAP), \
+ EC_CMD(GET_CMD_VERSIONS), \
+ EC_CMD(GET_COMMS_STATUS), \
+ EC_CMD(TEST_PROTOCOL), \
+ EC_CMD(GET_PROTOCOL_INFO), \
+ EC_CMD(GSV_PAUSE_IN_S5), \
+ EC_CMD(GET_FEATURES), \
+ EC_CMD(GET_SKU_ID), \
+ EC_CMD(SET_SKU_ID), \
+ EC_CMD(FLASH_INFO), \
+ EC_CMD(FLASH_READ), \
+ EC_CMD(FLASH_WRITE), \
+ EC_CMD(FLASH_ERASE), \
+ EC_CMD(FLASH_PROTECT), \
+ EC_CMD(FLASH_REGION_INFO), \
+ EC_CMD(VBNV_CONTEXT), \
+ EC_CMD(FLASH_SPI_INFO), \
+ EC_CMD(FLASH_SELECT), \
+ EC_CMD(PWM_GET_FAN_TARGET_RPM), \
+ EC_CMD(PWM_SET_FAN_TARGET_RPM), \
+ EC_CMD(PWM_GET_KEYBOARD_BACKLIGHT), \
+ EC_CMD(PWM_SET_KEYBOARD_BACKLIGHT), \
+ EC_CMD(PWM_SET_FAN_DUTY), \
+ EC_CMD(PWM_SET_DUTY), \
+ EC_CMD(PWM_GET_DUTY), \
+ EC_CMD(LIGHTBAR_CMD), \
+ EC_CMD(LED_CONTROL), \
+ EC_CMD(VBOOT_HASH), \
+ EC_CMD(MOTION_SENSE_CMD), \
+ EC_CMD(FORCE_LID_OPEN), \
+ EC_CMD(CONFIG_POWER_BUTTON), \
+ EC_CMD(USB_CHARGE_SET_MODE), \
+ EC_CMD(PSTORE_INFO), \
+ EC_CMD(PSTORE_READ), \
+ EC_CMD(PSTORE_WRITE), \
+ EC_CMD(RTC_GET_VALUE), \
+ EC_CMD(RTC_GET_ALARM), \
+ EC_CMD(RTC_SET_VALUE), \
+ EC_CMD(RTC_SET_ALARM), \
+ EC_CMD(PORT80_READ), \
+ EC_CMD(VSTORE_INFO), \
+ EC_CMD(VSTORE_READ), \
+ EC_CMD(VSTORE_WRITE), \
+ EC_CMD(THERMAL_SET_THRESHOLD), \
+ EC_CMD(THERMAL_GET_THRESHOLD), \
+ EC_CMD(THERMAL_AUTO_FAN_CTRL), \
+ EC_CMD(TMP006_GET_CALIBRATION), \
+ EC_CMD(TMP006_SET_CALIBRATION), \
+ EC_CMD(TMP006_GET_RAW), \
+ EC_CMD(MKBP_STATE), \
+ EC_CMD(MKBP_INFO), \
+ EC_CMD(MKBP_SIMULATE_KEY), \
+ EC_CMD(MKBP_SET_CONFIG), \
+ EC_CMD(MKBP_GET_CONFIG), \
+ EC_CMD(KEYSCAN_SEQ_CTRL), \
+ EC_CMD(GET_NEXT_EVENT), \
+ EC_CMD(KEYBOARD_FACTORY_TEST), \
+ EC_CMD(TEMP_SENSOR_GET_INFO), \
+ EC_CMD(ACPI_READ), \
+ EC_CMD(ACPI_WRITE), \
+ EC_CMD(ACPI_BURST_ENABLE), \
+ EC_CMD(ACPI_BURST_DISABLE), \
+ EC_CMD(ACPI_QUERY_EVENT), \
+ EC_CMD(HOST_EVENT_GET_B), \
+ EC_CMD(HOST_EVENT_GET_SMI_MASK), \
+ EC_CMD(HOST_EVENT_GET_SCI_MASK), \
+ EC_CMD(HOST_EVENT_SET_SMI_MASK), \
+ EC_CMD(HOST_EVENT_SET_SCI_MASK), \
+ EC_CMD(HOST_EVENT_CLEAR), \
+ EC_CMD(HOST_EVENT_GET_WAKE_MASK), \
+ EC_CMD(HOST_EVENT_SET_WAKE_MASK), \
+ EC_CMD(HOST_EVENT_CLEAR_B), \
+ EC_CMD(SWITCH_ENABLE_BKLIGHT), \
+ EC_CMD(SWITCH_ENABLE_WIRELESS), \
+ EC_CMD(GPIO_SET), \
+ EC_CMD(GPIO_GET), \
+ EC_CMD(I2C_READ), \
+ EC_CMD(I2C_WRITE), \
+ EC_CMD(CHARGE_CONTROL), \
+ EC_CMD(CONSOLE_SNAPSHOT), \
+ EC_CMD(CONSOLE_READ), \
+ EC_CMD(BATTERY_CUT_OFF), \
+ EC_CMD(USB_MUX), \
+ EC_CMD(LDO_SET), \
+ EC_CMD(LDO_GET), \
+ EC_CMD(POWER_INFO), \
+ EC_CMD(I2C_PASSTHRU), \
+ EC_CMD(HANG_DETECT), \
+ EC_CMD(CHARGE_STATE), \
+ EC_CMD(CHARGE_CURRENT_LIMIT), \
+ EC_CMD(EXTERNAL_POWER_LIMIT), \
+ EC_CMD(OVERRIDE_DEDICATED_CHARGER_LIMIT), \
+ EC_CMD(HOST_EVENT), \
+ EC_CMD(HIBERNATION_DELAY), \
+ EC_CMD(HOST_SLEEP_EVENT), \
+ EC_CMD(DEVICE_EVENT), \
+ EC_CMD(SB_READ_WORD), \
+ EC_CMD(SB_WRITE_WORD), \
+ EC_CMD(SB_READ_BLOCK), \
+ EC_CMD(SB_WRITE_BLOCK), \
+ EC_CMD(BATTERY_VENDOR_PARAM), \
+ EC_CMD(SB_FW_UPDATE), \
+ EC_CMD(ENTERING_MODE), \
+ EC_CMD(I2C_PASSTHRU_PROTECT), \
+ EC_CMD(REBOOT), \
+ EC_CMD(REBOOT_EC), \
+ EC_CMD(GET_PANIC_INFO), \
+ EC_CMD(RESEND_RESPONSE), \
+ EC_CMD(VERSION0), \
+ EC_CMD(PD_EXCHANGE_STATUS), \
+ EC_CMD(USB_PD_CONTROL), \
+ EC_CMD(USB_PD_PORTS), \
+ EC_CMD(USB_PD_POWER_INFO), \
+ EC_CMD(PD_HOST_EVENT_STATUS), \
+ EC_CMD(USB_PD_FW_UPDATE), \
+ EC_CMD(USB_PD_RW_HASH_ENTRY), \
+ EC_CMD(USB_PD_DEV_INFO), \
+ EC_CMD(USB_PD_DISCOVERY), \
+ EC_CMD(PD_CHARGE_PORT_OVERRIDE), \
+ EC_CMD(PD_GET_LOG_ENTRY), \
+ EC_CMD(USB_PD_GET_AMODE), \
+ EC_CMD(USB_PD_SET_AMODE), \
+ EC_CMD(PD_WRITE_LOG_ENTRY), \
+ EC_CMD(PD_CONTROL), \
+ EC_CMD(USB_PD_MUX_INFO), \
+ EC_CMD(PD_CHIP_INFO), \
+ EC_CMD(RWSIG_CHECK_STATUS), \
+ EC_CMD(RWSIG_ACTION), \
+ EC_CMD(CR51_BASE), \
+ EC_CMD(CR51_LAST), \
+ EC_CMD(FP_PASSTHRU), \
+ EC_CMD(FP_SENSOR_CONFIG), \
+ EC_CMD(FP_MODE), \
+ EC_CMD(FP_INFO), \
+ EC_CMD(FP_FRAME), \
+ EC_CMD(TP_SELF_TEST), \
+ EC_CMD(TP_FRAME_INFO), \
+ EC_CMD(TP_FRAME_SNAPSHOT), \
+ EC_CMD(TP_FRAME_GET), \
+ EC_CMD(BATTERY_GET_STATIC), \
+ EC_CMD(BATTERY_GET_DYNAMIC), \
+ EC_CMD(CHARGER_CONTROL), \
+ EC_CMD(BOARD_SPECIFIC_BASE), \
+ EC_CMD(BOARD_SPECIFIC_LAST)
+
+#define CREATE_TRACE_POINTS
+#include "cros_ec_trace.h"
new file mode 100644
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Trace events for the ChromeOS Embedded Controller
+ *
+ * Copyright 2019 Google LLC.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM cros_ec
+
+#if !defined(_CROS_EC_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
+#define _CROS_EC_TRACE_H_
+
+#include <linux/types.h>
+#include <linux/mfd/cros_ec.h>
+
+#include <linux/tracepoint.h>
+
+DECLARE_EVENT_CLASS(cros_ec_cmd_class,
+ TP_PROTO(struct cros_ec_command *cmd),
+ TP_ARGS(cmd),
+ TP_STRUCT__entry(
+ __field(uint32_t, version)
+ __field(uint32_t, command)
+ ),
+ TP_fast_assign(
+ __entry->version = cmd->version;
+ __entry->command = cmd->command;
+ ),
+ TP_printk("version: %u, command: %s", __entry->version,
+ __print_symbolic(__entry->command, ec_cmds))
+);
+
+
+DEFINE_EVENT(cros_ec_cmd_class, cros_ec_cmd,
+ TP_PROTO(struct cros_ec_command *cmd),
+ TP_ARGS(cmd)
+);
+
+
+#endif /* _CROS_EC_TRACE_H_ */
+
+/* this part must be outside header guard */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE cros_ec_trace
+
+#include <trace/define_trace.h>
This is useful to see which EC commands are being executed and when. To enable: echo 'cros_ec:*' >> /sys/kernel/debug/tracing/set_event Example: /* cros_ec_cmd: version: 0, command: GET_VERSION */ /* cros_ec_cmd: version: 0, command: GET_PROTOCOL_INFO */ /* cros_ec_cmd: version: 1, command: GET_CMD_VERSIONS */ /* cros_ec_cmd: version: 1, command: USB_PD_CONTROL */ Signed-off-by: Raul E Rangel <rrangel@chromium.org> --- Changes in v3: - Use a macro to avoid duplicating the ec command names. Changes in v2: - Changed comment style to match other cros_ec files. - Fixed commit tag. drivers/platform/chrome/Makefile | 4 +- drivers/platform/chrome/cros_ec_proto.c | 4 + drivers/platform/chrome/cros_ec_trace.c | 162 ++++++++++++++++++++++++ drivers/platform/chrome/cros_ec_trace.h | 51 ++++++++ 4 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/chrome/cros_ec_trace.c create mode 100644 drivers/platform/chrome/cros_ec_trace.h