Skip to contentSkip to conversation

pinmux: allow exlusive pin allocation among GPIO and peripheral funtions via flag strict in struct pinctrl_desc

PATCH Superseded Sonic Zhang 2 participants 2 messages Mar 31, 2015 – Apr 7, 2015

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pinmux: allow exlusive pin allocation among GPIO and peripheral funtions via flag strict in struct pinctrl_desc

From: Sonic Zhang <[email protected]>

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

v2-changes:
- if strict flag is set, check gpio_owner and mux_onwer in if and else clause

---
 drivers/pinctrl/pinctrl-adi2.c  |    1 +
 drivers/pinctrl/pinmux.c        |   13 +++++++++++++
 include/linux/pinctrl/pinctrl.h |    1 +
 3 files changed, 15 insertions(+)
drivers/pinctrl/pinctrl-adi2.c +1 -0
index 8434439..fbd4926 100644
@@ -710,6 +710,7 @@ static struct pinctrl_desc adi_pinmux_desc = {
 	.name = DRIVER_NAME,
 	.pctlops = &adi_pctrl_ops,
 	.pmxops = &adi_pinmux_ops,
+	.strict = true,
 	.owner = THIS_MODULE,
 };
 
drivers/pinctrl/pinmux.c +13 -0
index b874458..2546fa7 100644
@@ -107,6 +107,13 @@ static int pin_request(struct pinctrl_dev *pctldev,
 				desc->name, desc->gpio_owner, owner);
 			goto out;
 		}
+		if (pctldev->desc->strict && 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->gpio_owner = owner;
 	} else {
@@ -116,6 +123,12 @@ static int pin_request(struct pinctrl_dev *pctldev,
 				desc->name, desc->mux_owner, owner);
 			goto out;
 		}
+		if (pctldev->desc->strict && 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->mux_usecount++;
 		if (desc->mux_usecount > 1)
include/linux/pinctrl/pinctrl.h +1 -0
index 66e4697..ca6c99c0 100644
@@ -132,6 +132,7 @@ struct pinctrl_desc {
 	const struct pinctrl_ops *pctlops;
 	const struct pinmux_ops *pmxops;
 	const struct pinconf_ops *confops;
+	bool strict;
 	struct module *owner;
 #ifdef CONFIG_GENERIC_PINCONF
 	unsigned int num_custom_params;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 10 lines · Sonic Zhang

From: Sonic Zhang <[email protected]>

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

v2-changes:
- if strict flag is set, check gpio_owner and mux_onwer in if and else clause

(...)

include/linux/pinctrl/pinctrl.h struct pinctrl_desc { · line 135

Quoted 6 lines

+++ b/include/linux/pinctrl/pinctrl.h

include/linux/pinctrl/pinctrl.h +1 -0
@@ -132,6 +132,7 @@ struct pinctrl_desc {
        const struct pinctrl_ops *pctlops;
        const struct pinmux_ops *pmxops;
        const struct pinconf_ops *confops;
+       bool strict;

Also add kerneldoc for this struct.

Also augment Documentation/pinctrl.txt.

Yours,
Linus Walleij