All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] gpio/acpi: set direction for ACPI OpRegion GPIOs
@ 2019-05-29 10:13 Ard Biesheuvel
  2019-05-29 10:27 ` Mika Westerberg
  0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2019-05-29 10:13 UTC (permalink / raw)
  To: linux-gpio
  Cc: linux-acpi, mika.westerberg, andriy.shevchenko, linus.walleij,
	rjw, jarkko.nikula, Ard Biesheuvel

The ACPI GPIO OpRegion code never sets the direction for GPIOs that
it configures from scratch, leaving unconfigured GPIOs to be left
at the default direction, which is typically input not output.

So set the direction and default value explicitly.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/gpio/gpiolib-acpi.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index c9fc9e232aaf..02a2bc7fe18b 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -966,6 +966,12 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
 				goto out;
 			}
 
+			if (function == ACPI_WRITE)
+				gpiod_direction_output(desc,
+						       !!((1 << i) & *value));
+			else
+				gpiod_direction_input(desc);
+
 			conn->pin = pin;
 			conn->desc = desc;
 			list_add_tail(&conn->node, &achip->conns);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] gpio/acpi: set direction for ACPI OpRegion GPIOs
  2019-05-29 10:13 [RFC PATCH] gpio/acpi: set direction for ACPI OpRegion GPIOs Ard Biesheuvel
@ 2019-05-29 10:27 ` Mika Westerberg
  2019-05-29 10:50   ` Ard Biesheuvel
  0 siblings, 1 reply; 3+ messages in thread
From: Mika Westerberg @ 2019-05-29 10:27 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-gpio, linux-acpi, andriy.shevchenko, linus.walleij, rjw,
	jarkko.nikula

On Wed, May 29, 2019 at 12:13:42PM +0200, Ard Biesheuvel wrote:
> The ACPI GPIO OpRegion code never sets the direction for GPIOs that
> it configures from scratch, leaving unconfigured GPIOs to be left
> at the default direction, which is typically input not output.

The code does:

  enum gpiod_flags flags = acpi_gpio_to_gpiod_flags(agpio);

before it requests the GPIO. Isn't that sufficient?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] gpio/acpi: set direction for ACPI OpRegion GPIOs
  2019-05-29 10:27 ` Mika Westerberg
@ 2019-05-29 10:50   ` Ard Biesheuvel
  0 siblings, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2019-05-29 10:50 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: open list:GPIO SUBSYSTEM, ACPI Devel Maling List,
	Andy Shevchenko, Linus Walleij, Rafael J. Wysocki, Jarkko Nikula

On Wed, 29 May 2019 at 12:27, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
>
> On Wed, May 29, 2019 at 12:13:42PM +0200, Ard Biesheuvel wrote:
> > The ACPI GPIO OpRegion code never sets the direction for GPIOs that
> > it configures from scratch, leaving unconfigured GPIOs to be left
> > at the default direction, which is typically input not output.
>
> The code does:
>
>   enum gpiod_flags flags = acpi_gpio_to_gpiod_flags(agpio);
>
> before it requests the GPIO. Isn't that sufficient?

Yes, it works if I set the PullXxx value explicitly in the GpioIo() resource.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-29 10:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-29 10:13 [RFC PATCH] gpio/acpi: set direction for ACPI OpRegion GPIOs Ard Biesheuvel
2019-05-29 10:27 ` Mika Westerberg
2019-05-29 10:50   ` Ard Biesheuvel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.