linux/drivers/pinctrl
Linus Walleij ab78029ecc drivers/pinctrl: grab default handles from device core
This makes the device core auto-grab the pinctrl handle and set
the "default" (PINCTRL_STATE_DEFAULT) state for every device
that is present in the device model right before probe. This will
account for the lion's share of embedded silicon devcies.

A modification of the semantics for pinctrl_get() is also done:
previously if the pinctrl handle for a certain device was already
taken, the pinctrl core would return an error. Now, since the
core may have already default-grabbed the handle and set its
state to "default", if the handle was already taken, this will
be disregarded and the located, previously instanitated handle
will be returned to the caller.

This way all code in drivers explicitly requesting their pinctrl
handlers will still be functional, and drivers that want to
explicitly retrieve and switch their handles can still do that.
But if the desired functionality is just boilerplate of this
type in the probe() function:

struct pinctrl  *p;

p = devm_pinctrl_get_select_default(&dev);
if (IS_ERR(p)) {
   if (PTR_ERR(p) == -EPROBE_DEFER)
        return -EPROBE_DEFER;
        dev_warn(&dev, "no pinctrl handle\n");
}

The discussion began with the addition of such boilerplate
to the omap4 keypad driver:
http://marc.info/?l=linux-input&m=135091157719300&w=2

A previous approach using notifiers was discussed:
http://marc.info/?l=linux-kernel&m=135263661110528&w=2
This failed because it could not handle deferred probes.

This patch alone does not solve the entire dilemma faced:
whether code should be distributed into the drivers or
if it should be centralized to e.g. a PM domain. But it
solves the immediate issue of the addition of boilerplate
to a lot of drivers that just want to grab the default
state. As mentioned, they can later explicitly retrieve
the handle and set different states, and this could as
well be done by e.g. PM domains as it is only related
to a certain struct device * pointer.

ChangeLog v4->v5 (Stephen):
- Simplified the devicecore grab code.
- Deleted a piece of documentation recommending that pins
  be mapped to a device rather than hogged.
ChangeLog v3->v4 (Linus):
- Drop overzealous NULL checks.
- Move kref initialization to pinctrl_create().
- Seeking Tested-by from Stephen Warren so we do not disturb
  the Tegra platform.
- Seeking ACK on this from Greg (and others who like it) so I
  can merge it through the pinctrl subsystem.
ChangeLog v2->v3 (Linus):
- Abstain from using IS_ERR_OR_NULL() in the driver core,
  Russell recently sent a patch to remove it. Handle the
  NULL case explicitly even though it's a bogus case.
- Make sure we handle probe deferral correctly in the device
  core file. devm_kfree() the container on error so we don't
  waste memory for devices without pinctrl handles.
- Introduce reference counting into the pinctrl core using
  <linux/kref.h> so that we don't release pinctrl handles
  that have been obtained for two or more places.
ChangeLog v1->v2 (Linus):
- Only store a pointer in the device struct, and only allocate
  this if it's really used by the device.

Cc: Felipe Balbi <balbi@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Mitch Bradley <wmb@firmworks.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Rickard Andersson <rickard.andersson@stericsson.com>
Cc: Russell King <linux@arm.linux.org.uk>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
[swarren: fixed and simplified error-handling in pinctrl_bind_pins(), to
correctly handle deferred probe. Removed admonition from docs not to use
pinctrl hogs for devices]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2013-01-23 16:39:51 +01:00
..
mvebu ARM: arm-soc fixes for 3.8-rc 2013-01-08 18:53:56 -08:00
spear Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
core.c drivers/pinctrl: grab default handles from device core 2013-01-23 16:39:51 +01:00
core.h drivers/pinctrl: grab default handles from device core 2013-01-23 16:39:51 +01:00
devicetree.c pinctrl: do not defer device tree hogs 2013-01-11 21:49:21 +01:00
devicetree.h pinctrl: core device tree mapping table parsing support 2012-04-18 13:53:10 +02:00
Kconfig pinctrl: exynos: change PINCTRL_EXYNOS option 2013-01-18 20:35:06 +01:00
Makefile pinctrl: exynos: change PINCTRL_EXYNOS option 2013-01-18 20:35:06 +01:00
pinconf-generic.c pinctrl: generic: add slew rate config parameter 2013-01-21 15:43:42 +01:00
pinconf.c pinctrl: remove mutex lock in groups show 2012-10-18 20:27:31 +02:00
pinconf.h pinctrl: pinconf: fix compilation error if PINCONF is not selected 2012-04-18 13:53:12 +02:00
pinctrl-at91.c Driver core __dev* removal patches 2013-01-03 16:17:50 -08:00
pinctrl-bcm2835.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-coh901.c pinctrl/u300/coh901: stop spawning pinctrl from GPIO 2012-11-21 08:55:22 +01:00
pinctrl-coh901.h pinctrl: support pinconfig on the U300 2012-03-12 22:49:03 +01:00
pinctrl-exynos5440.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-exynos.c ARM: arm-soc: SoC updates for 3.8 2012-12-12 12:05:15 -08:00
pinctrl-exynos.h pinctrl: samsung: Use per-bank IRQ domain for wake-up interrupts 2012-10-15 09:10:12 +02:00
pinctrl-falcon.c pinctrl: Staticize pinconf_ops 2012-11-11 19:35:38 +01:00
pinctrl-imx6q.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-imx23.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-imx28.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-imx35.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-imx51.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-imx53.c Driver core __dev* removal patches 2013-01-03 16:17:50 -08:00
pinctrl-imx.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-imx.h pinctrl: pinctrl-imx: add imx pinctrl core driver 2012-05-02 01:14:40 +02:00
pinctrl-lantiq.c pinctrl: lantiq: Staticize non-exported symbols 2012-11-11 19:36:13 +01:00
pinctrl-lantiq.h OF: pinctrl: MIPS: lantiq: implement lantiq/xway pinctrl support 2012-09-13 10:30:49 +02:00
pinctrl-mmp2.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-mxs.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-mxs.h pinctrl: add pinctrl-mxs support 2012-05-02 01:18:27 +02:00
pinctrl-nomadik-db8500.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-nomadik-db8540.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-nomadik-stn8815.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-nomadik.c pinctrl: nomadik: Allow prcm_base to be extracted from Device Tree 2013-01-18 21:00:56 +01:00
pinctrl-nomadik.h pinctrl/nomadik: move the platform data header 2012-11-05 09:55:27 +01:00
pinctrl-pxa3xx.c pinctrl: pxa3xx: Remove phy_base and phy_size from struct pxa3xx_pinmux_info 2012-11-15 11:21:46 +01:00
pinctrl-pxa3xx.h pinctrl: pxa3xx: Remove phy_base and phy_size from struct pxa3xx_pinmux_info 2012-11-15 11:21:46 +01:00
pinctrl-pxa168.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-pxa910.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-samsung.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-samsung.h pinctrl: samsung: Fix a typo in pinctrl-samsung.h 2012-12-18 19:00:25 -08:00
pinctrl-single.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-sirf.c Driver core __dev* removal patches 2013-01-03 16:17:50 -08:00
pinctrl-tegra20.c pinctrl: tegra: add support for rcv-sel and drive type 2013-01-18 16:13:52 +01:00
pinctrl-tegra30.c pinctrl: tegra: add support for rcv-sel and drive type 2013-01-18 16:13:52 +01:00
pinctrl-tegra114.c pinctrl: tegra114: add pinctrl driver for NVIDIA's Tegra114 SoC 2013-01-18 16:14:54 +01:00
pinctrl-tegra.c pinctrl: tegra: add support for rcv-sel and drive type 2013-01-18 16:13:52 +01:00
pinctrl-tegra.h pinctrl: tegra: add support for rcv-sel and drive type 2013-01-18 16:13:52 +01:00
pinctrl-u300.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinctrl-xway.c Drivers: pinctrl: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
pinmux.c pinctrl: pinmux: Release all taken pins in pinmux_enable_setting error paths 2012-11-11 20:18:32 +01:00
pinmux.h pinctrl: ifdef CONFIG_DEBUG_FS cleanup 2012-04-18 13:53:12 +02:00