pinctrl: add pinctrl_provide_dummies interface for platforms to use
Add a interface pinctrl_provide_dummies for platform to indicate whether it needs use pinctrl dummy state. ChangeLog v3->v4: * remove dummy gpio support in pinctrl subsystem. Let gpio driver decide whether it wants to use pinctrl gpio mux function. ChangeLog v2->v3: * Also changed the missed pinctrl gpio APIs in v1. ChangeLog v1->v2: * Based on sascha's suggestion, drop using kconfig since it will hide pinctrl errors on all other boards. See: https://lkml.org/lkml/2012/4/18/282 It seemed both Linus and Stephen agreed with this way, so i'm ok with it too. * Add dummy gpio support. pinctrl gpio in the same situation as state. * Patch name changed. Original is pinctrl: handle dummy state in core. * Split removing old dt dummy interface into a separate patch Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
ad6e1107ba
commit
5b3aa5f7c6
|
@ -43,6 +43,8 @@ struct pinctrl_maps {
|
||||||
unsigned num_maps;
|
unsigned num_maps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool pinctrl_dummy_state;
|
||||||
|
|
||||||
/* Mutex taken by all entry points */
|
/* Mutex taken by all entry points */
|
||||||
DEFINE_MUTEX(pinctrl_mutex);
|
DEFINE_MUTEX(pinctrl_mutex);
|
||||||
|
|
||||||
|
@ -61,6 +63,19 @@ static LIST_HEAD(pinctrl_maps);
|
||||||
_i_ < _maps_node_->num_maps; \
|
_i_ < _maps_node_->num_maps; \
|
||||||
i++, _map_ = &_maps_node_->maps[_i_])
|
i++, _map_ = &_maps_node_->maps[_i_])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pinctrl_provide_dummies() - indicate if pinctrl provides dummy state support
|
||||||
|
*
|
||||||
|
* Usually this function is called by platforms without pinctrl driver support
|
||||||
|
* but run with some shared drivers using pinctrl APIs.
|
||||||
|
* After calling this function, the pinctrl core will return successfully
|
||||||
|
* with creating a dummy state for the driver to keep going smoothly.
|
||||||
|
*/
|
||||||
|
void pinctrl_provide_dummies(void)
|
||||||
|
{
|
||||||
|
pinctrl_dummy_state = true;
|
||||||
|
}
|
||||||
|
|
||||||
const char *pinctrl_dev_get_name(struct pinctrl_dev *pctldev)
|
const char *pinctrl_dev_get_name(struct pinctrl_dev *pctldev)
|
||||||
{
|
{
|
||||||
/* We're not allowed to register devices without name */
|
/* We're not allowed to register devices without name */
|
||||||
|
@ -719,8 +734,18 @@ static struct pinctrl_state *pinctrl_lookup_state_locked(struct pinctrl *p,
|
||||||
struct pinctrl_state *state;
|
struct pinctrl_state *state;
|
||||||
|
|
||||||
state = find_state(p, name);
|
state = find_state(p, name);
|
||||||
if (!state)
|
if (!state) {
|
||||||
return ERR_PTR(-ENODEV);
|
if (pinctrl_dummy_state) {
|
||||||
|
/* create dummy state */
|
||||||
|
dev_dbg(p->dev, "using pinctrl dummy state (%s)\n",
|
||||||
|
name);
|
||||||
|
state = create_state(p, name);
|
||||||
|
if (IS_ERR(state))
|
||||||
|
return state;
|
||||||
|
} else {
|
||||||
|
return ERR_PTR(-ENODEV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ struct pinctrl_map {
|
||||||
|
|
||||||
extern int pinctrl_register_mappings(struct pinctrl_map const *map,
|
extern int pinctrl_register_mappings(struct pinctrl_map const *map,
|
||||||
unsigned num_maps);
|
unsigned num_maps);
|
||||||
|
extern void pinctrl_provide_dummies(void);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
|
static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
|
||||||
|
@ -163,5 +163,8 @@ static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void pinctrl_provide_dummies(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
#endif /* !CONFIG_PINCTRL */
|
#endif /* !CONFIG_PINCTRL */
|
||||||
#endif
|
#endif
|
||||||
|
|
Reference in New Issue