diff options
author | Hank Xie <hank.xie@quanta.corp-partner.google.com> | 2022-03-28 02:05:23 -0400 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-04-07 16:07:15 +0000 |
commit | 683df8042535e697d3037bde1a92992f1d010b06 (patch) | |
tree | 5b151b55812dacdf128f027f56b2b10a5be91482 | |
parent | 045778d73461c40cd91b5ae12a071ad374a190f4 (diff) | |
download | chrome-ec-683df8042535e697d3037bde1a92992f1d010b06.tar.gz |
landia: Porting battery led behavior for firmware spec.
This patch changes the battery led behavior to meet firmware spec,
and keeps the old behavior of lantis.
BUG=b:227121467
BRANCH=dedede
TEST=On landia. Set CBI and make sure the battery led works normally.
Signed-off-by: Hank Xie <hank.xie@quanta.corp-partner.google.com>
Change-Id: I5d1d50f3f6d408d220810df85ad61575ff21f32b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3552483
Reviewed-by: Devin Lu <Devin.Lu@quantatw.com>
Reviewed-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | board/lantis/led.c | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/board/lantis/led.c b/board/lantis/led.c index 57d537cf13..632f91e118 100644 --- a/board/lantis/led.c +++ b/board/lantis/led.c @@ -134,6 +134,23 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) } /* + * lantis use old led policy. + * Use cbi fw_config to distinguish lantis from other boards. + * numeric_pad tablet mode + * lantis N N + * landrid Y N + * landia N Y + */ +static bool is_led_old_policy(void) +{ + if (get_cbi_fw_config_numeric_pad() == NUMERIC_PAD_ABSENT && + get_cbi_fw_config_tablet_mode() == TABLET_MODE_ABSENT) + return 1; + else + return 0; +} + +/* * Set active charge port color to the parameter, turn off all others. * If no port is active (-1), turn off all LEDs. */ @@ -190,18 +207,39 @@ static void led_set_battery(void) /* Intentional fall-through */ case PWR_STATE_DISCHARGE: /* - * Blink white light (1 sec on, 1 sec off) + * Blink white/amber light (1 sec on, 1 sec off) * when battery capacity is less than 10% */ - if (charge_get_percent() < 10) - led_set_color_battery(RIGHT_PORT, - (battery_ticks & 0x2) ? LED_WHITE : LED_OFF); - else + if (charge_get_percent() < 10) { + if (is_led_old_policy()) { + led_set_color_battery( + RIGHT_PORT, (battery_ticks & 0x2) ? + LED_WHITE : LED_OFF); + } else { + if (led_auto_control_is_enabled( + EC_LED_ID_RIGHT_LED)) + led_set_color_battery( + RIGHT_PORT, + (battery_ticks & 0x2) ? + LED_AMBER : LED_OFF); + if (led_auto_control_is_enabled( + EC_LED_ID_LEFT_LED)) + led_set_color_battery( + LEFT_PORT, + (battery_ticks & 0x2) ? + LED_AMBER : LED_OFF); + } + } else { set_active_port_color(LED_OFF); + } break; case PWR_STATE_ERROR: - set_active_port_color( - (battery_ticks % 0x2) ? LED_WHITE : LED_OFF); + if (is_led_old_policy()) + set_active_port_color( + (battery_ticks % 0x2) ? LED_WHITE : LED_OFF); + else + set_active_port_color( + (battery_ticks % 0x2) ? LED_AMBER : LED_OFF); break; case PWR_STATE_CHARGE_NEAR_FULL: set_active_port_color(LED_WHITE); |