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

Commit c7d28eca authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull GPIO updates from Linus Walleij:
 "This is the bulk of GPIO changes for the v4.13 series.

  Some administrativa:

  I have a slew of 8250 serial patches and the new IOT2040 serial+GPIO
  driver coming in through this tree, along with a whole bunch of Exar
  8250 fixes. These are ACKed by Greg and also hit drivers/platform/*
  where they are ACKed by Andy Shevchenko.

  Speaking about drivers/platform/* there is also a bunch of ACPI stuff
  coming through that route, again ACKed by Andy.

  The MCP23S08 changes are coming in here as well. You already have the
  commits in your tree, so this is just a result of sharing an immutable
  branch between pin control and GPIO.

  Core:
   - Export add/remove for lookup tables so that modules can export GPIO
     descriptor tables.
   - Handle GPIO sleep states: it is now possible to flag that a GPIO
     line may loose its state during suspend/resume of the system to
     save power. This is used in the Wolfson Micro Arizona driver.
   - ACPI-based GPIO was tightened up a lot around the edges.
   - Use bitmap_fill() to speed up a loop.

  New drivers:
   - Exar XRA1403 SPI-based GPIO.
   - MVEBU driver now supports Armada 7K and 8K.
   - LP87565 PMIC GPIO.
   - Renesas R-CAR R8A7743 (RZ/G1M).
   - The new IOT2040 8250 serial/GPIO also comes in through this
     changeset.

  Substantial driver changes:
   - Seriously fix the Exar 8250 GPIO portions to work.
   - The MCP23S08 was moved out to a pin control driver.
   - Convert MEVEBU to use regmap for register access.
   - Drop Vulcan support from the Broadcom driver.
   - Serious cleanup and improvement of the mockup driver, giving us a
     better test coverage.

  Misc:
   - Lots of janitorial clean up.
   - A bunch of documentation fixes"

* tag 'gpio-v4.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (70 commits)
  serial: exar: Add support for IOT2040 device
  gpio-exar/8250-exar: Make set of exported GPIOs configurable
  platform: Accept const properties
  serial: exar: Factor out platform hooks
  gpio-exar/8250-exar: Rearrange gpiochip parenthood
  gpio: exar: Fix iomap request
  gpio-exar/8250-exar: Do not even instantiate a GPIO device for Commtech cards
  serial: uapi: Add support for bus termination
  gpio: rcar: Add R8A7743 (RZ/G1M) support
  gpio: gpio-wcove: Fix GPIO control register offset calculation
  gpio: lp87565: Add support for GPIO
  gpio: dwapb: fix missing first irq for edgeboth irq type
  MAINTAINERS: Take maintainership for GPIO ACPI support
  gpio: exar: Fix reading of directions and values
  gpio: exar: Allocate resources on behalf of the platform device
  gpio-exar/8250-exar: Fix passing in of parent PCI device
  gpio: mockup: use devm_kcalloc() where applicable
  gpio: mockup: add myself as author
  gpio: mockup: improve the error message
  gpio: mockup: don't return magic numbers from probe()
  ...
parents dddd564d 413058df
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
@@ -156,3 +156,68 @@ pointed to by its first argument. That should be done in the driver's .probe()
routine.  On removal, the driver should unregister its GPIO mapping table by
calling acpi_dev_remove_driver_gpios() on the ACPI device object where that
table was previously registered.

Using the _CRS fallback
-----------------------

If a device does not have _DSD or the driver does not create ACPI GPIO
mapping, the Linux GPIO framework refuses to return any GPIOs. This is
because the driver does not know what it actually gets. For example if we
have a device like below:

  Device (BTH)
  {
      Name (_HID, ...)

      Name (_CRS, ResourceTemplate () {
          GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionNone,
                  "\\_SB.GPO0", 0, ResourceConsumer) {15}
          GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionNone,
                  "\\_SB.GPO0", 0, ResourceConsumer) {27}
      })
  }

The driver might expect to get the right GPIO when it does:

  desc = gpiod_get(dev, "reset", GPIOD_OUT_LOW);

but since there is no way to know the mapping between "reset" and
the GpioIo() in _CRS desc will hold ERR_PTR(-ENOENT).

The driver author can solve this by passing the mapping explictly
(the recommended way and documented in the above chapter).

The ACPI GPIO mapping tables should not contaminate drivers that are not
knowing about which exact device they are servicing on. It implies that
the ACPI GPIO mapping tables are hardly linked to ACPI ID and certain
objects, as listed in the above chapter, of the device in question.

Getting GPIO descriptor
-----------------------

There are two main approaches to get GPIO resource from ACPI:
	desc = gpiod_get(dev, connection_id, flags);
	desc = gpiod_get_index(dev, connection_id, index, flags);

We may consider two different cases here, i.e. when connection ID is
provided and otherwise.

Case 1:
	desc = gpiod_get(dev, "non-null-connection-id", flags);
	desc = gpiod_get_index(dev, "non-null-connection-id", index, flags);

Case 2:
	desc = gpiod_get(dev, NULL, flags);
	desc = gpiod_get_index(dev, NULL, index, flags);

Case 1 assumes that corresponding ACPI device description must have
defined device properties and will prevent to getting any GPIO resources
otherwise.

Case 2 explicitly tells GPIO core to look for resources in _CRS.

Be aware that gpiod_get_index() in cases 1 and 2, assuming that there
are two versions of ACPI device description provided and no mapping is
present in the driver, will return different resources. That's why a
certain driver has to handle them carefully as explained in previous
chapter.
+8 −5
Original line number Diff line number Diff line
@@ -74,11 +74,14 @@ GPIO pin number, and GPIO flags as accepted by the "qe_pio_e" gpio-controller.
Optional standard bitfield specifiers for the last cell:

- Bit 0: 0 means active high, 1 means active low
- Bit 1: 1 means single-ended wiring, see:
- Bit 1: 0 mean push-pull wiring, see:
           https://en.wikipedia.org/wiki/Push-pull_output
         1 means single-ended wiring, see:
           https://en.wikipedia.org/wiki/Single-ended_triode
	   When used with active-low, this means open drain/collector, see:
- Bit 2: 0 means open-source, 1 means open drain, see:
           https://en.wikipedia.org/wiki/Open_collector
	   When used with active-high, this means open source/emitter
- Bit 3: 0 means the output should be maintained during sleep/low-power mode
         1 means the output state can be lost during sleep/low-power mode

1.1) GPIO specifier best practices
----------------------------------
@@ -282,8 +285,8 @@ Example 1:
	};

Here, a single GPIO controller has GPIOs 0..9 routed to pin controller
pinctrl1's pins 20..29, and GPIOs 10..19 routed to pin controller pinctrl2's
pins 50..59.
pinctrl1's pins 20..29, and GPIOs 10..29 routed to pin controller pinctrl2's
pins 50..69.

Example 2:

+1 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
Required Properties:

  - compatible: should contain one of the following.
    - "renesas,gpio-r8a7743": for R8A7743 (RZ/G1M) 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-r8a7790": for R8A7790 (R-Car H2) compatible GPIO controller.
+24 −0
Original line number Diff line number Diff line
@@ -5747,6 +5747,15 @@ F: include/asm-generic/gpio.h
F:	include/uapi/linux/gpio.h
F:	tools/gpio/

GPIO ACPI SUPPORT
M:	Mika Westerberg <mika.westerberg@linux.intel.com>
M:	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
L:	linux-gpio@vger.kernel.org
L:	linux-acpi@vger.kernel.org
S:	Maintained
F:	Documentation/acpi/gpio-properties.txt
F:	drivers/gpio/gpiolib-acpi.c

GRE DEMULTIPLEXER DRIVER
M:	Dmitry Kozlov <xeb@mail.ru>
L:	netdev@vger.kernel.org
@@ -12026,6 +12035,13 @@ S: Maintained
F:	drivers/media/platform/davinci/
F:	include/media/davinci/

TI DAVINCI SERIES GPIO DRIVER
M:	Keerthy <j-keerthy@ti.com>
L:	linux-gpio@vger.kernel.org
S:	Maintained
F:	Documentation/devicetree/bindings/gpio/gpio-davinci.txt
F:	drivers/gpio/gpio-davinci.c

TI AM437X VPFE DRIVER
M:	"Lad, Prabhakar" <prabhakar.csengg@gmail.com>
L:	linux-media@vger.kernel.org
@@ -14338,6 +14354,14 @@ L: linux-kernel@vger.kernel.org
S:	Supported
F:	drivers/char/xillybus/

XRA1403 GPIO EXPANDER
M:	Nandor Han <nandor.han@ge.com>
M:	Semi Malinen <semi.malinen@ge.com>
L:	linux-gpio@vger.kernel.org
S:	Maintained
F:	drivers/gpio/gpio-xra1403.c
F:	Documentation/devicetree/bindings/gpio/gpio-xra1403.txt

XTENSA XTFPGA PLATFORM SUPPORT
M:	Max Filippov <jcmvbkbc@gmail.com>
L:	linux-xtensa@linux-xtensa.org
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
#include <linux/gpio/machine.h>
#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/i2c/pcf857x.h>
#include <linux/platform_data/pcf857x.h>
#include <linux/platform_data/at24.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
Loading