diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2011-11-14 04:06:22 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-01-03 03:10:01 -0500 |
commit | 542e704f3ffee1dc4539c9e8191e4dc215220f5e (patch) | |
tree | da2f8aae8bedb6e3216b4808dc743eb94c3270e3 /include/linux/pinctrl | |
parent | 75d6642a3ee1dfe2552028997cdcc2c4207bec8f (diff) |
pinctrl: GPIO direction support for muxing
When requesting a single GPIO pin to be muxed in, some controllers
will need to poke a different value into the control register
depending on whether the pin will be used for GPIO output or GPIO
input. So create pinmux counterparts to gpio_direction_[input|output]
in the pinctrl framework.
ChangeLog v1->v2:
- This also amends the documentation to make it clear the this
function and associated machinery is *ONLY* intended as a backend
to gpiolib machinery, not for everyone and his dog to start playing
around with pins.
ChangeLog v2->v3:
- Don't pass an argument to the common request function, instead
provide pinmux_* counterparts to the gpio_direction_[input|output]
calls, simpler and anyone can understand it.
ChangeLog v3->v4:
- Fix numerous spelling mistakes and dangling text in documentation.
Add Ack and Rewewed-by.
Cc: Igor Grinberg <grinberg@compulab.co.il>
Acked-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Thomas Abraham <thomas.abraham@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux/pinctrl')
-rw-r--r-- | include/linux/pinctrl/pinmux.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/include/linux/pinctrl/pinmux.h b/include/linux/pinctrl/pinmux.h index bb7a9792f1ea..937b3e2fa36f 100644 --- a/include/linux/pinctrl/pinmux.h +++ b/include/linux/pinctrl/pinmux.h | |||
@@ -54,7 +54,13 @@ struct pinctrl_dev; | |||
54 | * Implement this only if you can mux every pin individually as GPIO. The | 54 | * Implement this only if you can mux every pin individually as GPIO. The |
55 | * affected GPIO range is passed along with an offset(pin number) into that | 55 | * affected GPIO range is passed along with an offset(pin number) into that |
56 | * specific GPIO range - function selectors and pin groups are orthogonal | 56 | * specific GPIO range - function selectors and pin groups are orthogonal |
57 | * to this, the core will however make sure the pins do not collide | 57 | * to this, the core will however make sure the pins do not collide. |
58 | * @gpio_disable_free: free up GPIO muxing on a certain pin, the reverse of | ||
59 | * @gpio_request_enable | ||
60 | * @gpio_set_direction: Since controllers may need different configurations | ||
61 | * depending on whether the GPIO is configured as input or output, | ||
62 | * a direction selector function may be implemented as a backing | ||
63 | * to the GPIO controllers that need pin muxing. | ||
58 | */ | 64 | */ |
59 | struct pinmux_ops { | 65 | struct pinmux_ops { |
60 | int (*request) (struct pinctrl_dev *pctldev, unsigned offset); | 66 | int (*request) (struct pinctrl_dev *pctldev, unsigned offset); |
@@ -76,11 +82,17 @@ struct pinmux_ops { | |||
76 | void (*gpio_disable_free) (struct pinctrl_dev *pctldev, | 82 | void (*gpio_disable_free) (struct pinctrl_dev *pctldev, |
77 | struct pinctrl_gpio_range *range, | 83 | struct pinctrl_gpio_range *range, |
78 | unsigned offset); | 84 | unsigned offset); |
85 | int (*gpio_set_direction) (struct pinctrl_dev *pctldev, | ||
86 | struct pinctrl_gpio_range *range, | ||
87 | unsigned offset, | ||
88 | bool input); | ||
79 | }; | 89 | }; |
80 | 90 | ||
81 | /* External interface to pinmux */ | 91 | /* External interface to pinmux */ |
82 | extern int pinmux_request_gpio(unsigned gpio); | 92 | extern int pinmux_request_gpio(unsigned gpio); |
83 | extern void pinmux_free_gpio(unsigned gpio); | 93 | extern void pinmux_free_gpio(unsigned gpio); |
94 | extern int pinmux_gpio_direction_input(unsigned gpio); | ||
95 | extern int pinmux_gpio_direction_output(unsigned gpio); | ||
84 | extern struct pinmux * __must_check pinmux_get(struct device *dev, const char *name); | 96 | extern struct pinmux * __must_check pinmux_get(struct device *dev, const char *name); |
85 | extern void pinmux_put(struct pinmux *pmx); | 97 | extern void pinmux_put(struct pinmux *pmx); |
86 | extern int pinmux_enable(struct pinmux *pmx); | 98 | extern int pinmux_enable(struct pinmux *pmx); |
@@ -97,6 +109,16 @@ static inline void pinmux_free_gpio(unsigned gpio) | |||
97 | { | 109 | { |
98 | } | 110 | } |
99 | 111 | ||
112 | static inline int pinmux_gpio_direction_input(unsigned gpio) | ||
113 | { | ||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | static inline int pinmux_gpio_direction_output(unsigned gpio) | ||
118 | { | ||
119 | return 0; | ||
120 | } | ||
121 | |||
100 | static inline struct pinmux * __must_check pinmux_get(struct device *dev, const char *name) | 122 | static inline struct pinmux * __must_check pinmux_get(struct device *dev, const char *name) |
101 | { | 123 | { |
102 | return NULL; | 124 | return NULL; |