diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2021-05-05 14:02:19 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-10 17:56:03 +0000 |
commit | 0e605f4c165fb77737b2294ca2c234d98c90b189 (patch) | |
tree | cc006763d81bebeb900016ff8968e620518ec925 | |
parent | 0eb3a9b7b4df6bc4ac2ccdcc6ce979d225bc064a (diff) | |
download | chrome-ec-0e605f4c165fb77737b2294ca2c234d98c90b189.tar.gz |
Storo: Use display SoC to control charge LED
Currently, Storo uses the state of charge provided from the battery.
This isn't the same as the SoC shown on the screen because Powerd
compensates it based on the full factor and the low battery shutdown
threshold.
This change makes Storo use the display SoC for the charge LED module
so that the charge LED and the display SoC synchronously work.
BUG=b:181506409
BRANCH=dedede
TEST=Storo's LED turns from amber to white when the display soc
reaches 95% (internally 94.6%).
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Change-Id: I42c505c9fbd39f82de2318f0d7ff8589eeca4d8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2876165
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/storo/board.h | 3 | ||||
-rw-r--r-- | common/led_onoff_states.c | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/board/storo/board.h b/board/storo/board.h index a6bc89c44f..0693b3f3bc 100644 --- a/board/storo/board.h +++ b/board/storo/board.h @@ -21,6 +21,9 @@ /* Battery */ #define CONFIG_BATTERY_FUEL_GAUGE +#define CONFIG_BATTERY_EXPORT_DISPLAY_SOC +#undef CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE +#define CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE 3 /* BC 1.2 */ #define CONFIG_BC12_DETECT_PI3USB9201 diff --git a/common/led_onoff_states.c b/common/led_onoff_states.c index 7b699b4fea..595e8ab10d 100644 --- a/common/led_onoff_states.c +++ b/common/led_onoff_states.c @@ -15,6 +15,7 @@ #include "led_common.h" #include "led_onoff_states.h" #include "system.h" +#include "util.h" #define CPRINTS(format, args...) cprints(CC_GPIO, format, ## args) @@ -35,6 +36,14 @@ __overridable void led_set_color_battery(enum ec_led_colors color) int charge_get_percent(void); #endif +static int led_get_charge_percent(void) +{ + if (IS_ENABLED(CONFIG_BATTERY_EXPORT_DISPLAY_SOC)) + return DIV_ROUND_NEAREST(charge_get_display_charge(), 10); + else + return charge_get_percent(); +} + static enum led_states led_get_state(void) { int charge_lvl; @@ -46,7 +55,7 @@ static enum led_states led_get_state(void) switch (charge_get_state()) { case PWR_STATE_CHARGE: /* Get percent charge */ - charge_lvl = charge_get_percent(); + charge_lvl = led_get_charge_percent(); /* Determine which charge state to use */ if (charge_lvl < led_charge_lvl_1) new_state = STATE_CHARGING_LVL_1; @@ -70,7 +79,7 @@ static enum led_states led_get_state(void) case PWR_STATE_DISCHARGE /* and PWR_STATE_DISCHARGE_FULL */: if (chipset_in_state(CHIPSET_STATE_ON)) { #ifdef CONFIG_LED_ONOFF_STATES_BAT_LOW - if (charge_get_percent() < + if (led_get_charge_percent() < CONFIG_LED_ONOFF_STATES_BAT_LOW) new_state = STATE_DISCHARGE_S0_BAT_LOW; else |