summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2021-09-13 11:10:05 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-14 05:23:28 +0000
commit8b8de17aa9f124072f891d71e7d1731454771ce1 (patch)
tree635208c870c2fb030b77fdacfdf70e8e23944c1c
parent222d31de4bcf82884562719709e0dc2a8aa31301 (diff)
downloadchrome-ec-8b8de17aa9f124072f891d71e7d1731454771ce1.tar.gz
zephyr: Cleanup I2C initialization
Move the I2C initialization to compile time, saving a modest amount of RAM space BUG=b:199328071 BRANCH=none TEST=zmake testall TEST=boot Zephyr on Herobrine. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I9d324eedca25666bcce1928b069918a357cf6081 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3158973 Commit-Queue: Yuval Peress <peress@google.com> Reviewed-by: Yuval Peress <peress@google.com>
-rw-r--r--zephyr/shim/src/i2c.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/zephyr/shim/src/i2c.c b/zephyr/shim/src/i2c.c
index 065d1c059b..e67ea78be9 100644
--- a/zephyr/shim/src/i2c.c
+++ b/zephyr/shim/src/i2c.c
@@ -20,10 +20,10 @@
* This macro should be called from within DT_FOREACH_CHILD.
*/
#define INIT_DEV_BINDING(id) \
- i2c_devices[I2C_PORT(id)] = DEVICE_DT_GET(DT_PHANDLE(id, i2c_port));
+ [I2C_PORT(id)] = DEVICE_DT_GET(DT_PHANDLE(id, i2c_port)),
#define INIT_REMOTE_PORTS(id) \
- i2c_remote_ports[I2C_PORT(id)] = DT_PROP_OR(id, remote_port, -1);
+ [I2C_PORT(id)] = DT_PROP_OR(id, remote_port, -1),
#define INIT_PHYSICAL_PORTS(id) \
i2c_physical_ports[I2C_PORT(id)] = DT_PROP_OR(id, physical_port, -1);
@@ -45,16 +45,18 @@ const struct i2c_port_t i2c_ports[] = {
DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), I2C_PORT_INIT)
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-static int i2c_remote_ports[I2C_PORT_COUNT];
+static const int i2c_remote_ports[I2C_PORT_COUNT] = {
+ DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), INIT_REMOTE_PORTS)
+};
static int i2c_physical_ports[I2C_PORT_COUNT];
-static const struct device *i2c_devices[I2C_PORT_COUNT];
+static const struct device *i2c_devices[I2C_PORT_COUNT] = {
+ DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), INIT_DEV_BINDING)
+};
static int init_device_bindings(const struct device *device)
{
ARG_UNUSED(device);
- DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), INIT_DEV_BINDING)
- DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), INIT_REMOTE_PORTS)
DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), INIT_PHYSICAL_PORTS)
return 0;
}