diff options
Diffstat (limited to 'zephyr/shim/include/power/power.h')
-rw-r--r-- | zephyr/shim/include/power/power.h | 84 |
1 files changed, 27 insertions, 57 deletions
diff --git a/zephyr/shim/include/power/power.h b/zephyr/shim/include/power/power.h index 6ea2444705..1e780646af 100644 --- a/zephyr/shim/include/power/power.h +++ b/zephyr/shim/include/power/power.h @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -9,63 +9,36 @@ #include <zephyr/devicetree.h> #include <zephyr/drivers/gpio.h> -#define POWER_SIGNAL_LIST_NODE \ - DT_NODELABEL(power_signal_list) +#define POWER_SIGNAL_LIST_NODE DT_NODELABEL(power_signal_list) -#define SYSTEM_DT_POWER_SIGNAL_CONFIG \ - DT_NODE_EXISTS(POWER_SIGNAL_LIST_NODE) +#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 \ - ) - -#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), +#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), + +#define GEN_POWER_SIGNAL_ENUM_ENTRY(cid) \ + DT_STRING_UPPER_TOKEN(cid, power_enum_name) enum power_signal { - DT_FOREACH_CHILD( - POWER_SIGNAL_LIST_NODE, - GEN_POWER_SIGNAL_ENUM_ENTRY_COMMA) + DT_FOREACH_CHILD_SEP(POWER_SIGNAL_LIST_NODE, + GEN_POWER_SIGNAL_ENUM_ENTRY, (, )), POWER_SIGNAL_COUNT }; @@ -73,11 +46,8 @@ enum power_signal { * 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 \ - ) +#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 */ |