summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-09-07 00:32:08 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-07 20:02:55 +0000
commit1fba781b9f6d17dbab70227c4b90c268d6fe7af7 (patch)
treec52a6a017e6a48cf75da99dfb5c52140017016e0
parent968b86d63a578e72c2c9de8e6f5d2acb27cce9fa (diff)
downloadchrome-ec-1fba781b9f6d17dbab70227c4b90c268d6fe7af7.tar.gz
zephyr: emul: i2c: Add device label for better debug
Improve the debug output by including the device label in the common configs. BRANCH=none BUG=none TEST=zmake configure --test zephyr/test/drivers Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ic331e7842efdfae70d3f994a694c7723fdcd9640 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3144313 Reviewed-by: Tomasz Michalec <tm@semihalf.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r--zephyr/emul/emul_bb_retimer.c1
-rw-r--r--zephyr/emul/emul_bma255.c1
-rw-r--r--zephyr/emul/emul_bmi.c1
-rw-r--r--zephyr/emul/emul_common_i2c.c2
-rw-r--r--zephyr/emul/emul_smart_battery.c1
-rw-r--r--zephyr/emul/emul_tcs3400.c1
-rw-r--r--zephyr/include/emul/emul_common_i2c.h2
-rw-r--r--zephyr/test/drivers/prj.conf1
8 files changed, 9 insertions, 1 deletions
diff --git a/zephyr/emul/emul_bb_retimer.c b/zephyr/emul/emul_bb_retimer.c
index 93b0ae882a..ebbf2415dc 100644
--- a/zephyr/emul/emul_bb_retimer.c
+++ b/zephyr/emul/emul_bb_retimer.c
@@ -341,6 +341,7 @@ static int bb_emul_init(const struct emul *emul,
\
static const struct i2c_common_emul_cfg bb_emul_cfg_##n = { \
.i2c_label = DT_INST_BUS_LABEL(n), \
+ .dev_label = DT_INST_LABEL(n), \
.data = &bb_emul_data_##n.common, \
.addr = DT_INST_REG_ADDR(n), \
}; \
diff --git a/zephyr/emul/emul_bma255.c b/zephyr/emul/emul_bma255.c
index 9b6c401d0d..412e99b5f2 100644
--- a/zephyr/emul/emul_bma255.c
+++ b/zephyr/emul/emul_bma255.c
@@ -1018,6 +1018,7 @@ static int bma_emul_init(const struct emul *emul,
\
static const struct i2c_common_emul_cfg bma_emul_cfg_##n = { \
.i2c_label = DT_INST_BUS_LABEL(n), \
+ .dev_label = DT_INST_LABEL(n), \
.data = &bma_emul_data_##n.common, \
.addr = DT_INST_REG_ADDR(n), \
}; \
diff --git a/zephyr/emul/emul_bmi.c b/zephyr/emul/emul_bmi.c
index 7ba2ed3bab..8286d2d634 100644
--- a/zephyr/emul/emul_bmi.c
+++ b/zephyr/emul/emul_bmi.c
@@ -1092,6 +1092,7 @@ static int bmi_emul_init(const struct emul *emul,
\
static const struct i2c_common_emul_cfg bmi_emul_cfg_##n = { \
.i2c_label = DT_INST_BUS_LABEL(n), \
+ .dev_label = DT_INST_LABEL(n), \
.data = &bmi_emul_data_##n.common, \
.addr = DT_INST_REG_ADDR(n), \
}; \
diff --git a/zephyr/emul/emul_common_i2c.c b/zephyr/emul/emul_common_i2c.c
index 6cd93dfe18..99f3b1ced8 100644
--- a/zephyr/emul/emul_common_i2c.c
+++ b/zephyr/emul/emul_common_i2c.c
@@ -298,7 +298,7 @@ int i2c_common_emul_transfer(struct i2c_emul *emul, struct i2c_msg *msgs,
return -EIO;
}
- i2c_dump_msgs("emul", msgs, num_msgs, addr);
+ i2c_dump_msgs(cfg->dev_label, msgs, num_msgs, addr);
for (; num_msgs > 0; num_msgs--, msgs++) {
read = msgs->flags & I2C_MSG_READ;
diff --git a/zephyr/emul/emul_smart_battery.c b/zephyr/emul/emul_smart_battery.c
index 1fbc5b4993..1da517cd2a 100644
--- a/zephyr/emul/emul_smart_battery.c
+++ b/zephyr/emul/emul_smart_battery.c
@@ -869,6 +869,7 @@ static int sbat_emul_init(const struct emul *emul,
\
static const struct i2c_common_emul_cfg sbat_emul_cfg_##n = { \
.i2c_label = DT_INST_BUS_LABEL(n), \
+ .dev_label = DT_INST_LABEL(n), \
.data = &sbat_emul_data_##n.common, \
.addr = DT_INST_REG_ADDR(n), \
}; \
diff --git a/zephyr/emul/emul_tcs3400.c b/zephyr/emul/emul_tcs3400.c
index dd65b31211..6c2aa48816 100644
--- a/zephyr/emul/emul_tcs3400.c
+++ b/zephyr/emul/emul_tcs3400.c
@@ -626,6 +626,7 @@ static int tcs_emul_init(const struct emul *emul,
\
static const struct i2c_common_emul_cfg tcs_emul_cfg_##n = { \
.i2c_label = DT_INST_BUS_LABEL(n), \
+ .dev_label = DT_INST_LABEL(n), \
.data = &tcs_emul_data_##n.common, \
.addr = DT_INST_REG_ADDR(n), \
}; \
diff --git a/zephyr/include/emul/emul_common_i2c.h b/zephyr/include/emul/emul_common_i2c.h
index 3f48e2b33a..0457842a71 100644
--- a/zephyr/include/emul/emul_common_i2c.h
+++ b/zephyr/include/emul/emul_common_i2c.h
@@ -214,6 +214,8 @@ typedef int (*i2c_common_emul_write_func)(struct i2c_emul *emul, int reg,
struct i2c_common_emul_cfg {
/** Label of the I2C bus this emulator connects to */
const char *i2c_label;
+ /** Label of the I2C device being emulated */
+ const char *dev_label;
/** Pointer to run-time data */
struct i2c_common_emul_data *data;
/** Address of emulator on i2c bus */
diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf
index 44057c2c12..4a6e981d7a 100644
--- a/zephyr/test/drivers/prj.conf
+++ b/zephyr/test/drivers/prj.conf
@@ -7,6 +7,7 @@ CONFIG_PLATFORM_EC=y
CONFIG_CROS_EC=y
CONFIG_SHIMMED_TASKS=y
CONFIG_EMUL=y
+CONFIG_LOG=y
CONFIG_I2C=y
CONFIG_I2C_EMUL=y
CONFIG_GPIO=y