summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2020-01-10 14:37:55 -0800
committerCommit Bot <commit-bot@chromium.org>2020-01-14 14:56:25 +0000
commit3adc402be74c7bcfd0cbbca2ff4aa38944732c34 (patch)
treef0187f96c22c1e9519598d5894231d7aa95466a4
parentb82b98fe2ad79fb848401b424afb7db83a6b908b (diff)
downloadchrome-ec-3adc402be74c7bcfd0cbbca2ff4aa38944732c34.tar.gz
usb pd: Don't force VSafe5V when there is no active charge port
This CL fixes an issue where USB PD would not allow the max request when there is currently no charge port. This was causing issues following the jump to RW when the PD contract gets reestablished. There is a race condition between the PD contract negotiation and the charage manager being updated from the first 5V/3A state. This race condition results in selection of the vSafe5V PDO and this can cause problems with external adapters resulting in a hard reset. Note that this problem only occurs when no battery is present since otherwise there wouldn't have had a pd contract negotiated when the EC is executing from RO. BUG=b:145783611 BRANCH=firmware-hatch-12672.B TEST=On Kohaku using the kohaku provided external adapter, verified that kohaku can boot to the OS when SW sync is enabled and no battery is present. In addition, connected two kohaku chargers simultaneously (via power strip on button) and verified that only one port negotiates VBUS at 20V. Change-Id: I68b21f2a86634d4bae91a5b812f2a61b302b0ef3 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1993914 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org> (cherry picked from commit c75bc93c31bf9ecbe2b8f39193e949440ec962c7) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1999286 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Commit-Queue: Tim Wawrzynczak <twawrzynczak@chromium.org> Tested-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
-rw-r--r--common/usb_pd_protocol.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 5bd846363f..8fe7dbe011 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1519,9 +1519,20 @@ static int pd_send_request_msg(int port, int always_send_request)
int res;
#ifdef CONFIG_CHARGE_MANAGER
- int charging = (charge_manager_get_active_charge_port() == port);
+ /*
+ * If this port is the current charge port, or if there isn't an active
+ * charge port, set this value to true. If CHARGE_PORT_NONE isn't
+ * considered, then there can be a race condition in PD negotiation and
+ * the charge manager which forces an incorrect request for
+ * vSafe5V. This can then lead to a brownout condition when the input
+ * current limit gets incorrectly set to 0.5A.
+ */
+ int charging_allowed = ((charge_manager_get_active_charge_port() ==
+ port) ||
+ (charge_manager_get_active_charge_port() ==
+ CHARGE_PORT_NONE));
#else
- const int charging = 1;
+ const int charging_allowed = 1;
#endif
#ifdef CONFIG_USB_PD_CHECK_MAX_REQUEST_ALLOWED
@@ -1535,12 +1546,12 @@ static int pd_send_request_msg(int port, int always_send_request)
/* Build and send request RDO */
/*
- * If this port is not actively charging or we are not allowed to
+ * If currently charging on a different port, or we are not allowed to
* request the max voltage, then select vSafe5V
*/
pd_build_request(pd_get_src_cap_cnt(port), pd_get_src_caps(port), 0,
&rdo, &curr_limit, &supply_voltage,
- charging && max_request_allowed ?
+ charging_allowed && max_request_allowed ?
PD_REQUEST_MAX : PD_REQUEST_VSAFE5V,
pd_get_max_voltage());