diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-07-24 10:35:34 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-07-24 21:54:18 +0000 |
commit | e85a3fa0d4f8e43d2bbab90aa972bde6f6c64e5c (patch) | |
tree | e4777e271974fe821e061f288ef5cce0a636bae0 /common/usb_pd_tcpc.c | |
parent | b339fdf6c11dcc5bb89615ab426a97469362b0a5 (diff) | |
download | chrome-ec-e85a3fa0d4f8e43d2bbab90aa972bde6f6c64e5c.tar.gz |
tcpc: move tcpc initialized bit into error status register
Move TCPC initialized bit from alert register into error status
register. This is not part of the TCPCI spec, but the existing
code creates a bug that if TCPM reboots without TCPC also rebooting,
then we will never get the initialized alert from TCPC since
it has already happened, so the TCPM will loop indefinitely
waiting for TCPC to be ready. This fixes the bug by moving the
bit to a status register, which is more appropriate.
BUG=none
BRANCH=none
TEST=load on glados, reboot and make sure TCPM see's that the
TCPC is initialized.
Change-Id: I8e96b59031e01a4faec8f519727df1fa95f498bc
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/288342
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/usb_pd_tcpc.c')
-rw-r--r-- | common/usb_pd_tcpc.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c index 272b44e652..eb0b47b3c5 100644 --- a/common/usb_pd_tcpc.c +++ b/common/usb_pd_tcpc.c @@ -195,6 +195,8 @@ enum pd_tx_errors { PD_TX_ERR_COLLISION = -5 /* Collision detected during transmit */ }; +#define TCPC_FLAGS_INITIALIZED (1 << 0) /* TCPC is initialized */ + static struct pd_port_controller { /* current port power role (SOURCE or SINK) */ uint8_t power_role; @@ -211,6 +213,8 @@ static struct pd_port_controller { uint16_t alert_mask; /* RX enabled */ uint8_t rx_enabled; + /* TCPC flags */ + uint8_t flags; /* Last received */ int rx_head; @@ -811,7 +815,7 @@ void pd_task(void) tcpc_init(port); /* we are now initialized */ - alert(port, TCPC_REG_ALERT_TCPC_INITED); + pd[port].flags |= TCPC_FLAGS_INITIALIZED; while (1) { /* wait for next event/packet or timeout expiration */ @@ -1005,6 +1009,10 @@ static int tcpc_i2c_read(int port, int reg, uint8_t *payload) case TCPC_REG_VENDOR_ID: *(uint16_t *)payload = USB_VID_GOOGLE; return 2; + case TCPC_REG_ERROR_STATUS: + payload[0] = (pd[port].flags & TCPC_FLAGS_INITIALIZED) ? + 0 : TCPC_REG_ERROR_STATUS_UNINIT; + return 1; case TCPC_REG_CC_STATUS: tcpc_get_cc(port, &cc1, &cc2); payload[0] = TCPC_REG_CC_STATUS_SET( |