diff options
author | Aseda Aboagye <aaboagye@google.com> | 2019-02-13 15:28:01 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-02-15 14:07:26 -0800 |
commit | e60cd6a5e2066436a3cf7d8ebbb3d589a7932654 (patch) | |
tree | 1f71ebcd4e6b26e83cd6464b65ba06d2daf7b61e | |
parent | 60e7a350f0c2052a9691442e0b44ec3363744207 (diff) | |
download | chrome-ec-e60cd6a5e2066436a3cf7d8ebbb3d589a7932654.tar.gz |
pd: Don't Try.Src if battery is disconnected.
If a battery is disconnected (the discharge FET is disabled) we should
not attempt Try.Src even though the battery state of charge may be above
CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC. The reason is that in this case,
the battery is not providing charge to the system, so attempting Try.Src
will temporarily cut VBUS which may be the only power source in the
system at this time.
This commit simply checks the battery disconnect state when deciding to
attempt Try.Src.
BUG=b:123722302
BRANCH=firmware-nocturne-10984.B,master
TEST=Flash nocturne with battery stuck in disconnected state, verify
that Try.Src is not attempted.
Change-Id: I232dbb365fcdaf504b1957114bd1e29afd4cb2b2
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1474570
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 09afa57c7c..b5b4d6212e 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -2174,7 +2174,16 @@ static void pd_update_try_source(void) */ pd_try_src_enable = try_src && batt_soc >= CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC; -#if defined(CONFIG_BATTERY_PRESENT_CUSTOM) || \ + +#ifdef CONFIG_BATTERY_REVIVE_DISCONNECT + /* + * Don't attempt Try.Src if the battery is in the disconnect state. The + * discharge FET may not be enabled and so attempting Try.Src may cut + * off our only power source at the time. + */ + pd_try_src_enable &= (battery_get_disconnect_state() == + BATTERY_NOT_DISCONNECTED); +#elif defined(CONFIG_BATTERY_PRESENT_CUSTOM) || \ defined(CONFIG_BATTERY_PRESENT_GPIO) /* * When battery is cutoff in ship mode it may not be reliable to @@ -2182,7 +2191,7 @@ static void pd_update_try_source(void) * Also check if battery is initialized and ready to provide power. */ pd_try_src_enable &= (battery_is_present() == BP_YES); -#endif +#endif /* CONFIG_BATTERY_PRESENT_[CUSTOM|GPIO] */ /* * Clear this flag to cover case where a TrySrc @@ -2191,7 +2200,6 @@ static void pd_update_try_source(void) */ for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) pd[i].flags &= ~PD_FLAGS_TRY_SRC; - } DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE, pd_update_try_source, HOOK_PRIO_DEFAULT); #endif /* CONFIG_USB_PD_TRY_SRC */ |