All of lore.kernel.org
 help / color / mirror / Atom feed
From: damien.riegel.ext@parrot.com (Damien Riegel)
To: linux-arm-kernel@lists.infradead.org
Subject: Issue with gpio and pinmux
Date: Wed, 17 Jul 2013 11:45:32 +0200	[thread overview]
Message-ID: <51E667BC.3070804@parrot.com> (raw)

Hi,


In our ARM-based SoC, we can multiplex up to 4 functions on each pin,
but we have an issue when using a pin as a gpio: it can still be muxed
as another function.

In the gpio driver, we delegate calls to "request" to
"pinctrl_request_gpio":

	static int p7gpio_request(struct gpio_chip *chip, unsigned int offset)
	{
		return pinctrl_request_gpio(chip->base + offset);
	}

	static const struct gpio_chip p7gpio_chip_defaults = {
		.request            = p7gpio_request,
		[...]
	};

pinctrl_request_gpio will result in a call to pin_request, which behaves
differently if we request a gpio or another function, so at kernel
level they are not exclusive, but at hardware level they must be.

To avoid conflicts, the workaround I use is to implement "request" and
"gpio_request_enable" as below in a pinctrl driver to make mux and gpio
exclusive. But I really feel like I should not do so and let the kernel
do this for me.

	static int p7ctl_enable_gpio(struct pinctrl_dev* pctl,
					struct pinctrl_gpio_range* range,
					unsigned int gpio)
	{
		struct pin_desc *desc;
		desc = pin_desc_get(pctl, gpio);
		if (desc->mux_owner)
			return -EBUSY;
		
		[...]
	}

	static int p7ctl_request(struct pinctrl_dev* pctl, unsigned int pin)
	{
		struct pin_desc *desc;
		desc = pin_desc_get(pctl, pin);
		if (desc->gpio_owner)
			return -EBUSY;

		return 0;
	}

	static struct pinmux_ops p7ctl_mux_ops = {
		.request                = p7ctl_request,
		.gpio_request_enable    = p7ctl_enable_gpio,
		[...]
	};

Is this solution correct or is there a better way to claim the mux when
using a pin as a gpio ?

Note: we are using a kernel based on 3.4.11, but as far as I can tell,
pinctrl_request_gpio have the same behavior in the upstream kernel.


Thanks,
Damien

             reply	other threads:[~2013-07-17  9:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17  9:45 Damien Riegel [this message]
2013-07-18 18:11 ` Issue with gpio and pinmux Stephen Warren
2013-07-20 22:44   ` Linus Walleij
2013-07-21  3:44     ` Stephen Warren
2013-07-22  8:35       ` Christian Ruppert
2013-07-23 15:47         ` Stephen Warren
2013-07-26  9:26           ` Christian Ruppert
2013-07-25  9:37       ` Linus Walleij
2013-07-25 13:20         ` Damien Riegel
2013-07-25 13:24           ` Linus Walleij
2013-07-25 14:42             ` Damien Riegel
2013-07-25 15:06               ` Linus Walleij
2013-07-26  9:26         ` Christian Ruppert
2013-07-26 16:01           ` Stephen Warren
2013-07-26 22:39           ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51E667BC.3070804@parrot.com \
    --to=damien.riegel.ext@parrot.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.