summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2021-10-01 13:45:27 -0700
committerCommit Bot <commit-bot@chromium.org>2021-10-12 20:28:24 +0000
commitaf15326d86c6060aa5aaabb6d6a4ec3ae9e259bb (patch)
tree783c078ec98185d8f5c68a596fc7e9b976200ca9
parent184021ee2aca6d13b30c1d5b75eea39789acef92 (diff)
downloadchrome-ec-af15326d86c6060aa5aaabb6d6a4ec3ae9e259bb.tar.gz
IOEX: Cleanup: Use IOEX_FLAGS_INITIALIZED flag to get the IOEX status
IOEX_FLAGS_DISABLED is replaced with IOEX_FLAGS_DEFAULT_INIT_DISABLED hence use IOEX_FLAGS_INITIALIZED flag to get the initialization status of the IOEXes. BUG=none BRANCH=none TEST=Tested on Brya. 'ioexget' command works and also default init function skips IOEX initialization. Change-Id: I98ff9643223c02388a2fa679b4631e3389fd466e Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3200063 Reviewed-by: Poornima Tom <poornima.tom@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r--board/anahera/usbc_config.c8
-rw-r--r--board/brask/usbc_config.c5
-rw-r--r--board/brya/usbc_config.c9
-rw-r--r--board/dalboz/board.c4
-rw-r--r--board/felwinter/usbc_config.c5
-rw-r--r--board/gimble/usbc_config.c6
-rw-r--r--board/redrix/usbc_config.c8
-rw-r--r--board/taeko/usbc_config.c3
-rw-r--r--common/ioexpander.c17
-rw-r--r--include/ioexpander.h4
10 files changed, 30 insertions, 39 deletions
diff --git a/board/anahera/usbc_config.c b/board/anahera/usbc_config.c
index 73a7b402cc..00b6589a46 100644
--- a/board/anahera/usbc_config.c
+++ b/board/anahera/usbc_config.c
@@ -134,13 +134,13 @@ struct ioexpander_config_t ioex_config[] = {
.i2c_host_port = I2C_PORT_USB_C0_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
[IOEX_C1_NCT38XX] = {
.i2c_host_port = I2C_PORT_USB_C1_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR1_4_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
};
BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT);
@@ -211,10 +211,8 @@ static void board_tcpc_init(void)
if (!system_jumped_late()) {
board_reset_pd_mcu();
- for (i = 0; i < CONFIG_IO_EXPANDER_PORT_COUNT; ++i) {
- ioex_config[i].flags &= ~IOEX_FLAGS_DISABLED;
+ for (i = 0; i < CONFIG_IO_EXPANDER_PORT_COUNT; ++i)
ioex_init(i);
- }
}
/* Enable PPC interrupts. */
diff --git a/board/brask/usbc_config.c b/board/brask/usbc_config.c
index bd61f7ec1c..563034fcb4 100644
--- a/board/brask/usbc_config.c
+++ b/board/brask/usbc_config.c
@@ -169,13 +169,13 @@ struct ioexpander_config_t ioex_config[] = {
.i2c_host_port = I2C_PORT_USB_C0_C2_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
[IOEX_C2_NCT38XX] = {
.i2c_host_port = I2C_PORT_USB_C0_C2_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR2_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
};
BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT);
@@ -260,7 +260,6 @@ void board_reset_pd_mcu(void)
static void enable_ioex(int ioex)
{
- ioex_config[ioex].flags &= ~IOEX_FLAGS_DISABLED;
ioex_init(ioex);
}
diff --git a/board/brya/usbc_config.c b/board/brya/usbc_config.c
index 1780e1e16d..faf1904967 100644
--- a/board/brya/usbc_config.c
+++ b/board/brya/usbc_config.c
@@ -179,25 +179,25 @@ struct ioexpander_config_t ioex_config[] = {
.i2c_host_port = I2C_PORT_USB_C0_C2_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
[IOEX_C2_NCT38XX] = {
.i2c_host_port = I2C_PORT_USB_C0_C2_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR2_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
[IOEX_ID_1_C0_NCT38XX] = {
.i2c_host_port = I2C_PORT_USB_C0_C2_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
[IOEX_ID_1_C2_NCT38XX] = {
.i2c_host_port = I2C_PORT_USB_C0_C2_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR2_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
};
BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT);
@@ -308,7 +308,6 @@ void board_reset_pd_mcu(void)
static void enable_ioex(int ioex)
{
- ioex_config[ioex].flags &= ~IOEX_FLAGS_DISABLED;
ioex_init(ioex);
}
diff --git a/board/dalboz/board.c b/board/dalboz/board.c
index e4ee1bfe82..8b1dc01b39 100644
--- a/board/dalboz/board.c
+++ b/board/dalboz/board.c
@@ -640,13 +640,13 @@ struct ioexpander_config_t ioex_config[] = {
.i2c_host_port = I2C_PORT_TCPC1,
.i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
[IOEX_HDMI_PCAL6408] = {
.i2c_host_port = I2C_PORT_TCPC1,
.i2c_addr_flags = PCAL6408_I2C_ADDR0,
.drv = &pcal6408_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
};
BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT);
diff --git a/board/felwinter/usbc_config.c b/board/felwinter/usbc_config.c
index a301826c6a..b6d00575d6 100644
--- a/board/felwinter/usbc_config.c
+++ b/board/felwinter/usbc_config.c
@@ -176,13 +176,13 @@ struct ioexpander_config_t ioex_config[] = {
.i2c_host_port = I2C_PORT_USB_C1_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
[IOEX_C2_NCT38XX] = {
.i2c_host_port = I2C_PORT_USB_C2_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
};
BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT);
@@ -266,7 +266,6 @@ void board_reset_pd_mcu(void)
static void enable_ioex(int ioex)
{
- ioex_config[ioex].flags &= ~IOEX_FLAGS_DISABLED;
ioex_init(ioex);
}
diff --git a/board/gimble/usbc_config.c b/board/gimble/usbc_config.c
index 9f9f702364..312f735003 100644
--- a/board/gimble/usbc_config.c
+++ b/board/gimble/usbc_config.c
@@ -132,7 +132,7 @@ struct ioexpander_config_t ioex_config[] = {
.i2c_host_port = I2C_PORT_USB_C0_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
};
BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT);
@@ -194,10 +194,8 @@ static void board_tcpc_init(void)
if (!system_jumped_late()) {
board_reset_pd_mcu();
- for (i = 0; i < CONFIG_IO_EXPANDER_PORT_COUNT; ++i) {
- ioex_config[i].flags &= ~IOEX_FLAGS_DISABLED;
+ for (i = 0; i < CONFIG_IO_EXPANDER_PORT_COUNT; ++i)
ioex_init(i);
- }
}
/* Enable PPC interrupts. */
diff --git a/board/redrix/usbc_config.c b/board/redrix/usbc_config.c
index 73a7b402cc..00b6589a46 100644
--- a/board/redrix/usbc_config.c
+++ b/board/redrix/usbc_config.c
@@ -134,13 +134,13 @@ struct ioexpander_config_t ioex_config[] = {
.i2c_host_port = I2C_PORT_USB_C0_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
[IOEX_C1_NCT38XX] = {
.i2c_host_port = I2C_PORT_USB_C1_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR1_4_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
};
BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT);
@@ -211,10 +211,8 @@ static void board_tcpc_init(void)
if (!system_jumped_late()) {
board_reset_pd_mcu();
- for (i = 0; i < CONFIG_IO_EXPANDER_PORT_COUNT; ++i) {
- ioex_config[i].flags &= ~IOEX_FLAGS_DISABLED;
+ for (i = 0; i < CONFIG_IO_EXPANDER_PORT_COUNT; ++i)
ioex_init(i);
- }
}
/* Enable PPC interrupts. */
diff --git a/board/taeko/usbc_config.c b/board/taeko/usbc_config.c
index 993b10c99f..6219b8cd56 100644
--- a/board/taeko/usbc_config.c
+++ b/board/taeko/usbc_config.c
@@ -135,7 +135,7 @@ struct ioexpander_config_t ioex_config[] = {
.i2c_host_port = I2C_PORT_USB_C0_TCPC,
.i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
.drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DISABLED,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
},
};
BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT);
@@ -187,7 +187,6 @@ static void board_tcpc_init(void)
* C0/C2 TCPC, so they must be set up after the TCPC has
* been taken out of reset.
*/
- ioex_config[0].flags &= ~IOEX_FLAGS_DISABLED;
ioex_init(0);
}
diff --git a/common/ioexpander.c b/common/ioexpander.c
index d3e713a243..d30ed7ad9b 100644
--- a/common/ioexpander.c
+++ b/common/ioexpander.c
@@ -47,7 +47,7 @@ static const struct ioex_info *ioex_get_signal_info(enum ioex_signal signal)
g = ioex_list + signal - IOEX_SIGNAL_START;
- if (ioex_config[g->ioex].flags & IOEX_FLAGS_DISABLED) {
+ if (!(ioex_config[g->ioex].flags & IOEX_FLAGS_INITIALIZED)) {
CPRINTS("ioex %s disabled", g->name);
return NULL;
}
@@ -169,9 +169,6 @@ int ioex_init(int ioex)
int rv;
int i;
- if (ioex_config[ioex].flags & IOEX_FLAGS_DISABLED)
- return EC_ERROR_BUSY;
-
if (drv->init != NULL) {
rv = drv->init(ioex);
if (rv != EC_SUCCESS)
@@ -195,7 +192,7 @@ int ioex_init(int ioex)
}
}
- ioex_config[ioex].flags |= IOEX_FLAGS_INITIALIZED;
+ ioex_config[ioex].flags = IOEX_FLAGS_INITIALIZED;
return EC_SUCCESS;
}
@@ -205,8 +202,12 @@ static void ioex_init_default(void)
int 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)
+ /*
+ * If the IO Expander has been initialized or if the default
+ * initialization is disabled, skip initializing.
+ */
+ if (ioex_config[i].flags & (IOEX_FLAGS_INITIALIZED |
+ IOEX_FLAGS_DEFAULT_INIT_DISABLED))
continue;
ioex_init(i);
@@ -227,7 +228,7 @@ static void print_ioex_info(enum ioex_signal signal)
int flags = 0;
const struct ioex_info *g = ioex_list + signal - IOEX_SIGNAL_START;
- if (ioex_config[g->ioex].flags & IOEX_FLAGS_DISABLED) {
+ if (!(ioex_config[g->ioex].flags & IOEX_FLAGS_INITIALIZED)) {
ccprintf(" DISABLED %s\n", ioex_get_name(signal));
return;
}
diff --git a/include/ioexpander.h b/include/ioexpander.h
index be70346d81..e9499d27bd 100644
--- a/include/ioexpander.h
+++ b/include/ioexpander.h
@@ -54,8 +54,8 @@ struct ioexpander_drv {
#endif
};
-/* IO expander chip disabled. No I2C communication will be attempted. */
-#define IOEX_FLAGS_DISABLED BIT(0)
+/* IO expander default init disabled. No I2C communication will be attempted. */
+#define IOEX_FLAGS_DEFAULT_INIT_DISABLED BIT(0)
/* IO Expander has been initialized */
#define IOEX_FLAGS_INITIALIZED BIT(1)