summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Baltieri <fabiobaltieri@google.com>2022-11-03 12:09:49 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-09 19:08:59 +0000
commit621d0ee7ce950e99763175cca796f51df29785a6 (patch)
tree70ee34f15fd7046e2b4a6bb3bc94fe621d7eeccd
parentdf7862fa54ab94007110e1683351ee8d24a74f9a (diff)
downloadchrome-ec-621d0ee7ce950e99763175cca796f51df29785a6.tar.gz
zephyr: shim: use a Kconfig option for building power.c
Use an automatic Kconfig option to include power.c in the build, rather than including it unconditionally. Removes some precompiler guards from the source file and also move some macro that are only used in power.c out of the header file. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I021ec1384ef374f1c1dc841ea861e848ee9e65f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4003277 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r--zephyr/Kconfig8
-rw-r--r--zephyr/shim/include/power/power.h34
-rw-r--r--zephyr/shim/src/CMakeLists.txt3
-rw-r--r--zephyr/shim/src/power.c26
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);