summaryrefslogtreecommitdiff
path: root/zephyr/shim/include/gpio/gpio.h
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/shim/include/gpio/gpio.h')
-rw-r--r--zephyr/shim/include/gpio/gpio.h33
1 files changed, 15 insertions, 18 deletions
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_ */