Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e509660 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull GPIO tree bulk changes from Linus Walleij:
 "A big set this merge window, as we have much going on in this
  subsystem.  The changes to other subsystems (notably a slew of ARM
  machines as I am doing away with their custom APIs) have all been
  ACKed to the extent possible.

  Major changes this time:

   - Some core improvements and cleanups to the new GPIO descriptor API.
     This seems to be working now so we can start the exodus to this
     API, moving gradually away from the global GPIO numberspace.

   - Incremental improvements to the ACPI GPIO core, and move the few
     GPIO ACPI clients we have to the GPIO descriptor API right *now*
     before we go any further.  We actually managed to contain this
     *before* we started to litter the kernel with yet another hackish
     global numberspace for the ACPI GPIOs, which is a big win.

   - The RFkill GPIO driver and all platforms using it have been
     migrated to use the GPIO descriptors rather than fixed number
     assignments.  Tegra machine has been migrated as part of this.

   - New drivers for MOXA ART, Xtensa GPIO32 and SMSC SCH311x.  Those
     should be really good examples of how I expect a nice GPIO driver
     to look these days.

   - Do away with custom GPIO implementations on a major part of the ARM
     machines: ks8695, lpc32xx, mv78xx0.  Make a first step towards the
     same in the horribly convoluted Samsung S3C include forest.  We
     expect to continue to clean this up as we move forward.

   - Flag GPIO lines used for IRQ on adnp, bcm-kona, em, intel-mid and
     lynxpoint.

     This makes the GPIOlib core aware that a certain GPIO line is used
     for IRQs and can then enforce some semantics such as disallowing a
     GPIO line marked as in use for IRQ to be switched to output mode.

   - Drop all use of irq_set_chip_and_handler_name().  The name provided
     in these cases were just unhelpful tags like "mux" or "demux".

   - Extend the MCP23s08 driver to handle interrupts.

   - Minor incremental improvements for rcar, lynxpoint, em 74x164 and
     msm drivers.

   - Some non-urgent bug fixes here and there, duplicate #includes and
     that usual kind of cleanups"

Fix up broken Kconfig file manually to make this all compile.

* tag 'gpio-v3.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (71 commits)
  gpio: mcp23s08: fix casting caused build warning
  gpio: mcp23s08: depend on OF_GPIO
  gpio: mcp23s08: Add irq functionality for i2c chips
  ARM: S5P[v210|c100|64x0]: Fix build error
  gpio: pxa: clamp gpio get value to [0,1]
  ARM: s3c24xx: explicit dependency on <plat/gpio-cfg.h>
  ARM: S3C[24|64]xx: move includes back under <mach/> scope
  Documentation / ACPI: update to GPIO descriptor API
  gpio / ACPI: get rid of acpi_gpio.h
  gpio / ACPI: register to ACPI events automatically
  mmc: sdhci-acpi: convert to use GPIO descriptor API
  ARM: s3c24xx: fix build error
  gpio: f7188x: set can_sleep attribute
  gpio: samsung: Update documentation
  gpio: samsung: Remove hardware.h inclusion
  gpio: xtensa: depend on HAVE_XTENSA_GPIO32
  gpio: clps711x: Enable driver compilation with COMPILE_TEST
  gpio: clps711x: Use of_match_ptr()
  net: rfkill: gpio: convert to descriptor-based GPIO interface
  leds: s3c24xx: Fix build failure
  ...
parents 02d0a752 de755c33
Loading
Loading
Loading
Loading
+7 −29
Original line number Original line Diff line number Diff line
@@ -293,36 +293,13 @@ the device to the driver. For example:


These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0"
These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0"
specifies the path to the controller. In order to use these GPIOs in Linux
specifies the path to the controller. In order to use these GPIOs in Linux
we need to translate them to the Linux GPIO numbers.
we need to translate them to the corresponding Linux GPIO descriptors.


In a simple case of just getting the Linux GPIO number from device
There is a standard GPIO API for that and is documented in
resources one can use acpi_get_gpio_by_index() helper function. It takes
Documentation/gpio.txt.
pointer to the device and index of the GpioIo/GpioInt descriptor in the
device resources list. For example:


	int gpio_irq, gpio_power;
In the above example we can get the corresponding two GPIO descriptors with
	int ret;
a code like this:

	gpio_irq = acpi_get_gpio_by_index(dev, 1, NULL);
	if (gpio_irq < 0)
		/* handle error */

	gpio_power = acpi_get_gpio_by_index(dev, 0, NULL);
	if (gpio_power < 0)
		/* handle error */

	/* Now we can use the GPIO numbers */

Other GpioIo parameters must be converted first by the driver to be
suitable to the gpiolib before passing them.

In case of GpioInt resource an additional call to gpio_to_irq() must be
done before calling request_irq().

Note that the above API is ACPI specific and not recommended for drivers
that need to support non-ACPI systems. The recommended way is to use
the descriptor based GPIO interfaces. The above example looks like this
when converted to the GPIO desc:


	#include <linux/gpio/consumer.h>
	#include <linux/gpio/consumer.h>
	...
	...
@@ -339,4 +316,5 @@ when converted to the GPIO desc:


	/* Now we can use the GPIO descriptors */
	/* Now we can use the GPIO descriptors */


See also Documentation/gpio.txt.
There are also devm_* versions of these functions which release the
descriptors once the device is released.
+1 −12
Original line number Original line Diff line number Diff line
@@ -85,21 +85,10 @@ between the calls.
Headers
Headers
-------
-------


  See arch/arm/mach-s3c2410/include/mach/regs-gpio.h for the list
  See arch/arm/mach-s3c24xx/include/mach/regs-gpio.h for the list
  of GPIO pins, and the configuration values for them. This
  of GPIO pins, and the configuration values for them. This
  is included by using #include <mach/regs-gpio.h>
  is included by using #include <mach/regs-gpio.h>


  The GPIO management functions are defined in the hardware
  header arch/arm/mach-s3c2410/include/mach/hardware.h which can be
  included by #include <mach/hardware.h>

  A useful amount of documentation can be found in the hardware
  header on how the GPIO functions (and others) work.

  Whilst a number of these functions do make some checks on what
  is passed to them, for speed of use, they may not always ensure
  that the user supplied data to them is correct.



PIN Numbers
PIN Numbers
-----------
-----------
+27 −1
Original line number Original line Diff line number Diff line
@@ -38,12 +38,38 @@ Required device specific properties (only for SPI chips):
    removed.
    removed.
- spi-max-frequency = The maximum frequency this chip is able to handle
- spi-max-frequency = The maximum frequency this chip is able to handle


Example I2C:
Optional properties:
- #interrupt-cells : Should be two.
  - first cell is the pin number
  - second cell is used to specify flags.
- interrupt-controller: Marks the device node as a interrupt controller.
NOTE: The interrupt functionality is only supported for i2c versions of the
chips. The spi chips can also do the interrupts, but this is not supported by
the linux driver yet.

Optional device specific properties:
- microchip,irq-mirror: Sets the mirror flag in the IOCON register. Devices
        with two interrupt outputs (these are the devices ending with 17 and
        those that have 16 IOs) have two IO banks: IO 0-7 form bank 1 and
        IO 8-15 are bank 2. These chips have two different interrupt outputs:
        One for bank 1 and another for bank 2. If irq-mirror is set, both
        interrupts are generated regardless of the bank that an input change
        occured on. If it is not set, the interrupt are only generated for the
        bank they belong to.
        On devices with only one interrupt output this property is useless.

Example I2C (with interrupt):
gpiom1: gpio@20 {
gpiom1: gpio@20 {
        compatible = "microchip,mcp23017";
        compatible = "microchip,mcp23017";
        gpio-controller;
        gpio-controller;
        #gpio-cells = <2>;
        #gpio-cells = <2>;
        reg = <0x20>;
        reg = <0x20>;

        interrupt-parent = <&gpio1>;
        interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
        interrupt-controller;
        #interrupt-cells=<2>;
        microchip,irq-mirror;
};
};


Example SPI:
Example SPI:
+19 −0
Original line number Original line Diff line number Diff line
MOXA ART GPIO Controller

Required properties:

- #gpio-cells : Should be 2, The first cell is the pin number,
		the second cell is used to specify polarity:
			0 = active high
			1 = active low
- compatible : Must be "moxa,moxart-gpio"
- reg : Should contain registers location and length

Example:

	gpio: gpio@98700000 {
		gpio-controller;
		#gpio-cells = <2>;
		compatible = "moxa,moxart-gpio";
		reg =	<0x98700000 0xC>;
	};
+2 −1
Original line number Original line Diff line number Diff line
@@ -2,10 +2,11 @@


Required Properties:
Required Properties:


  - compatible: should be one of the following.
  - compatible: should contain one of the following.
    - "renesas,gpio-r8a7778": for R8A7778 (R-Mobile M1) compatible GPIO controller.
    - "renesas,gpio-r8a7778": for R8A7778 (R-Mobile M1) compatible GPIO controller.
    - "renesas,gpio-r8a7779": for R8A7779 (R-Car H1) compatible GPIO controller.
    - "renesas,gpio-r8a7779": for R8A7779 (R-Car H1) compatible GPIO controller.
    - "renesas,gpio-r8a7790": for R8A7790 (R-Car H2) compatible GPIO controller.
    - "renesas,gpio-r8a7790": for R8A7790 (R-Car H2) compatible GPIO controller.
    - "renesas,gpio-r8a7791": for R8A7791 (R-Car M2) compatible GPIO controller.
    - "renesas,gpio-rcar": for generic R-Car GPIO controller.
    - "renesas,gpio-rcar": for generic R-Car GPIO controller.


  - reg: Base address and length of each memory resource used by the GPIO
  - reg: Base address and length of each memory resource used by the GPIO
Loading