drivers: gpio: add "gpio-reserved-ranges" property support
Added
* GPIO_DT_RESERVED_RANGES_NGPIOS(node_id, ngpios),
* GPIO_DT_RESERVED_RANGES(node_id),
* GPIO_DT_INST_RESERVED_RANGES_NGPIOS(inst, ngpios) and
* GPIO_DT_INST_RESERVED_RANGES(inst)
as DT gpio's "gpio-reserved-ranges" property missing support.
The array of pins range pairs as shown below now works.
Also implemented paired extended versions of
GPIO_PORT_PIN_MASK_FROM_NGPIOS macro:
* GPIO_DT_PORT_PIN_MASK_NGPIOS_EXC(node_id, ngpios) and
* GPIO_DT_INST_PORT_PIN_MASK_NGPIOS_EXC(inst, ngpios)
with reserved (ie EXCluded) pins support too.
The implementation constraint is inherited from common DT limitations:
a maximum of 64 pairs can be used, i.e. theoretically no more than
128-bit gpio ports are supported (but resulted bitmask is actually
limited by the size of gpio_port_pins_t type).
Usage example:
The reserved mask, defined in the device tree as:
gpio0: gpio0 {
....
ngpios=<32>;
gpio-reserved-ranges = <0 8>, <9 5>, <15 16>;
....
};
and used in driver configuration as:
{
...
.gpio_reserved = GPIO_DT_RESERVED_RANGES(DT_NODELABEL(gpio0)),
.pin_port_mask = GPIO_DT_PORT_PIN_MASK_NGPIOS_EXC(
DT_NODELABEL(gpio0),
DT_PROP(DT_NODELABEL(gpio0), ngpios)),
...
}
correctly converts to:
.gpio_reserved = 0x7fffbeff, 0b01111111 11111111 10111110 11111111)
.pin_port_mask = 0x80004100, 0b10000000 00000000 01000001 00000000)
Signed-off-by:
Andrey VOLKOV <andrey.volkov@munic.io>
Loading
Please sign in to comment