summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/ioexpander.c10
-rw-r--r--include/ioexpander.h2
2 files changed, 10 insertions, 2 deletions
diff --git a/common/ioexpander.c b/common/ioexpander.c
index ccf3cc7c4a..d3e713a243 100644
--- a/common/ioexpander.c
+++ b/common/ioexpander.c
@@ -195,6 +195,8 @@ int ioex_init(int ioex)
}
}
+ ioex_config[ioex].flags |= IOEX_FLAGS_INITIALIZED;
+
return EC_SUCCESS;
}
@@ -202,8 +204,13 @@ static void ioex_init_default(void)
{
int i;
- for (i = 0; i < CONFIG_IO_EXPANDER_PORT_COUNT; i++)
+ for (i = 0; i < CONFIG_IO_EXPANDER_PORT_COUNT; i++) {
+ /* IO Expander has been initialized, skip re-initializing */
+ if (ioex_config[i].flags & IOEX_FLAGS_INITIALIZED)
+ continue;
+
ioex_init(i);
+ }
}
DECLARE_HOOK(HOOK_INIT, ioex_init_default, HOOK_PRIO_INIT_I2C + 1);
@@ -335,4 +342,3 @@ static int command_ioex_get(int argc, char **argv)
DECLARE_SAFE_CONSOLE_COMMAND(ioexget, command_ioex_get,
"[name]",
"Read level of IO expander pin(s)");
-
diff --git a/include/ioexpander.h b/include/ioexpander.h
index 4cd1930385..be70346d81 100644
--- a/include/ioexpander.h
+++ b/include/ioexpander.h
@@ -56,6 +56,8 @@ struct ioexpander_drv {
/* IO expander chip disabled. No I2C communication will be attempted. */
#define IOEX_FLAGS_DISABLED BIT(0)
+/* IO Expander has been initialized */
+#define IOEX_FLAGS_INITIALIZED BIT(1)
struct ioexpander_config_t {
/* Physical I2C port connects to the IO expander chip. */