summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYilun Lin <yllin@google.com>2019-04-10 14:14:19 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-05-14 20:13:14 -0700
commit6264b515814af52b403989557b9e14a1a699b460 (patch)
treee045144ab22629891b53b4d05b5180c85d6bb89b
parent1fa9dc3e2e8a2771a854657e0441128a9a119dbc (diff)
downloadchrome-ec-6264b515814af52b403989557b9e14a1a699b460.tar.gz
kukui: Loose charging 5V limitation strategy.
The charging limitation strategy is too conservative: it turns the charging voltage to 5V once the battery SOC hits 86 percent. However, this will make the battery SOC bouncing between 85 and 86 percent if connected to a external powered hub which can only do 500mA at 5V (2.5W) and that is not enough to charge the device. This CL looses the charging limitation strategy by taking IBAT into consideration. The strategy is proposed by vendor. When the battery is almost fully charged, IBAT will become smaller and smaller. This CL sets the IBAT limit to 1A, which is still quite large current, but is enough to charge battery SOC closing to 99 percent. It fixes: Battery SOC won't stuck at 85 percent with such hub, now it can reach 99 percent without damaging the chip. BRANCH=None BUG=b:128364884 TEST=- Charge krane with PD charger and see the PD voltage will be limited to 5V when SOC > 85% and IBAT <= 1A. - When PD voltage been limited to 5V, unplug charger, and wait for the SOC drops a little (95 -> 94) then plug a PD charger, and see the PD voltage limit been changed to 12.85V. Change-Id: I7bbdf242ff1568e3595252346eb0a3d7b3ac57ff Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1560811 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--board/kukui/battery.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/board/kukui/battery.c b/board/kukui/battery.c
index c24109f966..17d15256dc 100644
--- a/board/kukui/battery.c
+++ b/board/kukui/battery.c
@@ -33,10 +33,13 @@
#endif
#define BAT_LEVEL_PD_LIMIT 85
+#define IBAT_PD_LIMIT 1000
#define BATTERY_SIMPLO_CHARGE_MIN_TEMP 0
#define BATTERY_SIMPLO_CHARGE_MAX_TEMP 60
+#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
+
enum battery_type {
BATTERY_SIMPLO = 0,
BATTERY_MITSUMI,
@@ -131,6 +134,8 @@ enum battery_disconnect_state battery_get_disconnect_state(void)
int charger_profile_override(struct charge_state_data *curr)
{
+ static int previous_chg_limit_mv;
+ int chg_limit_mv;
#ifdef CONFIG_BATTERY_MAX17055
/* battery temp in 0.1 deg C */
int bat_temp_c = curr->batt.temperature - 2731;
@@ -202,6 +207,22 @@ int charger_profile_override(struct charge_state_data *curr)
}
#endif /* CONFIG_BATTERY_MAX17055 */
+ /* Limit input (=VBUS) to 5V when soc > 85% and charge current < 1A. */
+ if (!(curr->batt.flags & BATT_FLAG_BAD_CURRENT) &&
+ charge_get_percent() > BAT_LEVEL_PD_LIMIT &&
+ curr->batt.current < 1000)
+ chg_limit_mv = 5500;
+ else
+ chg_limit_mv = PD_MAX_VOLTAGE_MV;
+
+ if (chg_limit_mv != previous_chg_limit_mv)
+ CPRINTS("VBUS limited to %dmV", chg_limit_mv);
+ previous_chg_limit_mv = chg_limit_mv;
+
+ /* Pull down VBUS */
+ if (pd_get_max_voltage() != chg_limit_mv)
+ pd_set_external_voltage_limit(0, chg_limit_mv);
+
/*
* When the charger says it's done charging, even if fuel gauge says
* SOC < BATTERY_LEVEL_NEAR_FULL, we'll overwrite SOC with
@@ -229,23 +250,6 @@ DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE,
board_charge_termination,
HOOK_PRIO_DEFAULT);
-static void pd_limit_5v(uint8_t en)
-{
- int wanted_pd_voltage;
-
- wanted_pd_voltage = en ? 5500 : PD_MAX_VOLTAGE_MV;
-
- if (pd_get_max_voltage() != wanted_pd_voltage)
- pd_set_external_voltage_limit(0, wanted_pd_voltage);
-}
-
-/* When battery level > BAT_LEVEL_PD_LIMIT, we limit PD voltage to 5V. */
-static void board_pd_voltage(void)
-{
- pd_limit_5v(charge_get_percent() > BAT_LEVEL_PD_LIMIT);
-}
-DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE, board_pd_voltage, HOOK_PRIO_DEFAULT);
-
/* Customs options controllable by host command. */
#define PARAM_FASTCHARGE (CS_PARAM_CUSTOM_PROFILE_MIN + 0)