diff --git a/board/kevin/board.h b/board/kevin/board.h index fc550fd7c1..3c57ec8982 100644 --- a/board/kevin/board.h +++ b/board/kevin/board.h @@ -61,6 +61,7 @@ #define CONFIG_CHARGER_BD99956 #define CONFIG_BD9995X_POWER_SAVE_MODE BD9995X_PWR_SAVE_HIGH #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MAINTAIN_VBAT #define CONFIG_CHARGER_V2 #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 2 diff --git a/board/reef/board.h b/board/reef/board.h index 2829d27e62..80157e91df 100644 --- a/board/reef/board.h +++ b/board/reef/board.h @@ -62,6 +62,7 @@ #define CONFIG_CHARGER_INPUT_CURRENT 512 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000 +#define CONFIG_CHARGER_MAINTAIN_VBAT #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 #define CONFIG_USB_CHARGER #define CONFIG_CHARGER_PROFILE_OVERRIDE diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index dceec8d562..98461bb2c3 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -859,11 +859,13 @@ wait_for_it: } prev_full = is_full; +#ifndef CONFIG_CHARGER_MAINTAIN_VBAT /* Turn charger off if it's not needed */ if (curr.state == ST_IDLE || curr.state == ST_DISCHARGE) { curr.requested_voltage = 0; curr.requested_current = 0; } +#endif /* Apply external limits */ if (curr.requested_current > user_current_limit) @@ -882,8 +884,10 @@ wait_for_it: * charging it. Thus, we only charge when AC is on and * battery is not cut off yet. */ - if (battery_is_cut_off()) - charge_request(0, 0); + if (battery_is_cut_off()) { + curr.requested_voltage = 0; + curr.requested_current = 0; + } /* * As a safety feature, some chargers will stop * charging if we don't communicate with it frequently @@ -891,17 +895,17 @@ wait_for_it: * knows. */ else if (manual_mode) { - charge_request(curr.chg.voltage, - curr.chg.current); - } else { - charge_request(curr.requested_voltage, - curr.requested_current); + curr.requested_voltage = curr.chg.voltage; + curr.requested_current = curr.chg.current; } } else { - charge_request( - charger_closest_voltage( - curr.batt.voltage + info->voltage_step), -1); +#ifndef CONFIG_CHARGER_MAINTAIN_VBAT + curr.requested_voltage = charger_closest_voltage( + curr.batt.voltage + info->voltage_step); + curr.requested_current = -1; +#endif } + charge_request(curr.requested_voltage, curr.requested_current); /* How long to sleep? */ if (problems_exist) diff --git a/include/config.h b/include/config.h index b1655d1017..76a5e9805d 100644 --- a/include/config.h +++ b/include/config.h @@ -479,6 +479,13 @@ */ #undef CONFIG_CHARGER_MAX_INPUT_CURRENT +/* + * Leave charger VBAT configured to battery-requested voltage under all + * conditions, even when AC is not present. This may be necessary to work + * around quirks of certain charger chips, such as the BD9995X. + */ +#undef CONFIG_CHARGER_MAINTAIN_VBAT + /* Minimum battery percentage for power on */ #undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON