diff options
author | Yilun Lin <yllin@google.com> | 2019-04-30 16:47:11 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-02 16:12:36 -0700 |
commit | 34366869bbab2e7c27a037b4c7d3c15ee5bf151a (patch) | |
tree | 7c74dc6d186254f90d5305b78399fab1fae113fd /board/kukui/led.c | |
parent | 00f889bfcf324197f9469febc696bae5983c4775 (diff) | |
download | chrome-ec-34366869bbab2e7c27a037b4c7d3c15ee5bf151a.tar.gz |
kukui: Fix power leakage in LED.
Though setting the LED brighness to 0, LEDs are still sinking
power. This causes power leakage (2mA) in G3 state.
This CL turns off the LED current sinking if the LED brightness is set
to 0. This also fixes LED not able to enter auto mode if it has been
turned off previously.
BRANCH=None
BUG=b:131122365 b:131372801
TEST=see that the gap of the power of batt and sys are reduce from 2mA
to 0.06mA.
dut-control ppvar_batt_ma ppvar_sys_ma -t 3 |grep @@
@@ NAME COUNT AVERAGE STDDEV MAX MIN
@@ sample_msecs 527 5.69 1.12 11.73 4.73
@@ ppvar_batt_ma 527 3.96 0.29 4.00 2.00
@@ ppvar_sys_ma 527 3.90 0.45 6.00 2.00
TEST=ectool led battery off;
ectool led battery auto;
and see the battery led can blink.
Change-Id: I8422eb651781386caa0600448bde3a0825d65ec3
Signed-off-by: Yilun Lin <yllin@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1588302
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Yilun Lin <yllin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'board/kukui/led.c')
-rw-r--r-- | board/kukui/led.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/board/kukui/led.c b/board/kukui/led.c index ca111ca54b..0d7ec4556b 100644 --- a/board/kukui/led.c +++ b/board/kukui/led.c @@ -29,7 +29,7 @@ static void kukui_led_set_battery(void) { static enum charge_state prv_chstate = PWR_STATE_UNCHANGE; enum charge_state chstate; - uint8_t blue = 0, green = 0, red = 0; + uint8_t br[EC_LED_COLOR_COUNT] = { 0 }; chstate = charge_get_state(); @@ -41,25 +41,24 @@ static void kukui_led_set_battery(void) switch (chstate) { case PWR_STATE_CHARGE: /* Always indicate when charging, even in suspend. */ - blue = 1; + br[EC_LED_COLOR_BLUE] = 1; break; case PWR_STATE_DISCHARGE: if (charge_get_percent() <= 10) - red = 1; + br[EC_LED_COLOR_RED] = 1; break; case PWR_STATE_ERROR: - red = 1; + br[EC_LED_COLOR_RED] = 1; break; case PWR_STATE_CHARGE_NEAR_FULL: - green = 1; + br[EC_LED_COLOR_GREEN] = 1; break; default: /* Other states don't alter LED behavior */ return; } - mt6370_led_set_brightness(LED_RED, red); - mt6370_led_set_brightness(LED_BLUE, blue); - mt6370_led_set_brightness(LED_GREEN, green); + + led_set_brightness(EC_LED_ID_BATTERY_LED, br); } void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) @@ -74,12 +73,23 @@ void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) { + uint8_t red, green, blue; + if (led_id != EC_LED_ID_BATTERY_LED) return EC_ERROR_INVAL; - mt6370_led_set_brightness(LED_RED, brightness[EC_LED_COLOR_RED]); - mt6370_led_set_brightness(LED_GREEN, brightness[EC_LED_COLOR_GREEN]); - mt6370_led_set_brightness(LED_BLUE, brightness[EC_LED_COLOR_BLUE]); + red = brightness[EC_LED_COLOR_RED]; + green = brightness[EC_LED_COLOR_GREEN]; + blue = brightness[EC_LED_COLOR_BLUE]; + + mt6370_led_set_brightness(LED_RED, red); + mt6370_led_set_brightness(LED_GREEN, green); + mt6370_led_set_brightness(LED_BLUE, blue); + + /* Enables LED sink power if necessary. */ + mt6370_led_set_color((red ? LED_MASK_RED : 0) | + (blue ? LED_MASK_BLUE : 0) | + (green ? LED_MASK_GREEN : 0)); return EC_SUCCESS; } @@ -90,13 +100,3 @@ static void led_second(void) kukui_led_set_battery(); } DECLARE_HOOK(HOOK_SECOND, led_second, HOOK_PRIO_DEFAULT); - -static void kukui_led_init(void) -{ - /* Enable all LEDs, and set brightness to 0. */ - mt6370_led_set_brightness(LED_RED, 0); - mt6370_led_set_brightness(LED_GREEN, 0); - mt6370_led_set_brightness(LED_BLUE, 0); - mt6370_led_set_color(LED_MASK_RED | LED_MASK_GREEN | LED_MASK_BLUE); -} -DECLARE_HOOK(HOOK_INIT, kukui_led_init, HOOK_PRIO_DEFAULT); |