mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-07 16:11:43 +00:00
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>
This commit is contained in:
committed by
chrome-internal-fetch
parent
9e1f4ed701
commit
ddc5bfd3d0
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user