Skip to content

Commit ebcb577

Browse files
committed
Merge tag 'gpio-updates-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio updates from Bartosz Golaszewski: "Relatively few updates for this release cycle. We have a single new driver and some minor changes in drivers, more work on limiting the usage of of_node in drivers and DT updates: - new driver: gpio-en7523 - dt-bindings: convertion of faraday,ftgpio010 to YAML, new compatible string in gpio-vf610 and a bugfix in an example - gpiolib core: several improvements and some code shrink - documentation: convert all public docs into kerneldoc format - set IRQ bus token in gpio-crystalcove (addresses a debugfs issue) - add a missing return value check for kstrdup() in gpio-merrifield - allow gpio-tps68470 to be built as module - more work on limiting usage of of_node in GPIO drivers - several sysfs interface improvements - use SDPX in gpio-ts4900" * tag 'gpio-updates-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpio: ts4900: Use SPDX header gpiolib: Use list_first_entry()/list_last_entry() gpiolib: sysfs: Simplify edge handling in the code gpiolib: sysfs: Move kstrtox() calls outside of the mutex lock gpiolib: sysfs: Move sysfs_emit() calls outside of the mutex lock gpiolib: make struct comments into real kernel docs dt-bindings: gpio: convert faraday,ftgpio01 to yaml dt-bindings: gpio: gpio-vf610: Add imx93 compatible string gpiolib: Simplify error path in gpiod_get_index() when requesting GPIO gpiolib: Use short form of ternary operator in gpiod_get_index() gpiolib: Introduce for_each_gpio_desc_with_flag() macro gpio: Add support for Airoha EN7523 GPIO controller dt-bindings: arm: airoha: Add binding for Airoha GPIO controller dt-bindings: gpio: fix gpio-hog example gpio: tps68470: Allow building as module gpio: tegra: Get rid of duplicate of_node assignment gpio: altera-a10sr: Switch to use fwnode instead of of_node gpio: merrifield: check the return value of devm_kstrdup() gpio: crystalcove: Set IRQ domain bus token to DOMAIN_BUS_WIRED
2 parents 5e20645 + 87ba5ba commit ebcb577

19 files changed

+422
-154
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/gpio/airoha,en7523-gpio.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Airoha EN7523 GPIO controller
8+
9+
maintainers:
10+
- John Crispin <john@phrozen.org>
11+
12+
description: |
13+
Airoha's GPIO controller on their ARM EN7523 SoCs consists of two banks of 32
14+
GPIOs.
15+
16+
properties:
17+
$nodename:
18+
pattern: "^gpio@[0-9a-f]+$"
19+
20+
compatible:
21+
items:
22+
- const: airoha,en7523-gpio
23+
24+
reg:
25+
description: |
26+
The first tuple points to the input register.
27+
The second and third tuple point to the direction registers
28+
The fourth tuple points to the output register
29+
maxItems: 4
30+
31+
"#gpio-cells":
32+
const: 2
33+
34+
gpio-controller: true
35+
36+
required:
37+
- compatible
38+
- reg
39+
- "#gpio-cells"
40+
- gpio-controller
41+
42+
additionalProperties: false
43+
44+
examples:
45+
- |
46+
gpio0: gpio@1fbf0200 {
47+
compatible = "airoha,en7523-gpio";
48+
reg = <0x1fbf0204 0x4>,
49+
<0x1fbf0200 0x4>,
50+
<0x1fbf0220 0x4>,
51+
<0x1fbf0214 0x4>;
52+
gpio-controller;
53+
#gpio-cells = <2>;
54+
};
55+
56+
gpio1: gpio@1fbf0270 {
57+
compatible = "airoha,en7523-gpio";
58+
reg = <0x1fbf0270 0x4>,
59+
<0x1fbf0260 0x4>,
60+
<0x1fbf0264 0x4>,
61+
<0x1fbf0278 0x4>;
62+
gpio-controller;
63+
#gpio-cells = <2>;
64+
};
65+
66+
...

Documentation/devicetree/bindings/gpio/faraday,ftgpio010.txt

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/gpio/faraday,ftgpio010.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Faraday Technology FTGPIO010 GPIO Controller
8+
9+
maintainers:
10+
- Linus Walleij <linus.walleij@linaro.org>
11+
12+
properties:
13+
compatible:
14+
oneOf:
15+
- items:
16+
- const: cortina,gemini-gpio
17+
- const: faraday,ftgpio010
18+
- items:
19+
- const: moxa,moxart-gpio
20+
- const: faraday,ftgpio010
21+
- const: faraday,ftgpio010
22+
23+
reg:
24+
maxItems: 1
25+
26+
resets:
27+
maxItems: 1
28+
29+
clocks:
30+
maxItems: 1
31+
32+
interrupts:
33+
maxItems: 1
34+
description: Should contain the interrupt line for the GPIO block
35+
36+
gpio-controller: true
37+
"#gpio-cells":
38+
const: 2
39+
40+
interrupt-controller: true
41+
"#interrupt-cells":
42+
const: 2
43+
44+
required:
45+
- compatible
46+
- reg
47+
- interrupts
48+
- "#gpio-cells"
49+
- interrupt-controller
50+
- "#interrupt-cells"
51+
52+
additionalProperties: false
53+
54+
examples:
55+
- |
56+
#include <dt-bindings/interrupt-controller/irq.h>
57+
gpio@4d000000 {
58+
compatible = "cortina,gemini-gpio", "faraday,ftgpio010";
59+
reg = <0x4d000000 0x100>;
60+
interrupts = <22 IRQ_TYPE_LEVEL_HIGH>;
61+
gpio-controller;
62+
#gpio-cells = <2>;
63+
interrupt-controller;
64+
#interrupt-cells = <2>;
65+
};

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ properties:
2525
- const: fsl,imx7ulp-gpio
2626
- const: fsl,vf610-gpio
2727
- items:
28-
- const: fsl,imx8ulp-gpio
28+
- enum:
29+
- fsl,imx93-gpio
30+
- fsl,imx8ulp-gpio
2931
- const: fsl,imx7ulp-gpio
3032

3133
reg:

Documentation/devicetree/bindings/gpio/gpio.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Example of two SOC GPIO banks defined as gpio-controller nodes:
213213
gpio-controller;
214214
#gpio-cells = <2>;
215215

216-
line_b {
216+
line_b-hog {
217217
gpio-hog;
218218
gpios = <6 0>;
219219
output-low;

drivers/gpio/Kconfig

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,16 @@ config GPIO_EM
247247
help
248248
Say yes here to support GPIO on Renesas Emma Mobile SoCs.
249249

250+
config GPIO_EN7523
251+
tristate "Airoha GPIO support"
252+
depends on ARCH_AIROHA
253+
default ARCH_AIROHA
254+
select GPIO_GENERIC
255+
select GPIOLIB_IRQCHIP
256+
help
257+
Say Y or M here to support the GPIO controller block on the
258+
Airoha EN7523 SoC. It supports two banks of 32 GPIOs.
259+
250260
config GPIO_EP93XX
251261
def_bool y
252262
depends on ARCH_EP93XX
@@ -1380,7 +1390,7 @@ config GPIO_TPS65912
13801390
This driver supports TPS65912 GPIO chip.
13811391

13821392
config GPIO_TPS68470
1383-
bool "TPS68470 GPIO"
1393+
tristate "TPS68470 GPIO"
13841394
depends on INTEL_SKL_INT3472
13851395
help
13861396
Select this option to enable GPIO driver for the TPS68470
@@ -1390,10 +1400,6 @@ config GPIO_TPS68470
13901400
input or output as appropriate, the sensor related GPIOs
13911401
are "output only" GPIOs.
13921402

1393-
This driver config is bool, as the GPIO functionality
1394-
of the TPS68470 must be available before dependent
1395-
drivers are loaded.
1396-
13971403
config GPIO_TQMX86
13981404
tristate "TQ-Systems QTMX86 GPIO"
13991405
depends on MFD_TQMX86 || COMPILE_TEST

drivers/gpio/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ obj-$(CONFIG_GPIO_DLN2) += gpio-dln2.o
5555
obj-$(CONFIG_GPIO_DWAPB) += gpio-dwapb.o
5656
obj-$(CONFIG_GPIO_EIC_SPRD) += gpio-eic-sprd.o
5757
obj-$(CONFIG_GPIO_EM) += gpio-em.o
58+
obj-$(CONFIG_GPIO_EN7523) += gpio-en7523.o
5859
obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o
5960
obj-$(CONFIG_GPIO_EXAR) += gpio-exar.o
6061
obj-$(CONFIG_GPIO_F7188X) += gpio-f7188x.o

drivers/gpio/gpio-altera-a10sr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/gpio/driver.h>
1111
#include <linux/mfd/altera-a10sr.h>
1212
#include <linux/module.h>
13+
#include <linux/property.h>
1314

1415
/**
1516
* struct altr_a10sr_gpio - Altera Max5 GPIO device private data structure
@@ -88,7 +89,7 @@ static int altr_a10sr_gpio_probe(struct platform_device *pdev)
8889

8990
gpio->gp = altr_a10sr_gc;
9091
gpio->gp.parent = pdev->dev.parent;
91-
gpio->gp.of_node = pdev->dev.of_node;
92+
gpio->gp.fwnode = dev_fwnode(&pdev->dev);
9293

9394
return devm_gpiochip_add_data(&pdev->dev, &gpio->gp, gpio);
9495
}

drivers/gpio/gpio-crystalcove.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,14 @@ static int crystalcove_gpio_probe(struct platform_device *pdev)
370370
return retval;
371371
}
372372

373-
return devm_gpiochip_add_data(&pdev->dev, &cg->chip, cg);
373+
retval = devm_gpiochip_add_data(&pdev->dev, &cg->chip, cg);
374+
if (retval)
375+
return retval;
376+
377+
/* Distuingish IRQ domain from others sharing (MFD) the same fwnode */
378+
irq_domain_update_bus_token(cg->chip.irq.domain, DOMAIN_BUS_WIRED);
379+
380+
return 0;
374381
}
375382

376383
static struct platform_driver crystalcove_gpio_driver = {

drivers/gpio/gpio-en7523.c

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
3+
#include <linux/types.h>
4+
#include <linux/io.h>
5+
#include <linux/bits.h>
6+
#include <linux/gpio/driver.h>
7+
#include <linux/mod_devicetable.h>
8+
#include <linux/module.h>
9+
#include <linux/platform_device.h>
10+
#include <linux/property.h>
11+
12+
#define AIROHA_GPIO_MAX 32
13+
14+
/**
15+
* airoha_gpio_ctrl - Airoha GPIO driver data
16+
* @gc: Associated gpio_chip instance.
17+
* @data: The data register.
18+
* @dir0: The direction register for the lower 16 pins.
19+
* @dir1: The direction register for the higher 16 pins.
20+
* @output: The output enable register.
21+
*/
22+
struct airoha_gpio_ctrl {
23+
struct gpio_chip gc;
24+
void __iomem *data;
25+
void __iomem *dir[2];
26+
void __iomem *output;
27+
};
28+
29+
static struct airoha_gpio_ctrl *gc_to_ctrl(struct gpio_chip *gc)
30+
{
31+
return container_of(gc, struct airoha_gpio_ctrl, gc);
32+
}
33+
34+
static int airoha_dir_set(struct gpio_chip *gc, unsigned int gpio,
35+
int val, int out)
36+
{
37+
struct airoha_gpio_ctrl *ctrl = gc_to_ctrl(gc);
38+
u32 dir = ioread32(ctrl->dir[gpio / 16]);
39+
u32 output = ioread32(ctrl->output);
40+
u32 mask = BIT((gpio % 16) * 2);
41+
42+
if (out) {
43+
dir |= mask;
44+
output |= BIT(gpio);
45+
} else {
46+
dir &= ~mask;
47+
output &= ~BIT(gpio);
48+
}
49+
50+
iowrite32(dir, ctrl->dir[gpio / 16]);
51+
52+
if (out)
53+
gc->set(gc, gpio, val);
54+
55+
iowrite32(output, ctrl->output);
56+
57+
return 0;
58+
}
59+
60+
static int airoha_dir_out(struct gpio_chip *gc, unsigned int gpio,
61+
int val)
62+
{
63+
return airoha_dir_set(gc, gpio, val, 1);
64+
}
65+
66+
static int airoha_dir_in(struct gpio_chip *gc, unsigned int gpio)
67+
{
68+
return airoha_dir_set(gc, gpio, 0, 0);
69+
}
70+
71+
static int airoha_get_dir(struct gpio_chip *gc, unsigned int gpio)
72+
{
73+
struct airoha_gpio_ctrl *ctrl = gc_to_ctrl(gc);
74+
u32 dir = ioread32(ctrl->dir[gpio / 16]);
75+
u32 mask = BIT((gpio % 16) * 2);
76+
77+
return (dir & mask) ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
78+
}
79+
80+
static int airoha_gpio_probe(struct platform_device *pdev)
81+
{
82+
struct device *dev = &pdev->dev;
83+
struct airoha_gpio_ctrl *ctrl;
84+
int err;
85+
86+
ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL);
87+
if (!ctrl)
88+
return -ENOMEM;
89+
90+
ctrl->data = devm_platform_ioremap_resource(pdev, 0);
91+
if (IS_ERR(ctrl->data))
92+
return PTR_ERR(ctrl->data);
93+
94+
ctrl->dir[0] = devm_platform_ioremap_resource(pdev, 1);
95+
if (IS_ERR(ctrl->dir[0]))
96+
return PTR_ERR(ctrl->dir[0]);
97+
98+
ctrl->dir[1] = devm_platform_ioremap_resource(pdev, 2);
99+
if (IS_ERR(ctrl->dir[1]))
100+
return PTR_ERR(ctrl->dir[1]);
101+
102+
ctrl->output = devm_platform_ioremap_resource(pdev, 3);
103+
if (IS_ERR(ctrl->output))
104+
return PTR_ERR(ctrl->output);
105+
106+
err = bgpio_init(&ctrl->gc, dev, 4, ctrl->data, NULL,
107+
NULL, NULL, NULL, 0);
108+
if (err)
109+
return dev_err_probe(dev, err, "unable to init generic GPIO");
110+
111+
ctrl->gc.ngpio = AIROHA_GPIO_MAX;
112+
ctrl->gc.owner = THIS_MODULE;
113+
ctrl->gc.direction_output = airoha_dir_out;
114+
ctrl->gc.direction_input = airoha_dir_in;
115+
ctrl->gc.get_direction = airoha_get_dir;
116+
117+
return devm_gpiochip_add_data(dev, &ctrl->gc, ctrl);
118+
}
119+
120+
static const struct of_device_id airoha_gpio_of_match[] = {
121+
{ .compatible = "airoha,en7523-gpio" },
122+
{ }
123+
};
124+
MODULE_DEVICE_TABLE(of, airoha_gpio_of_match);
125+
126+
static struct platform_driver airoha_gpio_driver = {
127+
.driver = {
128+
.name = "airoha-gpio",
129+
.of_match_table = airoha_gpio_of_match,
130+
},
131+
.probe = airoha_gpio_probe,
132+
};
133+
module_platform_driver(airoha_gpio_driver);
134+
135+
MODULE_DESCRIPTION("Airoha GPIO support");
136+
MODULE_AUTHOR("John Crispin <john@phrozen.org>");
137+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)