diff options
author | Sonic Zhang <sonic.zhang@analog.com> | 2015-04-08 23:13:07 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-05-06 08:45:19 -0400 |
commit | fa76a3db7093a527333c380df82a0f158d9b8299 (patch) | |
tree | add57323d26140a8e2358da9b93066d096c9c38d /drivers/pinctrl/pinmux.c | |
parent | c30024a6449070d6fde51a8bddf4c97f884db2cc (diff) |
pinctrl: allow exlusive GPIO/mux pin allocation
Disallow simultaneous use of the the GPIO and peripheral mux
functions by setting a flag "strict" in struct pinctrl_desc.
The blackfin pinmux and gpio controller doesn't allow user to
set up a pin for both GPIO and peripheral function. So, add flag
strict in struct pinctrl_desc 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
v3-changes:
- add kerneldoc for this struct
- augment Documentation/pinctrl.txt
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinmux.c')
-rw-r--r-- | drivers/pinctrl/pinmux.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index b874458dcb88..2546fa783464 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c | |||
@@ -107,6 +107,13 @@ static int pin_request(struct pinctrl_dev *pctldev, | |||
107 | desc->name, desc->gpio_owner, owner); | 107 | desc->name, desc->gpio_owner, owner); |
108 | goto out; | 108 | goto out; |
109 | } | 109 | } |
110 | if (pctldev->desc->strict && desc->mux_usecount && | ||
111 | strcmp(desc->mux_owner, owner)) { | ||
112 | dev_err(pctldev->dev, | ||
113 | "pin %s already requested by %s; cannot claim for %s\n", | ||
114 | desc->name, desc->mux_owner, owner); | ||
115 | goto out; | ||
116 | } | ||
110 | 117 | ||
111 | desc->gpio_owner = owner; | 118 | desc->gpio_owner = owner; |
112 | } else { | 119 | } else { |
@@ -116,6 +123,12 @@ static int pin_request(struct pinctrl_dev *pctldev, | |||
116 | desc->name, desc->mux_owner, owner); | 123 | desc->name, desc->mux_owner, owner); |
117 | goto out; | 124 | goto out; |
118 | } | 125 | } |
126 | if (pctldev->desc->strict && desc->gpio_owner) { | ||
127 | dev_err(pctldev->dev, | ||
128 | "pin %s already requested by %s; cannot claim for %s\n", | ||
129 | desc->name, desc->gpio_owner, owner); | ||
130 | goto out; | ||
131 | } | ||
119 | 132 | ||
120 | desc->mux_usecount++; | 133 | desc->mux_usecount++; |
121 | if (desc->mux_usecount > 1) | 134 | if (desc->mux_usecount > 1) |