diff options
author | Scott Collyer <scollyer@google.com> | 2017-08-22 10:28:33 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-08-23 21:17:22 -0700 |
commit | 6d286d157ca32f8c6a39e463ea26b01715b10750 (patch) | |
tree | c9e61c3c5a9718b75da95f03d799ba6972b88624 | |
parent | c36102149845f7fb0238a0839f1e3fd96d89f0d7 (diff) | |
download | chrome-ec-6d286d157ca32f8c6a39e463ea26b01715b10750.tar.gz |
battery: Check physical battery presence before inhibiting power
In order to satisfy factory testing requirements we need to
boot a bare board with just an AC adapter without requiring
a power button.
However we also don't want to always allow booting of the
battery is present but cut-off (which will indicate BP_NO so
we can't use the existing battery_is_present function) or has
critically low level as it may not immediately boot.
To accomplish this add a function that allows the board to
specify a custom "hardware presence" for the battery that is
separate from the battery presence check.
This CL is taking a change done for Eve and pulling into TOT so it can
be used for other projects that have the same
requirements. https://chromium-review.googlesource.com/c/582544
BUG=b:63957122
BRANCH=none
TEST=manual
Change-Id: Ib1dc4f659adbf0eebd3dc8c3c61b39b8fa36cb4a
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/627113
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r-- | board/coral/battery.c | 2 | ||||
-rw-r--r-- | board/eve/battery.c | 2 | ||||
-rw-r--r-- | board/glkrvp/battery.c | 2 | ||||
-rw-r--r-- | board/poppy/battery.c | 2 | ||||
-rw-r--r-- | board/reef/battery.c | 2 | ||||
-rw-r--r-- | board/reef_it8320/battery.c | 2 | ||||
-rw-r--r-- | common/charge_state_v2.c | 9 | ||||
-rw-r--r-- | include/battery.h | 8 | ||||
-rw-r--r-- | include/config.h | 8 |
9 files changed, 29 insertions, 8 deletions
diff --git a/board/coral/battery.c b/board/coral/battery.c index 92fc6f56fe..a9009439af 100644 --- a/board/coral/battery.c +++ b/board/coral/battery.c @@ -226,7 +226,7 @@ int charger_profile_override(struct charge_state_data *curr) return 0; } -static inline enum battery_present battery_hw_present(void) +enum battery_present battery_hw_present(void) { /* The GPIO is low when the battery is physically present */ return gpio_get_level(GPIO_EC_BATT_PRES_L) ? BP_NO : BP_YES; diff --git a/board/eve/battery.c b/board/eve/battery.c index 0cb3a3bf1d..df0c976f7e 100644 --- a/board/eve/battery.c +++ b/board/eve/battery.c @@ -282,7 +282,7 @@ enum ec_status charger_profile_override_set_param(uint32_t param, return EC_RES_INVALID_PARAM; } -static inline enum battery_present battery_hw_present(void) +enum battery_present battery_hw_present(void) { /* The GPIO is low when the battery is physically present */ return gpio_get_level(GPIO_BATTERY_PRESENT_L) ? BP_NO : BP_YES; diff --git a/board/glkrvp/battery.c b/board/glkrvp/battery.c index c708d08fff..bd8cb9304f 100644 --- a/board/glkrvp/battery.c +++ b/board/glkrvp/battery.c @@ -173,7 +173,7 @@ static inline int batt_smp_cos4870_is_initialized(void) batt_status & STATUS_INITIALIZED; } -static inline enum battery_present battery_hw_present(void) +enum battery_present battery_hw_present(void) { int data; int rv; diff --git a/board/poppy/battery.c b/board/poppy/battery.c index 6764ae53da..63006b2bed 100644 --- a/board/poppy/battery.c +++ b/board/poppy/battery.c @@ -115,7 +115,7 @@ enum ec_status charger_profile_override_set_param(uint32_t param, return EC_RES_INVALID_PARAM; } -static enum battery_present battery_hw_present(void) +enum battery_present battery_hw_present(void) { /* The GPIO is low when the battery is physically present */ return gpio_get_level(GPIO_BATTERY_PRESENT_L) ? BP_NO : BP_YES; diff --git a/board/reef/battery.c b/board/reef/battery.c index b42f8c1132..83a3679b26 100644 --- a/board/reef/battery.c +++ b/board/reef/battery.c @@ -516,7 +516,7 @@ static inline const struct board_batt_params *board_get_batt_params(void) DEFAULT_BATTERY_TYPE : board_battery_type]; } -static inline enum battery_present battery_hw_present(void) +enum battery_present battery_hw_present(void) { /* The GPIO is low when the battery is physically present */ return gpio_get_level(GPIO_EC_BATT_PRES_L) ? BP_NO : BP_YES; diff --git a/board/reef_it8320/battery.c b/board/reef_it8320/battery.c index 1745bf736b..1b16a672b2 100644 --- a/board/reef_it8320/battery.c +++ b/board/reef_it8320/battery.c @@ -516,7 +516,7 @@ static inline const struct board_batt_params *board_get_batt_params(void) DEFAULT_BATTERY_TYPE : board_battery_type]; } -static inline enum battery_present battery_hw_present(void) +enum battery_present battery_hw_present(void) { /* The GPIO is low when the battery is physically present */ return gpio_get_level(GPIO_EC_BATT_PRES_L) ? BP_NO : BP_YES; diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 4eaa1efb95..5f5db0be47 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -1011,9 +1011,14 @@ int charge_prevent_power_on(int power_button_pressed) /* * Factory override: Always allow power on if WP is disabled, - * except when auto-power-on at EC startup. + * except when auto-power-on at EC startup and the battery + * is physically present. */ - prevent_power_on &= (system_is_locked() || automatic_power_on); + prevent_power_on &= (system_is_locked() || (automatic_power_on +#ifdef CONFIG_BATTERY_HW_PRESENT_CUSTOM + && battery_hw_present() == BP_YES +#endif + )); #endif return prevent_power_on; diff --git a/include/battery.h b/include/battery.h index b4b54bc72e..0ccd29319d 100644 --- a/include/battery.h +++ b/include/battery.h @@ -142,6 +142,14 @@ void battery_override_params(struct batt_params *batt); enum battery_present battery_is_present(void); /** + * Check for physical presence of battery. + * + * @return Whether there is a battery physically present, but possibly + * in a disconnected or cut off state, or if we can't tell; + */ +enum battery_present battery_hw_present(void); + +/** * Check for battery initialization status. * * @return zero if not initialized. diff --git a/include/config.h b/include/config.h index 86f5bf51ec..985cf91079 100644 --- a/include/config.h +++ b/include/config.h @@ -226,6 +226,14 @@ #define CONFIG_BATTERY_PRECHARGE_TIMEOUT 30 /* + * If defined, the charger will check a board specific function for battery hw + * presence as an additional condition to determine if power on is allowed for + * factory override, where allowing booting of a bare board with no battery and + * no power button press is required. + */ +#undef CONFIG_BATTERY_HW_PRESENT_CUSTOM + +/* * If defined, the charger will check for battery presence before attempting * to communicate with it. This avoids the 30 second delay when booting * without a battery present. Do not use with CONFIG_BATTERY_PRESENT_GPIO. |