diff options
| author | Stephen Warren <swarren@nvidia.com> | 2012-03-02 15:05:47 -0500 |
|---|---|---|
| committer | Linus Walleij <linus.walleij@linaro.org> | 2012-03-05 05:22:59 -0500 |
| commit | 6e5e959dde0d92d177f035652aeaa77f9330c9c6 (patch) | |
| tree | c2d874df6a1c591b558a17591a1c8fbc2ba7a1e1 /include/linux/pinctrl | |
| parent | 0e3db173e2b9fd3b82246516e72c17763eb5f98d (diff) | |
pinctrl: API changes to support multiple states per device
The API model is changed from:
p = pinctrl_get(dev, "state1");
pinctrl_enable(p);
...
pinctrl_disable(p);
pinctrl_put(p);
p = pinctrl_get(dev, "state2");
pinctrl_enable(p);
...
pinctrl_disable(p);
pinctrl_put(p);
to this:
p = pinctrl_get(dev);
s1 = pinctrl_lookup_state(p, "state1");
s2 = pinctrl_lookup_state(p, "state2");
pinctrl_select_state(p, s1);
...
pinctrl_select_state(p, s2);
...
pinctrl_put(p);
This allows devices to directly transition between states without
disabling the pin controller programming and put()/get()ing the
configuration data each time. This model will also better suit pinconf
programming, which doesn't have a concept of "disable".
The special-case hogging feature of pin controllers is re-written to use
the regular APIs instead of special-case code. Hence, the pinmux-hogs
debugfs file is removed; see the top-level pinctrl-handles files for
equivalent data.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux/pinctrl')
| -rw-r--r-- | include/linux/pinctrl/consumer.h | 55 | ||||
| -rw-r--r-- | include/linux/pinctrl/machine.h | 11 |
2 files changed, 53 insertions, 13 deletions
diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h index 30865947f2d9..9ad5896cfa0e 100644 --- a/include/linux/pinctrl/consumer.h +++ b/include/linux/pinctrl/consumer.h | |||
| @@ -12,12 +12,14 @@ | |||
| 12 | #ifndef __LINUX_PINCTRL_CONSUMER_H | 12 | #ifndef __LINUX_PINCTRL_CONSUMER_H |
| 13 | #define __LINUX_PINCTRL_CONSUMER_H | 13 | #define __LINUX_PINCTRL_CONSUMER_H |
| 14 | 14 | ||
| 15 | #include <linux/err.h> | ||
| 15 | #include <linux/list.h> | 16 | #include <linux/list.h> |
| 16 | #include <linux/seq_file.h> | 17 | #include <linux/seq_file.h> |
| 17 | #include "pinctrl.h" | 18 | #include "pinctrl.h" |
| 18 | 19 | ||
| 19 | /* This struct is private to the core and should be regarded as a cookie */ | 20 | /* This struct is private to the core and should be regarded as a cookie */ |
| 20 | struct pinctrl; | 21 | struct pinctrl; |
| 22 | struct pinctrl_state; | ||
| 21 | 23 | ||
| 22 | #ifdef CONFIG_PINCTRL | 24 | #ifdef CONFIG_PINCTRL |
| 23 | 25 | ||
| @@ -26,10 +28,13 @@ extern int pinctrl_request_gpio(unsigned gpio); | |||
| 26 | extern void pinctrl_free_gpio(unsigned gpio); | 28 | extern void pinctrl_free_gpio(unsigned gpio); |
| 27 | extern int pinctrl_gpio_direction_input(unsigned gpio); | 29 | extern int pinctrl_gpio_direction_input(unsigned gpio); |
| 28 | extern int pinctrl_gpio_direction_output(unsigned gpio); | 30 | extern int pinctrl_gpio_direction_output(unsigned gpio); |
| 29 | extern struct pinctrl * __must_check pinctrl_get(struct device *dev, const char *name); | 31 | |
| 32 | extern struct pinctrl * __must_check pinctrl_get(struct device *dev); | ||
| 30 | extern void pinctrl_put(struct pinctrl *p); | 33 | extern void pinctrl_put(struct pinctrl *p); |
| 31 | extern int pinctrl_enable(struct pinctrl *p); | 34 | extern struct pinctrl_state * __must_check pinctrl_lookup_state( |
| 32 | extern void pinctrl_disable(struct pinctrl *p); | 35 | struct pinctrl *p, |
| 36 | const char *name); | ||
| 37 | extern int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *s); | ||
| 33 | 38 | ||
| 34 | #else /* !CONFIG_PINCTRL */ | 39 | #else /* !CONFIG_PINCTRL */ |
| 35 | 40 | ||
| @@ -52,7 +57,7 @@ static inline int pinctrl_gpio_direction_output(unsigned gpio) | |||
| 52 | return 0; | 57 | return 0; |
| 53 | } | 58 | } |
| 54 | 59 | ||
| 55 | static inline struct pinctrl * __must_check pinctrl_get(struct device *dev, const char *name) | 60 | static inline struct pinctrl * __must_check pinctrl_get(struct device *dev) |
| 56 | { | 61 | { |
| 57 | return NULL; | 62 | return NULL; |
| 58 | } | 63 | } |
| @@ -61,17 +66,53 @@ static inline void pinctrl_put(struct pinctrl *p) | |||
| 61 | { | 66 | { |
| 62 | } | 67 | } |
| 63 | 68 | ||
| 64 | static inline int pinctrl_enable(struct pinctrl *p) | 69 | static inline struct pinctrl_state * __must_check pinctrl_lookup_state( |
| 70 | struct pinctrl *p, | ||
| 71 | const char *name) | ||
| 65 | { | 72 | { |
| 66 | return 0; | 73 | return NULL; |
| 67 | } | 74 | } |
| 68 | 75 | ||
| 69 | static inline void pinctrl_disable(struct pinctrl *p) | 76 | static inline int pinctrl_select_state(struct pinctrl *p, |
| 77 | struct pinctrl_state *s) | ||
| 70 | { | 78 | { |
| 79 | return 0; | ||
| 71 | } | 80 | } |
| 72 | 81 | ||
| 73 | #endif /* CONFIG_PINCTRL */ | 82 | #endif /* CONFIG_PINCTRL */ |
| 74 | 83 | ||
| 84 | static inline struct pinctrl * __must_check pinctrl_get_select( | ||
| 85 | struct device *dev, const char *name) | ||
| 86 | { | ||
| 87 | struct pinctrl *p; | ||
| 88 | struct pinctrl_state *s; | ||
| 89 | int ret; | ||
| 90 | |||
| 91 | p = pinctrl_get(dev); | ||
| 92 | if (IS_ERR(p)) | ||
| 93 | return p; | ||
| 94 | |||
| 95 | s = pinctrl_lookup_state(p, name); | ||
| 96 | if (IS_ERR(s)) { | ||
| 97 | pinctrl_put(p); | ||
| 98 | return ERR_PTR(PTR_ERR(s)); | ||
| 99 | } | ||
| 100 | |||
| 101 | ret = pinctrl_select_state(p, s); | ||
| 102 | if (ret < 0) { | ||
| 103 | pinctrl_put(p); | ||
| 104 | return ERR_PTR(ret); | ||
| 105 | } | ||
| 106 | |||
| 107 | return p; | ||
| 108 | } | ||
| 109 | |||
| 110 | static inline struct pinctrl * __must_check pinctrl_get_select_default( | ||
| 111 | struct device *dev) | ||
| 112 | { | ||
| 113 | return pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT); | ||
| 114 | } | ||
| 115 | |||
| 75 | #ifdef CONFIG_PINCONF | 116 | #ifdef CONFIG_PINCONF |
| 76 | 117 | ||
| 77 | extern int pin_config_get(const char *dev_name, const char *name, | 118 | extern int pin_config_get(const char *dev_name, const char *name, |
diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h index 20e97353d5f9..05d25c8adbaf 100644 --- a/include/linux/pinctrl/machine.h +++ b/include/linux/pinctrl/machine.h | |||
| @@ -21,23 +21,22 @@ | |||
| 21 | * same name as the pin controllers own dev_name(), the map entry will be | 21 | * same name as the pin controllers own dev_name(), the map entry will be |
| 22 | * hogged by the driver itself upon registration | 22 | * hogged by the driver itself upon registration |
| 23 | * @name: the name of this specific map entry for the particular machine. | 23 | * @name: the name of this specific map entry for the particular machine. |
| 24 | * This is the second parameter passed to pinmux_get() when you want | 24 | * This is the parameter passed to pinmux_lookup_state() |
| 25 | * to have several mappings to the same device | ||
| 26 | * @ctrl_dev_name: the name of the device controlling this specific mapping, | 25 | * @ctrl_dev_name: the name of the device controlling this specific mapping, |
| 27 | * the name must be the same as in your struct device* | 26 | * the name must be the same as in your struct device* |
| 28 | * @function: a function in the driver to use for this mapping, the driver | ||
| 29 | * will lookup the function referenced by this ID on the specified | ||
| 30 | * pin control device | ||
| 31 | * @group: sometimes a function can map to different pin groups, so this | 27 | * @group: sometimes a function can map to different pin groups, so this |
| 32 | * selects a certain specific pin group to activate for the function, if | 28 | * selects a certain specific pin group to activate for the function, if |
| 33 | * left as NULL, the first applicable group will be used | 29 | * left as NULL, the first applicable group will be used |
| 30 | * @function: a function in the driver to use for this mapping, the driver | ||
| 31 | * will lookup the function referenced by this ID on the specified | ||
| 32 | * pin control device | ||
| 34 | */ | 33 | */ |
| 35 | struct pinctrl_map { | 34 | struct pinctrl_map { |
| 36 | const char *dev_name; | 35 | const char *dev_name; |
| 37 | const char *name; | 36 | const char *name; |
| 38 | const char *ctrl_dev_name; | 37 | const char *ctrl_dev_name; |
| 39 | const char *function; | ||
| 40 | const char *group; | 38 | const char *group; |
| 39 | const char *function; | ||
| 41 | }; | 40 | }; |
| 42 | 41 | ||
| 43 | /* | 42 | /* |
