diff options
author | Michał Barnaś <mb@semihalf.com> | 2021-08-11 15:11:46 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-08-16 13:26:17 +0000 |
commit | d6ad168804224a29d03653c6480d46288d4dfc23 (patch) | |
tree | 36ebaeb88251f9534dea778fb346a24548c69af7 | |
parent | 7c684a81a49c03cb5c8688c8607e883f7604dad8 (diff) | |
download | chrome-ec-d6ad168804224a29d03653c6480d46288d4dfc23.tar.gz |
zephyr: Add switchcap for herobrine_npcx9 to device tree
This patch removes custom switchcap logic and uses
device tree implementation instead.
BRANCH=main
BUG=b:194211207
TEST=Compile and flash Zephyr's EC for herobrine_npcx9
Powering on and off should work correctly
Change-Id: Ice51e097c2126e78c6dbfb933a10724cf0374f67
Signed-off-by: Michał Barnaś <mb@semihalf.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3089119
Reviewed-by: Keith Short <keithshort@chromium.org>
6 files changed, 19 insertions, 26 deletions
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/CMakeLists.txt b/zephyr/projects/herobrine/herobrine_npcx9/CMakeLists.txt index 23b3a2c245..e6ac68192b 100644 --- a/zephyr/projects/herobrine/herobrine_npcx9/CMakeLists.txt +++ b/zephyr/projects/herobrine/herobrine_npcx9/CMakeLists.txt @@ -19,5 +19,4 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/i2c.c") zephyr_library_sources( - "src/battery.c" - "src/switchcap.c") + "src/battery.c") diff --git a/zephyr/projects/herobrine/herobrine_npcx9/gpio.dts b/zephyr/projects/herobrine/herobrine_npcx9/gpio.dts index fb8c0d8778..aa023e9110 100644 --- a/zephyr/projects/herobrine/herobrine_npcx9/gpio.dts +++ b/zephyr/projects/herobrine/herobrine_npcx9/gpio.dts @@ -151,7 +151,7 @@ enum-name = "GPIO_EC_INT_L"; label = "AP_EC_INT_L"; }; - switchcap_on { + gpio_switchcap_on: switchcap_on { gpios = <&gpiod 5 GPIO_OUT_LOW>; enum-name = "GPIO_SWITCHCAP_ON"; label = "SWITCHCAP_ON"; @@ -272,7 +272,7 @@ enum-name = "GPIO_SKU_ID2"; label = "SKU_ID2"; }; - src_vph_pwr_pg { + gpio_switchcap_pg: src_vph_pwr_pg { gpios = <&gpioe 2 (GPIO_INPUT | GPIO_PULL_DOWN)>; enum-name = "GPIO_SWITCHCAP_PG"; label = "SRC_VPH_PWR_PG"; diff --git a/zephyr/projects/herobrine/herobrine_npcx9/prj.conf b/zephyr/projects/herobrine/herobrine_npcx9/prj.conf index 03dbb23338..055ec976dd 100644 --- a/zephyr/projects/herobrine/herobrine_npcx9/prj.conf +++ b/zephyr/projects/herobrine/herobrine_npcx9/prj.conf @@ -31,6 +31,9 @@ CONFIG_PLATFORM_EC_PWM_KBLIGHT=y # Application Processor is Qualcomm SC7280 CONFIG_AP_ARM_QUALCOMM_SC7280=y +# GPIO Switchcap +CONFIG_PLATFORM_EC_SWITCHCAP_GPIO=y + # Board version is selected over GPIO board ID pins. CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y diff --git a/zephyr/projects/herobrine/herobrine_npcx9/src/switchcap.c b/zephyr/projects/herobrine/herobrine_npcx9/src/switchcap.c deleted file mode 100644 index 16b0db6ef6..0000000000 --- a/zephyr/projects/herobrine/herobrine_npcx9/src/switchcap.c +++ /dev/null @@ -1,22 +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. - */ - -#include "gpio.h" -#include "power/qcom.h" - -void board_set_switchcap_power(int enable) -{ - gpio_set_level(GPIO_SWITCHCAP_ON, enable); -} - -int board_is_switchcap_enabled(void) -{ - return gpio_get_level(GPIO_SWITCHCAP_ON); -} - -int board_is_switchcap_power_good(void) -{ - return gpio_get_level(GPIO_SWITCHCAP_PG); -} diff --git a/zephyr/projects/herobrine/herobrine_npcx9/switchcap.dts b/zephyr/projects/herobrine/herobrine_npcx9/switchcap.dts new file mode 100644 index 0000000000..b246274a7a --- /dev/null +++ b/zephyr/projects/herobrine/herobrine_npcx9/switchcap.dts @@ -0,0 +1,12 @@ +/* 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. + */ + +/ { + switchcap { + compatible = "switchcap-gpio"; + enable-pin = <&gpio_switchcap_on>; + power-good-pin = <&gpio_switchcap_pg>; + }; +}; diff --git a/zephyr/projects/herobrine/herobrine_npcx9/zmake.yaml b/zephyr/projects/herobrine/herobrine_npcx9/zmake.yaml index 5f93cd9f45..530278c5e7 100644 --- a/zephyr/projects/herobrine/herobrine_npcx9/zmake.yaml +++ b/zephyr/projects/herobrine/herobrine_npcx9/zmake.yaml @@ -8,6 +8,7 @@ dts-overlays: - battery.dts - i2c.dts - motionsense.dts + - switchcap.dts supported-zephyr-versions: - v2.6 toolchain: coreboot-sdk |