diff options
-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. |