diff options
author | Yuval Peress <peress@chromium.org> | 2021-03-23 01:24:03 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-08 07:39:45 +0000 |
commit | f48f2ee331ead2bf641279d37ee091217e0d141c (patch) | |
tree | a98177440f53292e19b68c87d0292d19e27d29d4 /zephyr/shim | |
parent | 8d70ee4c035e949d5e59655d93c43ebd81060c87 (diff) | |
download | chrome-ec-f48f2ee331ead2bf641279d37ee091217e0d141c.tar.gz |
zephyr: i2c mapping using an enum
Currently, every project will need to provide a custom mapping header
for i2c as well as gpios. We'd like to move that overhead to the dts
files, which will make the board dts a lot more reusable as well as
clean up the bringup of new boards.
Add to the i2c_ports enum from the dts named i2c port list. Each enum
is only added if a node exists using that enum. This also allowes for
verifying that the enum is only used once.
BRANCH=none
BUG=b:184786824
TEST=build and flashed volteer
TEST=zmake testall
Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: I42cc098a9badac57a3781fa9dfaf32c0ec0c5aca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2780838
Diffstat (limited to 'zephyr/shim')
-rw-r--r-- | zephyr/shim/include/board.h | 2 | ||||
-rw-r--r-- | zephyr/shim/include/i2c/i2c.h | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/zephyr/shim/include/board.h b/zephyr/shim/include/board.h index 2d62c078ab..3c12788663 100644 --- a/zephyr/shim/include/board.h +++ b/zephyr/shim/include/board.h @@ -18,7 +18,7 @@ /* Include board specific i2c mapping if I2C is enabled. */ #if defined(CONFIG_I2C) && !defined(CONFIG_ZTEST) -#include "i2c_map.h" +#include "i2c/i2c.h" #endif #ifdef CONFIG_PWM diff --git a/zephyr/shim/include/i2c/i2c.h b/zephyr/shim/include/i2c/i2c.h index 8c8e98ace8..4130ba2037 100644 --- a/zephyr/shim/include/i2c/i2c.h +++ b/zephyr/shim/include/i2c/i2c.h @@ -11,11 +11,18 @@ #ifdef CONFIG_PLATFORM_EC_I2C #if DT_NODE_EXISTS(DT_PATH(named_i2c_ports)) -#define I2C_PORT(id) DT_CAT(I2C_, id) + +/* EEPROM flags */ +#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_i2c_port_eeprom) +#define I2C_ADDR_EEPROM_FLAGS \ + DT_PROP(DT_INST(0, cros_ec_i2c_port_eeprom), addr_flags) +#endif +#define I2C_PORT(id) DT_ENUM_UPPER_TOKEN(id, enum_name) #define I2C_PORT_WITH_COMMA(id) I2C_PORT(id), + enum i2c_ports { -DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), I2C_PORT_WITH_COMMA) -I2C_PORT_COUNT + DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), I2C_PORT_WITH_COMMA) + I2C_PORT_COUNT }; #define NAMED_I2C(name) I2C_PORT(DT_PATH(named_i2c_ports, name)) #endif /* named_i2c_ports */ |