dm: gpio: Add better functions to request GPIOs
At present U-Boot sort-of supports the standard way of reading GPIOs from
device tree nodes, but the support is incomplete, a bit clunky and only
works for GPIO bindings where #gpio-cells is 2.
Add new functions to request GPIOs, taking full account of the device
tree binding. These permit requesting a GPIO with a simple call like:
gpio_request_by_name(dev, "cd-gpios", 0, &desc, GPIOD_IS_IN);
This will request the GPIO, looking at the device's node which might be
this, for example:
cd-gpios = <&gpio TEGRA_GPIO(B, 3) GPIO_ACTIVE_LOW>;
The GPIO will be set to input mode in this case and polarity will be
honoured by the GPIO calls.
It is also possible to request and free a list of GPIOs.
Signed-off-by:
Simon Glass <sjg@chromium.org>
Showing
- drivers/gpio/gpio-uclass.c 164 additions, 2 deletionsdrivers/gpio/gpio-uclass.c
- drivers/gpio/sandbox.c 20 additions, 0 deletionsdrivers/gpio/sandbox.c
- include/asm-generic/gpio.h 199 additions, 0 deletionsinclude/asm-generic/gpio.h
- test/dm/gpio.c 68 additions, 1 deletiontest/dm/gpio.c
- test/dm/test.dts 10 additions, 1 deletiontest/dm/test.dts
Loading
Please register or sign in to comment