summaryrefslogtreecommitdiff
path: root/zephyr/shim
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/shim')
-rw-r--r--zephyr/shim/src/pwm_led.c14
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 */