summaryrefslogtreecommitdiff
path: root/common/led_pwm.c
Commit message (Collapse)AuthorAgeFilesLines
* common: led_pwm: Enable pwm modules for each channels of LEDs.Mulin Chao2019-05-011-1/+21
| | | | | | | | | | | | | | | | | | | | | 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>
* led_pwm: use NEAR_FULL_COLOR when discharging-on-acCaveh Jalali2019-04-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | when CONFIG_PWR_STATE_DISCHARGE_FULL is enabled for a board, the charge state machine can enter a special PWR_STATE_DISCHARGE_FULL state used to indicate that we're on AC but powering the system from the battery. the system will hover in-and-out of this state over time while on AC. this should generally be transparent to the user, so we should indicate it using the LEDs the same way we indicate PWR_STATE_CHARGE_NEAR_FULL. BUG=b:128709632 BRANCH=none TEST=verified LED stays white on atlas while battery is draining on AC. LED goes out when charger is removed Change-Id: I3af6783bcdbe399a444099fcee8ebab07451ff2c Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1570613 Commit-Ready: Caveh Jalali <caveh@google.com> Tested-by: caveh jalali <caveh@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* led_pwm: Add CONFIG_LED_PWM_CHARGE_STATE_ONLYEdward Hill2018-11-211-7/+7
| | | | | | | | | | | | | | | 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 <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1344795 Tested-by: Josh Tsai <josh_tsai@compal.corp-partner.google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
* led_pwm: Fix pulsing bug after init.Aseda Aboagye2018-11-131-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | When the LED code starts determining what pattern to display, the charge state machine returns an error briefly at init. (The error is that the battery present status is unknown). Once it determines the battery is present, it no longer returns an error, but the LED code doesn't cancel the pulsing pattern. This commit simply fixes that bug. BUG=None BRANCH=firmware-nocturne-10984.B TEST=Flash nocturne; hibernate; wake via power button, verify that the LEDs do not pulse red continuously. Change-Id: Ibe225ba4c136b8758948bd72d9ba688cff15d9e9 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1239548 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> (cherry picked from commit a7a9223c640cfbd86fb0cac4d60d5ee9a233cc8c) Reviewed-on: https://chromium-review.googlesource.com/1332809 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* led_pwm: Turn off inactive charge port LEDs.Aseda Aboagye2018-11-131-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | When a board is configured to only show the charging led on the active charge port, we should ensure that the other ports' charging LED is turned off. This commit fixes a bug where both ports LEDs could remain lit even though there's only one active charge port at a time. BUG=b:116020780 BRANCH=firmware-nocturne-10984.B TEST=Plug in a low power charger on one port, plug in a higher powered charger on a different port, verify that the charging LED switches to the higher powered port and the other LED is off. Change-Id: I48992e36f49346c920170c5bf90761776824af48 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1239547 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> (cherry picked from commit 8d3e6bdaaca89ffda59ddb1fa01a6df921716bc7) Reviewed-on: https://chromium-review.googlesource.com/1333147 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* led_pwm: Turn off LEDs when not pulsing.Aseda Aboagye2018-07-311-0/+6
| | | | | | | | | | | | | | | | | | | | | | This commit fixes a bug where sometimes if the EC was showing battery error LED lights, one side would remain lit with the error condition. This is because it's possible that the EC decided not to pulse the LEDs anymore while in the "on" period. That coupled with showing the charging state on the active charge only, would mean that until an unplug happened, the other LED could remain lit. BUG=None BRANCH=None TEST=Flash nocturne; cutoff battery, plug AC in, verify that only the charge port LED is on. Change-Id: I3cf09d31749bc783b1507045e58b8b97968bae4b Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1155763 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* cleanup: Resolve some defects seen with Coverity.Jonathan Brandmeyer2018-07-201-2/+2
| | | | | | | | | | | | | | | | | | - Correct two range checks in set_pwm_led_color(). The erroneous checks allowed a real array out-of-bounds error accessible via the EC console. Scope is limited to pre-release hardware that had enabled CONFIG_CMD_LEDTEST. - Correct comparisons of unsigned integers to a negative constant. - Add an explicit /* fallthrough */ on an un-recognized deliberate fallthrough. TEST=make -j buildall BUG=none BRANCH=none Change-Id: Ifc460427729ce597e945142f0256a1364b0a083e Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1145051 Reviewed-by: Edward Hill <ecgh@chromium.org>
* led_pwm: Add CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY.Aseda Aboagye2018-06-271-26/+90
| | | | | | | | | | | | | | | | | | This commit adds support for a feature for the common PWM controlled LED behaviour to only show the charge state instead of including chipset state and low battery state as well. Additionally, this feature will only illuminate the LED of the active charge port. BUG=b:69138917 BRANCH=None TEST=Enable option on nocturne and verify behavior is as expected. Change-Id: Ie6a767084c9102ff9b7bdad9288fcebf2ed9706f Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1109032 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* led_pwm: Add a few more features to the ledtest commandSimon Glass2018-02-151-5/+10
| | | | | | | | | | | | | | | | | | | Add a way to report the current state using this command. This is useful when debugging. BUG=b:71902053 BRANCH=none TEST=manually > ledtest 0 PWM LED 0: led_id=0, auto_control=1 > ledtest 0 enable amber > ledtest 0 PWM LED 0: led_id=0, auto_control=0 Change-Id: I478980d82573b60b536ea0f4dcf324b7ccfb6fdb Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/919764
* common: Add support for PWM LEDs.Aseda Aboagye2018-02-051-0/+206
This commit adds support for a common framework for PWM controlled LEDs. If there are multiple LEDs, they will all follow the same pattern. The pattern is such that it follows the Chrome OS LED behaviour specification, essentially a similar version of led_policy_std.c but for PWM controlled LEDs. To use this framework, a board must do the following: - First, define the number of logical PWM LEDs which will be controlled by this common policy, CONFIG_LED_PWM_COUNT. - Then declare those logical LEDs and define the PWM channels that comprise those LEDs. (struct pwm_led pwm_leds[]). - Next, define what each color should look like (struct pwm_led led_color_map[]). By default, the colors follow the recommended colors in the LED behaviour spec, which assume an LED with a red and green channel. If a board differs or wishes to change the colors in general, they can redefine the colors (CONFIG_LED_PWM_*_COLOR) as they see fit. The colors must be one in enum ec_led_colors. These colors are the ones that can represent the charging state, SoC state, etc. BUG=b:69138917,chromium:752553 BRANCH=None TEST=make -j buildall TEST=Enable led_pwm for meowth, and verify that LEDs behave as expected. Change-Id: I945b86a7f8ed30df58d7da835d83577192548bea Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/888220 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>