From f6cff1fa6bead660a12222615f84f3f930a5e6f2 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Mon, 23 Feb 2015 14:13:37 -0800 Subject: samus: make sure EC sends battery percentage to PD on change Make sure the EC sends the battery state of charge to the PD every time it changes. BUG=none BRANCH=samus TEST=create command to fake battery percentage in driver/battery/smart.c: static int cmd_battfake(int argc, char **argv) { char *e; if (argc > 1) batt_fake = strtoi(argv[1], &e, 0); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(battfake, cmd_battfake, NULL, "", NULL); and in battery_get_params(): if (batt_cap > -1) batt_new.remaining_capacity = batt_cap; On samus use battfake command to change battery percentage back and forth every few seconds for minutes and make sure the PD receives host command 0x100 and that it is still happy. Change-Id: Ic69ab2af900fa2a38e3d2f6562675684487f556e Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/252350 Reviewed-by: Shawn N --- board/samus/extpower.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'board/samus/extpower.c') diff --git a/board/samus/extpower.c b/board/samus/extpower.c index 1da30de076..8a73c91a56 100644 --- a/board/samus/extpower.c +++ b/board/samus/extpower.c @@ -119,8 +119,10 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, cancel_charging_cutoff, HOOK_PRIO_DEFAULT); static void batt_soc_change(void) { /* If in S0, leave charging alone */ - if (chipset_in_state(CHIPSET_STATE_ON)) + if (chipset_in_state(CHIPSET_STATE_ON)) { + host_command_pd_send_status(PD_CHARGE_NO_CHANGE); return; + } /* Check to disable or enable charging based on batt state of charge */ if (!charge_is_disabled && charge_get_percent() == 100) { @@ -129,6 +131,9 @@ static void batt_soc_change(void) } else if (charge_is_disabled && charge_get_percent() < 100) { charge_is_disabled = 0; host_command_pd_send_status(PD_CHARGE_5V); + } else { + /* Leave charging alone, but update battery SOC */ + host_command_pd_send_status(PD_CHARGE_NO_CHANGE); } } DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE, batt_soc_change, HOOK_PRIO_DEFAULT); -- cgit v1.2.1