Skip to content

Commit

Permalink
Merge tag 'gpio-updates-for-v6.4' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/brgl/linux

Pull gpio updates from Bartosz Golaszewski:
 "We have some new drivers, significant refactoring of existing intel
  platforms, lots of improvements all around, mass conversion to using
  immutable irqchips by drivers that had not been converted individually
  yet and some changes in the core library code.

  Summary:

  New drivers:
   - add a driver for the Loongson GPIO controller
   - add a driver for the fxl6408 I2C GPIO expander
   - add a GPIO module containing code common for Intel Elkhart Lake and
     Merrifield platforms
   - add a driver for the Intel Elkhart Lake platform reusing the code
     from the intel tangier library

  GPIOLIB core:
   - GPIO ACPI improvements
   - simplify gpiochip_add_data_with_keys() fwnode handling
   - cleanup header inclusions (remove unneeded ones, order the rest
     alphabetically)
   - remove duplicate code (reuse krealloc() instead of open-coding it,
     drop a duplicated check in gpiod_find_and_request())
   - reshuffle the code to remove unnecessary forward declarations
   - coding style cleanups and improvements
   - add a helper for accessing device fwnodes
   - small updates in docs

  Driver improvements:
   - convert all remaining GPIO irqchip drivers to using immutable
     irqchips
   - drop unnecessary of_match_ptr() macro expansions
   - shrink the code in gpio-merrifield significantly by reusing the
     code from gpio-tangier + minor tweaks to the driver code
   - remove MODULE_LICENSE() from drivers that can only be built-in
   - add device-tree support to gpio-loongson1
   - use new regmap features in gpio-104-dio-48e and gpio-pcie-idio-24
   - minor tweaks and fixes to gpio-xra1403, gpio-sim, gpio-tegra194,
     gpio-omap, gpio-aspeed, gpio-raspberrypi-exp
   - shrink code in gpio-ich and gpio-pxa
   - Kconfig tweak for gpio-pmic-eic-sprd"

* tag 'gpio-updates-for-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (99 commits)
  gpio: gpiolib: Simplify gpiochip_add_data_with_key() fwnode
  gpiolib: Add gpiochip_set_data() helper
  gpiolib: Move gpiochip_get_data() higher in the code
  gpiolib: Check array_info for NULL only once in gpiod_get_array()
  gpiolib: Replace open coded krealloc()
  gpiolib: acpi: Add a ignore wakeup quirk for Clevo NL5xNU
  gpiolib: acpi: Move ACPI device NULL check to acpi_get_driver_gpio_data()
  gpiolib: acpi: use the fwnode in acpi_gpiochip_find()
  gpio: mm-lantiq: Fix typo in the newly added header filename
  sh: mach-x3proto: Add missing #include <linux/gpio/driver.h>
  powerpc/40x: Add missing select OF_GPIO_MM_GPIOCHIP
  gpio: xlp: Convert to immutable irq_chip
  gpio: xilinx: Convert to immutable irq_chip
  gpio: xgs-iproc: Convert to immutable irq_chip
  gpio: visconti: Convert to immutable irq_chip
  gpio: tqmx86: Convert to immutable irq_chip
  gpio: thunderx: Convert to immutable irq_chip
  gpio: stmpe: Convert to immutable irq_chip
  gpio: siox: Convert to immutable irq_chip
  gpio: rda: Convert to immutable irq_chip
  ...
  • Loading branch information
torvalds committed Apr 26, 2023
2 parents d849557 + 8a4adcf commit 2c96606
Show file tree
Hide file tree
Showing 109 changed files with 2,411 additions and 1,363 deletions.
2 changes: 1 addition & 1 deletion Documentation/admin-guide/gpio/sysfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ requested using gpio_request()::
/* export the GPIO to userspace */
int gpiod_export(struct gpio_desc *desc, bool direction_may_change);

/* reverse gpio_export() */
/* reverse gpiod_export() */
void gpiod_unexport(struct gpio_desc *desc);

/* create a sysfs link to an exported GPIO node */
Expand Down
58 changes: 58 additions & 0 deletions Documentation/devicetree/bindings/gpio/fcs,fxl6408.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/gpio/fcs,fxl6408.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Fairchild FXL6408 I2C GPIO Expander

maintainers:
- Emanuele Ghidoli <emanuele.ghidoli@toradex.com>

properties:
compatible:
enum:
- fcs,fxl6408

reg:
maxItems: 1

"#gpio-cells":
const: 2

gpio-controller: true

gpio-line-names:
minItems: 1
maxItems: 8

patternProperties:
"^(hog-[0-9]+|.+-hog(-[0-9]+)?)$":
required:
- gpio-hog

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

additionalProperties: false

examples:
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
gpio_expander_43: gpio-expander@43 {
compatible = "fcs,fxl6408";
reg = <0x43>;
gpio-controller;
#gpio-cells = <2>;
gpio-line-names = "Wi-Fi_W_DISABLE", "Wi-Fi_WKUP_WLAN",
"PWR_EN_+V3.3_WiFi_N", "PCIe_REF_CLK_EN",
"USB_RESET_N", "USB_BYPASS_N", "Wi-Fi_PDn",
"Wi-Fi_WKUP_BT";
};
};
41 changes: 29 additions & 12 deletions Documentation/devicetree/bindings/gpio/gpio.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,35 @@ of the GPIOs that can't be used.

Optionally, a GPIO controller may have a "gpio-line-names" property. This is
an array of strings defining the names of the GPIO lines going out of the
GPIO controller. This name should be the most meaningful producer name
for the system, such as a rail name indicating the usage. Package names
such as pin name are discouraged: such lines have opaque names (since they
are by definition generic purpose) and such names are usually not very
helpful. For example "MMC-CD", "Red LED Vdd" and "ethernet reset" are
reasonable line names as they describe what the line is used for. "GPIO0"
is not a good name to give to a GPIO line. Placeholders are discouraged:
rather use the "" (blank string) if the use of the GPIO line is undefined
in your design. The names are assigned starting from line offset 0 from
left to right from the passed array. An incomplete array (where the number
of passed named are less than ngpios) will still be used up until the last
provided valid line index.
GPIO controller.

For lines which are routed to on-board devices, this name should be
the most meaningful producer name for the system, such as a rail name
indicating the usage. Package names, such as a pin name, are discouraged:
such lines have opaque names (since they are by definition general-purpose)
and such names are usually not very helpful. For example "MMC-CD", "Red LED
Vdd" and "ethernet reset" are reasonable line names as they describe what
the line is used for. "GPIO0" is not a good name to give to a GPIO line
that is hard-wired to a specific device.

However, in the case of lines that are routed to a general purpose header
(e.g. the Raspberry Pi 40-pin header), and therefore are not hard-wired to
specific devices, using a pin number or the names on the header is fine
provided these are real (preferably unique) names. Using an SoC's pad name
or package name, or names made up from kernel-internal software constructs,
are strongly discouraged. For example "pin8 [gpio14/uart0_txd]" is fine
if the board's documentation labels pin 8 as such. However "PortB_24" (an
example of a name from an SoC's reference manual) would not be desirable.

In either case placeholders are discouraged: rather use the "" (blank
string) if the use of the GPIO line is undefined in your design. Ideally,
try to add comments to the dts file describing the naming the convention
you have chosen, and specifying from where the names are derived.

The names are assigned starting from line offset 0, from left to right,
from the passed array. An incomplete array (where the number of passed
names is less than ngpios) will be used up until the last provided valid
line index.

Example:

Expand Down
126 changes: 126 additions & 0 deletions Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/gpio/loongson,ls-gpio.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Loongson GPIO controller.

maintainers:
- Yinbo Zhu <zhuyinbo@loongson.cn>

properties:
compatible:
enum:
- loongson,ls2k-gpio
- loongson,ls7a-gpio

reg:
maxItems: 1

ngpios:
minimum: 1
maximum: 64

"#gpio-cells":
const: 2

gpio-controller: true

gpio-ranges: true

interrupts:
minItems: 1
maxItems: 64

required:
- compatible
- reg
- ngpios
- "#gpio-cells"
- gpio-controller
- gpio-ranges
- interrupts

additionalProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>
gpio0: gpio@1fe00500 {
compatible = "loongson,ls2k-gpio";
reg = <0x1fe00500 0x38>;
ngpios = <64>;
#gpio-cells = <2>;
gpio-controller;
gpio-ranges = <&pctrl 0 0 15>,
<&pctrl 16 16 15>,
<&pctrl 32 32 10>,
<&pctrl 44 44 20>;
interrupt-parent = <&liointc1>;
interrupts = <28 IRQ_TYPE_LEVEL_LOW>,
<29 IRQ_TYPE_LEVEL_LOW>,
<30 IRQ_TYPE_LEVEL_LOW>,
<30 IRQ_TYPE_LEVEL_LOW>,
<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YPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>,
<27 IRQ_TYPE_LEVEL_LOW>;
};
49 changes: 49 additions & 0 deletions Documentation/devicetree/bindings/gpio/loongson,ls1x-gpio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/gpio/loongson,ls1x-gpio.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Loongson-1 GPIO controller

maintainers:
- Keguang Zhang <keguang.zhang@gmail.com>

properties:
compatible:
const: loongson,ls1x-gpio

reg:
maxItems: 1

gpio-controller: true

"#gpio-cells":
const: 2

ngpios:
minimum: 1
maximum: 32

required:
- compatible
- reg
- gpio-controller
- "#gpio-cells"
- ngpios

additionalProperties: false

examples:
- |
gpio0: gpio@1fd010c0 {
compatible = "loongson,ls1x-gpio";
reg = <0x1fd010c0 0x4>;
gpio-controller;
#gpio-cells = <2>;
ngpios = <32>;
};
...
8 changes: 4 additions & 4 deletions Documentation/driver-api/gpio/driver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ not support open drain/open source in hardware, the GPIO library will instead
use a trick: when a line is set as output, if the line is flagged as open
drain, and the IN output value is low, it will be driven low as usual. But
if the IN output value is set to high, it will instead *NOT* be driven high,
instead it will be switched to input, as input mode is high impedance, thus
achieving an "open drain emulation" of sorts: electrically the behaviour will
be identical, with the exception of possible hardware glitches when switching
the mode of the line.
instead it will be switched to input, as input mode is an equivalent to
high impedance, thus achieving an "open drain emulation" of sorts: electrically
the behaviour will be identical, with the exception of possible hardware glitches
when switching the mode of the line.

For open source configuration the same principle is used, just that instead
of actively driving the line low, it is set to input.
Expand Down
23 changes: 0 additions & 23 deletions Documentation/driver-api/gpio/legacy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,6 @@ setup or driver probe/teardown code, so this is an easy constraint.)::
## gpio_free_array()

gpio_free()
gpio_set_debounce()



Claiming and Releasing GPIOs
Expand Down Expand Up @@ -716,27 +714,6 @@ gpiochip nodes (possibly in conjunction with schematics) to determine
the correct GPIO number to use for a given signal.


Exporting from Kernel code
--------------------------
Kernel code can explicitly manage exports of GPIOs which have already been
requested using gpio_request()::

/* export the GPIO to userspace */
int gpio_export(unsigned gpio, bool direction_may_change);

/* reverse gpio_export() */
void gpio_unexport();

After a kernel driver requests a GPIO, it may only be made available in
the sysfs interface by gpio_export(). The driver can control whether the
signal direction may change. This helps drivers prevent userspace code
from accidentally clobbering important system state.

This explicit exporting can help with debugging (by making some kinds
of experiments easier), or can provide an always-there interface that's
suitable for documenting as part of a board support package.


API Reference
=============

Expand Down
20 changes: 0 additions & 20 deletions Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ GPIO 值的命令需要等待其信息排到队首才发送命令,再获得其
## gpio_free_array()

gpio_free()
gpio_set_debounce()



Expand Down Expand Up @@ -654,25 +653,6 @@ GPIO 控制器的路径类似 /sys/class/gpio/gpiochip42/ (对于从#42 GPIO
确定给定信号所用的 GPIO 编号。


从内核代码中导出
----------------

内核代码可以明确地管理那些已通过 gpio_request()申请的 GPIO 的导出::

/* 导出 GPIO 到用户空间 */
int gpio_export(unsigned gpio, bool direction_may_change);

/* gpio_export()的逆操作 */
void gpio_unexport();

在一个内核驱动申请一个 GPIO 之后,它可以通过 gpio_export()使其在 sysfs
接口中可见。该驱动可以控制信号方向是否可修改。这有助于防止用户空间代码无意间
破坏重要的系统状态。

这个明确的导出有助于(通过使某些实验更容易来)调试,也可以提供一个始终存在的接口,
与文档配合作为板级支持包的一部分。


API参考
=======

Expand Down
Loading

0 comments on commit 2c96606

Please sign in to comment.