-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
#23245 improves the devicetree access solution significantly, but currently lacks a replacement for phandle-array values which are a series of phandle + specifier. Example is a GPIO device reference plus a pin and initial flags; or an ADC device and and an input channel. In the existing access solution a C initializer list is generated that captures the combined values, e.g. { "GPIO_0", 1, 0" }.
This gap complicates conversions of drivers that use the initializer list, e.g. the following:
- .bus_name = DT_INST_0_MAXIM_DS3231_BUS_NAME,
+ .bus_name = DT_INST_BUS_LABEL(0),
/* Driver does not currently use 32k GPIO. */
-#ifdef DT_INST_0_MAXIM_DS3231_ISW_GPIOS_CONTROLLER
- .isw_gpios = DT_INST_0_MAXIM_DS3231_ISW_GPIOS,
+#if DT_INST_NODE_HAS_PROP(0, isw_gpios)
+ .isw_gpios = DT_INST_GPIO(0, isw_gpios),
#endif
- .addr = DT_INST_0_MAXIM_DS3231_BASE_ADDRESS,
+ .addr = DT_INST_REG_ADDR(0),
requires local addition of the following macro:
#define DT_INST_GPIO(inst, gpio_pha) { \
DT_INST_GPIO_LABEL(inst, gpio_pha), \
DT_INST_GPIO_PIN(inst, gpio_pha), \
DT_INST_GPIO_FLAGS(inst, gpio_pha), \
}
to initialize the local definition:
struct gpios {
const char *ctrl;
gpio_pin_t pin;
gpio_dt_flags_t flags;
};
Such a definition has not been standardized because technically different GPIO controllers could use different cells in their specifiers.
Where we have consistent cells for all drivers it would good to have a standard structure that can be used to store a phandle+specifier, and a way to initialize such a structure.
See discussion at/around: #23245 (comment)