Message ID | 1352968600-15345-4-git-send-email-haojian.zhuang@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
* Haojian Zhuang <haojian.zhuang@gmail.com> [121115 00:39]: > --- a/include/linux/pinctrl/consumer.h > +++ b/include/linux/pinctrl/consumer.h > @@ -36,6 +36,10 @@ 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); > +extern const struct pinctrl_map * __must_check pinctrl_lookup_map( > + struct pinctrl *p, > + const char *name, > + unsigned type); > > extern struct pinctrl * __must_check devm_pinctrl_get(struct device *dev); > extern void devm_pinctrl_put(struct pinctrl *p); I think this should be in drivers/pinctrl/core.h, or is there a need for the consumer drivers to use this? Regards, Tony
On Sat, Nov 17, 2012 at 8:46 AM, Tony Lindgren <tony@atomide.com> wrote: > * Haojian Zhuang <haojian.zhuang@gmail.com> [121115 00:39]: >> --- a/include/linux/pinctrl/consumer.h >> +++ b/include/linux/pinctrl/consumer.h >> @@ -36,6 +36,10 @@ 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); >> +extern const struct pinctrl_map * __must_check pinctrl_lookup_map( >> + struct pinctrl *p, >> + const char *name, >> + unsigned type); >> >> extern struct pinctrl * __must_check devm_pinctrl_get(struct device *dev); >> extern void devm_pinctrl_put(struct pinctrl *p); > > I think this should be in drivers/pinctrl/core.h, or is there > a need for the consumer drivers to use this? > Seems reasonable. I'll move into into core.h.
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 2e39c04..0d36270 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -839,6 +839,30 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) } EXPORT_SYMBOL_GPL(pinctrl_select_state); +const struct pinctrl_map *pinctrl_lookup_map(struct pinctrl *p, + const char *name, unsigned type) +{ + struct pinctrl_maps *maps_node; + struct pinctrl_map const *map; + int i; + + for_each_maps(maps_node, i, map) { + /* Map must be for this device */ + if (strcmp(map->ctrl_dev_name, dev_name(p->dev))) + continue; + if (map->type != type) + continue; + if (map->type == PIN_MAP_TYPE_MUX_GROUP) + if (!strcmp(map->data.mux.group, name)) + return map; + if (map->type == PIN_MAP_TYPE_CONFIGS_GROUP) + if (!strcmp(map->data.configs.group_or_pin, name)) + return map; + } + return NULL; +} +EXPORT_SYMBOL_GPL(pinctrl_lookup_map); + static void devm_pinctrl_release(struct device *dev, void *res) { pinctrl_put(*(struct pinctrl **)res); diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h index 4aad3ce..2687515 100644 --- a/include/linux/pinctrl/consumer.h +++ b/include/linux/pinctrl/consumer.h @@ -36,6 +36,10 @@ 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); +extern const struct pinctrl_map * __must_check pinctrl_lookup_map( + struct pinctrl *p, + const char *name, + unsigned type); extern struct pinctrl * __must_check devm_pinctrl_get(struct device *dev); extern void devm_pinctrl_put(struct pinctrl *p);
pinctrl driver gets pinctrl map if both group and map type is specified. In pinctrl-single driver, each pin group is defined in DT file. The pinconf information is also defined in each pin group. pinctrl-single driver could store those mask/shift/value information into pinctrl map. pinconf_get()/pinconf_set() and pinconf_group_get()/pinconf_group_set() could get those information from pinctrl map. Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com> --- drivers/pinctrl/core.c | 24 ++++++++++++++++++++++++ include/linux/pinctrl/consumer.h | 4 ++++ 2 files changed, 28 insertions(+)