Commit aacc73ce authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'gpio-updates-for-v6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio updates from Bartosz Golaszewski:
 "We have three new drivers, some refactoring in the GPIO core, lots of
  various changes across many drivers, new configfs interface for the
  virtual gpio-aggregator module and DT-bindings updates.

  The treewide conversion of GPIO drivers to using the new value setter
  callbacks is ongoing with another round of GPIO drivers updated. You
  will also see these commits coming in from other subsystems as with
  the relevant changes merged into mainline last cycle, I've started
  converting GPIO providers located elsewhere than drivers/gpio/.

  GPIO core:
   - use more lock guards where applicable
   - refactor GPIO ACPI code and shrink it in the process by 8%
   - move GPIO ACPI quirks into a separate file
   - remove unneeded #ifdef
   - convert GPIO devres helpers to using devm_add_action() where
     applicable which shrinks and simplifies the code
   - refactor GPIO descriptor validation in GPIO consumer interfaces
   - don't allow setting values on input lines in the GPIO core which
     will take off the burden from GPIO drivers of checking this down
     the line
   - provide gpiod_is_equal() as a way of safely comparing two GPIO
     descriptors (the only current user is in regulator core)

  New drivers:
   - add the GPIO module for the max77759 multifunction device
   - add the GPIO driver for the VeriSilicon BLZP1600 GPIO controller
   - add the GPIO driver for the Spacemit K1 SoC

  Driver improvements:
   - convert more drivers to using the new GPIO line value setter
     callbacks
   - convert more drivers to making the irq_chip immutable as is
     recommended by the interrupt subsystem
   - extend build testing coverage by enabling more modules to be built
     with COMPILE_TEST=y
   - extend the gpio-aggregator module with a configfs interface that
     makes the setup easier for user-space than the existing
     driver-level sysfs attributes and also adds more advanced
     configuration features (such as referring to aggregated lines by
     their original names or modifying their names as exposed by the
     aggregated chip)
   - add a missing mutex_destroy() in gpio-imx-scu
   - add an OF polarity quirk for s5m8767
   - allow building gpio-vf610 as a loadable module
   - make gpio-mxc not hardcode its GPIO base number with GPIO SYSFS
     interface disabled (another small step towards getting rid of the
     global GPIO numberspace)
   - add support for level-triggered interrupts to gpio-pca953x
   - don't double-check the ngpios property in gpio-ds4520 as GPIO core
     already does it
   - don't double-check the number of GPIOs in gpio-imx-scu as GPIO core
     already does it
   - remove unused callbacks from gpio-max3191x

  DT bindings:
   - add device-tree bindings for max77759, spacemit,k1 and blzp1600
     (new drivers added this cycle)
   - document more properties for gpio-vf610 and gpio-tegra186
   - document a new pca95xx variant
   - fix style of examples in several GPIO DT-binding documents

  Misc:
   - TODO list updates"

* tag 'gpio-updates-for-v6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (123 commits)
  gpio: timberdale: select GPIOLIB_IRQCHIP
  gpio: lpc18xx: select GPIOLIB_IRQCHIP
  gpio: grgpio: select GPIOLIB_IRQCHIP
  gpio: bcm-kona: select GPIOLIB_IRQCHIP
  dt-bindings: gpio: vf610: add ngpios and gpio-reserved-ranges
  gpio: davinci: select GPIOLIB_IRQCHIP
  gpiolib-acpi: Update file references in the Documentation and MAINTAINERS
  gpiolib: acpi: Move quirks to a separate file
  gpiolib: acpi: Add acpi_gpio_need_run_edge_events_on_boot() getter
  gpiolib: acpi: Handle deferred list via new API
  gpiolib: acpi: Make sure we fill struct acpi_gpio_info
  gpiolib: acpi: Switch to use enum in acpi_gpio_in_ignore_list()
  gpiolib: acpi: Use temporary variable for struct acpi_gpio_info
  gpiolib: remove unneeded #ifdef
  gpio: mpc8xxx: select GPIOLIB_IRQCHIP
  gpio: pxa: select GPIOLIB_IRQCHIP
  gpio: pxa: Make irq_chip immutable
  gpio: timberdale: Make irq_chip immutable
  gpio: xgene-sb: Make irq_chip immutable
  gpio: davinci: Make irq_chip immutable
  ...
parents a9e6060b 8b8ef309
Loading
Loading
Loading
Loading
+107 −0
Original line number Diff line number Diff line
@@ -69,6 +69,113 @@ write-only attribute files in sysfs.
		    $ echo gpio-aggregator.0 > delete_device


Aggregating GPIOs using Configfs
--------------------------------

**Group:** ``/config/gpio-aggregator``

    This is the root directory of the gpio-aggregator configfs tree.

**Group:** ``/config/gpio-aggregator/<example-name>``

    This directory represents a GPIO aggregator device. You can assign any
    name to ``<example-name>`` (e.g. ``agg0``), except names starting with
    ``_sysfs`` prefix, which are reserved for auto-generated configfs
    entries corresponding to devices created via Sysfs.

**Attribute:** ``/config/gpio-aggregator/<example-name>/live``

    The ``live`` attribute allows to trigger the actual creation of the device
    once it's fully configured. Accepted values are:

    * ``1``, ``yes``, ``true`` : enable the virtual device
    * ``0``, ``no``, ``false`` : disable the virtual device

**Attribute:** ``/config/gpio-aggregator/<example-name>/dev_name``

    The read-only ``dev_name`` attribute exposes the name of the device as it
    will appear in the system on the platform bus (e.g. ``gpio-aggregator.0``).
    This is useful for identifying a character device for the newly created
    aggregator. If it's ``gpio-aggregator.0``,
    ``/sys/devices/platform/gpio-aggregator.0/gpiochipX`` path tells you that the
    GPIO device id is ``X``.

You must create subdirectories for each virtual line you want to
instantiate, named exactly as ``line0``, ``line1``, ..., ``lineY``, when
you want to instantiate ``Y+1`` (Y >= 0) lines.  Configure all lines before
activating the device by setting ``live`` to 1.

**Group:** ``/config/gpio-aggregator/<example-name>/<lineY>/``

    This directory represents a GPIO line to include in the aggregator.

**Attribute:** ``/config/gpio-aggregator/<example-name>/<lineY>/key``

**Attribute:** ``/config/gpio-aggregator/<example-name>/<lineY>/offset``

    The default values after creating the ``<lineY>`` directory are:

    * ``key`` : <empty>
    * ``offset`` : -1

    ``key`` must always be explicitly configured, while ``offset`` depends.
    Two configuration patterns exist for each ``<lineY>``:

    (a). For lookup by GPIO line name:

         * Set ``key`` to the line name.
         * Ensure ``offset`` remains -1 (the default).

    (b). For lookup by GPIO chip name and the line offset within the chip:

         * Set ``key`` to the chip name.
         * Set ``offset`` to the line offset (0 <= ``offset`` < 65535).

**Attribute:** ``/config/gpio-aggregator/<example-name>/<lineY>/name``

    The ``name`` attribute sets a custom name for lineY. If left unset, the
    line will remain unnamed.

Once the configuration is done, the ``'live'`` attribute must be set to 1
in order to instantiate the aggregator device. It can be set back to 0 to
destroy the virtual device. The module will synchronously wait for the new
aggregator device to be successfully probed and if this doesn't happen, writing
to ``'live'`` will result in an error. This is a different behaviour from the
case when you create it using sysfs ``new_device`` interface.

.. note::

   For aggregators created via Sysfs, the configfs entries are
   auto-generated and appear as ``/config/gpio-aggregator/_sysfs.<N>/``. You
   cannot add or remove line directories with mkdir(2)/rmdir(2). To modify
   lines, you must use the "delete_device" interface to tear down the
   existing device and reconfigure it from scratch. However, you can still
   toggle the aggregator with the ``live`` attribute and adjust the
   ``key``, ``offset``, and ``name`` attributes for each line when ``live``
   is set to 0 by hand (i.e. it's not waiting for deferred probe).

Sample configuration commands
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: sh

    # Create a directory for an aggregator device
    $ mkdir /sys/kernel/config/gpio-aggregator/agg0

    # Configure each line
    $ mkdir /sys/kernel/config/gpio-aggregator/agg0/line0
    $ echo gpiochip0 > /sys/kernel/config/gpio-aggregator/agg0/line0/key
    $ echo 6         > /sys/kernel/config/gpio-aggregator/agg0/line0/offset
    $ echo test0     > /sys/kernel/config/gpio-aggregator/agg0/line0/name
    $ mkdir /sys/kernel/config/gpio-aggregator/agg0/line1
    $ echo gpiochip0 > /sys/kernel/config/gpio-aggregator/agg0/line1/key
    $ echo 7         > /sys/kernel/config/gpio-aggregator/agg0/line1/offset
    $ echo test1     > /sys/kernel/config/gpio-aggregator/agg0/line1/name

    # Activate the aggregator device
    $ echo 1         > /sys/kernel/config/gpio-aggregator/agg0/live


Generic GPIO Driver
-------------------

+77 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/gpio/blaize,blzp1600-gpio.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Blaize BLZP1600 GPIO controller

description:
  Blaize BLZP1600 GPIO controller is an implementation of the VeriSilicon
  APB GPIO v0.2 IP block. It has 32 ports each of which are intended to be
  represented as child nodes with the generic GPIO-controller properties
  as described in this binding's file.

maintainers:
  - Nikolaos Pasaloukos <nikolaos.pasaloukos@blaize.com>
  - James Cowgill <james.cowgill@blaize.com>
  - Matt Redfearn <matt.redfearn@blaize.com>
  - Neil Jones <neil.jones@blaize.com>

properties:
  $nodename:
    pattern: "^gpio@[0-9a-f]+$"

  compatible:
    enum:
      - blaize,blzp1600-gpio

  reg:
    maxItems: 1

  gpio-controller: true

  '#gpio-cells':
    const: 2

  ngpios:
    default: 32
    minimum: 1
    maximum: 32

  interrupts:
    maxItems: 1

  gpio-line-names: true

  interrupt-controller: true

  '#interrupt-cells':
    const: 2

required:
  - compatible
  - reg
  - gpio-controller
  - '#gpio-cells'

dependencies:
  interrupt-controller: [ interrupts ]

additionalProperties: false

examples:
  - |
    #include <dt-bindings/interrupt-controller/arm-gic.h>

    gpio: gpio@4c0000 {
      compatible = "blaize,blzp1600-gpio";
      reg = <0x004c0000 0x1000>;
      gpio-controller;
      #gpio-cells = <2>;
      ngpios = <32>;
      interrupt-controller;
      #interrupt-cells = <2>;
      interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
    };
...
+11 −11
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ examples:
        #address-cells = <1>;
        #size-cells = <0>;

            gpio5: gpio5@0 {
        gpio5@0 {
            compatible = "fairchild,74hc595";
            reg = <0>;
            gpio-controller;
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@ description: |+
properties:
  compatible:
    oneOf:
      - items:
          - const: toradex,ecgpiol16
          - const: nxp,pcal6416
      - items:
          - const: diodes,pi4ioe5v6534q
          - const: nxp,pcal6534
@@ -132,6 +135,7 @@ allOf:
              - maxim,max7325
              - maxim,max7326
              - maxim,max7327
              - toradex,ecgpiol16
    then:
      properties:
        reset-gpios: false
+7 −0
Original line number Diff line number Diff line
@@ -70,6 +70,13 @@ properties:
    minItems: 1
    maxItems: 4

  gpio-reserved-ranges: true

  ngpios:
    minimum: 1
    maximum: 32
    default: 32

patternProperties:
  "^.+-hog(-[0-9]+)?$":
    type: object
Loading