All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinmux: 1 pin is not allowed to be configured for both GPIO and peripheral funtion
@ 2015-02-26  7:41 Sonic Zhang
  2015-03-04  7:57 ` Sonic Zhang
  2015-03-09 15:46 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Sonic Zhang @ 2015-02-26  7:41 UTC (permalink / raw)
  To: Linus Walleij, Grant Likely; +Cc: linux-gpio, adi-buildroot-devel, Sonic Zhang

From: Sonic Zhang <sonic.zhang@analog.com>

The blackfin pinmux and gpio controller doesn't allow user to set up 1 pin
for both GPIO and peripheral function. So, check both gpio_owner and
mux_owner before approving the pin request.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 drivers/pinctrl/pinmux.c |   28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index b874458..b58b97c 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -99,24 +99,24 @@ static int pin_request(struct pinctrl_dev *pctldev,
 	dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n",
 		pin, desc->name, owner);
 
+	if (desc->gpio_owner) {
+		dev_err(pctldev->dev,
+			"pin %s already requested by %s; cannot claim for %s\n",
+			desc->name, desc->gpio_owner, owner);
+		goto out;
+	}
+
+	if (desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
+		dev_err(pctldev->dev,
+			"pin %s already requested by %s; cannot claim for %s\n",
+			desc->name, desc->mux_owner, owner);
+		goto out;
+	}
+
 	if (gpio_range) {
 		/* There's no need to support multiple GPIO requests */
-		if (desc->gpio_owner) {
-			dev_err(pctldev->dev,
-				"pin %s already requested by %s; cannot claim for %s\n",
-				desc->name, desc->gpio_owner, owner);
-			goto out;
-		}
-
 		desc->gpio_owner = owner;
 	} else {
-		if (desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
-			dev_err(pctldev->dev,
-				"pin %s already requested by %s; cannot claim for %s\n",
-				desc->name, desc->mux_owner, owner);
-			goto out;
-		}
-
 		desc->mux_usecount++;
 		if (desc->mux_usecount > 1)
 			return 0;
-- 
1.7.9.5


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

* Re: [PATCH] pinmux: 1 pin is not allowed to be configured for both GPIO and peripheral funtion
  2015-02-26  7:41 [PATCH] pinmux: 1 pin is not allowed to be configured for both GPIO and peripheral funtion Sonic Zhang
@ 2015-03-04  7:57 ` Sonic Zhang
  2015-03-09 15:46 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Sonic Zhang @ 2015-03-04  7:57 UTC (permalink / raw)
  To: Linus Walleij, Grant Likely; +Cc: linux-gpio, adi-buildroot-devel, Sonic Zhang

PING

On Thu, Feb 26, 2015 at 3:41 PM, Sonic Zhang <sonic.adi@gmail.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> The blackfin pinmux and gpio controller doesn't allow user to set up 1 pin
> for both GPIO and peripheral function. So, check both gpio_owner and
> mux_owner before approving the pin request.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> ---
>  drivers/pinctrl/pinmux.c |   28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
> index b874458..b58b97c 100644
> --- a/drivers/pinctrl/pinmux.c
> +++ b/drivers/pinctrl/pinmux.c
> @@ -99,24 +99,24 @@ static int pin_request(struct pinctrl_dev *pctldev,
>         dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n",
>                 pin, desc->name, owner);
>
> +       if (desc->gpio_owner) {
> +               dev_err(pctldev->dev,
> +                       "pin %s already requested by %s; cannot claim for %s\n",
> +                       desc->name, desc->gpio_owner, owner);
> +               goto out;
> +       }
> +
> +       if (desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
> +               dev_err(pctldev->dev,
> +                       "pin %s already requested by %s; cannot claim for %s\n",
> +                       desc->name, desc->mux_owner, owner);
> +               goto out;
> +       }
> +
>         if (gpio_range) {
>                 /* There's no need to support multiple GPIO requests */
> -               if (desc->gpio_owner) {
> -                       dev_err(pctldev->dev,
> -                               "pin %s already requested by %s; cannot claim for %s\n",
> -                               desc->name, desc->gpio_owner, owner);
> -                       goto out;
> -               }
> -
>                 desc->gpio_owner = owner;
>         } else {
> -               if (desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
> -                       dev_err(pctldev->dev,
> -                               "pin %s already requested by %s; cannot claim for %s\n",
> -                               desc->name, desc->mux_owner, owner);
> -                       goto out;
> -               }
> -
>                 desc->mux_usecount++;
>                 if (desc->mux_usecount > 1)
>                         return 0;
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] pinmux: 1 pin is not allowed to be configured for both GPIO and peripheral funtion
  2015-02-26  7:41 [PATCH] pinmux: 1 pin is not allowed to be configured for both GPIO and peripheral funtion Sonic Zhang
  2015-03-04  7:57 ` Sonic Zhang
@ 2015-03-09 15:46 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2015-03-09 15:46 UTC (permalink / raw)
  To: Sonic Zhang; +Cc: Grant Likely, linux-gpio, adi-buildroot-devel, Sonic Zhang

On Thu, Feb 26, 2015 at 8:41 AM, Sonic Zhang <sonic.adi@gmail.com> wrote:

> From: Sonic Zhang <sonic.zhang@analog.com>
>
> The blackfin pinmux and gpio controller doesn't allow user to set up 1 pin
> for both GPIO and peripheral function. So, check both gpio_owner and
> mux_owner before approving the pin request.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>

So since there are pin controllers that can do this even though your
pin controller can't, you cannot forbit it for everyone like this.

We have discussed adding a field to struct pinctrl_desc,
bool strict, that would make the core disallow GPIOs and
functions to be used on a pin at the same time.

So if this behaviour is desired for a certain pin controller then
implement it like so: add bool strict to the struct pinctrl_desc,
and only do the above strict check for pin controllers that set
it, and set it for your pin controller.

Yours,
Linus Walleij

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

end of thread, other threads:[~2015-03-09 15:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-26  7:41 [PATCH] pinmux: 1 pin is not allowed to be configured for both GPIO and peripheral funtion Sonic Zhang
2015-03-04  7:57 ` Sonic Zhang
2015-03-09 15:46 ` Linus Walleij

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.