aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinconf-generic.c
diff options
context:
space:
mode:
authorSoren Brinkmann <soren.brinkmann@xilinx.com>2015-01-09 10:43:45 -0500
committerLinus Walleij <linus.walleij@linaro.org>2015-01-11 16:30:04 -0500
commit31c89c959667194350f496947b576c149503ce98 (patch)
tree2a80a80d0b2c3b529c019e13c5f98cd88fde5c97 /drivers/pinctrl/pinconf-generic.c
parente2821bee40bec00aed5abffa446a5ac3738b041e (diff)
pinctrl: pinconf-generic: Infer map type from DT property
With the new 'groups' property, the DT parser can infer the map type from the fact whether 'pins' or 'groups' is used to specify the pin group to work on. To maintain backwards compatibitliy with current usage of the DT binding, this is only done when PIN_MAP_TYPE_INVALID is passed to the parsing function as type. Also, a new helper 'pinconf_generic_dt_node_to_map_all()' is introduced, which can be used by drivers as generic callback for dt_node_to_map() to leverage the new feature. Changes since v2: - rename dt_pin_specifier to subnode_target_type - add additional comment in header file explaining passing an invalid map type - mention map_all() helper in commit message Changes since RFC v2: - none Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com> Tested-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinconf-generic.c')
-rw-r--r--drivers/pinctrl/pinconf-generic.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index f78b416d7984..21b3d90ebb2d 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -264,6 +264,7 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
264 unsigned reserve; 264 unsigned reserve;
265 struct property *prop; 265 struct property *prop;
266 const char *group; 266 const char *group;
267 const char *subnode_target_type = "pins";
267 268
268 ret = of_property_read_string(np, "function", &function); 269 ret = of_property_read_string(np, "function", &function);
269 if (ret < 0) { 270 if (ret < 0) {
@@ -284,10 +285,20 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
284 reserve++; 285 reserve++;
285 if (num_configs) 286 if (num_configs)
286 reserve++; 287 reserve++;
288
287 ret = of_property_count_strings(np, "pins"); 289 ret = of_property_count_strings(np, "pins");
288 if (ret < 0) { 290 if (ret < 0) {
289 dev_err(dev, "could not parse property pins\n"); 291 ret = of_property_count_strings(np, "groups");
290 goto exit; 292 if (ret < 0) {
293 dev_err(dev, "could not parse property pins/groups\n");
294 goto exit;
295 }
296 if (type == PIN_MAP_TYPE_INVALID)
297 type = PIN_MAP_TYPE_CONFIGS_GROUP;
298 subnode_target_type = "groups";
299 } else {
300 if (type == PIN_MAP_TYPE_INVALID)
301 type = PIN_MAP_TYPE_CONFIGS_PIN;
291 } 302 }
292 reserve *= ret; 303 reserve *= ret;
293 304
@@ -296,7 +307,7 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
296 if (ret < 0) 307 if (ret < 0)
297 goto exit; 308 goto exit;
298 309
299 of_property_for_each_string(np, "pins", prop, group) { 310 of_property_for_each_string(np, subnode_target_type, prop, group) {
300 if (function) { 311 if (function) {
301 ret = pinctrl_utils_add_map_mux(pctldev, map, 312 ret = pinctrl_utils_add_map_mux(pctldev, map,
302 reserved_maps, num_maps, group, 313 reserved_maps, num_maps, group,