diff options
author | Rong Chang <rongchang@chromium.org> | 2015-09-07 15:46:05 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-09-14 00:48:39 -0700 |
commit | 2eabf6fe8cffdd2c1e125344aa1692fab6795759 (patch) | |
tree | 96d0657ed25bb4344f9a08e1035405de5699ba54 /driver | |
parent | ea6c69c8392a3756c4f74ea23ab15db3ad263bbe (diff) | |
download | chrome-ec-2eabf6fe8cffdd2c1e125344aa1692fab6795759.tar.gz |
oak_pd: tcpm_power_status: Update power status on init
Oak board relies on TCPCI power status. When board init, PD should
update it's VBUS status and TCPM needs to get power status after enable
TCPC power status mask.
BRANCH=none
BUG=chrome-os-partner:44952
TEST=manual
build and load on oak, disconnect battery.
power on system with zinger, and check PD state.
Signed-off-by: Rong Chang <rongchang@chromium.org>
Change-Id: Ic0d4b50d38ac39ff31b3a257c4b3b5dde0ebda4b
Reviewed-on: https://chromium-review.googlesource.com/297871
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/tcpm/tcpci.c | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index 939ab9ccf2..926a1dda1b 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -55,31 +55,6 @@ static int init_power_status_mask(int port) } #endif -int tcpm_init(int port) -{ - int rv, err = 0; - - while (1) { - rv = i2c_read16(I2C_PORT_TCPC, I2C_ADDR_TCPC(port), - TCPC_REG_ERROR_STATUS, &err); - /* - * If i2c succeeds and the uninitialized bit is clear, then - * initalization is complete, clear all alert bits and write - * the initial alert mask. - */ - if (rv == EC_SUCCESS && !(err & TCPC_REG_ERROR_STATUS_UNINIT)) { - i2c_write16(I2C_PORT_TCPC, I2C_ADDR_TCPC(port), - TCPC_REG_ALERT, 0xff); -#ifdef CONFIG_USB_PD_TCPM_VBUS - /* Initialize power_status_mask */ - init_power_status_mask(port); -#endif - return init_alert_mask(port); - } - msleep(10); - } -} - int tcpm_get_cc(int port, int *cc1, int *cc2) { int status; @@ -294,3 +269,36 @@ void tcpc_alert(int port) TCPC_TX_COMPLETE_FAILED); } } + +int tcpm_init(int port) +{ + int rv, err = 0; +#ifdef CONFIG_USB_PD_TCPM_VBUS + int power_status; +#endif + + while (1) { + rv = i2c_read16(I2C_PORT_TCPC, I2C_ADDR_TCPC(port), + TCPC_REG_ERROR_STATUS, &err); + /* + * If i2c succeeds and the uninitialized bit is clear, then + * initalization is complete, clear all alert bits and write + * the initial alert mask. + */ + if (rv == EC_SUCCESS && !(err & TCPC_REG_ERROR_STATUS_UNINIT)) { + i2c_write16(I2C_PORT_TCPC, I2C_ADDR_TCPC(port), + TCPC_REG_ALERT, 0xff); +#ifdef CONFIG_USB_PD_TCPM_VBUS + /* Initialize power_status_mask */ + init_power_status_mask(port); + /* Read Power Status register */ + tcpm_get_power_status(port, &power_status); + /* Update VBUS status */ + tcpc_vbus[port] = power_status & + TCPC_REG_POWER_VBUS_PRES ? 1 : 0; +#endif + return init_alert_mask(port); + } + msleep(10); + } +} |