diff options
author | Kshitiz Godara <kgodara@qualcomm.corp-partner.google.com> | 2022-06-14 11:12:44 +0530 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-06-14 17:12:27 +0000 |
commit | d4511a09dfd816aece845e449852e017fbd0eafc (patch) | |
tree | f4aad83e96444bb7e3cef8cba6dab3ebf93bfe5b /zephyr/projects | |
parent | 8f6fc6ce71fa98ef593c41c359f1d97d4183ea75 (diff) | |
download | chrome-ec-d4511a09dfd816aece845e449852e017fbd0eafc.tar.gz |
zephyr: herobrine: Obsolete LED file removal
Removed obsolete source file and changed villager dt names for
uniformity. Also merged the LED configuration in common config and
removed from inidividual config.
BRANCH=None
BUG=None
TEST=Verified compilation for herobrine, villager and hoglin.
Tested on hoglin and LED color is changing based on charging states.
Signed-off-by: Kshitiz Godara <kgodara@qualcomm.corp-partner.google.com>
Change-Id: I5471b97ea554692a1da2750d85bb802642db1345
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3704918
Reviewed-by: Wai-Hong Tam <waihong@google.com>
Reviewed-by: Parth Malkan <parthmalkan@google.com>
Diffstat (limited to 'zephyr/projects')
-rw-r--r-- | zephyr/projects/herobrine/BUILD.py | 4 | ||||
-rw-r--r-- | zephyr/projects/herobrine/CMakeLists.txt | 2 | ||||
-rw-r--r-- | zephyr/projects/herobrine/led_pins_villager.dts (renamed from zephyr/projects/herobrine/gpio_led_villager.dts) | 0 | ||||
-rw-r--r-- | zephyr/projects/herobrine/led_policy_villager.dts (renamed from zephyr/projects/herobrine/led_villager.dts) | 5 | ||||
-rw-r--r-- | zephyr/projects/herobrine/prj.conf | 3 | ||||
-rw-r--r-- | zephyr/projects/herobrine/prj_herobrine.conf | 4 | ||||
-rw-r--r-- | zephyr/projects/herobrine/prj_hoglin.conf | 4 | ||||
-rw-r--r-- | zephyr/projects/herobrine/prj_villager.conf | 3 | ||||
-rw-r--r-- | zephyr/projects/herobrine/src/led.c | 175 |
9 files changed, 9 insertions, 191 deletions
diff --git a/zephyr/projects/herobrine/BUILD.py b/zephyr/projects/herobrine/BUILD.py index 6b333329e3..2a15441c55 100644 --- a/zephyr/projects/herobrine/BUILD.py +++ b/zephyr/projects/herobrine/BUILD.py @@ -66,8 +66,8 @@ register_variant( extra_dts_overlays=[ here / "battery_villager.dts", here / "gpio_villager.dts", - here / "gpio_led_villager.dts", - here / "led_villager.dts", + here / "led_pins_villager.dts", + here / "led_policy_villager.dts", here / "motionsense_villager.dts", here / "switchcap.dts", here / "usbc_villager.dts", diff --git a/zephyr/projects/herobrine/CMakeLists.txt b/zephyr/projects/herobrine/CMakeLists.txt index 64102e951c..537fa5ef68 100644 --- a/zephyr/projects/herobrine/CMakeLists.txt +++ b/zephyr/projects/herobrine/CMakeLists.txt @@ -12,8 +12,6 @@ cros_ec_library_include_directories(include) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usbc_config.c" "src/usb_pd_policy.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON - "src/led.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/i2c.c") diff --git a/zephyr/projects/herobrine/gpio_led_villager.dts b/zephyr/projects/herobrine/led_pins_villager.dts index 67a1d1926c..67a1d1926c 100644 --- a/zephyr/projects/herobrine/gpio_led_villager.dts +++ b/zephyr/projects/herobrine/led_pins_villager.dts diff --git a/zephyr/projects/herobrine/led_villager.dts b/zephyr/projects/herobrine/led_policy_villager.dts index 3bdf0147d7..46b0193e61 100644 --- a/zephyr/projects/herobrine/led_villager.dts +++ b/zephyr/projects/herobrine/led_policy_villager.dts @@ -1,3 +1,8 @@ +/* Copyright 2022 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + / { led-colors { compatible = "cros-ec,led-colors"; diff --git a/zephyr/projects/herobrine/prj.conf b/zephyr/projects/herobrine/prj.conf index 679c5c2424..a878b55f74 100644 --- a/zephyr/projects/herobrine/prj.conf +++ b/zephyr/projects/herobrine/prj.conf @@ -30,7 +30,8 @@ CONFIG_SHELL_TAB_AUTOCOMPLETION=y CONFIG_PLATFORM_EC_HIBERNATE_PSL=y # LED -CONFIG_PLATFORM_EC_LED_COMMON=y +CONFIG_PLATFORM_EC_LED_COMMON=n +CONFIG_PLATFORM_EC_LED_DT=y # PWM CONFIG_PWM=y diff --git a/zephyr/projects/herobrine/prj_herobrine.conf b/zephyr/projects/herobrine/prj_herobrine.conf index c91071d844..3c7eddbae6 100644 --- a/zephyr/projects/herobrine/prj_herobrine.conf +++ b/zephyr/projects/herobrine/prj_herobrine.conf @@ -5,10 +5,6 @@ # Herobrine-NPCX9 reference-board-specific Kconfig settings. CONFIG_BOARD_HEROBRINE=y -# LED -CONFIG_PLATFORM_EC_LED_COMMON=n -CONFIG_PLATFORM_EC_LED_DT=y - # Sensors CONFIG_PLATFORM_EC_ALS=y diff --git a/zephyr/projects/herobrine/prj_hoglin.conf b/zephyr/projects/herobrine/prj_hoglin.conf index 223596681c..370e942f45 100644 --- a/zephyr/projects/herobrine/prj_hoglin.conf +++ b/zephyr/projects/herobrine/prj_hoglin.conf @@ -13,7 +13,3 @@ CONFIG_PLATFORM_EC_ALS=y # Sensor Drivers CONFIG_PLATFORM_EC_ALS_TCS3400=y CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y -CONFIG_PLATFORM_EC_LED_COMMON=n diff --git a/zephyr/projects/herobrine/prj_villager.conf b/zephyr/projects/herobrine/prj_villager.conf index a63e003788..34c366a36f 100644 --- a/zephyr/projects/herobrine/prj_villager.conf +++ b/zephyr/projects/herobrine/prj_villager.conf @@ -5,7 +5,4 @@ # Villager board-specific Kconfig settings. CONFIG_BOARD_VILLAGER=y -# LED -CONFIG_PLATFORM_EC_LED_DT=y -CONFIG_PLATFORM_EC_LED_COMMON=n CONFIG_PLATFORM_EC_ACCEL_KX022=y diff --git a/zephyr/projects/herobrine/src/led.c b/zephyr/projects/herobrine/src/led.c deleted file mode 100644 index ac6092884d..0000000000 --- a/zephyr/projects/herobrine/src/led.c +++ /dev/null @@ -1,175 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Power and battery LED control. - */ - -#include <zephyr/drivers/gpio.h> - -#include "battery.h" -#include "charge_manager.h" -#include "charge_state.h" -#include "chipset.h" -#include "ec_commands.h" -#include "hooks.h" -#include "host_command.h" -#include "led_common.h" -#include "system.h" -#include "util.h" - -#define BAT_LED_ON 1 -#define BAT_LED_OFF 0 - -const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_RIGHT_LED, -#ifndef CONFIG_BOARD_HOGLIN - EC_LED_ID_LEFT_LED, -#endif -}; - -const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); - -enum led_color { - LED_OFF = 0, - LED_AMBER, - LED_WHITE, - LED_COLOR_COUNT /* Number of colors, not a color itself */ -}; - -static void side_led_set_color(int port, enum led_color color) -{ - gpio_pin_set_dt(port ? - GPIO_DT_FROM_NODELABEL(gpio_ec_chg_led_y_c1) : - GPIO_DT_FROM_NODELABEL(gpio_ec_chg_led_y_c0), - (color == LED_AMBER) ? BAT_LED_ON : BAT_LED_OFF); - gpio_pin_set_dt(port ? - GPIO_DT_FROM_NODELABEL(gpio_ec_chg_led_w_c1) : - GPIO_DT_FROM_NODELABEL(gpio_ec_chg_led_w_c0), - (color == LED_WHITE) ? BAT_LED_ON : BAT_LED_OFF); -} - -void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) -{ -#ifndef CONFIG_BOARD_HOGLIN - brightness_range[EC_LED_COLOR_AMBER] = 1; - brightness_range[EC_LED_COLOR_WHITE] = 1; -#else - brightness_range[EC_LED_COLOR_RED] = 1; - brightness_range[EC_LED_COLOR_BLUE] = 1; -#endif -} - -int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) -{ - int port; - - switch (led_id) { - case EC_LED_ID_RIGHT_LED: - port = 0; - break; - case EC_LED_ID_LEFT_LED: - port = 1; - break; - default: - return EC_ERROR_PARAM1; - } - - if (brightness[EC_LED_COLOR_WHITE] != 0) - side_led_set_color(port, LED_WHITE); - else if (brightness[EC_LED_COLOR_AMBER] != 0) - side_led_set_color(port, LED_AMBER); - else - side_led_set_color(port, LED_OFF); - - return EC_SUCCESS; -} - -/* - * Set active charge port color to the parameter, turn off all others. - * If no port is active (-1), turn off all LEDs. - */ -static void set_active_port_color(enum led_color color) -{ - int port = charge_manager_get_active_charge_port(); - - if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) - side_led_set_color(0, (port == 0) ? color : LED_OFF); - if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) - side_led_set_color(1, (port == 1) ? color : LED_OFF); -} - -static void board_led_set_battery(void) -{ - static int battery_ticks; - uint32_t chflags = charge_get_flags(); - - battery_ticks++; - - switch (charge_get_state()) { - case PWR_STATE_CHARGE: - /* Always indicate when charging, even in suspend. */ - set_active_port_color(LED_AMBER); - break; - case PWR_STATE_DISCHARGE: - if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) { - if (charge_get_percent() <= 10) - side_led_set_color(0, - (battery_ticks & 0x4) ? LED_WHITE : LED_OFF); - else - side_led_set_color(0, LED_OFF); - } - - if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) - side_led_set_color(1, LED_OFF); - break; - case PWR_STATE_ERROR: - set_active_port_color((battery_ticks & 0x2) ? - LED_WHITE : LED_OFF); - break; - case PWR_STATE_CHARGE_NEAR_FULL: - set_active_port_color(LED_WHITE); - break; - case PWR_STATE_IDLE: /* External power connected in IDLE */ - if (chflags & CHARGE_FLAG_FORCE_IDLE) - set_active_port_color((battery_ticks & 0x4) ? - LED_AMBER : LED_OFF); - else - set_active_port_color(LED_WHITE); - break; - default: - /* Other states don't alter LED behavior */ - break; - } -} - -/* Called by hook task every TICK */ -static void led_tick(void) -{ - board_led_set_battery(); -} -DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT); - -void led_control(enum ec_led_id led_id, enum ec_led_state state) -{ - enum led_color color; - - if ((led_id != EC_LED_ID_RECOVERY_HW_REINIT_LED) && - (led_id != EC_LED_ID_SYSRQ_DEBUG_LED)) - return; - - if (state == LED_STATE_RESET) { - led_auto_control(EC_LED_ID_LEFT_LED, 1); - led_auto_control(EC_LED_ID_RIGHT_LED, 1); - board_led_set_battery(); - return; - } - - color = state ? LED_WHITE : LED_OFF; - - led_auto_control(EC_LED_ID_LEFT_LED, 0); - led_auto_control(EC_LED_ID_RIGHT_LED, 0); - - side_led_set_color(0, color); - side_led_set_color(1, color); -} |