summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormick_hsiao <mick_hsiao@compal.corp-partner.google.com>2023-03-23 11:31:43 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-10 12:12:47 +0000
commit7de11dc636bc6cee6dfbb52b83407710e6257909 (patch)
tree0f7ed511b43dcb3e3ac279fc3596a1b6c9282685
parent5afa300f8f2066970719167af4d68aca50fc03c0 (diff)
downloadchrome-ec-7de11dc636bc6cee6dfbb52b83407710e6257909.tar.gz
Uldren: LED setting
set LED behavior in different power state BUG=b:274744844 BRANCH=none TEST=zmake build uldren successfully Change-Id: Ibac078642bc147319eaf8b0c62374e8e69a28c7c Signed-off-by: mick_hsiao <mick_hsiao@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4362342 Reviewed-by: Josh Tsai <josh_tsai@compal.corp-partner.google.com> Commit-Queue: Kyle Lin <kylelinck@google.com> Tested-by: Kyle Lin <kylelinck@google.com> Reviewed-by: Kyle Lin <kylelinck@google.com> Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
-rw-r--r--zephyr/program/nissa/CMakeLists.txt1
-rw-r--r--zephyr/program/nissa/uldren/led_pins.dtsi62
-rw-r--r--zephyr/program/nissa/uldren/led_policy.dtsi115
-rw-r--r--zephyr/program/nissa/uldren/project.conf2
-rw-r--r--zephyr/program/nissa/uldren/project.overlay17
-rw-r--r--zephyr/program/nissa/uldren/pwm_leds.dtsi62
-rw-r--r--zephyr/program/nissa/uldren/src/led.c51
7 files changed, 187 insertions, 123 deletions
diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt
index eaaa2ebee1..97b25e7e06 100644
--- a/zephyr/program/nissa/CMakeLists.txt
+++ b/zephyr/program/nissa/CMakeLists.txt
@@ -114,7 +114,6 @@ endif()
if(DEFINED CONFIG_BOARD_ULDREN)
project(uldren)
zephyr_library_sources(
- "uldren/src/led.c"
"uldren/src/keyboard.c"
)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "uldren/src/fan.c")
diff --git a/zephyr/program/nissa/uldren/led_pins.dtsi b/zephyr/program/nissa/uldren/led_pins.dtsi
new file mode 100644
index 0000000000..e9003ffc30
--- /dev/null
+++ b/zephyr/program/nissa/uldren/led_pins.dtsi
@@ -0,0 +1,62 @@
+/* Copyright 2023 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ pwmleds {
+ compatible = "pwm-leds";
+ pwm_led_y_c0: pwm_led_y_c0 {
+ pwms = <&pwm2 2 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+ pwm_led_w_c0: pwm_led_w_c0 {
+ pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+ /* reserve to use */
+ pwms = <&pwm1 1 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+
+ pwm-led-pins {
+ compatible = "cros-ec,pwm-led-pins";
+
+ color_off: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pwms = <&pwm_led_y_c0 &pwm_led_w_c0>;
+ led-values = <0 0>;
+ };
+
+ color_amber: color-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pwms = <&pwm_led_y_c0 &pwm_led_w_c0>;
+ led-values = <100 0>;
+ };
+
+ color_white: color-white {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-pwms = <&pwm_led_y_c0 &pwm_led_w_c0>;
+ led-values = <0 100>;
+ };
+ };
+};
+
+/* LED2 */
+&pwm0 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm0_gpc3>;
+ pinctrl-names = "default";
+};
+
+/* LED1 */
+&pwm2 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
+
diff --git a/zephyr/program/nissa/uldren/led_policy.dtsi b/zephyr/program/nissa/uldren/led_policy.dtsi
new file mode 100644
index 0000000000..95c614cafc
--- /dev/null
+++ b/zephyr/program/nissa/uldren/led_policy.dtsi
@@ -0,0 +1,115 @@
+#include <dt-bindings/battery.h>
+
+/ {
+ led-colors {
+ compatible = "cros-ec,led-policy";
+
+ power-state-charge {
+ charge-state = "PWR_STATE_CHARGE";
+ batt-lvl = <BATTERY_LEVEL_EMPTY
+ BATTERY_LEVEL_NEAR_FULL>;
+
+ color-0 {
+ led-color = <&color_white>;
+ };
+ };
+
+ power-state-near-full {
+ charge-state = "PWR_STATE_CHARGE_NEAR_FULL";
+
+ color-0 {
+ led-color = <&color_off>;
+ };
+ };
+
+ power-state-discharge-s0 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+ batt-lvl = <BATTERY_LEVEL_LOW BATTERY_LEVEL_FULL>;
+
+ color-0 {
+ led-color = <&color_off>;
+ };
+ };
+
+ power-state-discharge-s3 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S3";
+
+ color-0 {
+ led-color = <&color_off>;
+ };
+ };
+
+ power-state-discharge-s5 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S5";
+
+ color-0 {
+ led-color = <&color_off>;
+ };
+ };
+
+ power-state-discharge-s0-batt-low {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+ batt-lvl = <BATTERY_LEVEL_EMPTY BATTERY_LEVEL_LOW>;
+
+ color-0 {
+ led-color = <&color_amber>;
+ };
+ };
+
+ power-state-discharge-s3-batt-low {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S3";
+ batt-lvl = <BATTERY_LEVEL_EMPTY BATTERY_LEVEL_LOW>;
+
+ color-0 {
+ led-color = <&color_amber>;
+ };
+ };
+
+ power-state-error-s0 {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S0";
+ /* Amber 1 sec, off 1 sec */
+ color-0 {
+ led-color = <&color_amber>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <1000>;
+ };
+ };
+
+ power-state-error-s3 {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S3";
+ /* Amber 1 sec, off 3 sec */
+ color-0 {
+ led-color = <&color_amber>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <3000>;
+ };
+ };
+
+ power-state-error-s5 {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S5";
+ /* Amber 1 sec, off 3 sec */
+ color-0 {
+ led-color = <&color_amber>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <3000>;
+ };
+ };
+ };
+};
diff --git a/zephyr/program/nissa/uldren/project.conf b/zephyr/program/nissa/uldren/project.conf
index 4b735e69ec..0c64e7ad3d 100644
--- a/zephyr/program/nissa/uldren/project.conf
+++ b/zephyr/program/nissa/uldren/project.conf
@@ -17,5 +17,5 @@ CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_CDP_SDP_ONLY=y
CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_DEFAULT_CDP=y
CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_INVERTED=y
-#Disable keyboard backlight
+# Disable keyboard backlight
CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=n
diff --git a/zephyr/program/nissa/uldren/project.overlay b/zephyr/program/nissa/uldren/project.overlay
index 9ca681d979..10b76b0080 100644
--- a/zephyr/program/nissa/uldren/project.overlay
+++ b/zephyr/program/nissa/uldren/project.overlay
@@ -3,12 +3,13 @@
* found in the LICENSE file.
*/
-#include "../cbi.dtsi"
+ #include "../cbi.dtsi"
-#include "cbi.dtsi"
-#include "generated.dtsi"
-#include "keyboard.dtsi"
-#include "motionsense.dtsi"
-#include "overlay.dtsi"
-#include "power_signals.dtsi"
-#include "pwm_leds.dtsi"
+ #include "cbi.dtsi"
+ #include "generated.dtsi"
+ #include "keyboard.dtsi"
+ #include "led_pins.dtsi"
+ #include "led_policy.dtsi"
+ #include "motionsense.dtsi"
+ #include "overlay.dtsi"
+ #include "power_signals.dtsi"
diff --git a/zephyr/program/nissa/uldren/pwm_leds.dtsi b/zephyr/program/nissa/uldren/pwm_leds.dtsi
deleted file mode 100644
index a265a5929e..0000000000
--- a/zephyr/program/nissa/uldren/pwm_leds.dtsi
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- pwmleds {
- compatible = "pwm-leds";
- pwm_led0: pwm_led_0 {
- pwms = <&pwm2 2 PWM_HZ(324) PWM_POLARITY_INVERTED>,
- <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>,
- <&pwm1 1 PWM_HZ(324) PWM_POLARITY_INVERTED>;
- };
- };
-
- cros-pwmleds {
- compatible = "cros-ec,pwm-leds";
-
- leds = <&pwm_led0>;
-
- /*<red green blue>*/
- color-map-red = <100 0 0>;
- color-map-green = < 0 100 0>;
- color-map-blue = < 0 0 100>;
- color-map-yellow = < 0 50 50>;
- color-map-white = <100 100 100>;
- color-map-amber = <100 0 0>;
-
- brightness-range = <0 0 100 0 0 100>;
-
- #address-cells = <1>;
- #size-cells = <0>;
-
- pwm_led_0@0 {
- reg = <0>;
- ec-led-name = "EC_LED_ID_BATTERY_LED";
- };
- };
-};
-
-/* Enable LEDs to work while CPU suspended */
-
-&pwm0 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm0_gpc3>;
- pinctrl-names = "default";
-};
-
-&pwm1 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm1_gpc2>;
- pinctrl-names = "default";
-};
-
-&pwm2 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm2_gpc4>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/program/nissa/uldren/src/led.c b/zephyr/program/nissa/uldren/src/led.c
deleted file mode 100644
index f9e93f47e9..0000000000
--- a/zephyr/program/nissa/uldren/src/led.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright 2023 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Battery LED control for nissa
- */
-#include "common.h"
-#include "ec_commands.h"
-#include "led_common.h"
-#include "led_onoff_states.h"
-#include "led_pwm.h"
-
-__override const int led_charge_lvl_1 = 5;
-__override const int led_charge_lvl_2 = 97;
-__override struct led_descriptor
- led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = {
- [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER,
- LED_INDEFINITE } },
- [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER,
- LED_INDEFINITE } },
- [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_BLUE,
- LED_INDEFINITE } },
- [STATE_DISCHARGE_S0] = { { EC_LED_COLOR_BLUE,
- LED_INDEFINITE } },
- [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER,
- LED_INDEFINITE } },
- [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } },
- [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } },
- [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER,
- 1 * LED_ONE_SEC },
- { LED_OFF, 1 * LED_ONE_SEC } },
- [STATE_FACTORY_TEST] = { { EC_LED_COLOR_AMBER,
- 2 * LED_ONE_SEC },
- { EC_LED_COLOR_BLUE,
- 2 * LED_ONE_SEC } },
- };
-
-__override void led_set_color_battery(enum ec_led_colors color)
-{
- switch (color) {
- case EC_LED_COLOR_BLUE:
- set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_BLUE);
- break;
- case EC_LED_COLOR_AMBER:
- set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_AMBER);
- break;
- default: /* LED_OFF and other unsupported colors */
- set_pwm_led_color(EC_LED_ID_BATTERY_LED, -1);
- break;
- }
-}