summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/i2c_controller.c9
-rw-r--r--util/config_allowed.txt2
-rw-r--r--zephyr/CMakeLists.txt2
-rw-r--r--zephyr/Kconfig21
-rw-r--r--zephyr/shim/include/config_chip.h10
5 files changed, 41 insertions, 3 deletions
diff --git a/common/i2c_controller.c b/common/i2c_controller.c
index 90aed056ae..dfc3417e88 100644
--- a/common/i2c_controller.c
+++ b/common/i2c_controller.c
@@ -258,8 +258,15 @@ int i2c_xfer_unlocked(const int port,
ccprintf("Ignoring flags from i2c addr_flags: %04x",
no_pec_af);
- return i2c_transfer(i2c_get_device_for_port(port), msg,
+ ret = i2c_transfer(i2c_get_device_for_port(port), msg,
num_msgs, I2C_STRIP_FLAGS(no_pec_af));
+
+ if (IS_ENABLED(CONFIG_I2C_DEBUG)) {
+ i2c_trace_notify(port, addr_flags, out, out_size,
+ in, in_size);
+ }
+
+ return ret;
#elif defined(CONFIG_I2C_XFER_LARGE_TRANSFER)
ret = i2c_xfer_no_retry(port, no_pec_af,
out, out_size, in,
diff --git a/util/config_allowed.txt b/util/config_allowed.txt
index 8a0c1dac92..16f88d5a90 100644
--- a/util/config_allowed.txt
+++ b/util/config_allowed.txt
@@ -526,8 +526,6 @@ CONFIG_I2C_BITBANG
CONFIG_I2C_BUS_MAY_BE_UNPOWERED
CONFIG_I2C_CHIP_MAX_TRANSFER_SIZE
CONFIG_I2C_CONTROLLER
-CONFIG_I2C_DEBUG
-CONFIG_I2C_DEBUG_PASSTHRU
CONFIG_I2C_EXTRA_PACKET_SIZE
CONFIG_I2C_HID_TOUCHPAD
CONFIG_I2C_MULTI_PORT_CONTROLLER
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index 7dbab86eb9..4e3294220e 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -208,6 +208,8 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD_REGULATOR
"${PLATFORM_EC}/common/regulator.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C
"${PLATFORM_EC}/common/i2c_controller.c")
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C_DEBUG
+ "${PLATFORM_EC}/common/i2c_trace.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY
"${PLATFORM_EC}/common/virtual_battery.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index 3d4a5a62b5..2f4a653fea 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -454,6 +454,27 @@ config PLATFORM_EC_I2C
should make shimming other platform/ec modules which rely on i2c
communication "just work" without requiring any further code changes.
+config PLATFORM_EC_I2C_DEBUG
+ bool "I2C Tracing"
+ default n if ARCH_POSIX
+ depends on PLATFORM_EC_I2C
+ help
+ This option enables I2C bus communication tracing. Use the console
+ command "i2ctrace" to enable and disable tracing on specific I2C
+ peripherals.
+
+ Please see the I2C debugging documentation for more details:
+
+ https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/docs/i2c-debugging.md
+
+config PLATFORM_EC_I2C_DEBUG_PASSTHRU
+ bool "I2C Passthru Debug"
+ default n if ARCH_POSIX
+ depends on PLATFORM_EC_I2C
+ help
+ This option enables extra debug for I2C passthru operations initiated
+ by the AP.
+
config PLATFORM_EC_CONSOLE_CMD_I2C_PORTMAP
bool "Console command: i2c_portmap"
default y
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index f53e4025b7..8c8ba3bbf2 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -452,6 +452,16 @@
#define CONFIG_I2C_CONTROLLER
#endif
+#undef CONFIG_I2C_DEBUG
+#ifdef CONFIG_PLATFORM_EC_I2C_DEBUG
+#define CONFIG_I2C_DEBUG
+#endif
+
+#undef CONFIG_I2C_DEBUG_PASSTHRU
+#ifdef CONFIG_PLATFORM_EC_I2C_DEBUG_PASSTHRU
+#define CONFIG_I2C_DEBUG_PASSTHRU
+#endif
+
#undef CONFIG_SMBUS_PEC
#ifdef CONFIG_PLATFORM_EC_SMBUS_PEC
#define CONFIG_SMBUS_PEC