diff options
author | Fabio Baltieri <fabiobaltieri@google.com> | 2022-12-21 11:41:53 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-23 12:00:36 +0000 |
commit | 9d60e1406b943649cfefe57a6e3b8ae508010c71 (patch) | |
tree | 98ea8314cb0c156ca08e075148c2e67f6932fcf1 | |
parent | 372d8e0a0f13d4c3119aa5afcc264f4aa96e58a0 (diff) | |
download | chrome-ec-9d60e1406b943649cfefe57a6e3b8ae508010c71.tar.gz |
zephyr: unused-gpios: remove DT_PATH usages
Replace a bunch of DT_PATH usages with some common macros to access the
unused-gpios node based on the DT compatible.
BRANCH=none
BUG=none
TEST=cq dry run
TEST=zmake compare-builds -a
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change-Id: Ifb45205d5755b4ccf457df650b3f9c719e79096a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4116772
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r-- | zephyr/shim/chip/npcx/gpio.c | 4 | ||||
-rw-r--r-- | zephyr/shim/include/gpio/gpio.h | 33 |
2 files changed, 17 insertions, 20 deletions
diff --git a/zephyr/shim/chip/npcx/gpio.c b/zephyr/shim/chip/npcx/gpio.c index 1d51c00f61..85f52a60b1 100644 --- a/zephyr/shim/chip/npcx/gpio.c +++ b/zephyr/shim/chip/npcx/gpio.c @@ -106,8 +106,8 @@ static struct npcx_io_info gpio_info[] = { #if DT_NODE_EXISTS(DT_PATH(named_gpios)) DT_FOREACH_CHILD(DT_PATH(named_gpios), NAMED_GPIO_INIT) #endif -#if DT_NODE_EXISTS(DT_PATH(unused_pins)) - DT_FOREACH_PROP_ELEM(DT_PATH(unused_pins), unused_gpios, +#if DT_NODE_EXISTS(UNUSED_GPIOS_NODE) + DT_FOREACH_PROP_ELEM(UNUSED_GPIOS_NODE, unused_gpios, UNUSED_GPIO_INFO) #endif }; diff --git a/zephyr/shim/include/gpio/gpio.h b/zephyr/shim/include/gpio/gpio.h index fbe57729fe..b2cdc954d9 100644 --- a/zephyr/shim/include/gpio/gpio.h +++ b/zephyr/shim/include/gpio/gpio.h @@ -9,6 +9,7 @@ #include <zephyr/device.h> #include <zephyr/devicetree.h> #include <zephyr/drivers/gpio.h> +#include <zephyr/toolchain.h> /* * Validate interrupt flags are valid for the Zephyr GPIO driver. @@ -66,22 +67,18 @@ int gpio_config_unused_pins(void) __attribute__((weak)); */ int gpio_configure_port_pin(int port, int id, int flags) __attribute__((weak)); -#if DT_NODE_EXISTS(DT_PATH(unused_pins)) -/** - * @brief Get a node from path '/unused-pins' which has a prop 'unused-gpios'. - * It contains unused GPIOs and chip vendor needs to configure them for - * better power consumption in the lowest power state. - * - * @return node identifier with that path. - */ -#define UNUSED_PINS_LIST DT_PATH(unused_pins) +BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(unused_gpios) <= 1, + "at most one unused-gpios compatible node may be present"); + +#define UNUSED_GPIOS_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(unused_gpios) +#if DT_NODE_EXISTS(UNUSED_GPIOS_NODE) /** * @brief Length of 'unused-gpios' property * * @return length of 'unused-gpios' prop which type is 'phandle-array' */ -#define UNUSED_GPIOS_LIST_LEN DT_PROP_LEN(UNUSED_PINS_LIST, unused_gpios) +#define UNUSED_GPIOS_LIST_LEN DT_PROP_LEN(UNUSED_GPIOS_NODE, unused_gpios) /** * @brief Construct a unused_pin_config structure from 'unused-gpios' property @@ -90,13 +87,13 @@ int gpio_configure_port_pin(int port, int id, int flags) __attribute__((weak)); * @param i index of 'unused-gpios' prop which type is 'phandles-array' * @return unused_pin_config item at index 'i' */ -#define UNUSED_GPIO_CONFIG_BY_IDX(i, _) \ - { \ - .dev_name = DEVICE_DT_NAME(DT_GPIO_CTLR_BY_IDX( \ - UNUSED_PINS_LIST, unused_gpios, i)), \ - .pin = DT_GPIO_PIN_BY_IDX(UNUSED_PINS_LIST, unused_gpios, i), \ - .flags = DT_GPIO_FLAGS_BY_IDX(UNUSED_PINS_LIST, unused_gpios, \ - i), \ +#define UNUSED_GPIO_CONFIG_BY_IDX(i, _) \ + { \ + .dev_name = DEVICE_DT_NAME(DT_GPIO_CTLR_BY_IDX( \ + UNUSED_GPIOS_NODE, unused_gpios, i)), \ + .pin = DT_GPIO_PIN_BY_IDX(UNUSED_GPIOS_NODE, unused_gpios, i), \ + .flags = DT_GPIO_FLAGS_BY_IDX(UNUSED_GPIOS_NODE, unused_gpios, \ + i), \ }, /** @@ -124,6 +121,6 @@ int gpio_configure_port_pin(int port, int id, int flags) __attribute__((weak)); #else #define UNUSED_GPIO_CONFIG_LIST /* Nothing if no 'unused-pins' node */ -#endif /* unused_pins */ +#endif /* DT_NODE_EXISTS(UNUSED_GPIOS_NODE) */ #endif /* ZEPHYR_SHIM_INCLUDE_GPIO_GPIO_H_ */ |