diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2017-12-22 10:56:01 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-01-04 21:52:00 -0800 |
commit | 41af1bf27c0e983523a055d2567bc15e7814e289 (patch) | |
tree | d16f1c101c2f8658ec1998127fbe93c4f7258dc8 | |
parent | 113602c06e2fac46ca7d29433bb2a62864c633c5 (diff) | |
download | chrome-ec-41af1bf27c0e983523a055d2567bc15e7814e289.tar.gz |
wand: Make sure battery is cut-off when critical
Modify chipset_in_state to always say that the chipset is off,
when we do not actually have a chipset (like on hammer): that
makes sure the battery can actually be cut off (else the EC
would just wait forever for the chipset to turn off).
Also, wake the charger state on "AC" change, that is, when
charging_allowed changes state, to make sure the charging loop
is executed after lux tries to charge it (else the charging loop
would wait until timeout expires, and wand would ask the battery
to be cut off again).
BRANCH=none
BUG=b:65697962
TEST=Deplete wand battery, reboot without providing external power
to it.
After 30 seconds, battery is cut off:
[1.354683 Low battery: 2%, 6866mV]
[1.354888 charge warn shutdown due to critical battery]
[31.381410 Low battery: 2%, 6865mV]
[31.381643 charge force battery cut-off due to critical level]
TEST=Upon providing power to wand, charging loop is executed
regularly, and battery is charging.
Change-Id: I7154b25bd852b8422a0ae3b506675a297a948132
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/842742
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | board/hammer/board.h | 1 | ||||
-rw-r--r-- | common/ec_ec_comm_slave.c | 5 | ||||
-rw-r--r-- | include/chipset.h | 7 |
3 files changed, 8 insertions, 5 deletions
diff --git a/board/hammer/board.h b/board/hammer/board.h index 4c9675f312..0b04ced2cd 100644 --- a/board/hammer/board.h +++ b/board/hammer/board.h @@ -230,6 +230,7 @@ #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 #define CONFIG_CHARGER_DISCHARGE_ON_AC +#define CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF #define CONFIG_BATTERY_CUT_OFF #define CONFIG_BATTERY_SMART diff --git a/common/ec_ec_comm_slave.c b/common/ec_ec_comm_slave.c index 608e1edc4f..ae753274a5 100644 --- a/common/ec_ec_comm_slave.c +++ b/common/ec_ec_comm_slave.c @@ -14,6 +14,7 @@ #include "ec_ec_comm_slave.h" #include "extpower.h" #include "hwtimer.h" +#include "hooks.h" #include "queue.h" #include "queue_policies.h" #include "task.h" @@ -134,6 +135,7 @@ static void handle_cmd_charger_control( int data_len, int seq) { int ret = EC_RES_SUCCESS; + int prev_charging_allowed = charging_allowed; if (data_len != sizeof(*params)) { ret = EC_RES_INVALID_COMMAND; @@ -161,6 +163,9 @@ static void handle_cmd_charger_control( charging_allowed = 0; } + if (prev_charging_allowed != charging_allowed) + hook_notify(HOOK_AC_CHANGE); + out: write_response(ret, seq, NULL, 0); } diff --git a/include/chipset.h b/include/chipset.h index ed19ba4df3..5ada8c5c4b 100644 --- a/include/chipset.h +++ b/include/chipset.h @@ -91,14 +91,11 @@ void power_interrupt(enum gpio_signal signal); void chipset_handle_espi_reset_assert(void); #else /* !HAS_TASK_CHIPSET */ -/* - * Allow other modules to compile if the chipset module is disabled. This is - * commonly done during early stages of board bringup. - */ +/* When no chipset is present, assume it is always off. */ static inline int chipset_in_state(int state_mask) { - return 0; + return state_mask & CHIPSET_STATE_ANY_OFF; } static inline void chipset_exit_hard_off(void) { } |