zephyr: Add GPIO_DT_FROM_{NODE,ALIAS} macros
Add GPIO_DT_FROM_NODE and GPIO_DT_FROM_ALIAS macro.
Similar to GPIO_DT_FROM_NODELABEL, but references the spec
from a node or alias, not a node label.
TEST=zmake testall
BRANCH=none
@@ -83,21 +83,29 @@ BUILD_ASSERT(GPIO_COUNT < GPIO_LIMIT);
* enum-name = "GPIO_WP_L";
* };
*
+ * aliases {
+ * other_name = &gpio_ec_wp_l;
+ * };
+ *
* The following methods can all be used to access the GPIO:
*
* inp = gpio_get_level(GPIO_WP_L); // Legacy access
* inp = gpio_pin_get_dt(DT_GPIO_LID_OPEN); // Zephyr API
* inp = gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_wp_l)); // Zephyr API
+ * inp = gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(other_name));
* enum gpio_signal sig = GPIO_WP_L;
* inp = gpio_pin_get_dt(gpio_get_dt_spec(sig)); // Zephyr API
*
- * DT_GPIO_LID_OPEN and GPIO_DT_FROM_NODELABEL(gpio_ec_wp_l) will resolve at
- * build time, whereas gpio_get_dt_spec() will resolve at run-time.
+ * DT_GPIO_LID_OPEN, GPIO_DT_FROM_NODELABEL and GPIO_DT_FROM_ALIAS will
+ * resolve at build time, whereas gpio_get_dt_spec() will resolve at run-time.
*/
#define GPIO_DT_NAME(signal) DT_CAT(DT_, signal)
-#define GPIO_DT_FROM_NODELABEL(label) \
- GPIO_DT_NAME(GPIO_SIGNAL(DT_NODELABEL(label)))
+#define GPIO_DT_FROM_NODE(id) GPIO_DT_NAME(GPIO_SIGNAL(id))
+
+#define GPIO_DT_FROM_ALIAS(id) GPIO_DT_FROM_NODE(DT_ALIAS(id))
+
+#define GPIO_DT_FROM_NODELABEL(label) GPIO_DT_FROM_NODE(DT_NODELABEL(label))
#if DT_NODE_EXISTS(DT_PATH(named_gpios))
/*
