diff options
author | Wai-Hong Tam <waihong@google.com> | 2020-02-20 14:30:39 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-26 01:52:03 +0000 |
commit | 77bfd7f85e13898b0b159b7e6fb34fadc163ae5b (patch) | |
tree | c3434f01b71fbd37d5caaa36eac476cad9570f2e /driver | |
parent | ff6cbc138b6ed692fcbae21bd9bf12837c2aeb79 (diff) | |
download | chrome-ec-77bfd7f85e13898b0b159b7e6fb34fadc163ae5b.tar.gz |
PS8xxx: Workaround of Connection Detection not restarted
When issuing the COMMAND.Look4Connection to enable PS8805/PS8815 to
restart Connection Detection, PS8805/PS8815 doesn't do so if the
partner already presents Rp. This is a workaround that changes the
starting pull to the opposite when doing DRP auto-toggle.
BRANCH=None
BUG=b:149570002
TEST=Enabled TCPMv2 and verified a 20V charger detected properly.
TEST=Enabled TCPMv2 and verified a Type-C dongle detected properly.
Change-Id: Ic2f65bdd74d1825ae81fcd30fec5e72d29a51663
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2067481
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/tcpm/ps8xxx.c | 42 | ||||
-rw-r--r-- | driver/tcpm/tcpci.c | 4 | ||||
-rw-r--r-- | driver/tcpm/tcpci.h | 1 |
3 files changed, 44 insertions, 3 deletions
diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c index 177a3ee6f4..77de4fca15 100644 --- a/driver/tcpm/ps8xxx.c +++ b/driver/tcpm/ps8xxx.c @@ -133,6 +133,46 @@ static int ps8xxx_tcpm_release(int port) return tcpci_tcpm_release(port); } +#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE +static int ps8xxx_tcpc_drp_toggle(int port) +{ + int rv; + int status; + int opposite_pull; + + /* + * Workaround for PS8805/PS8815, which can't restart Connection + * Detection if the partner already presents pull. Now starts with + * the opposite pull. Check b/149570002. + */ + if (IS_ENABLED(CONFIG_USB_PD_TCPM_PS8805) || + IS_ENABLED(CONFIG_USB_PD_TCPM_PS8815)) { + /* Check CC_STATUS for the current pull */ + rv = tcpc_read(port, TCPC_REG_CC_STATUS, &status); + if (status & TCPC_REG_CC_STATUS_CONNECT_RESULT_MASK) { + /* Current pull: Rd */ + opposite_pull = TYPEC_CC_RP; + } else { + /* Current pull: Rp */ + opposite_pull = TYPEC_CC_RD; + } + + /* Set auto drp toggle, starting with the opposite pull */ + rv |= tcpci_set_role_ctrl(port, 1, TYPEC_RP_USB, opposite_pull); + + /* Set Look4Connection command */ + rv |= tcpc_write(port, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_LOOK4CONNECTION); + + return rv; + } else { + return tcpci_tcpc_drp_toggle(port); + } +} +#endif + + + static int ps8xxx_get_chip_info(int port, int live, struct ec_response_pd_chip_info_v1 **chip_info) { @@ -316,7 +356,7 @@ const struct tcpm_drv ps8xxx_tcpm_drv = { .tcpc_discharge_vbus = &tcpci_tcpc_discharge_vbus, #endif #ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE - .drp_toggle = &tcpci_tcpc_drp_toggle, + .drp_toggle = &ps8xxx_tcpc_drp_toggle, #endif #ifdef CONFIG_USBC_PPC .set_snk_ctrl = &tcpci_tcpm_set_snk_ctrl, diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index 0935f338c2..97768e6f1a 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -369,7 +369,7 @@ int tcpci_tcpm_set_cc(int port, int pull) } #ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE -static int set_role_ctrl(int port, int toggle, int rp, int pull) +int tcpci_set_role_ctrl(int port, int toggle, int rp, int pull) { return tcpc_write(port, TCPC_REG_ROLE_CTRL, TCPC_REG_ROLE_CTRL_SET(toggle, rp, pull, pull)); @@ -380,7 +380,7 @@ int tcpci_tcpc_drp_toggle(int port) int rv; /* Set auto drp toggle */ - rv = set_role_ctrl(port, 1, TYPEC_RP_USB, TYPEC_CC_RD); + rv = tcpci_set_role_ctrl(port, 1, TYPEC_RP_USB, TYPEC_CC_RD); /* Set Look4Connection command */ rv |= tcpc_write(port, TCPC_REG_COMMAND, diff --git a/driver/tcpm/tcpci.h b/driver/tcpm/tcpci.h index b96276d243..40b25f4fba 100644 --- a/driver/tcpm/tcpci.h +++ b/driver/tcpm/tcpci.h @@ -220,6 +220,7 @@ int tcpci_tcpm_transmit(int port, enum tcpm_transmit_type type, uint16_t header, const uint32_t *data); int tcpci_tcpm_release(int port); #ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE +int tcpci_set_role_ctrl(int port, int toggle, int rp, int pull); int tcpci_tcpc_drp_toggle(int port); #endif #ifdef CONFIG_USB_PD_TCPC_LOW_POWER |