From 1737e04d766b5d6be543960271b5e781cb9c9235 Mon Sep 17 00:00:00 2001 From: Vijay Hiremath Date: Wed, 22 Sep 2021 12:25:47 -0700 Subject: ioex: Skip initializing IOEXes if already initialized Some of the IOEXes are needed early than the task is initialized, those IOEXes will be initialized at the board level. This CL skips re-initializing the IOEXes from HOOK function if already initialized. BUG=none BRANCH=none TEST=Tested on ADL RVP, re-initialization of IOEX is skipped Change-Id: I3062c46992a5578bf8f0f0bc2613b6815c28a616 Signed-off-by: Vijay Hiremath Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3183330 Reviewed-by: Keith Short Reviewed-by: Deepti Deshatty Commit-Queue: Keith Short --- common/ioexpander.c | 10 ++++++++-- include/ioexpander.h | 2 ++ 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. */ -- cgit v1.2.1