Skip to content

Commit a409ed1

Browse files
committed
Merge tag 'gpio-v5.11-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 the GPIO changes for the v5.11 kernel cycle: Core changes: - Retired the old set-up function for GPIO IRQ chips. All chips now use the template struct gpio_irq_chip and pass that to the core to be set up alongside the gpio_chip. We can finally get rid of the old cruft. - Some refactoring and clean up of the core code. - Support edge event timestamps to be stamped using REALTIME (wall clock) timestamps. We have found solid use cases for this, so we support it. New drivers: - MStar MSC313 GPIO driver. - HiSilicon GPIO driver. Driver improvements: - The PCA953x driver now also supports the NXP PCAL9554B/C chips. - The mockup driver can now be probed from the device tree which is pretty useful for virtual prototyping of devices. - The Rcar driver now supports .get_multiple() - The MXC driver dropped some legacy and became a pure device tree client. - The Exar driver was moved over to the IDA interface for enumerating, and also switched over to using regmap for register access" * tag 'gpio-v5.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (87 commits) MAINTAINERS: Remove reference to non-existing file gpio: hisi: Do not require ACPI for COMPILE_TEST MAINTAINERS: Add maintainer for HiSilicon GPIO driver gpio: gpio-hisi: Add HiSilicon GPIO support gpio: cs5535: Simplify the return expression of cs5535_gpio_probe() gpiolib: irq hooks: fix recursion in gpiochip_irq_unmask dt-bindings: mt7621-gpio: convert bindings to YAML format gpiolib: cdev: Flag invalid GPIOs as used gpio: put virtual gpio device into their own submenu drivers: gpio: amd8111: use SPDX-License-Identifier drivers: gpio: amd8111: prefer dev_err()/dev_info() over raw printk drivers: gpio: bt8xx: prefer dev_err()/dev_warn() over of raw printk gpio: Add TODO item for debugfs interface gpio: just plain warning when nonexisting gpio requested tools: gpio: add option to report wall-clock time to gpio-event-mon tools: gpio: add support for reporting realtime event clock to lsgpio gpiolib: cdev: allow edge event timestamps to be configured as REALTIME gpio: msc313: MStar MSC313 GPIO driver dt-bindings: gpio: Binding for MStar MSC313 GPIO controller dt-bindings: gpio: Add a binding header for the MSC313 GPIO driver ...
2 parents 345b17a + 7ac5548 commit a409ed1

46 files changed

Lines changed: 1631 additions & 826 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/devicetree/bindings/gpio/gpio-pca95xx.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ properties:
4848
- nxp,pcal6416
4949
- nxp,pcal6524
5050
- nxp,pcal9535
51+
- nxp,pcal9554b
5152
- nxp,pcal9555a
5253
- onnn,cat9554
5354
- onnn,pca9654

Documentation/devicetree/bindings/gpio/gpio-xilinx.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Required properties:
1313
- gpio-controller : Marks the device node as a GPIO controller.
1414

1515
Optional properties:
16+
- clocks : Input clock specifier. Refer to common clock bindings.
1617
- interrupts : Interrupt mapping for GPIO IRQ.
1718
- xlnx,all-inputs : if n-th bit is setup, GPIO-n is input
1819
- xlnx,dout-default : if n-th bit is 1, GPIO-n default value is 1
@@ -29,6 +30,7 @@ Example:
2930
gpio: gpio@40000000 {
3031
#gpio-cells = <2>;
3132
compatible = "xlnx,xps-gpio-1.00.a";
33+
clocks = <&clkc25>;
3234
gpio-controller ;
3335
interrupt-parent = <&microblaze_0_intc>;
3436
interrupts = < 6 2 >;

Documentation/devicetree/bindings/gpio/mediatek,mt7621-gpio.txt

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/gpio/mediatek,mt7621-gpio.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Mediatek MT7621 SoC GPIO controller
8+
9+
maintainers:
10+
- Sergio Paracuellos <sergio.paracuellos@gmail.com>
11+
12+
description: |
13+
The IP core used inside these SoCs has 3 banks of 32 GPIOs each.
14+
The registers of all the banks are interwoven inside one single IO range.
15+
We load one GPIO controller instance per bank. Also the GPIO controller can receive
16+
interrupts on any of the GPIOs, either edge or level. It then interrupts the CPU
17+
using GIC INT12.
18+
19+
properties:
20+
$nodename:
21+
pattern: "^gpio@[0-9a-f]+$"
22+
23+
compatible:
24+
const: mediatek,mt7621-gpio
25+
26+
reg:
27+
maxItems: 1
28+
29+
"#gpio-cells":
30+
const: 2
31+
32+
gpio-controller: true
33+
gpio-ranges: true
34+
35+
interrupt-controller: true
36+
37+
"#interrupt-cells":
38+
const: 2
39+
40+
interrupts:
41+
maxItems: 1
42+
43+
required:
44+
- compatible
45+
- reg
46+
- "#gpio-cells"
47+
- gpio-controller
48+
- gpio-ranges
49+
- interrupt-controller
50+
- "#interrupt-cells"
51+
- interrupts
52+
53+
additionalProperties: false
54+
55+
examples:
56+
- |
57+
#include <dt-bindings/gpio/gpio.h>
58+
#include <dt-bindings/interrupt-controller/mips-gic.h>
59+
60+
gpio@600 {
61+
compatible = "mediatek,mt7621-gpio";
62+
reg = <0x600 0x100>;
63+
#gpio-cells = <2>;
64+
gpio-controller;
65+
gpio-ranges = <&pinctrl 0 0 95>;
66+
interrupt-controller;
67+
#interrupt-cells = <2>;
68+
interrupt-parent = <&gic>;
69+
interrupts = <GIC_SHARED 12 IRQ_TYPE_LEVEL_HIGH>;
70+
};
71+
72+
...
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/gpio/mstar,msc313-gpio.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: MStar/SigmaStar GPIO controller
8+
9+
maintainers:
10+
- Daniel Palmer <daniel@thingy.jp>
11+
12+
properties:
13+
$nodename:
14+
pattern: "^gpio@[0-9a-f]+$"
15+
16+
compatible:
17+
const: mstar,msc313-gpio
18+
19+
reg:
20+
maxItems: 1
21+
22+
gpio-controller: true
23+
24+
"#gpio-cells":
25+
const: 2
26+
27+
gpio-ranges: true
28+
29+
interrupt-controller: true
30+
31+
"#interrupt-cells":
32+
const: 2
33+
34+
required:
35+
- compatible
36+
- reg
37+
- gpio-controller
38+
- "#gpio-cells"
39+
- interrupt-controller
40+
- "#interrupt-cells"
41+
42+
additionalProperties: false
43+
44+
examples:
45+
- |
46+
#include <dt-bindings/gpio/msc313-gpio.h>
47+
48+
gpio: gpio@207800 {
49+
compatible = "mstar,msc313e-gpio";
50+
#gpio-cells = <2>;
51+
reg = <0x207800 0x200>;
52+
gpio-controller;
53+
gpio-ranges = <&pinctrl 0 36 22>,
54+
<&pinctrl 22 63 4>,
55+
<&pinctrl 26 68 6>;
56+
#interrupt-cells = <2>;
57+
interrupt-controller;
58+
interrupt-parent = <&intc_fiq>;
59+
};

Documentation/driver-api/gpio/consumer.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -440,18 +440,20 @@ For details refer to Documentation/firmware-guide/acpi/gpio-properties.rst
440440

441441
Interacting With the Legacy GPIO Subsystem
442442
==========================================
443-
Many kernel subsystems still handle GPIOs using the legacy integer-based
444-
interface. Although it is strongly encouraged to upgrade them to the safer
445-
descriptor-based API, the following two functions allow you to convert a GPIO
446-
descriptor into the GPIO integer namespace and vice-versa::
443+
Many kernel subsystems and drivers still handle GPIOs using the legacy
444+
integer-based interface. It is strongly recommended to update these to the new
445+
gpiod interface. For cases where both interfaces need to be used, the following
446+
two functions allow to convert a GPIO descriptor into the GPIO integer namespace
447+
and vice-versa::
447448

448449
int desc_to_gpio(const struct gpio_desc *desc)
449450
struct gpio_desc *gpio_to_desc(unsigned gpio)
450451

451-
The GPIO number returned by desc_to_gpio() can be safely used as long as the
452-
GPIO descriptor has not been freed. All the same, a GPIO number passed to
453-
gpio_to_desc() must have been properly acquired, and usage of the returned GPIO
454-
descriptor is only possible after the GPIO number has been released.
452+
The GPIO number returned by desc_to_gpio() can safely be used as a parameter of
453+
the gpio\_*() functions for as long as the GPIO descriptor `desc` is not freed.
454+
All the same, a GPIO number passed to gpio_to_desc() must first be properly
455+
acquired using e.g. gpio_request_one(), and the returned GPIO descriptor is only
456+
considered valid until that GPIO number is released using gpio_free().
455457

456458
Freeing a GPIO obtained by one API with the other API is forbidden and an
457459
unchecked error.

Documentation/driver-api/gpio/driver.rst

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@ The preferred way to set up the helpers is to fill in the
416416
struct gpio_irq_chip inside struct gpio_chip before adding the gpio_chip.
417417
If you do this, the additional irq_chip will be set up by gpiolib at the
418418
same time as setting up the rest of the GPIO functionality. The following
419-
is a typical example of a cascaded interrupt handler using gpio_irq_chip:
419+
is a typical example of a chained cascaded interrupt handler using
420+
the gpio_irq_chip:
420421

421422
.. code-block:: c
422423
@@ -452,7 +453,46 @@ is a typical example of a cascaded interrupt handler using gpio_irq_chip:
452453
453454
return devm_gpiochip_add_data(dev, &g->gc, g);
454455
455-
The helper support using hierarchical interrupt controllers as well.
456+
The helper supports using threaded interrupts as well. Then you just request
457+
the interrupt separately and go with it:
458+
459+
.. code-block:: c
460+
461+
/* Typical state container with dynamic irqchip */
462+
struct my_gpio {
463+
struct gpio_chip gc;
464+
struct irq_chip irq;
465+
};
466+
467+
int irq; /* from platform etc */
468+
struct my_gpio *g;
469+
struct gpio_irq_chip *girq;
470+
471+
/* Set up the irqchip dynamically */
472+
g->irq.name = "my_gpio_irq";
473+
g->irq.irq_ack = my_gpio_ack_irq;
474+
g->irq.irq_mask = my_gpio_mask_irq;
475+
g->irq.irq_unmask = my_gpio_unmask_irq;
476+
g->irq.irq_set_type = my_gpio_set_irq_type;
477+
478+
ret = devm_request_threaded_irq(dev, irq, NULL,
479+
irq_thread_fn, IRQF_ONESHOT, "my-chip", g);
480+
if (ret < 0)
481+
return ret;
482+
483+
/* Get a pointer to the gpio_irq_chip */
484+
girq = &g->gc.irq;
485+
girq->chip = &g->irq;
486+
/* This will let us handle the parent IRQ in the driver */
487+
girq->parent_handler = NULL;
488+
girq->num_parents = 0;
489+
girq->parents = NULL;
490+
girq->default_type = IRQ_TYPE_NONE;
491+
girq->handler = handle_bad_irq;
492+
493+
return devm_gpiochip_add_data(dev, &g->gc, g);
494+
495+
The helper supports using hierarchical interrupt controllers as well.
456496
In this case the typical set-up will look like this:
457497

458498
.. code-block:: c
@@ -493,32 +533,13 @@ the parent hardware irq from a child (i.e. this gpio chip) hardware irq.
493533
As always it is good to look at examples in the kernel tree for advice
494534
on how to find the required pieces.
495535

496-
The old way of adding irqchips to gpiochips after registration is also still
497-
available but we try to move away from this:
498-
499-
- DEPRECATED: gpiochip_irqchip_add(): adds a chained cascaded irqchip to a
500-
gpiochip. It will pass the struct gpio_chip* for the chip to all IRQ
501-
callbacks, so the callbacks need to embed the gpio_chip in its state
502-
container and obtain a pointer to the container using container_of().
503-
(See Documentation/driver-api/driver-model/design-patterns.rst)
504-
505-
- gpiochip_irqchip_add_nested(): adds a nested cascaded irqchip to a gpiochip,
506-
as discussed above regarding different types of cascaded irqchips. The
507-
cascaded irq has to be handled by a threaded interrupt handler.
508-
Apart from that it works exactly like the chained irqchip.
509-
510-
- gpiochip_set_nested_irqchip(): sets up a nested cascaded irq handler for a
511-
gpio_chip from a parent IRQ. As the parent IRQ has usually been
512-
explicitly requested by the driver, this does very little more than
513-
mark all the child IRQs as having the other IRQ as parent.
514-
515536
If there is a need to exclude certain GPIO lines from the IRQ domain handled by
516537
these helpers, we can set .irq.need_valid_mask of the gpiochip before
517538
devm_gpiochip_add_data() or gpiochip_add_data() is called. This allocates an
518539
.irq.valid_mask with as many bits set as there are GPIO lines in the chip, each
519540
bit representing line 0..n-1. Drivers can exclude GPIO lines by clearing bits
520-
from this mask. The mask must be filled in before gpiochip_irqchip_add() or
521-
gpiochip_irqchip_add_nested() is called.
541+
from this mask. The mask can be filled in the init_valid_mask() callback
542+
that is part of the struct gpio_irq_chip.
522543

523544
To use the helpers please keep the following in mind:
524545

MAINTAINERS

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,8 +2146,10 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
21462146
S: Maintained
21472147
W: http://linux-chenxing.org/
21482148
F: Documentation/devicetree/bindings/arm/mstar/*
2149+
F: Documentation/devicetree/bindings/gpio/mstar,msc313-gpio.yaml
21492150
F: arch/arm/boot/dts/mstar-*
21502151
F: arch/arm/mach-mstar/
2152+
F: drivers/gpio/gpio-msc313.c
21512153
F: include/dt-bindings/gpio/msc313-gpio.h
21522154

21532155
ARM/NEC MOBILEPRO 900/c MACHINE SUPPORT
@@ -7548,6 +7550,7 @@ M: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
75487550
L: linux-gpio@vger.kernel.org
75497551
L: linux-acpi@vger.kernel.org
75507552
S: Maintained
7553+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-gpio-intel.git
75517554
F: Documentation/firmware-guide/acpi/gpio-properties.rst
75527555
F: drivers/gpio/gpiolib-acpi.c
75537556
F: drivers/gpio/gpiolib-acpi.h
@@ -7981,6 +7984,12 @@ L: dmaengine@vger.kernel.org
79817984
S: Maintained
79827985
F: drivers/dma/hisi_dma.c
79837986

7987+
HISILICON GPIO DRIVER
7988+
M: Luo Jiaxing <luojiaxing@huawei.com>
7989+
L: linux-gpio@vger.kernel.org
7990+
S: Maintained
7991+
F: drivers/gpio/gpio-hisi.c
7992+
79847993
HISILICON HIGH PERFORMANCE RSA ENGINE DRIVER (HPRE)
79857994
M: Zaibo Xu <xuzaibo@huawei.com>
79867995
L: linux-crypto@vger.kernel.org
@@ -19500,6 +19509,16 @@ S: Maintained
1950019509
F: Documentation/devicetree/bindings/net/can/xilinx_can.txt
1950119510
F: drivers/net/can/xilinx_can.c
1950219511

19512+
XILINX GPIO DRIVER
19513+
M: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
19514+
R: Srinivas Neeli <srinivas.neeli@xilinx.com>
19515+
R: Michal Simek <michal.simek@xilinx.com>
19516+
S: Maintained
19517+
F: Documentation/devicetree/bindings/gpio/gpio-xilinx.txt
19518+
F: Documentation/devicetree/bindings/gpio/gpio-zynq.txt
19519+
F: drivers/gpio/gpio-xilinx.c
19520+
F: drivers/gpio/gpio-zynq.c
19521+
1950319522
XILINX SD-FEC IP CORES
1950419523
M: Derek Kiernan <derek.kiernan@xilinx.com>
1950519524
M: Dragan Cvetic <dragan.cvetic@xilinx.com>

0 commit comments

Comments
 (0)