Commit 0486beaf authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull GPIO updates from Linus Walleij:
 "This time very little driver changes but lots of core changes.

  We have some interesting cooperative work for ARM and Intel alike,
  making the GPIO subsystem more and more suitable for industrial
  systems and the like, in addition to the in-kernel users.

  We touch driver core (device properties) and lib/* by adding one
  simple string array free function, these are authored by Andy
  Shevchenko who is a well known and recognized core helpers maintainers
  so this should be fine.

  We also see some Android GKI-related modularization in the MXC
  drivers.

  Core changes:

   - The big core change is the updated (v2) userspace character device
     API.

     This corrects badly designed 64-bit alignment around the line
     events. We also add the debounce request feature. This echoes the
     often quotes passage from Frederick Brooks "The mythical man-month"
     to always throw one away, which we have seen before in things such
     as V4L2. So we put in a new one and deprecate and obsolete the old
     one.

   - All example tools in tools/gpio/* are migrated to the new API to
     set a good example. The libgpiod userspace library has been
     augmented to use this new API pretty much from day 1.

   - Some misc API hardening by using strn* function calls has been
     added as well.

   - Use the simpler IDA interface for GPIO chip instance enumeration.

   - Add device core function for counting string arrays in device
     properties.

   - Provide a generic library function kfree_strarray() that can be
     used throughout the kernel.

  Driver enhancements:

   - The DesignWare dwapb-gpio driver has been enhanced and now uses the
     IRQ handling in the gpiolib core.

   - The mockup and aggregator drivers have seen some substantial code
     clean-up and now use more of the core kernel inftrastructure.

   - Misc cleanups using dev_err_probe().

   - The MXC drivers (Freescale/NXP) can now be built modularized, which
     makes modularized GKI Android kernels happy"

* tag 'gpio-v5.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (73 commits)
  gpiolib: Update header block in gpiolib-cdev.h
  gpiolib: cdev: switch from kstrdup() to kstrndup()
  docs: gpio: add a new document to its index.rst
  gpio: pca953x: Add support for the NXP PCAL9554B/C
  tools: gpio: add debounce support to gpio-event-mon
  tools: gpio: add multi-line monitoring to gpio-event-mon
  tools: gpio: port gpio-event-mon to v2 uAPI
  tools: gpio: port gpio-hammer to v2 uAPI
  tools: gpio: rename nlines to num_lines
  tools: gpio: port gpio-watch to v2 uAPI
  tools: gpio: port lsgpio to v2 uAPI
  gpio: uapi: document uAPI v1 as deprecated
  gpiolib: cdev: support setting debounce
  gpiolib: cdev: support GPIO_V2_LINE_SET_VALUES_IOCTL
  gpiolib: cdev: support GPIO_V2_LINE_SET_CONFIG_IOCTL
  gpiolib: cdev: support edge detection for uAPI v2
  gpiolib: cdev: support GPIO_V2_GET_LINEINFO_IOCTL and GPIO_V2_GET_LINEINFO_WATCH_IOCTL
  gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL and GPIO_V2_LINE_GET_VALUES_IOCTL
  gpiolib: add build option for CDEV v1 ABI
  gpiolib: make cdev a build option
  ...
parents a996b9c6 fc709df5
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
.. SPDX-License-Identifier: GPL-2.0-only

GPIO Testing Driver
===================

The GPIO Testing Driver (gpio-mockup) provides a way to create simulated GPIO
chips for testing purposes. The lines exposed by these chips can be accessed
using the standard GPIO character device interface as well as manipulated
using the dedicated debugfs directory structure.

Creating simulated chips using module params
--------------------------------------------

When loading the gpio-mockup driver a number of parameters can be passed to the
module.

    gpio_mockup_ranges

        This parameter takes an argument in the form of an array of integer
        pairs. Each pair defines the base GPIO number (if any) and the number
        of lines exposed by the chip. If the base GPIO is -1, the gpiolib
        will assign it automatically.

        Example: gpio_mockup_ranges=-1,8,-1,16,405,4

        The line above creates three chips. The first one will expose 8 lines,
        the second 16 and the third 4. The base GPIO for the third chip is set
        to 405 while for two first chips it will be assigned automatically.

    gpio_named_lines

        This parameter doesn't take any arguments. It lets the driver know that
        GPIO lines exposed by it should be named.

        The name format is: gpio-mockup-X-Y where X is mockup chip's ID
        and Y is the line offset.

Manipulating simulated lines
----------------------------

Each mockup chip creates its own subdirectory in /sys/kernel/debug/gpio-mockup/.
The directory is named after the chip's label. A symlink is also created, named
after the chip's name, which points to the label directory.

Inside each subdirectory, there's a separate attribute for each GPIO line. The
name of the attribute represents the line's offset in the chip.

Reading from a line attribute returns the current value. Writing to it (0 or 1)
changes the configuration of the simulated pull-up/pull-down resistor
(1 - pull-up, 0 - pull-down).
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ gpio

    gpio-aggregator
    sysfs
    gpio-mockup

.. only::  subproject and html

+49 −6
Original line number Diff line number Diff line
@@ -11,12 +11,33 @@ maintainers:

properties:
  compatible:
    enum:
    oneOf:
      - enum:
          - fsl,imx1-gpio
          - fsl,imx21-gpio
          - fsl,imx31-gpio
          - fsl,imx35-gpio
          - fsl,imx7d-gpio
      - items:
          - const: fsl,imx35-gpio
          - const: fsl,imx31-gpio
      - items:
          - enum:
              - fsl,imx50-gpio
              - fsl,imx51-gpio
              - fsl,imx53-gpio
              - fsl,imx6q-gpio
              - fsl,imx6sl-gpio
              - fsl,imx6sll-gpio
              - fsl,imx6sx-gpio
              - fsl,imx6ul-gpio
              - fsl,imx7d-gpio
              - fsl,imx8mm-gpio
              - fsl,imx8mn-gpio
              - fsl,imx8mp-gpio
              - fsl,imx8mq-gpio
              - fsl,imx8qxp-gpio
          - const: fsl,imx35-gpio

  reg:
    maxItems: 1
@@ -41,6 +62,28 @@ properties:
    const: 2

  gpio-controller: true
  gpio-line-names: true
  gpio-ranges: true

  power-domains:
    maxItems: 1

patternProperties:
  "^(hog-[0-9]+|.+-hog(-[0-9]+)?)$":
    type: object
    properties:
      gpio-hog: true
      gpios: true
      input: true
      output-high: true
      output-low: true
      line-name: true

    required:
      - gpio-hog
      - gpios

    additionalProperties: false

required:
  - compatible
+0 −58
Original line number Diff line number Diff line
* MAX732x-compatible I/O expanders

Required properties:
  - compatible: Should be one of the following:
    - "maxim,max7319": For the Maxim MAX7319
    - "maxim,max7320": For the Maxim MAX7320
    - "maxim,max7321": For the Maxim MAX7321
    - "maxim,max7322": For the Maxim MAX7322
    - "maxim,max7323": For the Maxim MAX7323
    - "maxim,max7324": For the Maxim MAX7324
    - "maxim,max7325": For the Maxim MAX7325
    - "maxim,max7326": For the Maxim MAX7326
    - "maxim,max7327": For the Maxim MAX7327
  - reg: I2C slave address for this device.
  - gpio-controller: Marks the device node as a GPIO controller.
  - #gpio-cells: Should be 2.
    - first cell is the GPIO number
    - second cell specifies GPIO flags, as defined in <dt-bindings/gpio/gpio.h>.
      Only the GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW flags are supported.

Optional properties:

  The I/O expander can detect input state changes, and thus optionally act as
  an interrupt controller. When the expander interrupt line is connected all the
  following properties must be set. For more information please see the
  interrupt controller device tree bindings documentation available at
  Documentation/devicetree/bindings/interrupt-controller/interrupts.txt.

  - interrupt-controller: Identifies the node as an interrupt controller.
  - #interrupt-cells: Number of cells to encode an interrupt source, shall be 2.
    - first cell is the pin number
    - second cell is used to specify flags
  - interrupts: Interrupt specifier for the controllers interrupt.

Please refer to gpio.txt in this directory for details of the common GPIO
bindings used by client devices.

Example 1. MAX7325 with interrupt support enabled (CONFIG_GPIO_MAX732X_IRQ=y):

	expander: max7325@6d {
		compatible = "maxim,max7325";
		reg = <0x6d>;
		gpio-controller;
		#gpio-cells = <2>;
		interrupt-controller;
		#interrupt-cells = <2>;
		interrupt-parent = <&gpio4>;
		interrupts = <29 IRQ_TYPE_EDGE_FALLING>;
	};

Example 2. MAX7325 with interrupt support disabled (CONFIG_GPIO_MAX732X_IRQ=n):

	expander: max7325@6d {
		compatible = "maxim,max7325";
		reg = <0x6d>;
		gpio-controller;
		#gpio-cells = <2>;
	};
+0 −90
Original line number Diff line number Diff line
* NXP PCA953x I2C GPIO multiplexer

Required properties:
 - compatible: Has to contain one of the following:
	nxp,pca6416
	nxp,pca9505
	nxp,pca9534
	nxp,pca9535
	nxp,pca9536
	nxp,pca9537
	nxp,pca9538
	nxp,pca9539
	nxp,pca9554
	nxp,pca9555
	nxp,pca9556
	nxp,pca9557
	nxp,pca9574
	nxp,pca9575
	nxp,pca9698
	nxp,pcal6416
	nxp,pcal6524
	nxp,pcal9535
	nxp,pcal9555a
	maxim,max7310
	maxim,max7312
	maxim,max7313
	maxim,max7315
	ti,pca6107
	ti,pca9536
	ti,tca6408
	ti,tca6416
	ti,tca6424
	ti,tca9539
	ti,tca9554
	onnn,cat9554
	onnn,pca9654
	exar,xra1202
 - gpio-controller: if used as gpio expander.
 - #gpio-cells: if used as gpio expander.
 - interrupt-controller: if to be used as interrupt expander.
 - #interrupt-cells: if to be used as interrupt expander.

Optional properties:
 - interrupts: interrupt specifier for the device's interrupt output.
 - reset-gpios: GPIO specification for the RESET input. This is an
		active low signal to the PCA953x.
 - vcc-supply:	power supply regulator.

Example:


	gpio@20 {
		compatible = "nxp,pca9505";
		reg = <0x20>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_pca9505>;
		gpio-controller;
		#gpio-cells = <2>;
		interrupt-parent = <&gpio3>;
		interrupts = <23 IRQ_TYPE_LEVEL_LOW>;
	};


Example with Interrupts:


	gpio99: gpio@22 {
		compatible = "nxp,pcal6524";
		reg = <0x22>;
		interrupt-parent = <&gpio6>;
		interrupts = <1 IRQ_TYPE_EDGE_FALLING>;	/* gpio6_161 */
		interrupt-controller;
		#interrupt-cells = <2>;
		vcc-supply = <&vdds_1v8_main>;
		gpio-controller;
		#gpio-cells = <2>;
		gpio-line-names =
			"hdmi-ct-hpd", "hdmi.ls-oe", "p02", "p03", "vibra", "fault2", "p06", "p07",
			"en-usb", "en-host1", "en-host2", "chg-int", "p14", "p15", "mic-int", "en-modem",
			"shdn-hs-amp", "chg-status+red", "green", "blue", "en-esata", "fault1", "p26", "p27";
	};

	ts3a227@3b {
		compatible = "ti,ts3a227e";
		reg = <0x3b>;
		interrupt-parent = <&gpio99>;
		interrupts = <14 IRQ_TYPE_EDGE_RISING>;
		ti,micbias = <0>;	/* 2.1V */
	};
Loading