summaryrefslogtreecommitdiff
path: root/common/led_onoff_states.c
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2021-05-05 14:02:19 -0700
committerCommit Bot <commit-bot@chromium.org>2021-05-10 17:56:03 +0000
commit0e605f4c165fb77737b2294ca2c234d98c90b189 (patch)
treecc006763d81bebeb900016ff8968e620518ec925 /common/led_onoff_states.c
parent0eb3a9b7b4df6bc4ac2ccdcc6ce979d225bc064a (diff)
downloadchrome-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>
Diffstat (limited to 'common/led_onoff_states.c')
-rw-r--r--common/led_onoff_states.c13
1 files changed, 11 insertions, 2 deletions
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