Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: avoid duplicated calling enable_pinmux_setting for a pin

What the patch does:
1. Call pinmux_disable_setting ahead of pinmux_enable_setting
each time pinctrl_select_state is called
2. Remove the HW disable operation in pinmux_disable_setting function.
3. Remove the disable ops in struct pinmux_ops
4. Remove all the disable ops users in current code base.

Notes:
1. Great thanks for the suggestion from Linus, Tony Lindgren and
Stephen Warren and Everyone that shared comments on this patch.
2. The patch also includes comment fixes from Stephen Warren.

The reason why we do this:
1. To avoid duplicated calling of the enable_setting operation
without disabling operation inbetween which will let the pin
descriptor desc->mux_usecount increase monotonously.
2. The HW pin disable operation is not useful for any of the
existing platforms.
And this can be used to avoid the HW glitch after using the
item #1 modification.

In the following case, the issue can be reproduced:
1. There is a driver that need to switch pin state dynamically,
e.g. between "sleep" and "default" state
2. The pin setting configuration in a DTS node may be like this:

component a {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&a_grp_setting &c_grp_setting>;
pinctrl-1 = <&b_grp_setting &c_grp_setting>;
}

The "c_grp_setting" config node is totally identical, maybe like
following one:

c_grp_setting: c_grp_setting {
pinctrl-single,pins = <GPIO48 AF6>;
}

3. When switching the pin state in the following official pinctrl
sequence:
pin = pinctrl_get();
state = pinctrl_lookup_state(wanted_state);
pinctrl_select_state(state);
pinctrl_put();

Test Result:
1. The switch is completed as expected, that is: the device's
pin configuration is changed according to the description in the
"wanted_state" group setting
2. The "desc->mux_usecount" of the corresponding pins in "c_group"
is increased without being decreased, because the "desc" is for
each physical pin while the setting is for each setting node
in the DTS.
Thus, if the "c_grp_setting" in pinctrl-0 is not disabled ahead
of enabling "c_grp_setting" in pinctrl-1, the desc->mux_usecount
will keep increasing without any chance to be decreased.

According to the comments in the original code, only the setting,
in old state but not in new state, will be "disabled" (calling
pinmux_disable_setting), which is correct logic but not intact. We
still need consider case that the setting is in both old state
and new state. We can do this in the following two ways:

1. Avoid to "enable"(calling pinmux_enable_setting) the "same pin
setting" repeatedly
2. "Disable"(calling pinmux_disable_setting) the "same pin setting",
actually two setting instances, ahead of enabling them.

Analysis:
1. The solution #2 is better because it can avoid too much
iteration.
2. If we disable all of the settings in the old state and one of
the setting(s) exist in the new state, the pins mux function
change may happen when some SoC vendors defined the
"pinctrl-single,function-off"
in their DTS file.
old_setting => disabled_setting => new_setting.
3. In the pinmux framework, when a pin state is switched, the
setting in the old state should be marked as "disabled".

Conclusion:
1. To Remove the HW disabling operation to above the glitch mentioned
above.
2. Handle the issue mentioned above by disabling all of the settings
in old state and then enable the all of the settings in new state.

Signed-off-by: Fan Wu <fwu@marvell.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Patrice Chotard <patrice.chotard@st.com>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Maxime Coquelin <maxime.coquelin@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Fan Wu and committed by
Linus Walleij
2243a87d 607af165

+5 -420
+5 -19
drivers/pinctrl/core.c
··· 992 992 993 993 if (p->state) { 994 994 /* 995 - * The set of groups with a mux configuration in the old state 996 - * may not be identical to the set of groups with a mux setting 997 - * in the new state. While this might be unusual, it's entirely 998 - * possible for the "user"-supplied mapping table to be written 999 - * that way. For each group that was configured in the old state 1000 - * but not in the new state, this code puts that group into a 1001 - * safe/disabled state. 995 + * For each pinmux setting in the old state, forget SW's record 996 + * of mux owner for that pingroup. Any pingroups which are 997 + * still owned by the new state will be re-acquired by the call 998 + * to pinmux_enable_setting() in the loop below. 1002 999 */ 1003 1000 list_for_each_entry(setting, &p->state->settings, node) { 1004 - bool found = false; 1005 1001 if (setting->type != PIN_MAP_TYPE_MUX_GROUP) 1006 1002 continue; 1007 - list_for_each_entry(setting2, &state->settings, node) { 1008 - if (setting2->type != PIN_MAP_TYPE_MUX_GROUP) 1009 - continue; 1010 - if (setting2->data.mux.group == 1011 - setting->data.mux.group) { 1012 - found = true; 1013 - break; 1014 - } 1015 - } 1016 - if (!found) 1017 - pinmux_disable_setting(setting); 1003 + pinmux_disable_setting(setting); 1018 1004 } 1019 1005 } 1020 1006
-15
drivers/pinctrl/pinctrl-abx500.c
··· 737 737 return ret; 738 738 } 739 739 740 - static void abx500_pmx_disable(struct pinctrl_dev *pctldev, 741 - unsigned function, unsigned group) 742 - { 743 - struct abx500_pinctrl *pct = pinctrl_dev_get_drvdata(pctldev); 744 - const struct abx500_pingroup *g; 745 - 746 - g = &pct->soc->groups[group]; 747 - if (g->altsetting < 0) 748 - return; 749 - 750 - /* FIXME: poke out the mux, set the pin to some default state? */ 751 - dev_dbg(pct->dev, "disable group %s, %u pins\n", g->name, g->npins); 752 - } 753 - 754 740 static int abx500_gpio_request_enable(struct pinctrl_dev *pctldev, 755 741 struct pinctrl_gpio_range *range, 756 742 unsigned offset) ··· 785 799 .get_function_name = abx500_pmx_get_func_name, 786 800 .get_function_groups = abx500_pmx_get_func_groups, 787 801 .enable = abx500_pmx_enable, 788 - .disable = abx500_pmx_disable, 789 802 .gpio_request_enable = abx500_gpio_request_enable, 790 803 .gpio_disable_free = abx500_gpio_disable_free, 791 804 };
-30
drivers/pinctrl/pinctrl-adi2.c
··· 652 652 return 0; 653 653 } 654 654 655 - static void adi_pinmux_disable(struct pinctrl_dev *pctldev, unsigned func_id, 656 - unsigned group_id) 657 - { 658 - struct adi_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctldev); 659 - struct gpio_port *port; 660 - struct pinctrl_gpio_range *range; 661 - unsigned long flags; 662 - unsigned short *mux, pin; 663 - 664 - mux = (unsigned short *)pinctrl->soc->groups[group_id].mux; 665 - 666 - while (*mux) { 667 - pin = P_IDENT(*mux); 668 - 669 - range = pinctrl_find_gpio_range_from_pin(pctldev, pin); 670 - if (range == NULL) /* should not happen */ 671 - return; 672 - 673 - port = container_of(range->gc, struct gpio_port, chip); 674 - 675 - spin_lock_irqsave(&port->lock, flags); 676 - 677 - port_setup(port, pin_to_offset(range, pin), true); 678 - mux++; 679 - 680 - spin_unlock_irqrestore(&port->lock, flags); 681 - } 682 - } 683 - 684 655 static int adi_pinmux_get_funcs_count(struct pinctrl_dev *pctldev) 685 656 { 686 657 struct adi_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctldev); ··· 699 728 700 729 static struct pinmux_ops adi_pinmux_ops = { 701 730 .enable = adi_pinmux_enable, 702 - .disable = adi_pinmux_disable, 703 731 .get_functions_count = adi_pinmux_get_funcs_count, 704 732 .get_function_name = adi_pinmux_get_func_name, 705 733 .get_function_groups = adi_pinmux_get_groups,
-21
drivers/pinctrl/pinctrl-at91.c
··· 611 611 return 0; 612 612 } 613 613 614 - static void at91_pmx_disable(struct pinctrl_dev *pctldev, unsigned selector, 615 - unsigned group) 616 - { 617 - struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 618 - const struct at91_pmx_pin *pins_conf = info->groups[group].pins_conf; 619 - const struct at91_pmx_pin *pin; 620 - uint32_t npins = info->groups[group].npins; 621 - int i; 622 - unsigned mask; 623 - void __iomem *pio; 624 - 625 - for (i = 0; i < npins; i++) { 626 - pin = &pins_conf[i]; 627 - at91_pin_dbg(info->dev, pin); 628 - pio = pin_to_controller(info, pin->bank); 629 - mask = pin_to_mask(pin->pin); 630 - at91_mux_gpio_enable(pio, mask, 1); 631 - } 632 - } 633 - 634 614 static int at91_pmx_get_funcs_count(struct pinctrl_dev *pctldev) 635 615 { 636 616 struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); ··· 685 705 .get_function_name = at91_pmx_get_func_name, 686 706 .get_function_groups = at91_pmx_get_groups, 687 707 .enable = at91_pmx_enable, 688 - .disable = at91_pmx_disable, 689 708 .gpio_request_enable = at91_gpio_request_enable, 690 709 .gpio_disable_free = at91_gpio_disable_free, 691 710 };
-11
drivers/pinctrl/pinctrl-bcm2835.c
··· 841 841 return 0; 842 842 } 843 843 844 - static void bcm2835_pmx_disable(struct pinctrl_dev *pctldev, 845 - unsigned func_selector, 846 - unsigned group_selector) 847 - { 848 - struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev); 849 - 850 - /* disable by setting to GPIO_IN */ 851 - bcm2835_pinctrl_fsel_set(pc, group_selector, BCM2835_FSEL_GPIO_IN); 852 - } 853 - 854 844 static void bcm2835_pmx_gpio_disable_free(struct pinctrl_dev *pctldev, 855 845 struct pinctrl_gpio_range *range, 856 846 unsigned offset) ··· 870 880 .get_function_name = bcm2835_pmx_get_function_name, 871 881 .get_function_groups = bcm2835_pmx_get_function_groups, 872 882 .enable = bcm2835_pmx_enable, 873 - .disable = bcm2835_pmx_disable, 874 883 .gpio_disable_free = bcm2835_pmx_gpio_disable_free, 875 884 .gpio_set_direction = bcm2835_pmx_gpio_set_direction, 876 885 };
-8
drivers/pinctrl/pinctrl-exynos5440.c
··· 371 371 return 0; 372 372 } 373 373 374 - /* disable a specified pinmux by writing to registers */ 375 - static void exynos5440_pinmux_disable(struct pinctrl_dev *pctldev, 376 - unsigned selector, unsigned group) 377 - { 378 - exynos5440_pinmux_setup(pctldev, selector, group, false); 379 - } 380 - 381 374 /* 382 375 * The calls to gpio_direction_output() and gpio_direction_input() 383 376 * leads to this function call (via the pinctrl_gpio_direction_{input|output}() ··· 388 395 .get_function_name = exynos5440_pinmux_get_fname, 389 396 .get_function_groups = exynos5440_pinmux_get_groups, 390 397 .enable = exynos5440_pinmux_enable, 391 - .disable = exynos5440_pinmux_disable, 392 398 .gpio_set_direction = exynos5440_pinmux_gpio_set_direction, 393 399 }; 394 400
-25
drivers/pinctrl/pinctrl-msm.c
··· 165 165 return 0; 166 166 } 167 167 168 - static void msm_pinmux_disable(struct pinctrl_dev *pctldev, 169 - unsigned function, 170 - unsigned group) 171 - { 172 - struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 173 - const struct msm_pingroup *g; 174 - unsigned long flags; 175 - u32 val; 176 - 177 - g = &pctrl->soc->groups[group]; 178 - 179 - if (WARN_ON(g->mux_bit < 0)) 180 - return; 181 - 182 - spin_lock_irqsave(&pctrl->lock, flags); 183 - 184 - /* Clear the mux bits to select gpio mode */ 185 - val = readl(pctrl->regs + g->ctl_reg); 186 - val &= ~(0x7 << g->mux_bit); 187 - writel(val, pctrl->regs + g->ctl_reg); 188 - 189 - spin_unlock_irqrestore(&pctrl->lock, flags); 190 - } 191 - 192 168 static const struct pinmux_ops msm_pinmux_ops = { 193 169 .get_functions_count = msm_get_functions_count, 194 170 .get_function_name = msm_get_function_name, 195 171 .get_function_groups = msm_get_function_groups, 196 172 .enable = msm_pinmux_enable, 197 - .disable = msm_pinmux_disable, 198 173 }; 199 174 200 175 static int msm_config_reg(struct msm_pinctrl *pctrl,
-16
drivers/pinctrl/pinctrl-nomadik.c
··· 1765 1765 return ret; 1766 1766 } 1767 1767 1768 - static void nmk_pmx_disable(struct pinctrl_dev *pctldev, 1769 - unsigned function, unsigned group) 1770 - { 1771 - struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev); 1772 - const struct nmk_pingroup *g; 1773 - 1774 - g = &npct->soc->groups[group]; 1775 - 1776 - if (g->altsetting < 0) 1777 - return; 1778 - 1779 - /* Poke out the mux, set the pin to some default state? */ 1780 - dev_dbg(npct->dev, "disable group %s, %u pins\n", g->name, g->npins); 1781 - } 1782 - 1783 1768 static int nmk_gpio_request_enable(struct pinctrl_dev *pctldev, 1784 1769 struct pinctrl_gpio_range *range, 1785 1770 unsigned offset) ··· 1811 1826 .get_function_name = nmk_pmx_get_func_name, 1812 1827 .get_function_groups = nmk_pmx_get_func_groups, 1813 1828 .enable = nmk_pmx_enable, 1814 - .disable = nmk_pmx_disable, 1815 1829 .gpio_request_enable = nmk_gpio_request_enable, 1816 1830 .gpio_disable_free = nmk_gpio_disable_free, 1817 1831 };
-18
drivers/pinctrl/pinctrl-rockchip.c
··· 657 657 return 0; 658 658 } 659 659 660 - static void rockchip_pmx_disable(struct pinctrl_dev *pctldev, 661 - unsigned selector, unsigned group) 662 - { 663 - struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 664 - const unsigned int *pins = info->groups[group].pins; 665 - struct rockchip_pin_bank *bank; 666 - int cnt; 667 - 668 - dev_dbg(info->dev, "disable function %s group %s\n", 669 - info->functions[selector].name, info->groups[group].name); 670 - 671 - for (cnt = 0; cnt < info->groups[group].npins; cnt++) { 672 - bank = pin_to_bank(info, pins[cnt]); 673 - rockchip_set_mux(bank, pins[cnt] - bank->pin_base, 0); 674 - } 675 - } 676 - 677 660 /* 678 661 * The calls to gpio_direction_output() and gpio_direction_input() 679 662 * leads to this function call (via the pinctrl_gpio_direction_{input|output}() ··· 699 716 .get_function_name = rockchip_pmx_get_func_name, 700 717 .get_function_groups = rockchip_pmx_get_groups, 701 718 .enable = rockchip_pmx_enable, 702 - .disable = rockchip_pmx_disable, 703 719 .gpio_set_direction = rockchip_pmx_gpio_set_direction, 704 720 }; 705 721
-8
drivers/pinctrl/pinctrl-samsung.c
··· 333 333 return 0; 334 334 } 335 335 336 - /* disable a specified pinmux by writing to registers */ 337 - static void samsung_pinmux_disable(struct pinctrl_dev *pctldev, 338 - unsigned selector, unsigned group) 339 - { 340 - samsung_pinmux_setup(pctldev, selector, group, false); 341 - } 342 - 343 336 /* 344 337 * The calls to gpio_direction_output() and gpio_direction_input() 345 338 * leads to this function call (via the pinctrl_gpio_direction_{input|output}() ··· 383 390 .get_function_name = samsung_pinmux_get_fname, 384 391 .get_function_groups = samsung_pinmux_get_groups, 385 392 .enable = samsung_pinmux_enable, 386 - .disable = samsung_pinmux_disable, 387 393 .gpio_set_direction = samsung_pinmux_gpio_set_direction, 388 394 }; 389 395
-56
drivers/pinctrl/pinctrl-single.c
··· 488 488 return 0; 489 489 } 490 490 491 - static void pcs_disable(struct pinctrl_dev *pctldev, unsigned fselector, 492 - unsigned group) 493 - { 494 - struct pcs_device *pcs; 495 - struct pcs_function *func; 496 - int i; 497 - 498 - pcs = pinctrl_dev_get_drvdata(pctldev); 499 - /* If function mask is null, needn't disable it. */ 500 - if (!pcs->fmask) 501 - return; 502 - 503 - func = radix_tree_lookup(&pcs->ftree, fselector); 504 - if (!func) { 505 - dev_err(pcs->dev, "%s could not find function%i\n", 506 - __func__, fselector); 507 - return; 508 - } 509 - 510 - /* 511 - * Ignore disable if function-off is not specified. Some hardware 512 - * does not have clearly defined disable function. For pin specific 513 - * off modes, you can use alternate named states as described in 514 - * pinctrl-bindings.txt. 515 - */ 516 - if (pcs->foff == PCS_OFF_DISABLED) { 517 - dev_dbg(pcs->dev, "ignoring disable for %s function%i\n", 518 - func->name, fselector); 519 - return; 520 - } 521 - 522 - dev_dbg(pcs->dev, "disabling function%i %s\n", 523 - fselector, func->name); 524 - 525 - for (i = 0; i < func->nvals; i++) { 526 - struct pcs_func_vals *vals; 527 - unsigned long flags; 528 - unsigned val, mask; 529 - 530 - vals = &func->vals[i]; 531 - raw_spin_lock_irqsave(&pcs->lock, flags); 532 - val = pcs->read(vals->reg); 533 - 534 - if (pcs->bits_per_mux) 535 - mask = vals->mask; 536 - else 537 - mask = pcs->fmask; 538 - 539 - val &= ~mask; 540 - val |= pcs->foff << pcs->fshift; 541 - pcs->write(val, vals->reg); 542 - raw_spin_unlock_irqrestore(&pcs->lock, flags); 543 - } 544 - } 545 - 546 491 static int pcs_request_gpio(struct pinctrl_dev *pctldev, 547 492 struct pinctrl_gpio_range *range, unsigned pin) 548 493 { ··· 520 575 .get_function_name = pcs_get_function_name, 521 576 .get_function_groups = pcs_get_function_groups, 522 577 .enable = pcs_enable, 523 - .disable = pcs_disable, 524 578 .gpio_request_enable = pcs_request_gpio, 525 579 }; 526 580
-6
drivers/pinctrl/pinctrl-st.c
··· 930 930 return 0; 931 931 } 932 932 933 - static void st_pmx_disable(struct pinctrl_dev *pctldev, unsigned selector, 934 - unsigned group) 935 - { 936 - } 937 - 938 933 static int st_pmx_set_gpio_direction(struct pinctrl_dev *pctldev, 939 934 struct pinctrl_gpio_range *range, unsigned gpio, 940 935 bool input) ··· 952 957 .get_function_name = st_pmx_get_fname, 953 958 .get_function_groups = st_pmx_get_groups, 954 959 .enable = st_pmx_enable, 955 - .disable = st_pmx_disable, 956 960 .gpio_set_direction = st_pmx_set_gpio_direction, 957 961 }; 958 962
-17
drivers/pinctrl/pinctrl-tb10x.c
··· 738 738 return 0; 739 739 } 740 740 741 - static void tb10x_pctl_disable(struct pinctrl_dev *pctl, 742 - unsigned func_selector, unsigned group_selector) 743 - { 744 - struct tb10x_pinctrl *state = pinctrl_dev_get_drvdata(pctl); 745 - const struct tb10x_pinfuncgrp *grp = &state->pingroups[group_selector]; 746 - 747 - if (grp->port < 0) 748 - return; 749 - 750 - mutex_lock(&state->mutex); 751 - 752 - state->ports[grp->port].count--; 753 - 754 - mutex_unlock(&state->mutex); 755 - } 756 - 757 741 static struct pinmux_ops tb10x_pinmux_ops = { 758 742 .get_functions_count = tb10x_get_functions_count, 759 743 .get_function_name = tb10x_get_function_name, ··· 745 761 .gpio_request_enable = tb10x_gpio_request_enable, 746 762 .gpio_disable_free = tb10x_gpio_disable_free, 747 763 .enable = tb10x_pctl_enable, 748 - .disable = tb10x_pctl_disable, 749 764 }; 750 765 751 766 static struct pinctrl_desc tb10x_pindesc = {
-13
drivers/pinctrl/pinctrl-tegra.c
··· 290 290 return 0; 291 291 } 292 292 293 - static void tegra_pinctrl_disable(struct pinctrl_dev *pctldev, 294 - unsigned function, unsigned group) 295 - { 296 - struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 297 - const struct tegra_pingroup *g; 298 - 299 - g = &pmx->soc->groups[group]; 300 - 301 - if (WARN_ON(g->mux_reg < 0)) 302 - return; 303 - } 304 - 305 293 static const struct pinmux_ops tegra_pinmux_ops = { 306 294 .get_functions_count = tegra_pinctrl_get_funcs_count, 307 295 .get_function_name = tegra_pinctrl_get_func_name, 308 296 .get_function_groups = tegra_pinctrl_get_func_groups, 309 297 .enable = tegra_pinctrl_enable, 310 - .disable = tegra_pinctrl_disable, 311 298 }; 312 299 313 300 static int tegra_pinconf_reg(struct tegra_pmx *pmx,
-28
drivers/pinctrl/pinctrl-tz1090-pdc.c
··· 574 574 return 0; 575 575 } 576 576 577 - static void tz1090_pdc_pinctrl_disable(struct pinctrl_dev *pctldev, 578 - unsigned int function, 579 - unsigned int group) 580 - { 581 - struct tz1090_pdc_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 582 - const struct tz1090_pdc_pingroup *grp = &tz1090_pdc_groups[group]; 583 - 584 - dev_dbg(pctldev->dev, "%s(func=%u (%s), group=%u (%s))\n", 585 - __func__, 586 - function, tz1090_pdc_functions[function].name, 587 - group, tz1090_pdc_groups[group].name); 588 - 589 - /* is it even a mux? */ 590 - if (grp->drv) 591 - return; 592 - 593 - /* does this group even control the function? */ 594 - if (function != grp->func) 595 - return; 596 - 597 - /* record the pin being unmuxed and update mux bit */ 598 - spin_lock(&pmx->lock); 599 - pmx->mux_en &= ~BIT(grp->pins[0]); 600 - tz1090_pdc_pinctrl_mux(pmx, grp); 601 - spin_unlock(&pmx->lock); 602 - } 603 - 604 577 static const struct tz1090_pdc_pingroup *find_mux_group( 605 578 struct tz1090_pdc_pmx *pmx, 606 579 unsigned int pin) ··· 635 662 .get_function_name = tz1090_pdc_pinctrl_get_func_name, 636 663 .get_function_groups = tz1090_pdc_pinctrl_get_func_groups, 637 664 .enable = tz1090_pdc_pinctrl_enable, 638 - .disable = tz1090_pdc_pinctrl_disable, 639 665 .gpio_request_enable = tz1090_pdc_pinctrl_gpio_request_enable, 640 666 .gpio_disable_free = tz1090_pdc_pinctrl_gpio_disable_free, 641 667 };
-58
drivers/pinctrl/pinctrl-tz1090.c
··· 1479 1479 } 1480 1480 1481 1481 /** 1482 - * tz1090_pinctrl_disable() - Disable a function on a pin group. 1483 - * @pctldev: Pin control data 1484 - * @function: Function index to disable 1485 - * @group: Group index to disable 1486 - * 1487 - * Disable a particular function on a group of pins. The per GPIO pin pseudo pin 1488 - * groups can be used (in which case the pin will be taken out of peripheral 1489 - * mode. Some convenience pin groups can also be used in which case the effect 1490 - * is the same as enabling the function on each individual pin in the group. 1491 - */ 1492 - static void tz1090_pinctrl_disable(struct pinctrl_dev *pctldev, 1493 - unsigned int function, unsigned int group) 1494 - { 1495 - struct tz1090_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 1496 - struct tz1090_pingroup *grp; 1497 - unsigned int pin_num, mux_group, i, npins; 1498 - const unsigned int *pins; 1499 - 1500 - /* group of pins? */ 1501 - if (group < ARRAY_SIZE(tz1090_groups)) { 1502 - grp = &tz1090_groups[group]; 1503 - npins = grp->npins; 1504 - pins = grp->pins; 1505 - /* 1506 - * All pins in the group must belong to the same mux group, 1507 - * which allows us to just use the mux group of the first pin. 1508 - * By explicitly listing permitted pingroups for each function 1509 - * the pinmux core should ensure this is always the case. 1510 - */ 1511 - } else { 1512 - pin_num = group - ARRAY_SIZE(tz1090_groups); 1513 - npins = 1; 1514 - pins = &pin_num; 1515 - } 1516 - mux_group = tz1090_mux_pins[*pins]; 1517 - 1518 - /* no mux group, but can still be individually muxed to peripheral */ 1519 - if (mux_group >= TZ1090_MUX_GROUP_MAX) { 1520 - if (function == TZ1090_MUX_PERIP) 1521 - goto unmux_pins; 1522 - return; 1523 - } 1524 - 1525 - /* mux group already set to a different function? */ 1526 - grp = &tz1090_mux_groups[mux_group]; 1527 - dev_dbg(pctldev->dev, "%s: unmuxing %u pin(s) in '%s' from '%s'\n", 1528 - __func__, npins, grp->name, tz1090_functions[function].name); 1529 - 1530 - /* subtract pins from ref count and unmux individually */ 1531 - WARN_ON(grp->func_count < npins); 1532 - grp->func_count -= npins; 1533 - unmux_pins: 1534 - for (i = 0; i < npins; ++i) 1535 - tz1090_pinctrl_perip_select(pmx, pins[i], false); 1536 - } 1537 - 1538 - /** 1539 1482 * tz1090_pinctrl_gpio_request_enable() - Put pin in GPIO mode. 1540 1483 * @pctldev: Pin control data 1541 1484 * @range: GPIO range ··· 1518 1575 .get_function_name = tz1090_pinctrl_get_func_name, 1519 1576 .get_function_groups = tz1090_pinctrl_get_func_groups, 1520 1577 .enable = tz1090_pinctrl_enable, 1521 - .disable = tz1090_pinctrl_disable, 1522 1578 .gpio_request_enable = tz1090_pinctrl_gpio_request_enable, 1523 1579 .gpio_disable_free = tz1090_pinctrl_gpio_disable_free, 1524 1580 };
-14
drivers/pinctrl/pinctrl-u300.c
··· 970 970 return 0; 971 971 } 972 972 973 - static void u300_pmx_disable(struct pinctrl_dev *pctldev, unsigned selector, 974 - unsigned group) 975 - { 976 - struct u300_pmx *upmx; 977 - 978 - /* There is nothing to do with the power pins */ 979 - if (selector == 0) 980 - return; 981 - 982 - upmx = pinctrl_dev_get_drvdata(pctldev); 983 - u300_pmx_endisable(upmx, selector, false); 984 - } 985 - 986 973 static int u300_pmx_get_funcs_count(struct pinctrl_dev *pctldev) 987 974 { 988 975 return ARRAY_SIZE(u300_pmx_functions); ··· 995 1008 .get_function_name = u300_pmx_get_func_name, 996 1009 .get_function_groups = u300_pmx_get_groups, 997 1010 .enable = u300_pmx_enable, 998 - .disable = u300_pmx_disable, 999 1011 }; 1000 1012 1001 1013 static int u300_pin_config_get(struct pinctrl_dev *pctldev, unsigned pin,
-4
drivers/pinctrl/pinmux.c
··· 471 471 { 472 472 struct pinctrl_dev *pctldev = setting->pctldev; 473 473 const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; 474 - const struct pinmux_ops *ops = pctldev->desc->pmxops; 475 474 int ret = 0; 476 475 const unsigned *pins = NULL; 477 476 unsigned num_pins = 0; ··· 517 518 pins[i], desc->name, gname); 518 519 } 519 520 } 520 - 521 - if (ops->disable) 522 - ops->disable(pctldev, setting->data.mux.func, setting->data.mux.group); 523 521 } 524 522 525 523 #ifdef CONFIG_DEBUG_FS
-22
drivers/pinctrl/sh-pfc/pinctrl.c
··· 345 345 return ret; 346 346 } 347 347 348 - static void sh_pfc_func_disable(struct pinctrl_dev *pctldev, unsigned selector, 349 - unsigned group) 350 - { 351 - struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); 352 - struct sh_pfc *pfc = pmx->pfc; 353 - const struct sh_pfc_pin_group *grp = &pfc->info->groups[group]; 354 - unsigned long flags; 355 - unsigned int i; 356 - 357 - spin_lock_irqsave(&pfc->lock, flags); 358 - 359 - for (i = 0; i < grp->nr_pins; ++i) { 360 - int idx = sh_pfc_get_pin_index(pfc, grp->pins[i]); 361 - struct sh_pfc_pin_config *cfg = &pmx->configs[idx]; 362 - 363 - cfg->type = PINMUX_TYPE_NONE; 364 - } 365 - 366 - spin_unlock_irqrestore(&pfc->lock, flags); 367 - } 368 - 369 348 static int sh_pfc_gpio_request_enable(struct pinctrl_dev *pctldev, 370 349 struct pinctrl_gpio_range *range, 371 350 unsigned offset) ··· 443 464 .get_function_name = sh_pfc_get_function_name, 444 465 .get_function_groups = sh_pfc_get_function_groups, 445 466 .enable = sh_pfc_func_enable, 446 - .disable = sh_pfc_func_disable, 447 467 .gpio_request_enable = sh_pfc_gpio_request_enable, 448 468 .gpio_disable_free = sh_pfc_gpio_disable_free, 449 469 .gpio_set_direction = sh_pfc_gpio_set_direction,
-10
drivers/pinctrl/sirf/pinctrl-sirf.c
··· 186 186 return 0; 187 187 } 188 188 189 - static void sirfsoc_pinmux_disable(struct pinctrl_dev *pmxdev, unsigned selector, 190 - unsigned group) 191 - { 192 - struct sirfsoc_pmx *spmx; 193 - 194 - spmx = pinctrl_dev_get_drvdata(pmxdev); 195 - sirfsoc_pinmux_endisable(spmx, selector, false); 196 - } 197 - 198 189 static int sirfsoc_pinmux_get_funcs_count(struct pinctrl_dev *pmxdev) 199 190 { 200 191 return sirfsoc_pmxfunc_cnt; ··· 231 240 232 241 static struct pinmux_ops sirfsoc_pinmux_ops = { 233 242 .enable = sirfsoc_pinmux_enable, 234 - .disable = sirfsoc_pinmux_disable, 235 243 .get_functions_count = sirfsoc_pinmux_get_funcs_count, 236 244 .get_function_name = sirfsoc_pinmux_get_func_name, 237 245 .get_function_groups = sirfsoc_pinmux_get_groups,
-7
drivers/pinctrl/spear/pinctrl-spear.c
··· 274 274 return spear_pinctrl_endisable(pctldev, function, group, true); 275 275 } 276 276 277 - static void spear_pinctrl_disable(struct pinctrl_dev *pctldev, 278 - unsigned function, unsigned group) 279 - { 280 - spear_pinctrl_endisable(pctldev, function, group, false); 281 - } 282 - 283 277 /* gpio with pinmux */ 284 278 static struct spear_gpio_pingroup *get_gpio_pingroup(struct spear_pmx *pmx, 285 279 unsigned pin) ··· 339 345 .get_function_name = spear_pinctrl_get_func_name, 340 346 .get_function_groups = spear_pinctrl_get_func_groups, 341 347 .enable = spear_pinctrl_enable, 342 - .disable = spear_pinctrl_disable, 343 348 .gpio_request_enable = gpio_request_enable, 344 349 .gpio_disable_free = gpio_disable_free, 345 350 };
-12
drivers/pinctrl/vt8500/pinctrl-wmt.c
··· 141 141 return wmt_set_pinmux(data, func_selector, pinnum); 142 142 } 143 143 144 - static void wmt_pmx_disable(struct pinctrl_dev *pctldev, 145 - unsigned func_selector, 146 - unsigned group_selector) 147 - { 148 - struct wmt_pinctrl_data *data = pinctrl_dev_get_drvdata(pctldev); 149 - u32 pinnum = data->pins[group_selector].number; 150 - 151 - /* disable by setting GPIO_IN */ 152 - wmt_set_pinmux(data, WMT_FSEL_GPIO_IN, pinnum); 153 - } 154 - 155 144 static void wmt_pmx_gpio_disable_free(struct pinctrl_dev *pctldev, 156 145 struct pinctrl_gpio_range *range, 157 146 unsigned offset) ··· 169 180 .get_function_name = wmt_pmx_get_function_name, 170 181 .get_function_groups = wmt_pmx_get_function_groups, 171 182 .enable = wmt_pmx_enable, 172 - .disable = wmt_pmx_disable, 173 183 .gpio_disable_free = wmt_pmx_gpio_disable_free, 174 184 .gpio_set_direction = wmt_pmx_gpio_set_direction, 175 185 };
-2
include/linux/pinctrl/pinmux.h
··· 70 70 unsigned * const num_groups); 71 71 int (*enable) (struct pinctrl_dev *pctldev, unsigned func_selector, 72 72 unsigned group_selector); 73 - void (*disable) (struct pinctrl_dev *pctldev, unsigned func_selector, 74 - unsigned group_selector); 75 73 int (*gpio_request_enable) (struct pinctrl_dev *pctldev, 76 74 struct pinctrl_gpio_range *range, 77 75 unsigned offset);