diff options
author | Fabio Baltieri <fabiobaltieri@google.com> | 2021-09-20 17:05:01 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-09-22 20:49:48 +0000 |
commit | 2c0d93a1ae43c4ed9745005f46787fcaf7285b39 (patch) | |
tree | bc26735734db186928d2d4c939dacb4a5716e7dd /zephyr/shim/src | |
parent | ba61af3b8c8a1f04caba91c4a264c78c1fe7d77b (diff) | |
download | chrome-ec-2c0d93a1ae43c4ed9745005f46787fcaf7285b39.tar.gz |
zephyr: shim: implement a generic led_get_brightness_range
Implement a generic led_get_brightness_range function using static
values from the device tree. This is currently ignoring led_id, but no
pwm_led based device is using it right now anyway, so this could cover
all existing use cases.
BRANCH=none
BUG=b:177452529
TEST=called the function, verified the values in runtime
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change-Id: I67dc7564eb6724e401961261ff5cc5892899ad5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3170401
Reviewed-by: Yuval Peress <peress@google.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/shim/src')
-rw-r--r-- | zephyr/shim/src/pwm_led.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/zephyr/shim/src/pwm_led.c b/zephyr/shim/src/pwm_led.c index 879f339b24..48565d2e56 100644 --- a/zephyr/shim/src/pwm_led.c +++ b/zephyr/shim/src/pwm_led.c @@ -5,6 +5,7 @@ #define DT_DRV_COMPAT cros_ec_pwm_leds +#include <string.h> #include <devicetree.h> #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) @@ -43,4 +44,17 @@ struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = { [EC_LED_COLOR_AMBER] = DT_INST_PROP(0, color_map_amber), }; +BUILD_ASSERT(DT_INST_PROP_LEN(0, brightness_range) == EC_LED_COLOR_COUNT, + "brightness_range must have exactly EC_LED_COLOR_COUNT values"); + +static const uint8_t dt_brigthness_range[EC_LED_COLOR_COUNT] = DT_INST_PROP( + 0, brightness_range); + +void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) +{ + /* led_id is ignored, same ranges for all LEDs */ + memcpy(brightness_range, dt_brigthness_range, + sizeof(dt_brigthness_range)); +} + #endif /* DT_HAS_COMPAT_STATUS_OKAY */ |