From a96fbd0c9722abed0891c95bf6accc51ebf4da6a Mon Sep 17 00:00:00 2001 From: Aseda Aboagye Date: Fri, 9 Mar 2018 18:09:38 -0800 Subject: [PATCH] meowth: zoombini: Ignore AC when checking cutoff. When charge manager safe mode is enabled, it prevents us from selecting CHARGE_PORT_NONE if we have a battery which is disconnected/cutoff. The cutoff reporting code was essentially making the assumption that if AC is not present, then we must be running off of battery power. However, AC presence is debounced and can take some time to be reported to the system. Therefore, we may wrongly assume that we are running off of battery power and cut off our AC power source. This commit simply removes that assumption and still consults the battery regarding the cutoff/disconnect state. BUG=b:74125001 BRANCH=stabilize-meowth-10444.B TEST=flash meowth; cutoff battery, insert AC, verify system comes up. Verify that CHARGE_PORT_NONE is not selected until battery wakes up. Change-Id: I79a27bd2d5f09c2ffe65df98402c0ae0182fdba2 Signed-off-by: Aseda Aboagye Reviewed-on: https://chromium-review.googlesource.com/957888 Commit-Ready: Aseda Aboagye Tested-by: Aseda Aboagye Reviewed-by: Aseda Aboagye --- board/zoombini/battery.c | 46 ++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/board/zoombini/battery.c b/board/zoombini/battery.c index f29f9b6009..d508e88d65 100644 --- a/board/zoombini/battery.c +++ b/board/zoombini/battery.c @@ -89,30 +89,26 @@ enum battery_disconnect_state battery_get_disconnect_state(void) if (not_disconnected) return BATTERY_NOT_DISCONNECTED; - if (extpower_is_present()) { - /* Check if battery charging + discharging is disabled. */ - rv = sb_read_mfgacc(PARAM_OPERATION_STATUS, - SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data)); - if (rv) - return BATTERY_DISCONNECT_ERROR; - if (~data[3] & (BATTERY_DISCHARGING_DISABLED | - BATTERY_CHARGING_DISABLED)) { - not_disconnected = 1; - return BATTERY_NOT_DISCONNECTED; - } - - /* - * Battery is neither charging nor discharging. Verify that - * we didn't enter this state due to a safety fault. - */ - rv = sb_read_mfgacc(PARAM_SAFETY_STATUS, - SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data)); - if (rv || data[2] || data[3] || data[4] || data[5]) - return BATTERY_DISCONNECT_ERROR; - - /* No safety fault, battery is disconnected */ - return BATTERY_DISCONNECTED; + /* Check if battery charging + discharging is disabled. */ + rv = sb_read_mfgacc(PARAM_OPERATION_STATUS, + SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data)); + if (rv) + return BATTERY_DISCONNECT_ERROR; + if (~data[3] & (BATTERY_DISCHARGING_DISABLED | + BATTERY_CHARGING_DISABLED)) { + not_disconnected = 1; + return BATTERY_NOT_DISCONNECTED; } - not_disconnected = 1; - return BATTERY_NOT_DISCONNECTED; + + /* + * Battery is neither charging nor discharging. Verify that + * we didn't enter this state due to a safety fault. + */ + rv = sb_read_mfgacc(PARAM_SAFETY_STATUS, + SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data)); + if (rv || data[2] || data[3] || data[4] || data[5]) + return BATTERY_DISCONNECT_ERROR; + + /* No safety fault, battery is disconnected */ + return BATTERY_DISCONNECTED; }