diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-12-17 13:22:36 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-01-03 02:26:21 +0000 |
commit | 2b0895179733852a7eb13051ad99a494af5cc3bd (patch) | |
tree | 557338d88ec7a20212bc8c4f457d7867073513a5 /common/charge_manager.c | |
parent | a3f3e38da09eb196a5773021a54832a553c206e3 (diff) | |
download | chrome-ec-2b0895179733852a7eb13051ad99a494af5cc3bd.tar.gz |
samus: when battery is full, and not in S0, stop charging
When battery is full and system is not in S0, then stop charging
and allow battery to power the system. Once battery is no longer
full and requests current, allow charging again. This is to work
around power consumption issues in our AC input path. The charge
override port is stored upon entering S3 and restored going back
to S0 so that the charge override port is not affected by this.
This also fixes lightbar so lightbar checks if battery is full
instead of checking raw percentage. The lightbar is also changed
to use the last tap direction if no charger is plugged in. And
the lightbar tap for battery threshold for turning green is
lowered to 95%.
This also moves some samus_pd board code out of interrupt handlers
and in to deferred functions to minimize time in interrupts.
BUG=chrome-os-partner:34640, chrome-os-partner:34847
BRANCH=samus
TEST=load onto samus. use battfake command from pd console to
set battery percentage. when system is in G3, see that
batt = 100% stops charging, and when batt < 100% it starts
charging again.
tested that we receive host command from EC with battery
information every time battery changes SOC.
Change-Id: Ia8e0721508e34ee3630f5e5b0c2f431a00329caf
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/236411
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/charge_manager.c')
-rw-r--r-- | common/charge_manager.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c index 651cf3af5e..4b400f137c 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -347,6 +347,8 @@ int charge_manager_set_override(int port) ASSERT(port >= OVERRIDE_DONT_CHARGE && port < PD_PORT_COUNT); + CPRINTS("Charge Override: %d", port); + /* Supersede any pending delayed overrides. */ if (delayed_override_port != OVERRIDE_OFF) { if (delayed_override_port != port) @@ -387,6 +389,17 @@ int charge_manager_set_override(int port) return retval; } +/** + * Get the override port. OVERRIDE_OFF if no override port. + * OVERRIDE_DONT_CHARGE if override is set for no port. + * + * @return override port + */ +int charge_manager_get_override(void) +{ + return override_port; +} + int charge_manager_get_active_charge_port(void) { return charge_port; @@ -508,16 +521,19 @@ DECLARE_HOST_COMMAND(EC_CMD_PD_CHARGE_PORT_OVERRIDE, static int command_charge_port_override(int argc, char **argv) { int port = OVERRIDE_OFF; + int ret = EC_SUCCESS; char *e; if (argc >= 2) { port = strtoi(argv[1], &e, 0); if (*e || port < OVERRIDE_DONT_CHARGE || port >= PD_PORT_COUNT) return EC_ERROR_PARAM1; + ret = charge_manager_set_override(port); } - ccprintf("Set override: %d\n", port); - return charge_manager_set_override(port); + ccprintf("Override: %d\n", (argc >= 2 && ret == EC_SUCCESS) ? + port : override_port); + return ret; } DECLARE_CONSOLE_COMMAND(chgoverride, command_charge_port_override, "[port | -1 | -2]", |