From: Artem Lapkin Date: Fri, 15 Jan 2021 13:15:57 +0800 Subject: [PATCH 1/2] gpio: gpio-uclass: add OPEN_DRAIN flag parsing In-Reply-To: <20210115051558.469734-1-art@khadas.com> References: <20210115051558.469734-1-art@khadas.com> Message-ID: <20210115051558.469734-2-art@khadas.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- 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; -- 2.25.1