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>
This commit is contained in:

committed by
Linus Walleij

parent
0e3db173e2
commit
6e5e959dde
@@ -12,12 +12,14 @@
|
||||
#ifndef __LINUX_PINCTRL_CONSUMER_H
|
||||
#define __LINUX_PINCTRL_CONSUMER_H
|
||||
|
||||
#include <linux/err.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include "pinctrl.h"
|
||||
|
||||
/* This struct is private to the core and should be regarded as a cookie */
|
||||
struct pinctrl;
|
||||
struct pinctrl_state;
|
||||
|
||||
#ifdef CONFIG_PINCTRL
|
||||
|
||||
@@ -26,10 +28,13 @@ extern int pinctrl_request_gpio(unsigned gpio);
|
||||
extern void pinctrl_free_gpio(unsigned gpio);
|
||||
extern int pinctrl_gpio_direction_input(unsigned gpio);
|
||||
extern int pinctrl_gpio_direction_output(unsigned gpio);
|
||||
extern struct pinctrl * __must_check pinctrl_get(struct device *dev, const char *name);
|
||||
|
||||
extern struct pinctrl * __must_check pinctrl_get(struct device *dev);
|
||||
extern void pinctrl_put(struct pinctrl *p);
|
||||
extern int pinctrl_enable(struct pinctrl *p);
|
||||
extern void pinctrl_disable(struct pinctrl *p);
|
||||
extern struct pinctrl_state * __must_check pinctrl_lookup_state(
|
||||
struct pinctrl *p,
|
||||
const char *name);
|
||||
extern int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *s);
|
||||
|
||||
#else /* !CONFIG_PINCTRL */
|
||||
|
||||
@@ -52,7 +57,7 @@ static inline int pinctrl_gpio_direction_output(unsigned gpio)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline struct pinctrl * __must_check pinctrl_get(struct device *dev, const char *name)
|
||||
static inline struct pinctrl * __must_check pinctrl_get(struct device *dev)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -61,16 +66,52 @@ static inline void pinctrl_put(struct pinctrl *p)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int pinctrl_enable(struct pinctrl *p)
|
||||
static inline struct pinctrl_state * __must_check pinctrl_lookup_state(
|
||||
struct pinctrl *p,
|
||||
const char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int pinctrl_select_state(struct pinctrl *p,
|
||||
struct pinctrl_state *s)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void pinctrl_disable(struct pinctrl *p)
|
||||
#endif /* CONFIG_PINCTRL */
|
||||
|
||||
static inline struct pinctrl * __must_check pinctrl_get_select(
|
||||
struct device *dev, const char *name)
|
||||
{
|
||||
struct pinctrl *p;
|
||||
struct pinctrl_state *s;
|
||||
int ret;
|
||||
|
||||
p = pinctrl_get(dev);
|
||||
if (IS_ERR(p))
|
||||
return p;
|
||||
|
||||
s = pinctrl_lookup_state(p, name);
|
||||
if (IS_ERR(s)) {
|
||||
pinctrl_put(p);
|
||||
return ERR_PTR(PTR_ERR(s));
|
||||
}
|
||||
|
||||
ret = pinctrl_select_state(p, s);
|
||||
if (ret < 0) {
|
||||
pinctrl_put(p);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PINCTRL */
|
||||
static inline struct pinctrl * __must_check pinctrl_get_select_default(
|
||||
struct device *dev)
|
||||
{
|
||||
return pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PINCONF
|
||||
|
||||
|
@@ -21,23 +21,22 @@
|
||||
* same name as the pin controllers own dev_name(), the map entry will be
|
||||
* hogged by the driver itself upon registration
|
||||
* @name: the name of this specific map entry for the particular machine.
|
||||
* This is the second parameter passed to pinmux_get() when you want
|
||||
* to have several mappings to the same device
|
||||
* This is the parameter passed to pinmux_lookup_state()
|
||||
* @ctrl_dev_name: the name of the device controlling this specific mapping,
|
||||
* the name must be the same as in your struct device*
|
||||
* @function: a function in the driver to use for this mapping, the driver
|
||||
* will lookup the function referenced by this ID on the specified
|
||||
* pin control device
|
||||
* @group: sometimes a function can map to different pin groups, so this
|
||||
* selects a certain specific pin group to activate for the function, if
|
||||
* left as NULL, the first applicable group will be used
|
||||
* @function: a function in the driver to use for this mapping, the driver
|
||||
* will lookup the function referenced by this ID on the specified
|
||||
* pin control device
|
||||
*/
|
||||
struct pinctrl_map {
|
||||
const char *dev_name;
|
||||
const char *name;
|
||||
const char *ctrl_dev_name;
|
||||
const char *function;
|
||||
const char *group;
|
||||
const char *function;
|
||||
};
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user