forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'gpio-v5.8-1' of git://git.kernel.org/pub/scm/linux/kernel/…
…git/linusw/linux-gpio Pull GPIO updates from Linus Walleij: "This is the bulk of GPIO changes for the v5.8 kernel cycle. Core changes: - A new GPIO aggregator driver has been merged: this can join a few select GPIO lines into a new aggregated GPIO chip. This can be used for security: a process can be granted access to only these lines, for example for industrial control. Another way to use this is to reexpose certain select lines to a virtual machine or container. - Warn if the gpio-line-names is too long in he DT parser core. - GPIO lines can now be looked up by line name in addition to being looked up by offset. New drivers: - A new generic regmap GPIO driver has been merged. Too many regmap drivers are starting to look like each other so we need to create some common ground and try to move drivers over to using that. - The F7188X driver now supports F81865. Driver improvements: - Large improvements to the PCA953x expander, get multiple lines and several cleanups. - Large improvements to the DesignWare DWAPB driver, and Sergey Semin has volunteered to maintain it. - PL061 can now be built as a module, this is part of a bigger effort to make the ARM platforms more modular" * tag 'gpio-v5.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (77 commits) gpio: pca953x: Drop unneeded ACPI_PTR() MAINTAINERS: Add gpio regmap section gpio: add a reusable generic gpio_chip using regmap gpiolib: Introduce gpiochip_irqchip_add_domain() gpio: gpiolib: Allow GPIO IRQs to lazy disable gpiolib: Separate GPIO_GET_LINEINFO_WATCH_IOCTL conditional gpio: rcar: Fix runtime PM imbalance on error gpio: pca935x: Allow IRQ support for driver built as a module gpio: pxa: Add COMPILE_TEST support dt-bindings: gpio: Add renesas,em-gio bindings MAINTAINERS: Fix file name for DesignWare GPIO DT schema gpio: dwapb: Remove unneeded has_irq member in struct dwapb_port_property gpio: dwapb: Don't use IRQ 0 as valid Linux interrupt gpio: dwapb: avoid error message for optional IRQ gpio: dwapb: Call acpi_gpiochip_free_interrupts() on GPIO chip de-registration gpio: max730x: bring gpiochip_add_data after port config MAINTAINERS: Add GPIO Aggregator section docs: gpio: Add GPIO Aggregator documentation gpio: Add GPIO Aggregator gpiolib: Add support for GPIO lookup by line name ...
- Loading branch information
Showing
40 changed files
with
1,859 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
.. SPDX-License-Identifier: GPL-2.0-only | ||
GPIO Aggregator | ||
=============== | ||
|
||
The GPIO Aggregator provides a mechanism to aggregate GPIOs, and expose them as | ||
a new gpio_chip. This supports the following use cases. | ||
|
||
|
||
Aggregating GPIOs using Sysfs | ||
----------------------------- | ||
|
||
GPIO controllers are exported to userspace using /dev/gpiochip* character | ||
devices. Access control to these devices is provided by standard UNIX file | ||
system permissions, on an all-or-nothing basis: either a GPIO controller is | ||
accessible for a user, or it is not. | ||
|
||
The GPIO Aggregator provides access control for a set of one or more GPIOs, by | ||
aggregating them into a new gpio_chip, which can be assigned to a group or user | ||
using standard UNIX file ownership and permissions. Furthermore, this | ||
simplifies and hardens exporting GPIOs to a virtual machine, as the VM can just | ||
grab the full GPIO controller, and no longer needs to care about which GPIOs to | ||
grab and which not, reducing the attack surface. | ||
|
||
Aggregated GPIO controllers are instantiated and destroyed by writing to | ||
write-only attribute files in sysfs. | ||
|
||
/sys/bus/platform/drivers/gpio-aggregator/ | ||
|
||
"new_device" ... | ||
Userspace may ask the kernel to instantiate an aggregated GPIO | ||
controller by writing a string describing the GPIOs to | ||
aggregate to the "new_device" file, using the format | ||
|
||
.. code-block:: none | ||
[<gpioA>] [<gpiochipB> <offsets>] ... | ||
Where: | ||
|
||
"<gpioA>" ... | ||
is a GPIO line name, | ||
|
||
"<gpiochipB>" ... | ||
is a GPIO chip label, and | ||
|
||
"<offsets>" ... | ||
is a comma-separated list of GPIO offsets and/or | ||
GPIO offset ranges denoted by dashes. | ||
|
||
Example: Instantiate a new GPIO aggregator by aggregating GPIO | ||
line 19 of "e6052000.gpio" and GPIO lines 20-21 of | ||
"e6050000.gpio" into a new gpio_chip: | ||
|
||
.. code-block:: sh | ||
$ echo 'e6052000.gpio 19 e6050000.gpio 20-21' > new_device | ||
"delete_device" ... | ||
Userspace may ask the kernel to destroy an aggregated GPIO | ||
controller after use by writing its device name to the | ||
"delete_device" file. | ||
|
||
Example: Destroy the previously-created aggregated GPIO | ||
controller, assumed to be "gpio-aggregator.0": | ||
|
||
.. code-block:: sh | ||
$ echo gpio-aggregator.0 > delete_device | ||
Generic GPIO Driver | ||
------------------- | ||
|
||
The GPIO Aggregator can also be used as a generic driver for a simple | ||
GPIO-operated device described in DT, without a dedicated in-kernel driver. | ||
This is useful in industrial control, and is not unlike e.g. spidev, which | ||
allows the user to communicate with an SPI device from userspace. | ||
|
||
Binding a device to the GPIO Aggregator is performed either by modifying the | ||
gpio-aggregator driver, or by writing to the "driver_override" file in Sysfs. | ||
|
||
Example: If "door" is a GPIO-operated device described in DT, using its own | ||
compatible value:: | ||
|
||
door { | ||
compatible = "myvendor,mydoor"; | ||
|
||
gpios = <&gpio2 19 GPIO_ACTIVE_HIGH>, | ||
<&gpio2 20 GPIO_ACTIVE_LOW>; | ||
gpio-line-names = "open", "lock"; | ||
}; | ||
|
||
it can be bound to the GPIO Aggregator by either: | ||
|
||
1. Adding its compatible value to ``gpio_aggregator_dt_ids[]``, | ||
2. Binding manually using "driver_override": | ||
|
||
.. code-block:: sh | ||
$ echo gpio-aggregator > /sys/bus/platform/devices/door/driver_override | ||
$ echo door > /sys/bus/platform/drivers/gpio-aggregator/bind | ||
After that, a new gpiochip "door" has been created: | ||
|
||
.. code-block:: sh | ||
$ gpioinfo door | ||
gpiochip12 - 2 lines: | ||
line 0: "open" unused input active-high | ||
line 1: "lock" unused input active-high |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ gpio | |
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
gpio-aggregator | ||
sysfs | ||
|
||
.. only:: subproject and html | ||
|
70 changes: 70 additions & 0 deletions
70
Documentation/devicetree/bindings/gpio/renesas,em-gio.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | ||
%YAML 1.2 | ||
--- | ||
$id: http://devicetree.org/schemas/gpio/renesas,em-gio.yaml# | ||
$schema: http://devicetree.org/meta-schemas/core.yaml# | ||
|
||
title: Renesas EMMA Mobile General Purpose I/O Interface | ||
|
||
maintainers: | ||
- Magnus Damm <[email protected]> | ||
|
||
properties: | ||
compatible: | ||
const: renesas,em-gio | ||
|
||
reg: | ||
items: | ||
- description: First set of contiguous registers | ||
- description: Second set of contiguous registers | ||
|
||
interrupts: | ||
items: | ||
- description: Interrupt for the first set of 16 GPIO ports | ||
- description: Interrupt for the second set of 16 GPIO ports | ||
|
||
gpio-controller: true | ||
|
||
'#gpio-cells': | ||
const: 2 | ||
|
||
gpio-ranges: | ||
maxItems: 1 | ||
|
||
ngpios: | ||
minimum: 1 | ||
maximum: 32 | ||
|
||
interrupt-controller: true | ||
|
||
'#interrupt-cells': | ||
const: 2 | ||
|
||
required: | ||
- compatible | ||
- reg | ||
- interrupts | ||
- gpio-controller | ||
- '#gpio-cells' | ||
- gpio-ranges | ||
- ngpios | ||
- interrupt-controller | ||
- '#interrupt-cells' | ||
|
||
additionalProperties: false | ||
|
||
examples: | ||
- | | ||
#include <dt-bindings/interrupt-controller/arm-gic.h> | ||
gpio0: gpio@e0050000 { | ||
compatible = "renesas,em-gio"; | ||
reg = <0xe0050000 0x2c>, <0xe0050040 0x20>; | ||
interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>, | ||
<GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>; | ||
gpio-controller; | ||
#gpio-cells = <2>; | ||
gpio-ranges = <&pfc 0 0 32>; | ||
ngpios = <32>; | ||
interrupt-controller; | ||
#interrupt-cells = <2>; | ||
}; |
134 changes: 134 additions & 0 deletions
134
Documentation/devicetree/bindings/gpio/snps,dw-apb-gpio.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) | ||
%YAML 1.2 | ||
--- | ||
$id: http://devicetree.org/schemas/gpio/snps,dw-apb-gpio.yaml# | ||
$schema: http://devicetree.org/meta-schemas/core.yaml# | ||
|
||
title: Synopsys DesignWare APB GPIO controller | ||
|
||
description: | | ||
Synopsys DesignWare GPIO controllers have a configurable number of ports, | ||
each of which are intended to be represented as child nodes with the generic | ||
GPIO-controller properties as desribed in this bindings file. | ||
maintainers: | ||
- Hoan Tran <[email protected]> | ||
- Serge Semin <[email protected]> | ||
|
||
properties: | ||
$nodename: | ||
pattern: "^gpio@[0-9a-f]+$" | ||
|
||
compatible: | ||
const: snps,dw-apb-gpio | ||
|
||
"#address-cells": | ||
const: 1 | ||
|
||
"#size-cells": | ||
const: 0 | ||
|
||
reg: | ||
maxItems: 1 | ||
|
||
clocks: | ||
minItems: 1 | ||
items: | ||
- description: APB interface clock source | ||
- description: DW GPIO debounce reference clock source | ||
|
||
clock-names: | ||
minItems: 1 | ||
items: | ||
- const: bus | ||
- const: db | ||
|
||
resets: | ||
maxItems: 1 | ||
|
||
patternProperties: | ||
"^gpio-(port|controller)@[0-9a-f]+$": | ||
type: object | ||
properties: | ||
compatible: | ||
const: snps,dw-apb-gpio-port | ||
|
||
reg: | ||
maxItems: 1 | ||
|
||
gpio-controller: true | ||
|
||
'#gpio-cells': | ||
const: 2 | ||
|
||
snps,nr-gpios: | ||
description: The number of GPIO pins exported by the port. | ||
default: 32 | ||
allOf: | ||
- $ref: /schemas/types.yaml#/definitions/uint32 | ||
- minimum: 1 | ||
maximum: 32 | ||
|
||
interrupts: | ||
description: | | ||
The interrupts to the parent controller raised when GPIOs generate | ||
the interrupts. If the controller provides one combined interrupt | ||
for all GPIOs, specify a single interrupt. If the controller provides | ||
one interrupt for each GPIO, provide a list of interrupts that | ||
correspond to each of the GPIO pins. | ||
minItems: 1 | ||
maxItems: 32 | ||
|
||
interrupt-controller: true | ||
|
||
'#interrupt-cells': | ||
const: 2 | ||
|
||
required: | ||
- compatible | ||
- reg | ||
- gpio-controller | ||
- '#gpio-cells' | ||
|
||
dependencies: | ||
interrupt-controller: [ interrupts ] | ||
|
||
additionalProperties: false | ||
|
||
additionalProperties: false | ||
|
||
required: | ||
- compatible | ||
- reg | ||
- "#address-cells" | ||
- "#size-cells" | ||
|
||
examples: | ||
- | | ||
gpio: gpio@20000 { | ||
compatible = "snps,dw-apb-gpio"; | ||
reg = <0x20000 0x1000>; | ||
#address-cells = <1>; | ||
#size-cells = <0>; | ||
porta: gpio-port@0 { | ||
compatible = "snps,dw-apb-gpio-port"; | ||
reg = <0>; | ||
gpio-controller; | ||
#gpio-cells = <2>; | ||
snps,nr-gpios = <8>; | ||
interrupt-controller; | ||
#interrupt-cells = <2>; | ||
interrupt-parent = <&vic1>; | ||
interrupts = <0>; | ||
}; | ||
portb: gpio-port@1 { | ||
compatible = "snps,dw-apb-gpio-port"; | ||
reg = <1>; | ||
gpio-controller; | ||
#gpio-cells = <2>; | ||
snps,nr-gpios = <8>; | ||
}; | ||
}; | ||
... |
65 changes: 0 additions & 65 deletions
65
Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.