[PATCH 1/2] gpio: gpio-uclass: add OPEN_DRAIN flag parsing
Neil Armstrong
narmstrong at baylibre.com
Fri Jan 15 09:11:01 CET 2021
Hi,
This has already been pushed on u-boot master:
https://patchwork.ozlabs.org/project/uboot/patch/20200505084318.15307-2-narmstrong@baylibre.com/
Commit: 47bd533e9dd0f967ff7b62f3edfd6c97131e1501
Author: Neil Armstrong <narmstrong at baylibre.com>
Date: Tue May 5 10:43:17 2020 +0200
gpio: emulate open drain & open source in dm_gpio_set_value()
Handle the GPIOD_OPEN_DRAIN & GPIOD_OPEN_SOURCE flags to emulate open drain
and open source by setting the GPIO line as input depending on the
requested value.
The behaviour is taken from the Linux gpiolib.
Signed-off-by: Neil Armstrong <narmstrong at baylibre.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
Neil
On 15/01/2021 06:15, Artem Lapkin wrote:
> add GPIOD_OPEN_DRAIN flag which cant parsed properly
>
> Problem: for example cant power video system for sm1 g12a socs
> because OPEN_DRAIN flag cant parsed
>
> DTS examples:
>
> ```
> $ grep GPIO_OPEN_DRAIN\> arch/arm/dts/meson-*.dt*
> arch/arm/dts/meson-g12a-sei510.dts: gpio = <&gpio GPIOH_8 GPIO_OPEN_DRAIN>;
> arch/arm/dts/meson-g12a-u200.dts: gpio = <&gpio GPIOH_8 GPIO_OPEN_DRAIN>;
> arch/arm/dts/meson-gx-libretech-pc.dtsi: gpio = <&gpio GPIOH_3 GPIO_OPEN_DRAIN>;
> arch/arm/dts/meson-khadas-vim3.dtsi: gpio = <&gpio GPIOH_8 GPIO_OPEN_DRAIN>;
> arch/arm/dts/meson-sm1-sei610.dts: gpio = <&gpio GPIOH_8 GPIO_OPEN_DRAIN>;
> ```
>
> Signed-off-by: Artem Lapkin <art at khadas.com>
> ---
> drivers/gpio/gpio-uclass.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
> index bad6b71e0c..6225f32457 100644
> --- a/drivers/gpio/gpio-uclass.c
> +++ b/drivers/gpio/gpio-uclass.c
> @@ -574,6 +574,15 @@ int dm_gpio_set_value(const struct gpio_desc *desc, int value)
> if (ret)
> return ret;
>
> + if (desc->flags & GPIOD_OPEN_DRAIN) {
> + if (value)
> + gpio_get_ops(desc->dev)->direction_input(desc->dev, desc->offset);
> + else
> + gpio_get_ops(desc->dev)->direction_output(desc->dev, desc->offset, 0);
> +
> + return 0;
> + }
> +
> if (desc->flags & GPIOD_ACTIVE_LOW)
> value = !value;
>
>
More information about the U-Boot
mailing list