From 0c28fa95119487b51be5aa189060333f8da0c817 Mon Sep 17 00:00:00 2001 From: Edward Hill Date: Tue, 20 Nov 2018 14:57:58 -0700 Subject: led_pwm: Add CONFIG_LED_PWM_CHARGE_STATE_ONLY Add an option for devices that want to show only the charging state, but on all LEDs. BUG=b:119746227 BRANCH=grunt TEST=Liara LED is on when charging from either side. Change-Id: I819eaf27d3700748e47886855765c2da6f3d9eb8 Signed-off-by: Edward Hill Reviewed-on: https://chromium-review.googlesource.com/1344795 Tested-by: Josh Tsai Reviewed-by: Diana Z --- common/led_pwm.c | 14 +++++++------- include/config.h | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/common/led_pwm.c b/common/led_pwm.c index b9d13a3d6c..87ec59a127 100644 --- a/common/led_pwm.c +++ b/common/led_pwm.c @@ -160,20 +160,20 @@ static int show_charge_state(void) pulse_leds(CONFIG_LED_PWM_CHARGE_ERROR_COLOR, 1, 2); } else { /* Discharging or not charging. */ -#ifdef CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY +#ifdef CONFIG_LED_PWM_CHARGE_STATE_ONLY /* - * If we only show the active charge port, the only reason we + * If we only show the charge state, the only reason we * would pulse the LEDs is if we had an error. If it no longer * exists, stop pulsing the LEDs. */ led_is_pulsing = 0; -#endif /* CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY */ +#endif /* CONFIG_LED_PWM_CHARGE_STATE_ONLY */ return 0; } return 1; } -#ifndef CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY +#ifndef CONFIG_LED_PWM_CHARGE_STATE_ONLY static int show_battery_state(void) { int batt_percentage = charge_get_percent(); @@ -213,7 +213,7 @@ static int show_chipset_state(void) } return 1; } -#endif /* CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY */ +#endif /* CONFIG_LED_PWM_CHARGE_STATE_ONLY */ static void update_leds(void) { @@ -221,13 +221,13 @@ static void update_leds(void) if (show_charge_state()) return; -#ifndef CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY +#ifndef CONFIG_LED_PWM_CHARGE_STATE_ONLY if (show_battery_state()) return; if (show_chipset_state()) return; -#endif /* CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY */ +#endif /* CONFIG_LED_PWM_CHARGE_STATE_ONLY */ set_led_color(-1); } diff --git a/include/config.h b/include/config.h index 2ff47b6972..4df4b61217 100644 --- a/include/config.h +++ b/include/config.h @@ -2220,10 +2220,16 @@ /* * By default the PWM LED behaviour is reflected on both LEDs and includes the - * chipset state, battery state, as well as the charging state. However, enable - * this CONFIG_* option to only allow the charging state to be reflected on the - * LEDs. Additionally, only the active charge port will indicate the charge - * state. + * chipset state, battery state, as well as the charging state. Enable + * this CONFIG_* option to show only the charging state on the LEDs. + */ +#undef CONFIG_LED_PWM_CHARGE_STATE_ONLY + +/* + * By default the PWM LED behaviour is reflected on both LEDs and includes the + * chipset state, battery state, as well as the charging state. Enable + * this CONFIG_* option to show only the charging state, and only on the LED of + * the active charge port. */ #undef CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY @@ -3935,6 +3941,10 @@ #define CONFIG_LED_PWM #endif /* defined(CONFIG_LED_PWM_COUNT) */ +#ifdef CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY +#define CONFIG_LED_PWM_CHARGE_STATE_ONLY +#endif + /*****************************************************************************/ /* * Define derived configuration options for EC-EC communication -- cgit v1.2.1