linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] gpio: mvebu: implement get_direction
@ 2019-01-10 12:26 Baruch Siach
  2019-01-10 12:26 ` [PATCH 2/2] PCI: armada8k: don't toggle reset twice Baruch Siach
  2019-01-10 15:20 ` [PATCH 1/2] gpio: mvebu: implement get_direction Linus Walleij
  0 siblings, 2 replies; 12+ messages in thread
From: Baruch Siach @ 2019-01-10 12:26 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
	Thomas Petazzoni, Lorenzo Pieralisi, Bjorn Helgaas
  Cc: Sven Auhagen, linux-pwm, linux-gpio, linux-pci, linux-arm-kernel,
	Jason Cooper, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Baruch Siach

struct gpio_chip documentation recommends to always implement this
callback function.

A more concrete motivation is to be able (in combination with
GPIOD_ASIS) to detect whether the bootloader has changed the state of a
GPIO signal.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 drivers/gpio/gpio-mvebu.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 7d5c55494ccd..f97ed32b8beb 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -376,6 +376,16 @@ static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned int pin,
 	return 0;
 }
 
+static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
+{
+	struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip);
+	u32 u;
+
+	regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u);
+
+	return !!(u & BIT(pin));
+}
+
 static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
 {
 	struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip);
@@ -1130,6 +1140,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 	mvchip->chip.parent = &pdev->dev;
 	mvchip->chip.request = gpiochip_generic_request;
 	mvchip->chip.free = gpiochip_generic_free;
+	mvchip->chip.get_direction = mvebu_gpio_get_direction;
 	mvchip->chip.direction_input = mvebu_gpio_direction_input;
 	mvchip->chip.get = mvebu_gpio_get;
 	mvchip->chip.direction_output = mvebu_gpio_direction_output;
-- 
2.20.1


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

end of thread, other threads:[~2019-01-14  7:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-10 12:26 [PATCH 1/2] gpio: mvebu: implement get_direction Baruch Siach
2019-01-10 12:26 ` [PATCH 2/2] PCI: armada8k: don't toggle reset twice Baruch Siach
2019-01-10 12:55   ` Andrew Lunn
2019-01-10 13:05     ` Baruch Siach
2019-01-10 13:19       ` Andrew Lunn
2019-01-10 15:57         ` Baruch Siach
2019-01-13 12:38           ` Baruch Siach
2019-01-13 15:40             ` Andrew Lunn
2019-01-13 18:42               ` Baruch Siach
2019-01-13 23:35               ` Linus Walleij
2019-01-14  7:19                 ` Baruch Siach
2019-01-10 15:20 ` [PATCH 1/2] gpio: mvebu: implement get_direction Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).