diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-12-03 22:23:55 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-12-08 23:16:15 +0000 |
commit | ddc5bfd3d0921a80dbb987025f06b8cbf773a640 (patch) | |
tree | 4c0a72ee52ab64e59ecb6a39ba1d041d517d48fb | |
parent | 9e1f4ed7015ac8543169fe41b74f1939a8b86f3b (diff) | |
download | chrome-ec-ddc5bfd3d0921a80dbb987025f06b8cbf773a640.tar.gz |
pd: do not allow FW update on active charging port if no battery
Do not allow remote PD firmware update of a device that is providing
us power when we have no battery (or else we will lose power).
BUG=none
BRANCH=samus
TEST=attach a zinger that has an old FW to samus with no battery and
see that host attempts to update FW but PD MCU does not allow it.
Change-Id: Iaf816dc44017d9c65a2b248ea8536d7c03898910
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/233752
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index b9ed705d65..e20d2c21cb 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -4,6 +4,7 @@ */ #include "adc.h" +#include "battery.h" #include "board.h" #include "charge_manager.h" #include "chipset.h" @@ -2783,6 +2784,17 @@ static int hc_remote_flash(struct host_cmd_handler_args *args) if (p->size + sizeof(*p) > args->params_size) return EC_RES_INVALID_PARAM; +#if defined(CONFIG_BATTERY_PRESENT_CUSTOM) || \ + defined(CONFIG_BATTERY_PRESENT_GPIO) + /* + * Do not allow PD firmware update if no battery and this port + * is sinking power, because we will lose power. + */ + if (battery_is_present() != BP_YES && + charge_manager_get_active_charge_port() == port) + return EC_RES_UNAVAILABLE; +#endif + switch (p->cmd) { case USB_PD_FW_REBOOT: pd_send_vdm(port, USB_VID_GOOGLE, VDO_CMD_REBOOT, NULL, 0); |