summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hendricks <dhendrix@chromium.org>2016-07-15 19:38:20 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-21 00:48:05 -0700
commit4fe82acac2f4c9e458321611a424fb7fbc74e363 (patch)
treef224eaa7059d4fa22a96fafaf048630db8536fd6
parentf2fa9c94772f245bf7b91779a4765103d07df156 (diff)
downloadchrome-ec-4fe82acac2f4c9e458321611a424fb7fbc74e363.tar.gz
tcpm: anx74xx: Add alert polarity member to tcpc_config_t
This allows us to specify the polarity of the alert signal for each TCPC chip onboard, even if we have multiple instances of the same chip. BUG=none BRANCH=none TEST=built and booted on reef Change-Id: I06a58c4e26892843243e8e98f2c86c6d3a696eb1 Signed-off-by: David Hendricks <dhendrix@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/360948 Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--board/amenia/board.c6
-rw-r--r--board/amenia/board.h1
-rw-r--r--board/reef/board.c4
-rw-r--r--driver/tcpm/anx74xx.c4
-rw-r--r--driver/tcpm/anx74xx.h1
-rw-r--r--include/usb_pd_tcpm.h6
6 files changed, 15 insertions, 7 deletions
diff --git a/board/amenia/board.c b/board/amenia/board.c
index 56d02895b5..a019ba0a5e 100644
--- a/board/amenia/board.c
+++ b/board/amenia/board.c
@@ -139,8 +139,10 @@ const struct i2c_port_t i2c_ports[] = {
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
- {I2C_PORT_TCPC0, TCPC0_I2C_ADDR, &anx74xx_tcpm_drv},
- {I2C_PORT_TCPC1, TCPC1_I2C_ADDR, &tcpci_tcpm_drv},
+ {I2C_PORT_TCPC0, TCPC0_I2C_ADDR, &anx74xx_tcpm_drv,
+ TCPC_ALERT_ACTIVE_HIGH},
+ {I2C_PORT_TCPC1, TCPC1_I2C_ADDR, &tcpci_tcpm_drv,
+ TCPC_ALERT_ACTIVE_LOW},
};
const enum gpio_signal hibernate_wake_pins[] = {
diff --git a/board/amenia/board.h b/board/amenia/board.h
index 5833543fb1..c1d0e16c43 100644
--- a/board/amenia/board.h
+++ b/board/amenia/board.h
@@ -88,7 +88,6 @@
#define CONFIG_USB_PD_PORT_COUNT 2
#define CONFIG_USB_PD_TCPM_ANX74XX
#define TCPC0_I2C_ADDR 0x50
-#define ANX74XX_INT_ACTIVE_POLARITY ANX74XX_REG_IRQ_POL_HIGH
#define CONFIG_USB_PD_TCPM_PS8751
#define CONFIG_USB_PD_TCPM_TCPCI
#define TCPC1_I2C_ADDR 0x16
diff --git a/board/reef/board.c b/board/reef/board.c
index 87bcc263fa..032fc79cce 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -126,8 +126,8 @@ const struct i2c_port_t i2c_ports[] = {
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
- {NPCX_I2C_PORT0_0, 0x50, &anx74xx_tcpm_drv},
- {NPCX_I2C_PORT0_1, 0x16, &tcpci_tcpm_drv},
+ {NPCX_I2C_PORT0_0, 0x50, &anx74xx_tcpm_drv, TCPC_ALERT_ACTIVE_HIGH},
+ {NPCX_I2C_PORT0_1, 0x16, &tcpci_tcpm_drv, TCPC_ALERT_ACTIVE_LOW},
};
uint16_t tcpc_get_alert_status(void)
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c
index ed38fccb23..bd5032376c 100644
--- a/driver/tcpm/anx74xx.c
+++ b/driver/tcpm/anx74xx.c
@@ -762,7 +762,9 @@ int anx74xx_tcpm_init(int port)
/* Initialize interrupt polarity */
rv |= tcpc_write(port, ANX74XX_REG_IRQ_STATUS,
- ANX74XX_INT_ACTIVE_POLARITY);
+ tcpc_config[port].pol == TCPC_ALERT_ACTIVE_LOW ?
+ ANX74XX_REG_IRQ_POL_LOW :
+ ANX74XX_REG_IRQ_POL_HIGH);
/* unmask interrupts */
rv |= tcpc_read(port, ANX74XX_REG_IRQ_EXT_MASK_1, &reg);
diff --git a/driver/tcpm/anx74xx.h b/driver/tcpm/anx74xx.h
index 972be9648a..e395083d33 100644
--- a/driver/tcpm/anx74xx.h
+++ b/driver/tcpm/anx74xx.h
@@ -12,7 +12,6 @@
#define ANX74XX_REG_IRQ_POL_LOW 0x00
#define ANX74XX_REG_IRQ_POL_HIGH 0x02
-#define ANX74XX_INT_ACTIVE_POLARITY ANX74XX_REG_IRQ_POL_HIGH
#define ANX74XX_REG_IRQ_STATUS 0x53
diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h
index 90dae03fd2..ab7123676b 100644
--- a/include/usb_pd_tcpm.h
+++ b/include/usb_pd_tcpm.h
@@ -161,10 +161,16 @@ struct tcpm_drv {
void (*tcpc_alert)(int port);
};
+enum tcpc_alert_polarity {
+ TCPC_ALERT_ACTIVE_LOW,
+ TCPC_ALERT_ACTIVE_HIGH,
+};
+
struct tcpc_config_t {
int i2c_host_port;
int i2c_slave_addr;
const struct tcpm_drv *drv;
+ enum tcpc_alert_polarity pol;
};
/**