diff options
author | Diana Z <dzigterman@chromium.org> | 2019-02-25 10:46:14 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-03-08 21:21:10 -0800 |
commit | 4524f0cd70fb5a96d2618a2f4a2bb43ecc6f36e7 (patch) | |
tree | a3e42606e9ad3a2d4cbe226a78bdb647e750b1ae | |
parent | f294d87354b797698cd66b812b4f9656e81cce59 (diff) | |
download | chrome-ec-4524f0cd70fb5a96d2618a2f4a2bb43ecc6f36e7.tar.gz |
PD: Set Rp consistently on initial connection, increasing later
This change ensures that the charge_manager always selects
CONFIG_USB_PD_PULLUP on inactive ports. This should prevent us from
presenting Rp 3.0A on an initial source connection, which can trigger
CCD mode detection.
This change also sets the correct Rp to represent our current
capabilities after Vconn is sourced, when we should be able to set Rp
3.0A without triggering CCD.
BRANCH=octopus
BUG=b:123063171, b:124531988
TEST=on orbatrix with an HDMI dongle, added debug prints into the
tcpci set_role_ctrl function to ensure that any Rp values set before
the partner was attached were to 1.5 A and Rp was set to 3.0 A after
the connection was stable, regardless of whether the dongle had been
plugged into port 1 previously
Change-Id: Iba38f9c07d85c1eb03ae1b8b3e476197a9841121
Signed-off-by: Diana Z <dzigterman@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1487116
Tested-by: Matt Wang <matt_wang@compal.corp-partner.google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r-- | common/charge_manager.c | 8 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 24 |
2 files changed, 13 insertions, 19 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c index 46fcb91730..6793b095b4 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -1070,19 +1070,19 @@ static int can_supply_max_current(int port) * port gets 3A. */ int p; - if (!is_active_source(port) && has_other_active_source(port)) - /* Another port will get 3A */ + if (!is_active_source(port)) + /* Non-active ports don't get 3A */ return 0; for (p = 0; p < CONFIG_USB_PD_PORT_COUNT; p++) { if (p == port) continue; - if (is_active_source(p) && source_port_rp[p] == + if (source_port_rp[p] == CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT) return 0; } return 1; #else - return !has_other_active_source(port); + return is_active_source(port) && !has_other_active_source(port); #endif /* CONFIG_USB_PD_MAX_TOTAL_SOURCE_CURRENT */ } diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 1c6d7e699c..b73ac2af8c 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -715,23 +715,10 @@ static inline void set_state(int port, enum pd_states next_state) set_vconn(port, 0); #endif /* CONFIG_USBC_VCONN */ #endif /* !CONFIG_USB_PD_DUAL_ROLE */ - /* - * If we are source, make sure VBUS is off and - * if PD REV3.0, restore RP. - */ + /* If we are source, make sure VBUS is off and restore RP */ if (pd[port].power_role == PD_ROLE_SOURCE) { - /* - * If CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT is - * defined, Rp is reset as follows. - * If all ports are open, pd_power_supply_reset will - * change Rp to 3A for all ports. If the other port is - * occupied, it'll be given 3A and this port will be - * given 1.5A. - * In either case, this port is immediately reset to - * 1.5A by tcpm_select_rp_value. - */ + /* Restore non-active ports to CONFIG_USB_PD_PULLUP */ pd_power_supply_reset(port); - tcpm_select_rp_value(port, CONFIG_USB_PD_PULLUP); tcpm_set_cc(port, TYPEC_CC_RP); } #ifdef CONFIG_USB_PD_REV30 @@ -3118,6 +3105,13 @@ void pd_task(void *u) #endif /* CONFIG_USBC_SS_MUX */ break; } + /* + * Set correct Rp value determined during + * pd_set_power_supply_ready. This should be + * safe because Vconn is being sourced, + * preventing incorrect CCD detection. + */ + tcpm_set_cc(port, TYPEC_CC_RP); #endif /* CONFIG_USBC_BACKWARDS_COMPATIBLE_DFP */ /* If PD comm is enabled, enable TCPC RX */ if (pd_comm_is_enabled(port)) |