diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2019-07-11 18:17:34 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-07-17 21:45:18 +0000 |
commit | f8d6179a26bf512c43638d0916fde0fc966cc3fb (patch) | |
tree | d4df87ff4a738060d20f874eaa75cc3b2d24cdb9 /common/i2c_master.c | |
parent | 21a255ea953e8ac64d05147ad7f11491db126cf4 (diff) | |
download | chrome-ec-f8d6179a26bf512c43638d0916fde0fc966cc3fb.tar.gz |
common: add i2c tracing functionality
crbug.com/982442 requests a way for developers to enable tracing of
i2c commands when debugging. This adds a new debug feature, the
i2ctrace command, which provides that. The command is guarded by
CONFIG_I2C_DEBUG.
BUG=chromium:982442
BRANCH=none
TEST=enabled CONFIG_I2C_DEBUG on arcada_ish, made sure that command
functioned as it says on the tin
Change-Id: I9c762271237cbf131e5ef7c0f605c89af4f209fd
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699347
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'common/i2c_master.c')
-rw-r--r-- | common/i2c_master.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/common/i2c_master.c b/common/i2c_master.c index 79ee897d25..2efd6e9450 100644 --- a/common/i2c_master.c +++ b/common/i2c_master.c @@ -76,16 +76,20 @@ static int chip_i2c_xfer_with_notify(int port, int slave_addr, { int ret; -#ifdef CONFIG_I2C_XFER_BOARD_CALLBACK - i2c_start_xfer_notify(port, slave_addr); -#endif + if (IS_ENABLED(CONFIG_I2C_DEBUG)) + i2c_trace_notify(port, slave_addr, 0, out, out_size); + + if (IS_ENABLED(CONFIG_I2C_XFER_BOARD_CALLBACK)) + i2c_start_xfer_notify(port, slave_addr); ret = chip_i2c_xfer(port, slave_addr, out, out_size, in, in_size, flags); -#ifdef CONFIG_I2C_XFER_BOARD_CALLBACK - i2c_end_xfer_notify(port, slave_addr); -#endif + if (IS_ENABLED(CONFIG_I2C_XFER_BOARD_CALLBACK)) + i2c_end_xfer_notify(port, slave_addr); + + if (IS_ENABLED(CONFIG_I2C_DEBUG)) + i2c_trace_notify(port, slave_addr, 1, in, in_size); return ret; } |