diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-10-20 15:37:11 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-10-22 17:40:31 -0700 |
commit | 7e81bebb48274055ace613796b9d1ede45c8c9d7 (patch) | |
tree | 2a02ef3b96049225f30369e82b2f2b9f007eda20 /common/usb_pd_tcpc.c | |
parent | 0f4e6d217d930c6f3b849f232b1260aed099f260 (diff) | |
download | chrome-ec-7e81bebb48274055ace613796b9d1ede45c8c9d7.tar.gz |
tcpc: re-initialize tcpc if it reboots while tcpm is running
On TCPC startup, set an alert to notify TCPM that we have been
reset. When TCPM gets this notification, it should re-send
initial TCPC parameters. If we were in a stable contract as
a sink, make sure we don't reset connection. If not, then
reset PD protocol state machine to the default state.
This fixes a bug where if the TCPC reboots while the TCPM is
still running, then the TCPC would not get re-initialized and
therefore no PD communication would not work. This also fixes
it such that if we are in a stable contract as a sink and the
TCPC reboots, then we don't lose power.
BUG=chrome-os-partner:46676
BRANCH=none
TEST=tested on glados. reboot PD MCU with and without a charger
plugged in and verify that PD communication works after the
reboot. verify that with a charger, we don't lose power.
also tested with a hoho plugged in during reboot.
Change-Id: I84fec4577b0daf5891bd8461d3f3d925014a5ecf
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307187
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'common/usb_pd_tcpc.c')
-rw-r--r-- | common/usb_pd_tcpc.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c index cad272f9a3..99867e338a 100644 --- a/common/usb_pd_tcpc.c +++ b/common/usb_pd_tcpc.c @@ -1069,6 +1069,13 @@ void tcpc_init(int port) tcpc_set_power_status(port, !gpio_get_level(GPIO_USB_C0_VBUS_WAKE_L)); #endif /* CONFIG_USB_PD_PORT_COUNT >= 2 */ #endif /* CONFIG_USB_PD_TCPM_VBUS */ + + /* set default alert and power mask register values */ + pd[port].alert_mask = TCPC_REG_ALERT_MASK_ALL; + pd[port].power_status_mask = TCPC_REG_POWER_STATUS_MASK_ALL; + + /* set power status alert since the UNINIT bit has been set */ + alert(port, TCPC_REG_ALERT_POWER_STATUS); } #ifdef CONFIG_USB_PD_TCPM_VBUS @@ -1201,6 +1208,9 @@ static int tcpc_i2c_read(int port, int reg, uint8_t *payload) case TCPC_REG_POWER_STATUS: payload[0] = pd[port].power_status; return 1; + case TCPC_REG_POWER_STATUS_MASK: + payload[0] = pd[port].power_status_mask; + return 1; case TCPC_REG_TX_BYTE_CNT: payload[0] = PD_HEADER_CNT(pd[port].tx_head); return 1; @@ -1299,12 +1309,14 @@ static int command_tcpc(int argc, char **argv) ccprintf("set TX frequency to %d Hz\n", freq); return EC_SUCCESS; } else if (!strncasecmp(argv[2], "state", 5)) { - ccprintf("Port C%d, %s - CC:%d, CC0:%d, CC1:%d, " - "Alert: 0x%02x\n", port, + ccprintf("Port C%d, %s - CC:%d, CC0:%d, CC1:%d\n" + "Alert: 0x%02x Mask: 0x%04x\n" + "Power Status: 0x%02x Mask: 0x%02x\n", port, pd[port].rx_enabled ? "Ena" : "Dis", pd[port].cc_pull, pd[port].cc_status[0], pd[port].cc_status[1], - pd[port].alert); + pd[port].alert, pd[port].alert_mask, + pd[port].power_status, pd[port].power_status_mask); } return EC_SUCCESS; |