summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2019-04-02 17:35:02 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-17 21:32:25 -0700
commitf562e995c896e32816f013b848b8ffe61c8f09cd (patch)
treef19048398dc014684479eb162f3db3e56cbd9f24
parent8841b815c195aadacb8f0f6e625041c3427bbd97 (diff)
downloadchrome-ec-f562e995c896e32816f013b848b8ffe61c8f09cd.tar.gz
tcpm: Refactor tcpc_config to include a flags field
tcpc_config contained a field for both the alert polarity and open drain/push pull configuration. There is also a possible difference in TCPC reset polarity. Instead of adding yet another field to describe this configuration, it would be better to convert alert polairty, open drain and reset polarity into a single flags field. This CL modifies the tcpc_config struct to use a single flags field and adds defines for what existing flag options can be. BUG=b:130194031 BRANCH=none TEST=make -j buildall Change-Id: Ifb7e7604edb7021fb2d36ee279049eb52fefc99e Signed-off-by: Scott Collyer <scollyer@google.com> Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1551581 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
-rw-r--r--baseboard/dragonegg/baseboard.c9
-rw-r--r--baseboard/grunt/baseboard.c7
-rw-r--r--baseboard/hatch/baseboard.c6
-rw-r--r--baseboard/kalista/baseboard.c4
-rw-r--r--baseboard/octopus/variant_usbc_ec_tcpcs.c6
-rw-r--r--baseboard/octopus/variant_usbc_standalone_tcpcs.c9
-rw-r--r--board/atlas/board.c6
-rw-r--r--board/cheza/board.c7
-rw-r--r--board/coral/board.c6
-rw-r--r--board/eve/board.c6
-rw-r--r--board/fizz/board.c4
-rw-r--r--board/glkrvp/chg_usb_pd.c6
-rw-r--r--board/glkrvp_ite/chg_usb_pd.c6
-rw-r--r--board/nami/board.c6
-rw-r--r--board/nautilus/board.c6
-rw-r--r--board/nocturne/board.c6
-rw-r--r--board/poppy/board.c6
-rw-r--r--board/rammus/board.c6
-rw-r--r--board/reef/board.c6
-rw-r--r--board/reef_mchp/board.c6
-rw-r--r--driver/tcpm/anx74xx.c9
-rw-r--r--include/usb_pd_tcpm.h23
22 files changed, 96 insertions, 60 deletions
diff --git a/baseboard/dragonegg/baseboard.c b/baseboard/dragonegg/baseboard.c
index 54cc16a98d..dbf3a8fedd 100644
--- a/baseboard/dragonegg/baseboard.c
+++ b/baseboard/dragonegg/baseboard.c
@@ -166,20 +166,23 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_ITE_0] = {
/* TCPC is embedded within EC so no i2c config needed */
.drv = &it83xx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
[USB_PD_PORT_ITE_1] = {
/* TCPC is embedded within EC so no i2c config needed */
.drv = &it83xx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
[USB_PD_PORT_TUSB422_2] = {
.i2c_host_port = I2C_PORT_USBC1C2,
.i2c_slave_addr = TUSB422_I2C_ADDR,
.drv = &tusb422_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c
index 70350cffec..e743c195a4 100644
--- a/baseboard/grunt/baseboard.c
+++ b/baseboard/grunt/baseboard.c
@@ -89,14 +89,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.i2c_host_port = I2C_PORT_TCPC0,
.i2c_slave_addr = ANX74XX_I2C_ADDR1,
.drv = &anx74xx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
- .od = TCPC_ALERT_OPEN_DRAIN,
+ /* Alert is active-low, open-drain */
+ .flags = TCPC_FLAGS_ALERT_OD,
},
[USB_PD_PORT_PS8751] = {
.i2c_host_port = I2C_PORT_TCPC1,
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/baseboard/hatch/baseboard.c b/baseboard/hatch/baseboard.c
index ad89d52284..ba90e10fa2 100644
--- a/baseboard/hatch/baseboard.c
+++ b/baseboard/hatch/baseboard.c
@@ -151,13 +151,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.i2c_host_port = I2C_PORT_TCPC0,
.i2c_slave_addr = AN7447_TCPC0_I2C_ADDR,
.drv = &anx7447_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
[USB_PD_PORT_TCPC_1] = {
.i2c_host_port = I2C_PORT_TCPC1,
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/baseboard/kalista/baseboard.c b/baseboard/kalista/baseboard.c
index 53e75508a9..08fa73dd92 100644
--- a/baseboard/kalista/baseboard.c
+++ b/baseboard/kalista/baseboard.c
@@ -150,8 +150,8 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* TCPC mux configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
- {I2C_PORT_TCPC0, I2C_ADDR_TCPC0, &ps8xxx_tcpm_drv,
- TCPC_ALERT_ACTIVE_LOW},
+ /* Alert is active-low, push-pull */
+ {I2C_PORT_TCPC0, I2C_ADDR_TCPC0, &ps8xxx_tcpm_drv, 0},
};
static int ps8751_tune_mux(int port)
diff --git a/baseboard/octopus/variant_usbc_ec_tcpcs.c b/baseboard/octopus/variant_usbc_ec_tcpcs.c
index 570a919b6c..2bdb7d2c1d 100644
--- a/baseboard/octopus/variant_usbc_ec_tcpcs.c
+++ b/baseboard/octopus/variant_usbc_ec_tcpcs.c
@@ -31,12 +31,14 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
[USB_PD_PORT_ITE_0] = {
/* TCPC is embedded within EC so no i2c config needed */
.drv = &it83xx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
[USB_PD_PORT_ITE_1] = {
/* TCPC is embedded within EC so no i2c config needed */
.drv = &it83xx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/baseboard/octopus/variant_usbc_standalone_tcpcs.c b/baseboard/octopus/variant_usbc_standalone_tcpcs.c
index fbae3e70d0..4d4ac83b6d 100644
--- a/baseboard/octopus/variant_usbc_standalone_tcpcs.c
+++ b/baseboard/octopus/variant_usbc_standalone_tcpcs.c
@@ -35,18 +35,21 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
#if defined(VARIANT_OCTOPUS_TCPC_0_PS8751)
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW
+ /* Alert is active-low, push-pull */
+ .flags = 0,
#else
.i2c_slave_addr = AN7447_TCPC0_I2C_ADDR,
.drv = &anx7447_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
#endif
},
[USB_PD_PORT_TCPC_1] = {
.i2c_host_port = I2C_PORT_TCPC1,
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/board/atlas/board.c b/board/atlas/board.c
index e0fc4d07e7..fd38f1cee2 100644
--- a/board/atlas/board.c
+++ b/board/atlas/board.c
@@ -174,14 +174,16 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.i2c_host_port = I2C_PORT_TCPC0,
.i2c_slave_addr = I2C_ADDR_TCPC,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
{
/* right port */
.i2c_host_port = I2C_PORT_TCPC1,
.i2c_slave_addr = I2C_ADDR_TCPC,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/board/cheza/board.c b/board/cheza/board.c
index 460708e566..5d9413b4a2 100644
--- a/board/cheza/board.c
+++ b/board/cheza/board.c
@@ -256,10 +256,11 @@ unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
/* TCPC mux configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
+ /* Alert is active-low, open-drain */
[USB_PD_PORT_ANX3429] = {I2C_PORT_TCPC0, 0x50, &anx74xx_tcpm_drv,
- TCPC_ALERT_ACTIVE_LOW, TCPC_ALERT_OPEN_DRAIN},
- [USB_PD_PORT_PS8751] = {I2C_PORT_TCPC1, 0x16, &ps8xxx_tcpm_drv,
- TCPC_ALERT_ACTIVE_LOW},
+ TCPC_FLAGS_ALERT_OD},
+ /* Alert is active-low, push-pull */
+ [USB_PD_PORT_PS8751] = {I2C_PORT_TCPC1, 0x16, &ps8xxx_tcpm_drv, 0},
};
/*
diff --git a/board/coral/board.c b/board/coral/board.c
index 5955474620..ccd63c5022 100644
--- a/board/coral/board.c
+++ b/board/coral/board.c
@@ -245,13 +245,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.i2c_host_port = NPCX_I2C_PORT0_0,
.i2c_slave_addr = ANX74XX_I2C_ADDR1,
.drv = &anx74xx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
[USB_PD_PORT_PS8751] = {
.i2c_host_port = NPCX_I2C_PORT0_1,
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/board/eve/board.c b/board/eve/board.c
index ea213d9b9f..bb8bef1b55 100644
--- a/board/eve/board.c
+++ b/board/eve/board.c
@@ -218,13 +218,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.i2c_host_port = I2C_PORT_TCPC0,
.i2c_slave_addr = ANX74XX_I2C_ADDR1,
.drv = &anx74xx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
{
.i2c_host_port = I2C_PORT_TCPC1,
.i2c_slave_addr = ANX74XX_I2C_ADDR1,
.drv = &anx74xx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/board/fizz/board.c b/board/fizz/board.c
index 8d0c0fd2a2..69759eb68e 100644
--- a/board/fizz/board.c
+++ b/board/fizz/board.c
@@ -191,8 +191,8 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
/* TCPC mux configuration */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
- {NPCX_I2C_PORT0_0, I2C_ADDR_TCPC0, &ps8xxx_tcpm_drv,
- TCPC_ALERT_ACTIVE_LOW},
+ /* Alert is active-low, push-pull */
+ {NPCX_I2C_PORT0_0, I2C_ADDR_TCPC0, &ps8xxx_tcpm_drv, 0},
};
static int ps8751_tune_mux(int port)
diff --git a/board/glkrvp/chg_usb_pd.c b/board/glkrvp/chg_usb_pd.c
index c10c1e14a4..020b628083 100644
--- a/board/glkrvp/chg_usb_pd.c
+++ b/board/glkrvp/chg_usb_pd.c
@@ -31,8 +31,10 @@ enum glkrvp_charge_ports {
};
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
- {NPCX_I2C_PORT7_0, 0xA0, &tcpci_tcpm_drv, TCPC_ALERT_ACTIVE_LOW},
- {NPCX_I2C_PORT7_0, 0xA4, &tcpci_tcpm_drv, TCPC_ALERT_ACTIVE_LOW},
+ /* Alert is active-low, push-pull */
+ {NPCX_I2C_PORT7_0, 0xA0, &tcpci_tcpm_drv, 0},
+ /* Alert is active-low, push-pull */
+ {NPCX_I2C_PORT7_0, 0xA4, &tcpci_tcpm_drv, 0},
};
BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_COUNT);
diff --git a/board/glkrvp_ite/chg_usb_pd.c b/board/glkrvp_ite/chg_usb_pd.c
index 1ddef2c60d..5fb88a919a 100644
--- a/board/glkrvp_ite/chg_usb_pd.c
+++ b/board/glkrvp_ite/chg_usb_pd.c
@@ -31,8 +31,10 @@ enum glkrvp_charge_ports {
};
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
- {IT83XX_I2C_CH_B, 0xA0, &tcpci_tcpm_drv, TCPC_ALERT_ACTIVE_LOW},
- {IT83XX_I2C_CH_B, 0xA4, &tcpci_tcpm_drv, TCPC_ALERT_ACTIVE_LOW},
+ /* Alert is active-low, push-pull */
+ {IT83XX_I2C_CH_B, 0xA0, &tcpci_tcpm_drv, 0},
+ /* Alert is active-low, push-pull */
+ {IT83XX_I2C_CH_B, 0xA4, &tcpci_tcpm_drv, 0},
};
BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_COUNT);
diff --git a/board/nami/board.c b/board/nami/board.c
index 87771912f1..1b680f955a 100644
--- a/board/nami/board.c
+++ b/board/nami/board.c
@@ -248,13 +248,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.i2c_host_port = NPCX_I2C_PORT0_0,
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
[USB_PD_PORT_ANX7447] = {
.i2c_host_port = NPCX_I2C_PORT0_1,
.i2c_slave_addr = AN7447_TCPC3_I2C_ADDR, /* Verified on v1.1 */
.drv = &anx7447_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/board/nautilus/board.c b/board/nautilus/board.c
index dd79aebf27..5bb202982e 100644
--- a/board/nautilus/board.c
+++ b/board/nautilus/board.c
@@ -171,13 +171,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.i2c_host_port = NPCX_I2C_PORT0_0,
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
{
.i2c_host_port = NPCX_I2C_PORT0_1,
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/board/nocturne/board.c b/board/nocturne/board.c
index c3ac854a26..f8e188b36c 100644
--- a/board/nocturne/board.c
+++ b/board/nocturne/board.c
@@ -316,14 +316,16 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.i2c_host_port = I2C_PORT_USB_C0,
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &tcpci_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
{
.i2c_host_port = I2C_PORT_USB_C1,
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &tcpci_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/board/poppy/board.c b/board/poppy/board.c
index 36ba4561eb..c65d65260c 100644
--- a/board/poppy/board.c
+++ b/board/poppy/board.c
@@ -213,13 +213,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.i2c_host_port = NPCX_I2C_PORT0_0,
.i2c_slave_addr = ANX74XX_I2C_ADDR1,
.drv = &anx74xx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
{
.i2c_host_port = NPCX_I2C_PORT0_0,
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/board/rammus/board.c b/board/rammus/board.c
index 31b0a3fb10..4f703ed00d 100644
--- a/board/rammus/board.c
+++ b/board/rammus/board.c
@@ -166,13 +166,15 @@ struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.i2c_host_port = I2C_PORT_TCPC1,
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
[USB_PD_PORT_ANX7447] = {
.i2c_host_port = I2C_PORT_TCPC0,
.i2c_slave_addr = AN7447_TCPC3_I2C_ADDR, /* Verified on v1.1 */
.drv = &anx7447_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/board/reef/board.c b/board/reef/board.c
index 2579b103fc..15e1627651 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -250,13 +250,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.i2c_host_port = NPCX_I2C_PORT0_0,
.i2c_slave_addr = ANX74XX_I2C_ADDR1,
.drv = &anx74xx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
[USB_PD_PORT_PS8751] = {
.i2c_host_port = NPCX_I2C_PORT0_1,
.i2c_slave_addr = PS8751_I2C_ADDR1,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/board/reef_mchp/board.c b/board/reef_mchp/board.c
index 7547b82167..11266a9ca0 100644
--- a/board/reef_mchp/board.c
+++ b/board/reef_mchp/board.c
@@ -364,13 +364,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.i2c_host_port = MCHP_I2C_PORT0,
.i2c_slave_addr = 0x50,
.drv = &anx74xx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
[USB_PD_PORT_PS8751] = {
.i2c_host_port = MCHP_I2C_PORT2,
.i2c_slave_addr = 0x16,
.drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
+ /* Alert is active-low, push-pull */
+ .flags = 0,
},
};
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c
index 248887be28..274e668960 100644
--- a/driver/tcpm/anx74xx.c
+++ b/driver/tcpm/anx74xx.c
@@ -1045,17 +1045,16 @@ static int anx74xx_tcpm_init(int port)
/* Initialize interrupt open-drain */
rv |= tcpc_read(port, ANX74XX_REG_INTP_VCONN_CTRL, &reg);
- if (tcpc_config[port].od == TCPC_ALERT_OPEN_DRAIN)
+ if (tcpc_config[port].flags & TCPC_FLAGS_ALERT_OD)
reg |= ANX74XX_REG_R_INTERRUPT_OPEN_DRAIN;
else
reg &= ~ANX74XX_REG_R_INTERRUPT_OPEN_DRAIN;
rv |= tcpc_write(port, ANX74XX_REG_INTP_VCONN_CTRL, reg);
/* Initialize interrupt polarity */
- rv |= tcpc_write(port, ANX74XX_REG_IRQ_STATUS,
- tcpc_config[port].pol == TCPC_ALERT_ACTIVE_LOW ?
- ANX74XX_REG_IRQ_POL_LOW :
- ANX74XX_REG_IRQ_POL_HIGH);
+ reg = tcpc_config[port].flags & TCPC_FLAGS_ALERT_ACTIVE_HIGH ?
+ ANX74XX_REG_IRQ_POL_HIGH : ANX74XX_REG_IRQ_POL_LOW;
+ rv |= tcpc_write(port, ANX74XX_REG_IRQ_STATUS, reg);
/* unmask interrupts */
rv |= tcpc_read(port, ANX74XX_REG_IRQ_EXT_MASK_1, &reg);
diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h
index bdd497b563..874b231dce 100644
--- a/include/usb_pd_tcpm.h
+++ b/include/usb_pd_tcpm.h
@@ -265,22 +265,23 @@ struct tcpm_drv {
#endif
};
-enum tcpc_alert_polarity {
- TCPC_ALERT_ACTIVE_LOW,
- TCPC_ALERT_ACTIVE_HIGH,
-};
-
-enum tcpc_alert_open_drain {
- TCPC_ALERT_PUSH_PULL = 0,
- TCPC_ALERT_OPEN_DRAIN,
-};
+/*
+ * Macros for tcpc_config_t flags field.
+ *
+ * Bit 0 --> Polarity for TCPC alert. Set to 1 if alert is active high.
+ * Bit 1 --> Set to 1 if TCPC alert line is open-drain instead of push-pull.
+ * Bit 2 --> Polarity for TCPC reset. Set to 1 if reset line is active high.
+ */
+#define TCPC_FLAGS_ALERT_ACTIVE_HIGH BIT(0)
+#define TCPC_FLAGS_ALERT_OD BIT(1)
+#define TCPC_FLAGS_RESET_ACTIVE_HIGH BIT(2)
struct tcpc_config_t {
int i2c_host_port;
int i2c_slave_addr;
const struct tcpm_drv *drv;
- enum tcpc_alert_polarity pol;
- enum tcpc_alert_open_drain od;
+ /* See TCPC_FLAGS_* above */
+ uint32_t flags;
};
/**