diff options
author | Rajesh Kumar <rajesh3.kumar@intel.com> | 2022-01-06 17:56:00 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-11 18:01:00 +0000 |
commit | ecbc63992b3a5f4772bfb5ad9da25c21888e914c (patch) | |
tree | cdb9850e885654dc75889a0d1328de0605b7434f | |
parent | 4270aa209ef211185efd476b3478238c5ec60082 (diff) | |
download | chrome-ec-ecbc63992b3a5f4772bfb5ad9da25c21888e914c.tar.gz |
zephyr: brya: add hooks to enable kblight gpio
Add hooks to enable kblight gpio for brya board id 1 and 2
BUG=b:212541307
BRANCH=none
TEST=zmake testall
TEST=EC console command "kblight"
Signed-off-by: Rajesh Kumar <rajesh3.kumar@intel.com>
Change-Id: I656b2e2865ec9b4db413fea92e9c0b24559d929b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3371941
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r-- | zephyr/projects/brya/brya/CMakeLists.txt | 2 | ||||
-rw-r--r-- | zephyr/projects/brya/brya/kblight_hooks.c | 51 |
2 files changed, 53 insertions, 0 deletions
diff --git a/zephyr/projects/brya/brya/CMakeLists.txt b/zephyr/projects/brya/brya/CMakeLists.txt index c5f11ebf5f..857e59eb47 100644 --- a/zephyr/projects/brya/brya/CMakeLists.txt +++ b/zephyr/projects/brya/brya/CMakeLists.txt @@ -15,3 +15,5 @@ zephyr_include_directories(include zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM "${PLATFORM_EC_BASEBOARD}/cbi.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PWM_KBLIGHT + "kblight_hooks.c") diff --git a/zephyr/projects/brya/brya/kblight_hooks.c b/zephyr/projects/brya/brya/kblight_hooks.c new file mode 100644 index 0000000000..6e5c4cde03 --- /dev/null +++ b/zephyr/projects/brya/brya/kblight_hooks.c @@ -0,0 +1,51 @@ +/* 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. + */ + +#include <stdbool.h> + +#include "cbi.h" +#include "gpio.h" +#include "hooks.h" + +/* Enable/Disable keyboard backlight gpio */ +static inline void kbd_backlight_enable(bool enable) +{ + if (get_board_id() == 1) + gpio_set_level(GPIO_ID_1_EC_KB_BL_EN, enable); + else + gpio_set_level(GPIO_EC_KB_BL_EN_L, !enable); +} + +/* Called on AP S3 -> S0 transition */ +static void board_chipset_resume(void) +{ + /* Allow keyboard backlight to be enabled */ + + kbd_backlight_enable(true); +} +DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT); + +/* Called on AP S0 -> S3 transition */ +static void board_chipset_suspend(void) +{ + /* Turn off the keyboard backlight if it's on. */ + + kbd_backlight_enable(false); +} +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); + +/* + * Explicitly apply the board ID 1 *gpio.inc settings to pins that + * were reassigned on current boards. + */ + +static void set_board_id_1_gpios(void) +{ + if (get_board_id() != 1) + return; + + gpio_set_flags(GPIO_ID_1_EC_KB_BL_EN, GPIO_OUT_LOW); +} +DECLARE_HOOK(HOOK_INIT, set_board_id_1_gpios, HOOK_PRIO_FIRST); |