linux/drivers/pinctrl
Fan Wu 2243a87d90 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>
2014-07-11 14:08:26 +02:00
..
berlin pinctrl: berlin: Use devm_ioremap_resource() 2014-05-27 16:03:24 +02:00
mvebu pinctrl: mvebu: new driver for Orion platforms 2014-04-24 15:09:35 +02:00
sh-pfc pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
sirf pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
spear pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
sunxi pinctrl: sunxi: Fix multi bank interrupt support in gpio_to_irq 2014-07-11 14:08:25 +02:00
vt8500 pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
core.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
core.h pinctrl: move subsystem mutex to pinctrl_dev struct 2013-04-26 17:01:35 +02:00
devicetree.c pinctrl: Quiet logging about missing DT nodes when not using DT 2014-02-24 10:44:54 +01:00
devicetree.h
Kconfig pinctrl: Add i.MX1 pincontrol driver 2014-07-11 14:08:25 +02:00
Makefile pinctrl: Add i.MX1 pincontrol driver 2014-07-11 14:08:25 +02:00
pinconf-generic.c pinctrl: Enable "power-source" to be extracted from DT files 2014-05-28 10:16:35 +02:00
pinconf.c pinctrl: pinconf: remove warning: unused variable 'ops' 2013-12-13 13:55:15 +01:00
pinconf.h pinctrl: add function to parse generic pinconfig properties from a dt node 2013-06-16 11:57:32 +02:00
pinctrl-ab8500.c pinctrl: ab8500: Staticize some symbols 2013-04-09 09:54:00 +02:00
pinctrl-ab8505.c pinctrl: ab8505: Staticize some symbols 2013-04-09 09:59:42 +02:00
pinctrl-ab8540.c pinctrl: ab8540: Staticize some symbols 2013-04-09 09:58:02 +02:00
pinctrl-ab9540.c pinctrl: ab9540: Staticize some symbols 2013-04-09 09:55:59 +02:00
pinctrl-abx500.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-abx500.h mfd/pinctrl: Delete platform data header 2014-01-21 08:27:42 +00:00
pinctrl-adi2-bf54x.c pinctrl: pinctrl-adi: combine multiple groups of one function together 2014-02-25 10:49:13 +01:00
pinctrl-adi2-bf60x.c pinctrl: pinctrl-adi: combine multiple groups of one function together 2014-02-25 10:49:13 +01:00
pinctrl-adi2.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-adi2.h pinctrl: pinctrl-adi: combine multiple groups of one function together 2014-02-25 10:49:13 +01:00
pinctrl-apq8064.c pinctrl: msm: Add missing sdc1 and sdc3 groups 2014-05-28 11:02:23 +02:00
pinctrl-as3722.c pinctrl: as3722: fix handling of GPIO invert bit 2014-04-22 17:04:11 +02:00
pinctrl-at91.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-baytrail.c pinctrl: baytrail: Add pull type, strength and open drain to debugfs output 2014-05-23 00:01:54 +02:00
pinctrl-bcm281xx.c pinctrl: Rename Broadcom Capri pinctrl driver 2014-04-14 09:39:33 +02:00
pinctrl-bcm2835.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-coh901.c pinctrl: coh901: convert driver to use gpiolib irqchip 2014-03-26 10:31:34 +01:00
pinctrl-coh901.h
pinctrl-exynos5440.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-exynos.c pinctrl: exynos: Add driver data for Exynos3250 2014-04-23 09:00:25 +02:00
pinctrl-exynos.h pinctrl: exynos: Handle suspend/resume of GPIO EINT registers 2013-05-27 15:37:09 +02:00
pinctrl-falcon.c pinctrl: Pass all configs to driver on pin_config_set() 2013-08-28 13:34:41 +02:00
pinctrl-imx1-core.c pinctrl: imx27: fix offset calculation in imx_read_2bit 2014-02-03 09:08:09 +01:00
pinctrl-imx1.c pinctrl: Add i.MX1 pincontrol driver 2014-07-11 14:08:25 +02:00
pinctrl-imx1.h pinctrl: imx1 core driver 2013-10-29 06:54:37 -07:00
pinctrl-imx6dl.c pinctrl: remove redundant of_match_ptr 2013-10-08 10:02:25 +02:00
pinctrl-imx6q.c pinctrl: remove redundant of_match_ptr 2013-10-08 10:02:25 +02:00
pinctrl-imx6sl.c pinctrl: remove redundant of_match_ptr 2013-10-08 10:02:25 +02:00
pinctrl-imx6sx.c pinctrl: add pinctrl driver for imx6sx 2014-05-27 11:24:28 +02:00
pinctrl-imx23.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-imx25.c pinctrl: pinctrl-imx: add imx25 pinctrl driver 2013-11-25 09:08:30 +01:00
pinctrl-imx27.c pinctrl: i.MX27: Remove nonexistent pad definitions 2014-07-11 14:08:26 +02:00
pinctrl-imx28.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-imx35.c pinctrl: remove redundant of_match_ptr 2013-10-08 10:02:25 +02:00
pinctrl-imx50.c pinctrl: imx50: add pinctrl support code for the IMX50 SoC 2013-11-06 10:06:59 +01:00
pinctrl-imx51.c pinctrl: remove redundant of_match_ptr 2013-10-08 10:02:25 +02:00
pinctrl-imx53.c pinctrl: remove redundant of_match_ptr 2013-10-08 10:02:25 +02:00
pinctrl-imx.c pinctrl: pinctrl-imx: Print the mux_mode field in hex format 2014-04-22 15:10:35 +02:00
pinctrl-imx.h pinctrl: imx: Use struct type for pins 2013-08-16 14:43:56 +02:00
pinctrl-ipq8064.c pinctrl: qcom: ipq8064: Fix naming convention 2014-05-29 10:37:43 +02:00
pinctrl-lantiq.c pinctrl/lantiq: Free mapping configs for both pin and groups 2013-05-15 13:28:46 +02:00
pinctrl-lantiq.h pinctrl: lantiq: Fix header file include guard 2014-04-22 08:41:35 +02:00
pinctrl-msm8x74.c pinctrl: msm: Add more MSM8X74 pin definitions 2014-05-29 10:42:59 +02:00
pinctrl-msm.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-msm.h pinctrl: msm: Make number of functions variable 2014-04-22 08:41:34 +02:00
pinctrl-mxs.c pinctrl: Pass all configs to driver on pin_config_set() 2013-08-28 13:34:41 +02:00
pinctrl-mxs.h
pinctrl-nomadik-db8500.c pinctrl/nomadik-db8500: Fix checkpatch errors 2013-03-27 22:21:32 +01:00
pinctrl-nomadik-db8540.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-nomadik-stn8815.c pinctrl: pinctrl-nomadik-stn8815: Fix checkpatch error 2013-03-13 19:50:20 +01:00
pinctrl-nomadik.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-nomadik.h pinctrl: nomadik: move platform data handling into driver 2013-11-26 21:01:58 +01:00
pinctrl-palmas.c pinctrl: palmas: remove pin config BIAS_PULL_PIN_DEFAULT support 2013-10-08 13:27:27 +02:00
pinctrl-rockchip.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-s3c24xx.c pinctrl: s3c24xx: off by one in s3c24xx_eint_init() 2013-08-28 14:44:25 +02:00
pinctrl-s3c64xx.c pinctrl: s3c64xx: Fix build error caused by undefined chained_irq_enter 2013-04-23 13:59:45 +02:00
pinctrl-samsung.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-samsung.h pinctrl: exynos: Add driver data for Exynos3250 2014-04-23 09:00:25 +02:00
pinctrl-single.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-st.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-tb10x.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-tegra20.c pinctrl: tegra: remove fsafe from data tables 2014-04-22 16:50:24 +02:00
pinctrl-tegra30.c pinctrl: tegra: remove fsafe from data tables 2014-04-22 16:50:24 +02:00
pinctrl-tegra114.c pinctrl: tegra: remove fsafe from data tables 2014-04-22 16:50:24 +02:00
pinctrl-tegra124.c pinctrl: tegra: remove fsafe from data tables 2014-04-22 16:50:24 +02:00
pinctrl-tegra.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-tegra.h pinctrl: tegra: add missing kerneldoc 2014-04-22 16:55:41 +02:00
pinctrl-tz1090-pdc.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-tz1090.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-u300.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinctrl-utils.c pinctrl: utils: include export.h to avoid warnings 2013-08-28 15:50:33 +02:00
pinctrl-utils.h pinctrl: add utility functions for add map/configs 2013-08-14 21:00:41 +02:00
pinctrl-vf610.c pinctrl: remove redundant of_match_ptr 2013-10-08 10:02:25 +02:00
pinctrl-xway.c pinctrl/lantiq: fix typo 2014-01-08 10:13:38 +01:00
pinmux.c pinctrl: avoid duplicated calling enable_pinmux_setting for a pin 2014-07-11 14:08:26 +02:00
pinmux.h