diff options
author | Mulin Chao <mlchao@nuvoton.com> | 2019-04-22 19:15:06 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-01 01:50:25 -0700 |
commit | a24c74c759ba98df67935a344e31dfe494605237 (patch) | |
tree | 180a0b27c0ae5ee5f56994deb212ee0bb362069a /common | |
parent | b7e78ed3873c250983437b28e182bfcfcd76d285 (diff) | |
download | chrome-ec-a24c74c759ba98df67935a344e31dfe494605237.tar.gz |
common: led_pwm: Enable pwm modules for each channels of LEDs.
Since pwm_set_raw_duty() won't enable pwm module when its duty is not
zero automatically after CL 1475096 was merged, this CL enables all pwm
modules used by LEDs in init_leds_off(). Then we can see pwm output
signals when set_led_color() is executed.
BRANCH=none
BUG=b:123552920
TEST=No build errors for npcx7 series. LED light was observed on grunt
when a charger is plugged in.
Change-Id: Icd2d19d24dc0354519561f145244f9ae8e9af93b
Signed-off-by: Caveh Jalali <caveh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1575883
Commit-Ready: Caveh Jalali <caveh@google.com>
Tested-by: caveh jalali <caveh@chromium.org>
Tested-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: caveh jalali <caveh@chromium.org>
Reviewed-by: Caveh Jalali <caveh@google.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/led_pwm.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/common/led_pwm.c b/common/led_pwm.c index d167a5bd6f..dd8f33a137 100644 --- a/common/led_pwm.c +++ b/common/led_pwm.c @@ -90,10 +90,30 @@ static void set_led_color(int color) #endif /* CONFIG_LED_PWM_COUNT >= 2 */ } +static void set_pwm_led_enable(enum pwm_led_id id, int enable) +{ + if ((id >= CONFIG_LED_PWM_COUNT) || (id < 0)) + return; + + if (pwm_leds[id].ch0 != PWM_LED_NO_CHANNEL) + pwm_enable(pwm_leds[id].ch0, enable); + if (pwm_leds[id].ch1 != PWM_LED_NO_CHANNEL) + pwm_enable(pwm_leds[id].ch1, enable); + if (pwm_leds[id].ch2 != PWM_LED_NO_CHANNEL) + pwm_enable(pwm_leds[id].ch2, enable); +} + static void init_leds_off(void) { - /* Turn off LEDs such that they are in a known state. */ + /* Turn off LEDs such that they are in a known state with zero duty. */ set_led_color(-1); + + /* Enable pwm modules for each channels of LEDs */ + set_pwm_led_enable(PWM_LED0, 1); + +#if CONFIG_LED_PWM_COUNT >= 2 + set_pwm_led_enable(PWM_LED1, 1); +#endif /* CONFIG_LED_PWM_COUNT >= 2 */ } DECLARE_HOOK(HOOK_INIT, init_leds_off, HOOK_PRIO_INIT_PWM + 1); |