linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: sunxi: set pin function as input on export
@ 2016-02-08 14:37 Krzysztof Adamski
       [not found] ` <1454942242-25690-1-git-send-email-krzysztof.adamski-++hxYGjEMp0AvxtiuMwx3w@public.gmane.org>
  2016-02-15 22:04 ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Krzysztof Adamski @ 2016-02-08 14:37 UTC (permalink / raw)
  To: Linus Walleij, Maxime Ripard, Chen-Yu Tsai, Hans de Goede,
	Thomas Gleixner, Lee Jones, Jonas Gorski, Krzysztof Adamski,
	linux-gpio, linux-arm-kernel, linux-kernel, linux-sunxi

Default function of a pin in sunxi SoCs is "disabled". By default gpios
exported by sysfs are set as input and indeed, when reading "direction"
file you will get "in". The "value" pin won't return proper value,
though, confusing user of this interface.

This patch sets direction of a GPIO as input when exporting it.

Signed-off-by: Krzysztof Adamski <krzysztof.adamski@tieto.com>
---
 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index 7a2465f..905a9fb 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -452,6 +452,16 @@ static int sunxi_pinctrl_gpio_direction_input(struct gpio_chip *chip,
 	return pinctrl_gpio_direction_input(chip->base + offset);
 }
 
+int sunxi_pinctrl_gpio_request(struct gpio_chip *chip, unsigned offset)
+{
+	int ret = pinctrl_gpio_direction_input(chip->base + offset);
+
+	if (ret)
+		return ret;
+
+	return pinctrl_request_gpio(chip->base + offset);
+}
+
 static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
 	struct sunxi_pinctrl *pctl = gpiochip_get_data(chip);
@@ -946,7 +956,7 @@ int sunxi_pinctrl_init(struct platform_device *pdev,
 
 	last_pin = pctl->desc->pins[pctl->desc->npins - 1].pin.number;
 	pctl->chip->owner = THIS_MODULE;
-	pctl->chip->request = gpiochip_generic_request,
+	pctl->chip->request = sunxi_pinctrl_gpio_request,
 	pctl->chip->free = gpiochip_generic_free,
 	pctl->chip->direction_input = sunxi_pinctrl_gpio_direction_input,
 	pctl->chip->direction_output = sunxi_pinctrl_gpio_direction_output,
-- 
2.4.2

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

end of thread, other threads:[~2016-02-16 15:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-08 14:37 [PATCH] pinctrl: sunxi: set pin function as input on export Krzysztof Adamski
     [not found] ` <1454942242-25690-1-git-send-email-krzysztof.adamski-++hxYGjEMp0AvxtiuMwx3w@public.gmane.org>
2016-02-08 17:20   ` Maxime Ripard
2016-02-15 22:04 ` Linus Walleij
     [not found]   ` <CACRpkdbd4f3yj2MnR6PU5SuhV5Tj4HzWLc0UX8jQkcJp7MoTig-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-16  8:00     ` Krzysztof Adamski
     [not found]       ` <20160216080004.GA24625-xLeyfSbClftGit24Ens98Q@public.gmane.org>
2016-02-16 15:35         ` 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).