diff options
author | Denis Brockus <dbrockus@google.com> | 2021-10-26 16:50:44 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-03 21:43:57 +0000 |
commit | 7709b473263a7d8a740080ccbc848c54c76569d9 (patch) | |
tree | 9f1aeebc0c0617a43fa375121b56270955bed0ab | |
parent | 67b3cae16ba1a80407ccf7f82ec7695ba6cd44c1 (diff) | |
download | chrome-ec-7709b473263a7d8a740080ccbc848c54c76569d9.tar.gz |
zephyr: mt8192: gather power-signal information from DT
This currently only uses DT power-signal for
platforms that define CONFIG_AP_ARM_MTK_MT8192
BUG=b:188674805
BRANCH=none
TEST=zmake testall
Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: I151c451f0725449459744b1ebda042c0c3aa6ad8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3246296
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
Tested-by: Denis Brockus <dbrockus@chromium.org>
Auto-Submit: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | include/power/mt8192.h | 4 | ||||
-rw-r--r-- | power/mt8192.c | 4 | ||||
-rw-r--r-- | zephyr/dts/bindings/cros_pwr_signal/mediatek,power-signal-list.yaml | 19 | ||||
-rw-r--r-- | zephyr/dts/bindings/cros_pwr_signal/power-signal-list.yaml | 24 | ||||
-rw-r--r-- | zephyr/projects/asurada/hayato/gpio.dts | 29 | ||||
-rw-r--r-- | zephyr/projects/corsola/krabby/gpio.dts | 29 | ||||
-rw-r--r-- | zephyr/shim/include/board.h | 3 | ||||
-rw-r--r-- | zephyr/shim/include/power/power.h | 83 | ||||
-rw-r--r-- | zephyr/shim/src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/shim/src/power.c | 21 |
10 files changed, 205 insertions, 12 deletions
diff --git a/include/power/mt8192.h b/include/power/mt8192.h index e0c65c3bcc..7a992001ab 100644 --- a/include/power/mt8192.h +++ b/include/power/mt8192.h @@ -6,6 +6,8 @@ #ifndef __CROS_EC_POWER_MT8192_H_ #define __CROS_EC_POWER_MT8192_H_ +#ifndef CONFIG_ZEPHYR + enum power_signal { PMIC_PWR_GOOD, AP_IN_S3_L, @@ -13,4 +15,6 @@ enum power_signal { POWER_SIGNAL_COUNT, }; +#endif /* !CONFIG_ZEPHYR */ + #endif /* __CROS_EC_POWER_MT8192_H_ */ diff --git a/power/mt8192.c b/power/mt8192.c index f1c8e994c1..1ec7a79c42 100644 --- a/power/mt8192.c +++ b/power/mt8192.c @@ -79,6 +79,8 @@ /* 30 ms for hard reset, we hold it longer to prevent TPM false alarm. */ #define SYS_RST_PULSE_LENGTH (50 * MSEC) +#ifndef CONFIG_ZEPHYR + /* power signal list. Must match order of enum power_signal. */ const struct power_signal_info power_signal_list[] = { {GPIO_PMIC_EC_PWRGD, POWER_SIGNAL_ACTIVE_HIGH, "PMIC_PWR_GOOD"}, @@ -87,6 +89,8 @@ const struct power_signal_info power_signal_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); +#endif /* !CONFIG_ZEPHYR */ + static int forcing_shutdown; static void watchdog_interrupt_deferred(void) diff --git a/zephyr/dts/bindings/cros_pwr_signal/mediatek,power-signal-list.yaml b/zephyr/dts/bindings/cros_pwr_signal/mediatek,power-signal-list.yaml new file mode 100644 index 0000000000..0fddc44b37 --- /dev/null +++ b/zephyr/dts/bindings/cros_pwr_signal/mediatek,power-signal-list.yaml @@ -0,0 +1,19 @@ +# Copyright 2021 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +description: MediaTek, Power Signal List +compatible: "mediatek,power-signal-list" + +include: power-signal-list.yaml + +properties: + power-signals-required: + default: 3 + +child-binding: + properties: + power-enum-name: + enum: + - AP_IN_S3_L + - AP_WDT_ASSERTED + - PMIC_PWR_GOOD diff --git a/zephyr/dts/bindings/cros_pwr_signal/power-signal-list.yaml b/zephyr/dts/bindings/cros_pwr_signal/power-signal-list.yaml new file mode 100644 index 0000000000..1346968cc0 --- /dev/null +++ b/zephyr/dts/bindings/cros_pwr_signal/power-signal-list.yaml @@ -0,0 +1,24 @@ +# Copyright 2021 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +description: Power Signal List + +properties: + power-signals-required: + description: + Number of power-signal children there should be for the current AP + type: int + +child-binding: + description: Power Signal List child node + properties: + gpio: + description: + PHandle to the associated GPIO + type: phandle + required: true + power-enum-name: + description: + Enumeration values for power-signal-list + type: string + required: true diff --git a/zephyr/projects/asurada/hayato/gpio.dts b/zephyr/projects/asurada/hayato/gpio.dts index f04171651f..3c62140a8a 100644 --- a/zephyr/projects/asurada/hayato/gpio.dts +++ b/zephyr/projects/asurada/hayato/gpio.dts @@ -27,14 +27,15 @@ enum-name = "GPIO_AP_EC_WARM_RST_REQ"; label = "AP_EC_WARM_RST_REQ"; }; - ap_ec_watchdog_l { - gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + ap_ec_watchdog_l: ap_ec_watchdog_l { + gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_EC_WATCHDOG_L"; label = "AP_EC_WATCHDOG_L"; }; - ap_in_sleep_l { + ap_in_sleep_l: ap_in_sleep_l { gpios = <&gpiof 2 (GPIO_INPUT | GPIO_PULL_DOWN | - GPIO_VOLTAGE_1P8)>; + GPIO_VOLTAGE_1P8 | GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_IN_SLEEP_L"; label = "AP_IN_SLEEP_L"; }; @@ -44,9 +45,9 @@ enum-name = "GPIO_AP_XHCI_INIT_DONE"; label = "AP_XHCI_INIT_DONE"; }; - pmic_ec_pwrgd { + pmic_ec_pwrgd: pmic_ec_pwrgd { gpios = <&gpiof 3 (GPIO_INPUT | GPIO_PULL_DOWN | - GPIO_VOLTAGE_1P8)>; + GPIO_VOLTAGE_1P8 | GPIO_ACTIVE_HIGH)>; enum-name = "GPIO_PMIC_EC_PWRGD"; label = "PMIC_EC_PWRGD"; }; @@ -327,6 +328,22 @@ &lid_open>; }; + power_signal_list: power-signal-list { + compatible = "mediatek,power-signal-list"; + pmic_pwr_good { + power-enum-name = "PMIC_PWR_GOOD"; + gpio = <&pmic_ec_pwrgd>; + }; + ap_in_s3_l { + power-enum-name = "AP_IN_S3_L"; + gpio = <&ap_in_sleep_l>; + }; + ap_wdt_asserted { + power-enum-name = "AP_WDT_ASSERTED"; + gpio = <&ap_ec_watchdog_l>; + }; + }; + unused-pins { compatible = "unused-gpios"; diff --git a/zephyr/projects/corsola/krabby/gpio.dts b/zephyr/projects/corsola/krabby/gpio.dts index f04171651f..3c62140a8a 100644 --- a/zephyr/projects/corsola/krabby/gpio.dts +++ b/zephyr/projects/corsola/krabby/gpio.dts @@ -27,14 +27,15 @@ enum-name = "GPIO_AP_EC_WARM_RST_REQ"; label = "AP_EC_WARM_RST_REQ"; }; - ap_ec_watchdog_l { - gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + ap_ec_watchdog_l: ap_ec_watchdog_l { + gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_EC_WATCHDOG_L"; label = "AP_EC_WATCHDOG_L"; }; - ap_in_sleep_l { + ap_in_sleep_l: ap_in_sleep_l { gpios = <&gpiof 2 (GPIO_INPUT | GPIO_PULL_DOWN | - GPIO_VOLTAGE_1P8)>; + GPIO_VOLTAGE_1P8 | GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_IN_SLEEP_L"; label = "AP_IN_SLEEP_L"; }; @@ -44,9 +45,9 @@ enum-name = "GPIO_AP_XHCI_INIT_DONE"; label = "AP_XHCI_INIT_DONE"; }; - pmic_ec_pwrgd { + pmic_ec_pwrgd: pmic_ec_pwrgd { gpios = <&gpiof 3 (GPIO_INPUT | GPIO_PULL_DOWN | - GPIO_VOLTAGE_1P8)>; + GPIO_VOLTAGE_1P8 | GPIO_ACTIVE_HIGH)>; enum-name = "GPIO_PMIC_EC_PWRGD"; label = "PMIC_EC_PWRGD"; }; @@ -327,6 +328,22 @@ &lid_open>; }; + power_signal_list: power-signal-list { + compatible = "mediatek,power-signal-list"; + pmic_pwr_good { + power-enum-name = "PMIC_PWR_GOOD"; + gpio = <&pmic_ec_pwrgd>; + }; + ap_in_s3_l { + power-enum-name = "AP_IN_S3_L"; + gpio = <&ap_in_sleep_l>; + }; + ap_wdt_asserted { + power-enum-name = "AP_WDT_ASSERTED"; + gpio = <&ap_ec_watchdog_l>; + }; + }; + unused-pins { compatible = "unused-gpios"; diff --git a/zephyr/shim/include/board.h b/zephyr/shim/include/board.h index fd855e4378..a1059eb426 100644 --- a/zephyr/shim/include/board.h +++ b/zephyr/shim/include/board.h @@ -11,6 +11,9 @@ /* Included shimed version of gpio signal. */ #include "gpio_signal.h" +/* Include shimmed version of power signal */ +#include "power/power.h" + /* Include board specific gpio mapping/aliases if named_pgios node exists */ #if DT_NODE_EXISTS(DT_PATH(named_gpios)) #include "gpio_map.h" diff --git a/zephyr/shim/include/power/power.h b/zephyr/shim/include/power/power.h new file mode 100644 index 0000000000..26d6ddadea --- /dev/null +++ b/zephyr/shim/include/power/power.h @@ -0,0 +1,83 @@ +/* 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. + */ + +#ifndef ZEPHYR_CHROME_POWER_POWER_H +#define ZEPHYR_CHROME_POWER_POWER_H + +#include <devicetree.h> + +#define POWER_SIGNAL_LIST_NODE \ + DT_NODELABEL(power_signal_list) + +#define SYSTEM_DT_POWER_SIGNAL_CONFIG \ + DT_NODE_EXISTS(POWER_SIGNAL_LIST_NODE) + +#if (SYSTEM_DT_POWER_SIGNAL_CONFIG) + +#define GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid) \ + DT_STRING_UPPER_TOKEN( \ + DT_PROP( \ + cid, \ + gpio \ + ), \ + enum_name \ + ) +#define GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid) \ +( \ + DT_GPIO_FLAGS( \ + DT_PROP( \ + cid, \ + gpio \ + ), \ + gpios \ + ) & GPIO_ACTIVE_LOW \ + ? POWER_SIGNAL_ACTIVE_LOW \ + : POWER_SIGNAL_ACTIVE_HIGH \ +) +#define GEN_POWER_SIGNAL_STRUCT_ENTRY_NAME(cid) \ + DT_PROP( \ + cid, \ + power_enum_name \ + ) + +#define GEN_POWER_SIGNAL_STRUCT_ENTRY(cid) \ +{ \ + .gpio = GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid), \ + .flags = GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid), \ + .name = GEN_POWER_SIGNAL_STRUCT_ENTRY_NAME(cid) \ +} +#define GEN_POWER_SIGNAL_STRUCT(cid) \ + [GEN_POWER_SIGNAL_ENUM_ENTRY(cid)] = \ + GEN_POWER_SIGNAL_STRUCT_ENTRY(cid), + + +#define GEN_POWER_SIGNAL_ENUM_ENTRY(cid) \ + DT_STRING_UPPER_TOKEN( \ + cid, \ + power_enum_name \ + ) +#define GEN_POWER_SIGNAL_ENUM_ENTRY_COMMA(cid) \ + GEN_POWER_SIGNAL_ENUM_ENTRY(cid), + +enum power_signal { + DT_FOREACH_CHILD( + POWER_SIGNAL_LIST_NODE, + GEN_POWER_SIGNAL_ENUM_ENTRY_COMMA) + POWER_SIGNAL_COUNT +}; + +/* + * Verify the number of required power-signals are specified in + * the DeviceTree + */ +#define POWER_SIGNALS_REQUIRED \ + DT_PROP( \ + POWER_SIGNAL_LIST_NODE, \ + power_signals_required \ + ) +BUILD_ASSERT(POWER_SIGNALS_REQUIRED == POWER_SIGNAL_COUNT); + +#endif /* SYSTEM_DT_POWER_SIGNAL_CONFIG */ +#endif /* ZEPHYR_CHROME_POWER_POWER_H */ diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt index 5515058684..92894630bc 100644 --- a/zephyr/shim/src/CMakeLists.txt +++ b/zephyr/shim/src/CMakeLists.txt @@ -6,6 +6,7 @@ zephyr_library_sources(console.c) zephyr_library_sources(crc.c) zephyr_library_sources(gpio.c) zephyr_library_sources(gpio_id.c) +zephyr_library_sources(power.c) if (DEFINED CONFIG_ARCH_POSIX) zephyr_library_sources(ztest_system.c) diff --git a/zephyr/shim/src/power.c b/zephyr/shim/src/power.c new file mode 100644 index 0000000000..6d09dba9d3 --- /dev/null +++ b/zephyr/shim/src/power.c @@ -0,0 +1,21 @@ +/* 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 <sys/util.h> + +#include "console.h" +#include "power.h" +#include "power/power.h" + +#if (SYSTEM_DT_POWER_SIGNAL_CONFIG) + +const struct power_signal_info power_signal_list[] = { + DT_FOREACH_CHILD( + POWER_SIGNAL_LIST_NODE, + GEN_POWER_SIGNAL_STRUCT) +}; +BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); + +#endif /* SYSTEM_DT_POWER_SIGNAL_CONFIG */ |