diff options
Diffstat (limited to 'drivers/pinctrl/nomadik')
-rw-r--r-- | drivers/pinctrl/nomadik/pinctrl-nomadik.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c index 6c9667a44b7b..09efb8c1a2eb 100644 --- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c +++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c | |||
@@ -1505,51 +1505,55 @@ static int nmk_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev, | |||
1505 | const char *function = NULL; | 1505 | const char *function = NULL; |
1506 | unsigned long configs = 0; | 1506 | unsigned long configs = 0; |
1507 | bool has_config = 0; | 1507 | bool has_config = 0; |
1508 | unsigned reserve = 0; | ||
1509 | struct property *prop; | 1508 | struct property *prop; |
1510 | const char *group, *gpio_name; | 1509 | const char *group, *gpio_name; |
1511 | struct device_node *np_config; | 1510 | struct device_node *np_config; |
1512 | 1511 | ||
1513 | ret = of_property_read_string(np, "ste,function", &function); | 1512 | ret = of_property_read_string(np, "ste,function", &function); |
1514 | if (ret >= 0) | 1513 | if (ret >= 0) { |
1515 | reserve = 1; | 1514 | ret = of_property_count_strings(np, "ste,pins"); |
1516 | 1515 | if (ret < 0) | |
1517 | has_config = nmk_pinctrl_dt_get_config(np, &configs); | 1516 | goto exit; |
1518 | 1517 | ||
1519 | np_config = of_parse_phandle(np, "ste,config", 0); | 1518 | ret = pinctrl_utils_reserve_map(pctldev, map, |
1520 | if (np_config) | 1519 | reserved_maps, |
1521 | has_config |= nmk_pinctrl_dt_get_config(np_config, &configs); | 1520 | num_maps, ret); |
1522 | 1521 | if (ret < 0) | |
1523 | ret = of_property_count_strings(np, "ste,pins"); | 1522 | goto exit; |
1524 | if (ret < 0) | 1523 | |
1525 | goto exit; | 1524 | of_property_for_each_string(np, "ste,pins", prop, group) { |
1526 | |||
1527 | if (has_config) | ||
1528 | reserve++; | ||
1529 | |||
1530 | reserve *= ret; | ||
1531 | |||
1532 | ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps, num_maps, reserve); | ||
1533 | if (ret < 0) | ||
1534 | goto exit; | ||
1535 | |||
1536 | of_property_for_each_string(np, "ste,pins", prop, group) { | ||
1537 | if (function) { | ||
1538 | ret = nmk_dt_add_map_mux(map, reserved_maps, num_maps, | 1525 | ret = nmk_dt_add_map_mux(map, reserved_maps, num_maps, |
1539 | group, function); | 1526 | group, function); |
1540 | if (ret < 0) | 1527 | if (ret < 0) |
1541 | goto exit; | 1528 | goto exit; |
1542 | } | 1529 | } |
1543 | if (has_config) { | 1530 | } |
1531 | |||
1532 | has_config = nmk_pinctrl_dt_get_config(np, &configs); | ||
1533 | np_config = of_parse_phandle(np, "ste,config", 0); | ||
1534 | if (np_config) | ||
1535 | has_config |= nmk_pinctrl_dt_get_config(np_config, &configs); | ||
1536 | if (has_config) { | ||
1537 | ret = of_property_count_strings(np, "ste,pins"); | ||
1538 | if (ret < 0) | ||
1539 | goto exit; | ||
1540 | ret = pinctrl_utils_reserve_map(pctldev, map, | ||
1541 | reserved_maps, | ||
1542 | num_maps, ret); | ||
1543 | if (ret < 0) | ||
1544 | goto exit; | ||
1545 | |||
1546 | of_property_for_each_string(np, "ste,pins", prop, group) { | ||
1544 | gpio_name = nmk_find_pin_name(pctldev, group); | 1547 | gpio_name = nmk_find_pin_name(pctldev, group); |
1545 | 1548 | ||
1546 | ret = nmk_dt_add_map_configs(map, reserved_maps, num_maps, | 1549 | ret = nmk_dt_add_map_configs(map, reserved_maps, |
1547 | gpio_name, &configs, 1); | 1550 | num_maps, |
1551 | gpio_name, &configs, 1); | ||
1548 | if (ret < 0) | 1552 | if (ret < 0) |
1549 | goto exit; | 1553 | goto exit; |
1550 | } | 1554 | } |
1551 | |||
1552 | } | 1555 | } |
1556 | |||
1553 | exit: | 1557 | exit: |
1554 | return ret; | 1558 | return ret; |
1555 | } | 1559 | } |