diff options
-rw-r--r-- | zephyr/Kconfig | 8 | ||||
-rw-r--r-- | zephyr/shim/include/power/power.h | 34 | ||||
-rw-r--r-- | zephyr/shim/src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | zephyr/shim/src/power.c | 26 |
4 files changed, 37 insertions, 34 deletions
diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 5e3a7d3302..7f9dee962c 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -465,6 +465,14 @@ config PLATFORM_EC_POWER_COMMON help Compile common code for AP power state machine. +config CROS_EC_POWER_SIGNAL_LIST + bool "Define the power signal list from the devicetree" + default y + depends on $(dt_nodelabel_enabled,power_signal_list) + help + Define the global power_signal_list[] from the devicetree. Requires a + node with nodelabel power_signal_list. + config PLATFORM_EC_MKBP_EVENT bool "MKBP event" help diff --git a/zephyr/shim/include/power/power.h b/zephyr/shim/include/power/power.h index 1e780646af..a764e0c8b5 100644 --- a/zephyr/shim/include/power/power.h +++ b/zephyr/shim/include/power/power.h @@ -9,29 +9,9 @@ #include <zephyr/devicetree.h> #include <zephyr/drivers/gpio.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, power_gpio_pin), enum_name) -#define GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid) \ - (DT_GPIO_FLAGS(DT_PROP(cid, power_gpio_pin), 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) +#if CONFIG_CROS_EC_POWER_SIGNAL_LIST -#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 POWER_SIGNAL_LIST_NODE DT_NODELABEL(power_signal_list) #define GEN_POWER_SIGNAL_ENUM_ENTRY(cid) \ DT_STRING_UPPER_TOKEN(cid, power_enum_name) @@ -42,13 +22,5 @@ enum power_signal { 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 /* CONFIG_CROS_EC_POWER_SIGNAL_LIST */ #endif /* ZEPHYR_CHROME_POWER_POWER_H */ diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt index c2cb0b92da..d5de268be5 100644 --- a/zephyr/shim/src/CMakeLists.txt +++ b/zephyr/shim/src/CMakeLists.txt @@ -7,7 +7,6 @@ zephyr_library_sources(console.c) zephyr_library_sources(crc.c) zephyr_library_sources(gpio.c) zephyr_library_sources(gpio_int.c) -zephyr_library_sources(power.c) add_subdirectory("cbi") add_subdirectory("led_driver") @@ -51,6 +50,8 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MKBP_EVENT mkbp_event.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MOTIONSENSE motionsense_sensors.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PANIC panic.c) +zephyr_library_sources_ifdef(CONFIG_CROS_EC_POWER_SIGNAL_LIST + power.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PWM_HC pwm_hc.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_PWM pwm_led.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_RTC rtc.c) diff --git a/zephyr/shim/src/power.c b/zephyr/shim/src/power.c index 007c40ab71..51ae788d98 100644 --- a/zephyr/shim/src/power.c +++ b/zephyr/shim/src/power.c @@ -9,10 +9,32 @@ #include "power.h" #include "power/power.h" -#if (SYSTEM_DT_POWER_SIGNAL_CONFIG) +#define GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid) \ + DT_STRING_UPPER_TOKEN(DT_PROP(cid, power_gpio_pin), enum_name) +#define GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid) \ + (DT_GPIO_FLAGS(DT_PROP(cid, power_gpio_pin), 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), 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 */ +/* + * 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); |