From 6b6a6fbca659c6a11eb41017ad0df479b39fbea2 Mon Sep 17 00:00:00 2001 From: Vijay Hiremath Date: Fri, 22 Jul 2016 14:43:41 -0700 Subject: [PATCH] charge_state_v2: Add console command to test discharge on AC Added support to test discharge on AC using console command. BUG=chrome-os-partner:55572 BRANCH=none TEST=Manually tested on Reef. "chgstate discharge on" - Battery is discharging "chgstate discharge off" - Battery is charging Change-Id: I07733fe28d22b0ad6e3bd172a445e43a60650762 Signed-off-by: Vijay Hiremath Reviewed-on: https://chromium-review.googlesource.com/362678 Commit-Ready: Vijay P Hiremath Tested-by: Vijay P Hiremath Reviewed-by: Aseda Aboagye --- common/charge_state_v2.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 48799bf5c3..1051365d20 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -1313,13 +1313,30 @@ static int command_chgstate(int argc, char **argv) CHARGE_CONTROL_NORMAL); if (rv) return rv; +#ifdef CONFIG_CHARGER_DISCHARGE_ON_AC + } else if (!strcasecmp(argv[1], "discharge")) { + if (argc <= 2) + return EC_ERROR_PARAM_COUNT; + if (!parse_bool(argv[2], &val)) + return EC_ERROR_PARAM2; + rv = set_chg_ctrl_mode(val ? CHARGE_CONTROL_DISCHARGE : + CHARGE_CONTROL_NORMAL); + if (rv) + return rv; +#ifdef CONFIG_CHARGER_DISCHARGE_ON_AC_CUSTOM + rv = board_discharge_on_ac(val); +#else + rv = charger_discharge_on_ac(val); +#endif /* CONFIG_CHARGER_DISCHARGE_ON_AC_CUSTOM */ + if (rv) + return rv; +#endif /* CONFIG_CHARGER_DISCHARGE_ON_AC */ } else if (!strcasecmp(argv[1], "debug")) { if (argc <= 2) return EC_ERROR_PARAM_COUNT; if (!parse_bool(argv[2], &debugging)) return EC_ERROR_PARAM2; } else { - /* maybe handle board_discharge_on_ac() too? */ return EC_ERROR_PARAM1; } } @@ -1328,6 +1345,6 @@ static int command_chgstate(int argc, char **argv) return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(chgstate, command_chgstate, - "[idle|debug on|off]", + "[idle|discharge|debug on|off]", "Get/set charge state machine status", NULL);