summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Baltieri <fabiobaltieri@google.com>2021-10-05 21:48:42 +0000
committerCommit Bot <commit-bot@chromium.org>2021-10-06 00:05:00 +0000
commit9b17a09cf339aecb77b462fbac2efbc122ca21da (patch)
treec968e1e1975c3fce44a903ef092736fb6f628011
parentaabb0eb2685f011fd50b41ba3df0b2b562d1fa83 (diff)
downloadchrome-ec-9b17a09cf339aecb77b462fbac2efbc122ca21da.tar.gz
zephyr: shim: make color-map- properties optional
These are not needed in few boards, make them default to zero. BRANCH=none BUG=b:177452529 TEST=build and gdb check led_color_map Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I83cd38d9438ee0d8d99ae187075c6f7f34791a17 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3207146 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/dts/bindings/led/cros-ec,pwm-leds.yaml17
-rw-r--r--zephyr/shim/src/pwm_led.c20
2 files changed, 23 insertions, 14 deletions
diff --git a/zephyr/dts/bindings/led/cros-ec,pwm-leds.yaml b/zephyr/dts/bindings/led/cros-ec,pwm-leds.yaml
index fd99e3202a..cad2e14088 100644
--- a/zephyr/dts/bindings/led/cros-ec,pwm-leds.yaml
+++ b/zephyr/dts/bindings/led/cros-ec,pwm-leds.yaml
@@ -35,9 +35,10 @@ properties:
color-map-red:
type: array
- required: true
+ required: false
description: |
- A map of PWM duty cycles per color, up to three channels.
+ A map of PWM duty cycles per color, up to three channels. Unset values
+ default to zero.
For example
color-map-red = <100 0 0>;
@@ -49,27 +50,27 @@ properties:
color-map-green:
type: array
- required: true
+ required: false
color-map-blue:
type: array
- required: true
+ required: false
color-map-yellow:
type: array
- required: true
+ required: false
color-map-white:
type: array
- required: true
+ required: false
color-map-amber:
type: array
- required: true
+ required: false
brightness-range:
type: array
- required: true
+ required: false
description: |
A list of brigthness range value for all supported channels in order,
Red, Green, Blue, Yellow, White, Amber (0 to 255).
diff --git a/zephyr/shim/src/pwm_led.c b/zephyr/shim/src/pwm_led.c
index 2646f09c43..4fef611a76 100644
--- a/zephyr/shim/src/pwm_led.c
+++ b/zephyr/shim/src/pwm_led.c
@@ -41,13 +41,21 @@ struct pwm_led pwm_leds[] = {
DT_INST_FOREACH_PROP_ELEM(0, leds, PWM_LED_INIT)
};
+#define EC_LED_COLOR_BLANK {0}
+
struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
- [EC_LED_COLOR_RED] = DT_INST_PROP(0, color_map_red),
- [EC_LED_COLOR_GREEN] = DT_INST_PROP(0, color_map_green),
- [EC_LED_COLOR_BLUE] = DT_INST_PROP(0, color_map_blue),
- [EC_LED_COLOR_YELLOW] = DT_INST_PROP(0, color_map_yellow),
- [EC_LED_COLOR_WHITE] = DT_INST_PROP(0, color_map_white),
- [EC_LED_COLOR_AMBER] = DT_INST_PROP(0, color_map_amber),
+ [EC_LED_COLOR_RED] = DT_INST_PROP_OR(0, color_map_red,
+ EC_LED_COLOR_BLANK),
+ [EC_LED_COLOR_GREEN] = DT_INST_PROP_OR(0, color_map_green,
+ EC_LED_COLOR_BLANK),
+ [EC_LED_COLOR_BLUE] = DT_INST_PROP_OR(0, color_map_blue,
+ EC_LED_COLOR_BLANK),
+ [EC_LED_COLOR_YELLOW] = DT_INST_PROP_OR(0, color_map_yellow,
+ EC_LED_COLOR_BLANK),
+ [EC_LED_COLOR_WHITE] = DT_INST_PROP_OR(0, color_map_white,
+ EC_LED_COLOR_BLANK),
+ [EC_LED_COLOR_AMBER] = DT_INST_PROP_OR(0, color_map_amber,
+ EC_LED_COLOR_BLANK),
};
BUILD_ASSERT(DT_INST_PROP_LEN(0, brightness_range) == EC_LED_COLOR_COUNT,