Skip to contentSkip to conversation

Add support of IRQs to QUICC ENGINE GPIOs

PATCH Superseded Christophe Leroy 4 participants 21 messages Aug 25, 2025 – Aug 29, 2025

Subsystems (5)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#20 lore raw

PATCH v3 6/6 dt-bindings: soc: fsl: qe: Add an interrupt controller for QUICC Engine Ports

In reply to Christophe Leroy

The QUICC Engine provides interrupts for a few I/O ports. This is handled via a separate interrupt ID and managed via a triplet of dedicated registers hosted by the SoC.

Implement an interrupt driver for it for that those IRQs can then be linked to the related GPIOs.

---
 .../soc/fsl/cpm_qe/fsl,qe-ports-ic.yaml       | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/fsl/cpm_qe/fsl,qe-ports-ic.yaml
Documentation/devicetree/bindings/soc/fsl/cpm_qe/fsl,qe-ports-ic.yaml new file +58 -0
new file mode 100644
index 000000000000..a356ad8b13f5
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/fsl/cpm_qe/fsl,qe-ports-ic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Freescale QUICC Engine I/O Ports Interrupt Controller
+
+maintainers:
+  - Christophe Leroy <[email protected]>
+
+description:
+  Interrupt controller for the QUICC Engine I/O ports found on some Freescale/NXP PowerQUICC and QorIQ SoCs.
+
+properties:
+  compatible:
+    enum:
+      - fsl,mpc8323-qe-ports-ic
+      - fsl,mpc8360-qe-ports-ic
+      - fsl,mpc8568-qe-ports-ic
+
+  reg:
+    maxItems: 1
+    description: Base address and size of the QE I/O Ports Interrupt Controller registers.
+
+  interrupt-controller: true
+
+  '#address-cells':
+    const: 0
+
+  '#interrupt-cells':
+    const: 1
+
+  interrupts:
+    maxItems: 1
+    description: Interrupt line to which the QE I/O Ports controller is connected.
+
+required:
+  - compatible
+  - reg
+  - interrupt-controller
+  - '#address-cells'
+  - '#interrupt-cells'
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    interrupt-controller@c00 {
+      compatible = "fsl,mpc8323-qe-ports-ic";
+      reg = <0xc00 0x18>;
+      interrupt-controller;
+      #address-cells = <0>;
+      #interrupt-cells = <1>;
+      interrupts = <74 0x8>;
+      interrupt-parent = <&ipic>;
+    };
Signature · 1 line
2.49.0
#0 lore raw

v3 cover Add support of IRQs to QUICC ENGINE GPIOs

The QUICC Engine provides interrupts for a few I/O ports. This is handled via a separate interrupt ID and managed via a triplet of dedicated registers hosted by the SoC.

Implement an interrupt driver for those IRQs then add IRQs capability to the QUICC ENGINE GPIOs.

The number of GPIOs for which interrupts are supported depends on the microcontroller:
- mpc8323 has 10 GPIOS supporting interrupts
- mpc8360 has 28 GPIOS supporting interrupts
- mpc8568 has 18 GPIOS supporting interrupts

Changes in v3:
- Splited dt-bindings update out of patch "soc: fsl: qe: Add support of IRQ in QE GPIO"
- Reordered DTS node exemples iaw dts-coding-style.rst

Changes in v2:
- Fixed warning on PPC64 build (Patch 1)
- Using devm_kzalloc() instead of kzalloc (Patch 2)
- Stop using of-mm-gpiochip (New patch 3)
- Added fsl,qe-gpio-irq-mask propertie in DT binding doc (Patch 4)
- Fixed problems reported by 'make dt_binding_check' (Patch 5)

Christophe Leroy (6):
soc: fsl: qe: Add an interrupt controller for QUICC Engine Ports
soc: fsl: qe: Change GPIO driver to a proper platform driver
soc: fsl: qe: Drop legacy-of-mm-gpiochip.h header from GPIO driver
soc: fsl: qe: Add support of IRQ in QE GPIO
dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO
dt-bindings: soc: fsl: qe: Add an interrupt controller for QUICC
Engine Ports

 .../soc/fsl/cpm_qe/fsl,qe-ports-ic.yaml       |  58 +++++++
 .../bindings/soc/fsl/cpm_qe/qe/par_io.txt     |  19 +++
 arch/powerpc/platforms/Kconfig                |   1 -
 drivers/soc/fsl/qe/Makefile                   |   2 +-
 drivers/soc/fsl/qe/gpio.c                     | 145 +++++++++-------
 drivers/soc/fsl/qe/qe_ports_ic.c              | 156 ++++++++++++++++++
 6 files changed, 322 insertions(+), 59 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/soc/fsl/cpm_qe/fsl,qe-ports-ic.yaml
 create mode 100644 drivers/soc/fsl/qe/qe_ports_ic.c
Signature · 1 line
2.49.0
#1 lore raw

PATCH v3 1/6 soc: fsl: qe: Add an interrupt controller for QUICC Engine Ports

The QUICC Engine provides interrupts for a few I/O ports. This is handled via a separate interrupt ID and managed via a triplet of dedicated registers hosted by the SoC.

Implement an interrupt driver for it for that those IRQs can then be linked to the related GPIOs.

The number of ports for which interrupts are supported depends on the microcontroller:
- mpc8323 has 10 interrupts
- mpc8360 has 28 interrupts
- mpc8568 has 18 interrupts
So add this information as data of the compatible.

---
 drivers/soc/fsl/qe/Makefile      |   2 +-
 drivers/soc/fsl/qe/qe_ports_ic.c | 156 +++++++++++++++++++++++++++++++
 2 files changed, 157 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/fsl/qe/qe_ports_ic.c
drivers/soc/fsl/qe/Makefile +1 -1
index ec8506e13113..901a9c40d5eb 100644
@@ -11,4 +11,4 @@ obj-$(CONFIG_UCC_SLOW)	+= ucc_slow.o
 obj-$(CONFIG_UCC_FAST)	+= ucc_fast.o
 obj-$(CONFIG_QE_TDM)	+= qe_tdm.o
 obj-$(CONFIG_QE_USB)	+= usb.o
-obj-$(CONFIG_QE_GPIO)	+= gpio.o
+obj-$(CONFIG_QE_GPIO)	+= gpio.o qe_ports_ic.o
drivers/soc/fsl/qe/qe_ports_ic.c new file +156 -0

156 lines not on this page · raw message

Signature · 1 line
2.49.0
#11 lore raw

PATCH v3 5/6 dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO

In reply to Christophe Leroy

In the QE, a few GPIOs are IRQ capable. Similarly to commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO"), add IRQ support to QE GPIO.

Add property 'fsl,qe-gpio-irq-mask' similar to 'fsl,cpm1-gpio-irq-mask' that define which of the GPIOs have IRQs.

Here is an exemple for port B of mpc8323 which has IRQs for GPIOs PB7, PB9, PB25 and PB27.

	qe_pio_b: gpio-controller@1418 {
		compatible = "fsl,mpc8323-qe-pario-bank";
		reg = <0x1418 0x18>;
		interrupts = <4 5 6 7>;
		interrupt-parent = <&qepic>;
		gpio-controller;
		#gpio-cells = <2>;
		fsl,qe-gpio-irq-mask = <0x01400050>;
	};
---
 .../bindings/soc/fsl/cpm_qe/qe/par_io.txt     | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/par_io.txt +19 -0
index 09b1b05fa677..829fe9a3d70c 100644
@@ -32,6 +32,15 @@ Required properties:
   "fsl,mpc8323-qe-pario-bank".
 - reg : offset to the register set and its length.
 - gpio-controller : node to identify gpio controllers.
+Optional properties:
+- fsl,qe-gpio-irq-mask : For banks having interrupt capability this item tells
+  which ports have an associated interrupt (ports are listed in the same order
+  as in QE ports registers)
+- interrupts : This property provides the list of interrupt for each GPIO having
+  one as described by the fsl,cpm1-gpio-irq-mask property. There should be as
+  many interrupts as number of ones in the mask property. The first interrupt in
+  the list corresponds to the most significant bit of the mask.
+- interrupt-parent : Parent for the above interrupt property.
 
 Example:
 	qe_pio_a: gpio-controller@1400 {
@@ -42,6 +51,16 @@ Example:
 		gpio-controller;
 	  };
 
+	qe_pio_b: gpio-controller@1418 {
+		#gpio-cells = <2>;
+		compatible = "fsl,mpc8323-qe-pario-bank";
+		reg = <0x1418 0x18>;
+		interrupts = <4 5 6 7>;
+		fsl,qe-gpio-irq-mask = <0x01400050>;
+		interrupt-parent = <&qepic>;
+		gpio-controller;
+	  };
+
 	qe_pio_e: gpio-controller@1460 {
 		#gpio-cells = <2>;
 		compatible = "fsl,mpc8360-qe-pario-bank",
Signature · 1 line
2.49.0
#2 lore raw

PATCH v3 2/6 soc: fsl: qe: Change GPIO driver to a proper platform driver

In reply to Christophe Leroy

In order to be able to add interrupts to the GPIOs, first change the QE GPIO driver to the proper platform driver in order to allow initialisation to be done in the right order, otherwise the GPIOs get added before the interrupts are registered.

---
 drivers/soc/fsl/qe/gpio.c | 86 +++++++++++++++++++++------------------
 1 file changed, 47 insertions(+), 39 deletions(-)
drivers/soc/fsl/qe/gpio.c +47 -39
index 8df1e8fa86a5..93fcc6d85ac7 100644
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/export.h>
 #include <linux/property.h>
+#include <linux/platform_device.h>
 
 #include <soc/fsl/qe/qe.h>
 
@@ -295,45 +296,52 @@ void qe_pin_set_gpio(struct qe_pin *qe_pin)
 }
 EXPORT_SYMBOL(qe_pin_set_gpio);
 
-static int __init qe_add_gpiochips(void)
+static int qe_gpio_probe(struct platform_device *ofdev)
 {
-	struct device_node *np;
-
-	for_each_compatible_node(np, NULL, "fsl,mpc8323-qe-pario-bank") {
-		int ret;
-		struct qe_gpio_chip *qe_gc;
-		struct of_mm_gpio_chip *mm_gc;
-		struct gpio_chip *gc;
-
-		qe_gc = kzalloc(sizeof(*qe_gc), GFP_KERNEL);
-		if (!qe_gc) {
-			ret = -ENOMEM;
-			goto err;
-		}
+	struct device *dev = &ofdev->dev;
+	struct device_node *np = dev->of_node;
+	struct qe_gpio_chip *qe_gc;
+	struct of_mm_gpio_chip *mm_gc;
+	struct gpio_chip *gc;
 
-		spin_lock_init(&qe_gc->lock);
-
-		mm_gc = &qe_gc->mm_gc;
-		gc = &mm_gc->gc;
-
-		mm_gc->save_regs = qe_gpio_save_regs;
-		gc->ngpio = QE_PIO_PINS;
-		gc->direction_input = qe_gpio_dir_in;
-		gc->direction_output = qe_gpio_dir_out;
-		gc->get = qe_gpio_get;
-		gc->set = qe_gpio_set;
-		gc->set_multiple = qe_gpio_set_multiple;
-
-		ret = of_mm_gpiochip_add_data(np, mm_gc, qe_gc);
-		if (ret)
-			goto err;
-		continue;
-err:
-		pr_err("%pOF: registration failed with status %d\n",
-		       np, ret);
-		kfree(qe_gc);
-		/* try others anyway */
-	}
-	return 0;
+	qe_gc = devm_kzalloc(dev, sizeof(*qe_gc), GFP_KERNEL);
+	if (!qe_gc)
+		return -ENOMEM;
+
+	spin_lock_init(&qe_gc->lock);
+
+	mm_gc = &qe_gc->mm_gc;
+	gc = &mm_gc->gc;
+
+	mm_gc->save_regs = qe_gpio_save_regs;
+	gc->ngpio = QE_PIO_PINS;
+	gc->direction_input = qe_gpio_dir_in;
+	gc->direction_output = qe_gpio_dir_out;
+	gc->get = qe_gpio_get;
+	gc->set = qe_gpio_set;
+	gc->set_multiple = qe_gpio_set_multiple;
+
+	return of_mm_gpiochip_add_data(np, mm_gc, qe_gc);
+}
+
+static const struct of_device_id qe_gpio_match[] = {
+	{
+		.compatible = "fsl,mpc8323-qe-pario-bank",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, qe_gpio_match);
+
+static struct platform_driver qe_gpio_driver = {
+	.probe		= qe_gpio_probe,
+	.driver		= {
+		.name	= "qe-gpio",
+		.of_match_table	= qe_gpio_match,
+	},
+};
+
+static int __init qe_gpio_init(void)
+{
+	return platform_driver_register(&qe_gpio_driver);
 }
-arch_initcall(qe_add_gpiochips);
+arch_initcall(qe_gpio_init);
Signature · 1 line
2.49.0
#6 lore raw

PATCH v3 3/6 soc: fsl: qe: Drop legacy-of-mm-gpiochip.h header from GPIO driver

In reply to Christophe Leroy

Remove legacy-of-mm-gpiochip.h header file. The above mentioned file provides an OF API that's deprecated. There is no agnostic alternatives to it and we have to open code the logic which was hidden behind of_mm_gpiochip_add_data(). Note, most of the GPIO drivers are using their own labeling schemas and resource retrieval that only a few may gain of the code deduplication, so whenever alternative is appear we can move drivers again to use that one.

As a side effect this change fixes a potential memory leak on an error path, if of_mm_gpiochip_add_data() fails.

[Text copied from commit 34064c8267a6 ("powerpc/8xx: Drop legacy-of-mm-gpiochip.h header")]

---
 arch/powerpc/platforms/Kconfig |  1 -
 drivers/soc/fsl/qe/gpio.c      | 51 ++++++++++++++++++----------------
 2 files changed, 27 insertions(+), 25 deletions(-)
arch/powerpc/platforms/Kconfig +0 -1
index fea3766eac0f..5b689bd3ddf4 100644
@@ -232,7 +232,6 @@ config QE_GPIO
 	bool "QE GPIO support"
 	depends on QUICC_ENGINE
 	select GPIOLIB
-	select OF_GPIO_MM_GPIOCHIP
 	help
 	  Say Y here if you're going to use hardware that connects to the
 	  QE GPIOs.
drivers/soc/fsl/qe/gpio.c +27 -24

151 lines not on this page · raw message

Signature · 1 line
2.49.0
#7 lore raw

PATCH v3 4/6 soc: fsl: qe: Add support of IRQ in QE GPIO

In reply to Christophe Leroy

In the QE, a few GPIOs are IRQ capable. Similarly to commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO"), add IRQ support to QE GPIO.

Add property 'fsl,qe-gpio-irq-mask' similar to 'fsl,cpm1-gpio-irq-mask' that define which of the GPIOs have IRQs.

Here is an exemple for port B of mpc8323 which has IRQs for GPIOs PB7, PB9, PB25 and PB27.

	qe_pio_b: gpio-controller@1418 {
		compatible = "fsl,mpc8323-qe-pario-bank";
		reg = <0x1418 0x18>;
		interrupts = <4 5 6 7>;
		interrupt-parent = <&qepic>;
		gpio-controller;
		#gpio-cells = <2>;
		fsl,qe-gpio-irq-mask = <0x01400050>;
	};
---
 drivers/soc/fsl/qe/gpio.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/soc/fsl/qe/gpio.c +20 -0
index a338469cebe4..91d469403126 100644
@@ -13,6 +13,7 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/of.h>
+#include <linux/of_irq.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/slab.h>
@@ -32,6 +33,8 @@ struct qe_gpio_chip {
 
 	/* saved_regs used to restore dedicated functions */
 	struct qe_pio_regs saved_regs;
+
+	int irq[32];
 };
 
 static void qe_gpio_save_regs(struct qe_gpio_chip *qe_gc)
@@ -135,6 +138,13 @@ static int qe_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 	return 0;
 }
 
+static int qe_gpio_to_irq(struct gpio_chip *gc, unsigned int gpio)
+{
+	struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc);
+
+	return qe_gc->irq[gpio] ? : -ENXIO;
+}
+
 struct qe_pin {
 	/*
 	 * The qe_gpio_chip name is unfortunate, we should change that to
@@ -295,6 +305,7 @@ static int qe_gpio_probe(struct platform_device *ofdev)
 	struct device_node *np = dev->of_node;
 	struct qe_gpio_chip *qe_gc;
 	struct gpio_chip *gc;
+	u32 mask;
 
 	qe_gc = devm_kzalloc(dev, sizeof(*qe_gc), GFP_KERNEL);
 	if (!qe_gc)
@@ -302,6 +313,14 @@ static int qe_gpio_probe(struct platform_device *ofdev)
 
 	spin_lock_init(&qe_gc->lock);
 
+	if (!of_property_read_u32(np, "fsl,qe-gpio-irq-mask", &mask)) {
+		int i, j;
+
+		for (i = 0, j = 0; i < ARRAY_SIZE(qe_gc->irq); i++)
+			if (mask & (1 << (31 - i)))
+				qe_gc->irq[i] = irq_of_parse_and_map(np, j++);
+	}
+
 	gc = &qe_gc->gc;
 
 	gc->base = -1;
@@ -311,6 +330,7 @@ static int qe_gpio_probe(struct platform_device *ofdev)
 	gc->get = qe_gpio_get;
 	gc->set = qe_gpio_set;
 	gc->set_multiple = qe_gpio_set_multiple;
+	gc->to_irq = qe_gpio_to_irq;
 	gc->parent = dev;
 	gc->owner = THIS_MODULE;
 
Signature · 1 line
2.49.0
#3 lore raw

Re: [PATCH v3 2/6] soc: fsl: qe: Change GPIO driver to a proper platform driver

In reply to Christophe Leroy
Quoted 8 lines · Christophe Leroy

In order to be able to add interrupts to the GPIOs, first change the QE GPIO driver to the proper platform driver in order to allow initialisation to be done in the right order, otherwise the GPIOs get added before the interrupts are registered.

Hi! I retracted my review tag under v1 because...

[snip]

Quoted 9 lines
drivers/soc/fsl/qe/gpio.c +8 -1
-       return 0;
+       qe_gc = devm_kzalloc(dev, sizeof(*qe_gc), GFP_KERNEL);
+       if (!qe_gc)
+               return -ENOMEM;
+
+       spin_lock_init(&qe_gc->lock);
+
+       mm_gc = &qe_gc->mm_gc;
+       gc = &mm_gc->gc;

drivers/soc/fsl/qe/gpio.c void qe_pin_set_gpio(struct qe_pin *qe_pin) · line 324

Quoted 10 lines
drivers/soc/fsl/qe/gpio.c +10 -0
+
+       mm_gc->save_regs = qe_gpio_save_regs;
+       gc->ngpio = QE_PIO_PINS;
+       gc->direction_input = qe_gpio_dir_in;
+       gc->direction_output = qe_gpio_dir_out;
+       gc->get = qe_gpio_get;
+       gc->set = qe_gpio_set;
+       gc->set_multiple = qe_gpio_set_multiple;
+
+       return of_mm_gpiochip_add_data(np, mm_gc, qe_gc);

... I believe this can be dropped now and replaced with devm_gpiochip_add_data().

Bart

Quoted 27 lines
drivers/soc/fsl/qe/gpio.c +22 -2
+}
+
+static const struct of_device_id qe_gpio_match[] = {
+       {
+               .compatible = "fsl,mpc8323-qe-pario-bank",
+       },
+       {},
+};
+MODULE_DEVICE_TABLE(of, qe_gpio_match);
+
+static struct platform_driver qe_gpio_driver = {
+       .probe          = qe_gpio_probe,
+       .driver         = {
+               .name   = "qe-gpio",
+               .of_match_table = qe_gpio_match,
+       },
+};
+
+static int __init qe_gpio_init(void)
+{
+       return platform_driver_register(&qe_gpio_driver);
 }
-arch_initcall(qe_add_gpiochips);
+arch_initcall(qe_gpio_init);
--

2.49.0

#4 lore raw

Re: [PATCH v3 2/6] soc: fsl: qe: Change GPIO driver to a proper platform driver

Quoted 9 lines · Bartosz Golaszewski
Quoted 6 lines · Christophe Leroy

In order to be able to add interrupts to the GPIOs, first change the QE GPIO driver to the proper platform driver in order to allow initialisation to be done in the right order, otherwise the GPIOs get added before the interrupts are registered.

Quoted 5 lines
Quoted 2 lines

Hi! I retracted my review tag under v1 because...

Ah, sorry for the noise, you did that in a separate patch, please keep my R-b.

Bartosz

#8 lore raw

Re: [PATCH v3 4/6] soc: fsl: qe: Add support of IRQ in QE GPIO

In reply to Christophe Leroy
Quoted 70 lines · Christophe Leroy

In the QE, a few GPIOs are IRQ capable. Similarly to commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO"), add IRQ support to QE GPIO.

Add property 'fsl,qe-gpio-irq-mask' similar to 'fsl,cpm1-gpio-irq-mask' that define which of the GPIOs have IRQs.

Here is an exemple for port B of mpc8323 which has IRQs for GPIOs PB7, PB9, PB25 and PB27.

        qe_pio_b: gpio-controller@1418 {
                compatible = "fsl,mpc8323-qe-pario-bank";
                reg = <0x1418 0x18>;
                interrupts = <4 5 6 7>;
                interrupt-parent = <&qepic>;
                gpio-controller;
                #gpio-cells = <2>;
                fsl,qe-gpio-irq-mask = <0x01400050>;
        };
---
 drivers/soc/fsl/qe/gpio.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/soc/fsl/qe/gpio.c +11 -0
index a338469cebe4..91d469403126 100644
@@ -13,6 +13,7 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/of.h>
+#include <linux/of_irq.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/slab.h>
@@ -32,6 +33,8 @@ struct qe_gpio_chip {
 
        /* saved_regs used to restore dedicated functions */
        struct qe_pio_regs saved_regs;
+
+       int irq[32];
 };
 
 static void qe_gpio_save_regs(struct qe_gpio_chip *qe_gc)
@@ -135,6 +138,13 @@ static int qe_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
        return 0;
 }
 
+static int qe_gpio_to_irq(struct gpio_chip *gc, unsigned int gpio)
+{
+       struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc);
+
+       return qe_gc->irq[gpio] ? : -ENXIO;
+}
+
 struct qe_pin {
        /*
         * The qe_gpio_chip name is unfortunate, we should change that to
@@ -295,6 +305,7 @@ static int qe_gpio_probe(struct platform_device *ofdev)
        struct device_node *np = dev->of_node;
        struct qe_gpio_chip *qe_gc;
        struct gpio_chip *gc;
+       u32 mask;
 
        qe_gc = devm_kzalloc(dev, sizeof(*qe_gc), GFP_KERNEL);
        if (!qe_gc)

drivers/soc/fsl/qe/gpio.c static int qe_gpio_probe(struct platform_device *ofdev) · line 316

Quoted 4 lines
drivers/soc/fsl/qe/gpio.c +1 -0
@@ -302,6 +313,14 @@ static int qe_gpio_probe(struct platform_device *ofdev)
 
        spin_lock_init(&qe_gc->lock);
 
+       if (!of_property_read_u32(np, "fsl,qe-gpio-irq-mask", &mask)) {

Please use device_property_read_u32 and stop including of.h if possible (it seems it is upon visual inspection).

Bart

Quoted 21 lines
drivers/soc/fsl/qe/gpio.c +8 -1
+               int i, j;
+
+               for (i = 0, j = 0; i < ARRAY_SIZE(qe_gc->irq); i++)
+                       if (mask & (1 << (31 - i)))
+                               qe_gc->irq[i] = irq_of_parse_and_map(np, j++);
+       }
+
        gc = &qe_gc->gc;
 
        gc->base = -1;
@@ -311,6 +330,7 @@ static int qe_gpio_probe(struct platform_device *ofdev)
        gc->get = qe_gpio_get;
        gc->set = qe_gpio_set;
        gc->set_multiple = qe_gpio_set_multiple;
+       gc->to_irq = qe_gpio_to_irq;
        gc->parent = dev;
        gc->owner = THIS_MODULE;
 
--

2.49.0

#9 lore raw

PATCH v4 1/1 soc: fsl: qe: Add support of IRQ in QE GPIO

In reply to Christophe Leroy

In the QE, a few GPIOs are IRQ capable. Similarly to commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO"), add IRQ support to QE GPIO.

Add property 'fsl,qe-gpio-irq-mask' similar to 'fsl,cpm1-gpio-irq-mask' that define which of the GPIOs have IRQs.

Here is an exemple for port B of mpc8323 which has IRQs for GPIOs PB7, PB9, PB25 and PB27.

	qe_pio_b: gpio-controller@1418 {
		compatible = "fsl,mpc8323-qe-pario-bank";
		reg = <0x1418 0x18>;
		interrupts = <4 5 6 7>;
		interrupt-parent = <&qepic>;
		gpio-controller;
		#gpio-cells = <2>;
		fsl,qe-gpio-irq-mask = <0x01400050>;
	};

---
v4: Using device_property_read_u32() instead of of_property_read_u32()

---
 drivers/soc/fsl/qe/gpio.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/soc/fsl/qe/gpio.c +21 -0
index 5bf073bbaac8..68bcd6048b1c 100644
@@ -12,11 +12,13 @@
 #include <linux/spinlock.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/of_irq.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/slab.h>
 #include <linux/export.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 
 #include <soc/fsl/qe/qe.h>
 
@@ -30,6 +32,8 @@ struct qe_gpio_chip {
 
 	/* saved_regs used to restore dedicated functions */
 	struct qe_pio_regs saved_regs;
+
+	int irq[32];
 };
 
 static void qe_gpio_save_regs(struct qe_gpio_chip *qe_gc)
@@ -133,6 +137,13 @@ static int qe_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 	return 0;
 }
 
+static int qe_gpio_to_irq(struct gpio_chip *gc, unsigned int gpio)
+{
+	struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc);
+
+	return qe_gc->irq[gpio] ? : -ENXIO;
+}
+
 struct qe_pin {
 	/*
 	 * The qe_gpio_chip name is unfortunate, we should change that to
@@ -293,6 +304,7 @@ static int qe_gpio_probe(struct platform_device *ofdev)
 	struct device_node *np = dev->of_node;
 	struct qe_gpio_chip *qe_gc;
 	struct gpio_chip *gc;
+	u32 mask;
 
 	qe_gc = devm_kzalloc(dev, sizeof(*qe_gc), GFP_KERNEL);
 	if (!qe_gc)
@@ -300,6 +312,14 @@ static int qe_gpio_probe(struct platform_device *ofdev)
 
 	spin_lock_init(&qe_gc->lock);
 
+	if (!device_property_read_u32(dev, "fsl,qe-gpio-irq-mask", &mask)) {
+		int i, j;
+
+		for (i = 0, j = 0; i < ARRAY_SIZE(qe_gc->irq); i++)
+			if (mask & (1 << (31 - i)))
+				qe_gc->irq[i] = irq_of_parse_and_map(np, j++);
+	}
+
 	gc = &qe_gc->gc;
 
 	gc->base = -1;
@@ -309,6 +329,7 @@ static int qe_gpio_probe(struct platform_device *ofdev)
 	gc->get = qe_gpio_get;
 	gc->set = qe_gpio_set;
 	gc->set_multiple = qe_gpio_set_multiple;
+	gc->to_irq = qe_gpio_to_irq;
 	gc->parent = dev;
 	gc->owner = THIS_MODULE;
 
Signature · 1 line
2.49.0
#5 lore raw

PATCH v4 1/1 soc: fsl: qe: Change GPIO driver to a proper platform driver

In reply to Christophe Leroy

In order to be able to add interrupts to the GPIOs, first change the QE GPIO driver to the proper platform driver in order to allow initialisation to be done in the right order, otherwise the GPIOs get added before the interrupts are registered.

Removing linux/of.h and linux/property.h which are unused.

---
v4: Removed unused headers

---
 drivers/soc/fsl/qe/gpio.c | 88 +++++++++++++++++++++------------------
 1 file changed, 47 insertions(+), 41 deletions(-)
drivers/soc/fsl/qe/gpio.c +47 -41
index 8df1e8fa86a5..fece644ce914 100644
@@ -12,13 +12,12 @@
 #include <linux/spinlock.h>
 #include <linux/err.h>
 #include <linux/io.h>
-#include <linux/of.h>
 #include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/slab.h>
 #include <linux/export.h>
-#include <linux/property.h>
+#include <linux/platform_device.h>
 
 #include <soc/fsl/qe/qe.h>
 
@@ -295,45 +294,52 @@ void qe_pin_set_gpio(struct qe_pin *qe_pin)
 }
 EXPORT_SYMBOL(qe_pin_set_gpio);
 
-static int __init qe_add_gpiochips(void)
+static int qe_gpio_probe(struct platform_device *ofdev)
 {
-	struct device_node *np;
-
-	for_each_compatible_node(np, NULL, "fsl,mpc8323-qe-pario-bank") {
-		int ret;
-		struct qe_gpio_chip *qe_gc;
-		struct of_mm_gpio_chip *mm_gc;
-		struct gpio_chip *gc;
-
-		qe_gc = kzalloc(sizeof(*qe_gc), GFP_KERNEL);
-		if (!qe_gc) {
-			ret = -ENOMEM;
-			goto err;
-		}
+	struct device *dev = &ofdev->dev;
+	struct device_node *np = dev->of_node;
+	struct qe_gpio_chip *qe_gc;
+	struct of_mm_gpio_chip *mm_gc;
+	struct gpio_chip *gc;
 
-		spin_lock_init(&qe_gc->lock);
-
-		mm_gc = &qe_gc->mm_gc;
-		gc = &mm_gc->gc;
-
-		mm_gc->save_regs = qe_gpio_save_regs;
-		gc->ngpio = QE_PIO_PINS;
-		gc->direction_input = qe_gpio_dir_in;
-		gc->direction_output = qe_gpio_dir_out;
-		gc->get = qe_gpio_get;
-		gc->set = qe_gpio_set;
-		gc->set_multiple = qe_gpio_set_multiple;
-
-		ret = of_mm_gpiochip_add_data(np, mm_gc, qe_gc);
-		if (ret)
-			goto err;
-		continue;
-err:
-		pr_err("%pOF: registration failed with status %d\n",
-		       np, ret);
-		kfree(qe_gc);
-		/* try others anyway */
-	}
-	return 0;
+	qe_gc = devm_kzalloc(dev, sizeof(*qe_gc), GFP_KERNEL);
+	if (!qe_gc)
+		return -ENOMEM;
+
+	spin_lock_init(&qe_gc->lock);
+
+	mm_gc = &qe_gc->mm_gc;
+	gc = &mm_gc->gc;
+
+	mm_gc->save_regs = qe_gpio_save_regs;
+	gc->ngpio = QE_PIO_PINS;
+	gc->direction_input = qe_gpio_dir_in;
+	gc->direction_output = qe_gpio_dir_out;
+	gc->get = qe_gpio_get;
+	gc->set = qe_gpio_set;
+	gc->set_multiple = qe_gpio_set_multiple;
+
+	return of_mm_gpiochip_add_data(np, mm_gc, qe_gc);
+}
+
+static const struct of_device_id qe_gpio_match[] = {
+	{
+		.compatible = "fsl,mpc8323-qe-pario-bank",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, qe_gpio_match);
+
+static struct platform_driver qe_gpio_driver = {
+	.probe		= qe_gpio_probe,
+	.driver		= {
+		.name	= "qe-gpio",
+		.of_match_table	= qe_gpio_match,
+	},
+};
+
+static int __init qe_gpio_init(void)
+{
+	return platform_driver_register(&qe_gpio_driver);
 }
-arch_initcall(qe_add_gpiochips);
+arch_initcall(qe_gpio_init);
Signature · 1 line
2.49.0
Reviewed-by on v4 1/1
#10 lore raw

Re: [PATCH v4] soc: fsl: qe: Add support of IRQ in QE GPIO

In reply to Christophe Leroy
Quoted 21 lines · Christophe Leroy

In the QE, a few GPIOs are IRQ capable. Similarly to commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO"), add IRQ support to QE GPIO.

Add property 'fsl,qe-gpio-irq-mask' similar to 'fsl,cpm1-gpio-irq-mask' that define which of the GPIOs have IRQs.

Here is an exemple for port B of mpc8323 which has IRQs for GPIOs PB7, PB9, PB25 and PB27.

        qe_pio_b: gpio-controller@1418 {
                compatible = "fsl,mpc8323-qe-pario-bank";
                reg = <0x1418 0x18>;
                interrupts = <4 5 6 7>;
                interrupt-parent = <&qepic>;
                gpio-controller;
                #gpio-cells = <2>;
                fsl,qe-gpio-irq-mask = <0x01400050>;
        };
Quoted 2 lines

---

maintainer
#12 lore raw

Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO

In reply to Christophe Leroy
Quoted 7 lines · Christophe Leroy

In the QE, a few GPIOs are IRQ capable. Similarly to commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO"), add IRQ support to QE GPIO.

Add property 'fsl,qe-gpio-irq-mask' similar to 'fsl,cpm1-gpio-irq-mask' that define which of the GPIOs have IRQs.

Why do you need to know this? The ones that have interrupts will be referenced by an 'interrupts' property somewhere.

Quoted 1 line

Here is an exemple for port B of mpc8323 which has IRQs for

typo

Quoted 11 lines

GPIOs PB7, PB9, PB25 and PB27.

        qe_pio_b: gpio-controller@1418 {
                compatible = "fsl,mpc8323-qe-pario-bank";
                reg = <0x1418 0x18>;
                interrupts = <4 5 6 7>;
                interrupt-parent = <&qepic>;
                gpio-controller;
                #gpio-cells = <2>;
                fsl,qe-gpio-irq-mask = <0x01400050>;
        };

You are missing #interrupt-cells and interrupt-controller properties.

With multiple new properties, this should be converted to schema first.

Quoted 46 lines
---
 .../bindings/soc/fsl/cpm_qe/qe/par_io.txt     | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/par_io.txt +19 -1
index 09b1b05fa677..829fe9a3d70c 100644
@@ -32,6 +32,15 @@ Required properties:
   "fsl,mpc8323-qe-pario-bank".
 - reg : offset to the register set and its length.
 - gpio-controller : node to identify gpio controllers.
+Optional properties:
+- fsl,qe-gpio-irq-mask : For banks having interrupt capability this item tells
+  which ports have an associated interrupt (ports are listed in the same order
+  as in QE ports registers)
+- interrupts : This property provides the list of interrupt for each GPIO having
+  one as described by the fsl,cpm1-gpio-irq-mask property. There should be as
+  many interrupts as number of ones in the mask property. The first interrupt in
+  the list corresponds to the most significant bit of the mask.
+- interrupt-parent : Parent for the above interrupt property.
 
 Example:
        qe_pio_a: gpio-controller@1400 {
@@ -42,6 +51,16 @@ Example:
                gpio-controller;
          };
 
+       qe_pio_b: gpio-controller@1418 {
+               #gpio-cells = <2>;
+               compatible = "fsl,mpc8323-qe-pario-bank";
+               reg = <0x1418 0x18>;
+               interrupts = <4 5 6 7>;
+               fsl,qe-gpio-irq-mask = <0x01400050>;
+               interrupt-parent = <&qepic>;
+               gpio-controller;
+         };
+
        qe_pio_e: gpio-controller@1460 {
                #gpio-cells = <2>;
                compatible = "fsl,mpc8360-qe-pario-bank",
--

2.49.0

#13 lore raw

Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO

Le 28/08/2025 à 15:28, Rob Herring a écrit :

Quoted 7 lines
Quoted 5 lines · Christophe Leroy

In the QE, a few GPIOs are IRQ capable. Similarly to commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO"), add IRQ support to QE GPIO.

Quoted 5 lines
Quoted 2 lines

Add property 'fsl,qe-gpio-irq-mask' similar to 'fsl,cpm1-gpio-irq-mask' that define which of the GPIOs have IRQs.

Why do you need to know this? The ones that have interrupts will be referenced by an 'interrupts' property somewhere.

I don't follow you. The ones that have interrupts need to be reported by gc->qe_gpio_to_irq[] so that gpiod_to_irq() return the IRQ number, for instance to gpio_sysfs_request_irq() so that it can install an irq handler. I can't see where they would be referenced by an "interrupts" property.

Quoted 17 lines
Quoted 2 lines

Here is an exemple for port B of mpc8323 which has IRQs for

typo

Quoted 11 lines

GPIOs PB7, PB9, PB25 and PB27.

         qe_pio_b: gpio-controller@1418 {
                 compatible = "fsl,mpc8323-qe-pario-bank";
                 reg = <0x1418 0x18>;
                 interrupts = <4 5 6 7>;
                 interrupt-parent = <&qepic>;
                 gpio-controller;
                 #gpio-cells = <2>;
                 fsl,qe-gpio-irq-mask = <0x01400050>;
         };
Quoted 1 line

You are missing #interrupt-cells and interrupt-controller properties.

The gpio controller is not an interrupt controller. The GPIO controller is brought by patch 1/6 and documented in patch 6/6.

Quoted 2 lines

With multiple new properties, this should be converted to schema first.

Ah. I didn't know, and checkpatch.pl doesn't know either it seems.

Christophe

#14 lore raw

Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO

Quoted 13 lines · Christophe Leroy

Le 28/08/2025 à 15:28, Rob Herring a écrit :

Quoted 10 lines
Quoted 7 lines · Christophe Leroy

In the QE, a few GPIOs are IRQ capable. Similarly to commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO"), add IRQ support to QE GPIO.

Add property 'fsl,qe-gpio-irq-mask' similar to 'fsl,cpm1-gpio-irq-mask' that define which of the GPIOs have IRQs.

Quoted 8 lines
Quoted 2 lines

Why do you need to know this? The ones that have interrupts will be referenced by an 'interrupts' property somewhere.

I don't follow you. The ones that have interrupts need to be reported by gc->qe_gpio_to_irq[] so that gpiod_to_irq() return the IRQ number, for instance to gpio_sysfs_request_irq() so that it can install an irq handler. I can't see where they would be referenced by an "interrupts" property.

They would be referenced by every consumer of these interrupts. IOW, this property is completely redundant, because DT holds this information already in other place.

Quoted 18 lines
Quoted 18 lines
Quoted 3 lines

Here is an exemple for port B of mpc8323 which has IRQs for

typo

Quoted 11 lines

GPIOs PB7, PB9, PB25 and PB27.

         qe_pio_b: gpio-controller@1418 {
                 compatible = "fsl,mpc8323-qe-pario-bank";
                 reg = <0x1418 0x18>;
                 interrupts = <4 5 6 7>;
                 interrupt-parent = <&qepic>;
                 gpio-controller;
                 #gpio-cells = <2>;
                 fsl,qe-gpio-irq-mask = <0x01400050>;
         };
Quoted 4 lines
Quoted 1 line

You are missing #interrupt-cells and interrupt-controller properties.

The gpio controller is not an interrupt controller. The GPIO controller is brought by patch 1/6 and documented in patch 6/6.

Then the IRQ mask property is not right here. If you say "this GPIOs have IRQs" it means this is an interrupt controller.

If you say this is not an interrupt controller, then you cannot have here interrupts per some GPIOs, obviously.

Best regards,
Krzysztof

#19 lore raw

Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO

In reply to Christophe Leroy
Quoted 10 lines · Christophe Leroy

In the QE, a few GPIOs are IRQ capable. Similarly to commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO"), add IRQ support to QE GPIO.

Add property 'fsl,qe-gpio-irq-mask' similar to 'fsl,cpm1-gpio-irq-mask' that define which of the GPIOs have IRQs.

Here is an exemple for port B of mpc8323 which has IRQs for GPIOs PB7, PB9, PB25 and PB27.

Quoted 8 lines
	qe_pio_b: gpio-controller@1418 {
		compatible = "fsl,mpc8323-qe-pario-bank";
		reg = <0x1418 0x18>;
		interrupts = <4 5 6 7>;
		interrupt-parent = <&qepic>;
		gpio-controller;
		#gpio-cells = <2>;
		fsl,qe-gpio-irq-mask = <0x01400050>;

We see this from the patch. No need to repeat the patch contents in the commit msg.

Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/par_io.txt Example: · line 56

Quoted 9 lines

Example:

Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/par_io.txt +3 -0
 	qe_pio_a: gpio-controller@1400 {
@@ -42,6 +51,16 @@ Example:
 		gpio-controller;
 	  };
 
+	qe_pio_b: gpio-controller@1418 {
+		#gpio-cells = <2>;
+		compatible = "fsl,mpc8323-qe-pario-bank";

Please follow DTS coding style.

Best regards,
Krzysztof

#15 lore raw

Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO

In reply to Krzysztof Kozlowski

Le 29/08/2025 à 09:47, Krzysztof Kozlowski a écrit :

Quoted 23 lines · Christophe Leroy
Quoted 13 lines

Le 28/08/2025 à 15:28, Rob Herring a écrit :

Quoted 10 lines
Quoted 7 lines · Christophe Leroy

In the QE, a few GPIOs are IRQ capable. Similarly to commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO"), add IRQ support to QE GPIO.

Add property 'fsl,qe-gpio-irq-mask' similar to 'fsl,cpm1-gpio-irq-mask' that define which of the GPIOs have IRQs.

Quoted 8 lines
Quoted 2 lines

Why do you need to know this? The ones that have interrupts will be referenced by an 'interrupts' property somewhere.

I don't follow you. The ones that have interrupts need to be reported by gc->qe_gpio_to_irq[] so that gpiod_to_irq() return the IRQ number, for instance to gpio_sysfs_request_irq() so that it can install an irq handler. I can't see where they would be referenced by an "interrupts" property.

Quoted 3 lines

They would be referenced by every consumer of these interrupts. IOW, this property is completely redundant, because DT holds this information already in other place.

But the gpio controller _is_ the consumer of these interrupts, it it _not_ the provider.

The interrupts are provided by a separate interrupt controller. Let's take the exemple of powerpc 8xx. Here is the list of interrupts handled by the CPM interrupt controller on the 8xx:

1 - GPIO Port C Line 4 interrupt 2 - GPIO Port C Line 5 interrupt 3 - SMC2 Serial controller interrupt 4 - SMC1 Serial controller interrupt 5 - SPI controller interrupt
6 - GPIO Port C Line 6 interrupt 7 - Timer 4 interrupt
8 - SCCd Serial controller interrupt 9 - GPIO Port C Line 7 interrupt 10 - GPIO Port C Line 8 interrupt 11 - GPIO Port C Line 9 interrupt 12 - Timer 3 interrupt
13 - SCCc Serial controller interrupt 14 - GPIO Port C Line 10 interrupt 15 - GPIO Port C Line 11 interrupt 16 - I2C Controller interrupt 17 - RISC timer table interrupt 18 - Timer 2 interrupt
19 - SCCb Serial controller interrupt 20 - IDMA2 interrupt
21 - IDMA1 interrupt
22 - SDMA channel bus error interrupt 23 - GPIO Port C Line 12 interrupt 24 - GPIO Port C Line 13 interrupt 25 - Timer 1 interrupt
26 - GPIO Port C Line 14 interrupt 27 - SCCd Serial controller interrupt 28 - SCCc Serial controller interrupt 29 - SCCb Serial controller interrupt 30 - SCCa Serial controller interrupt 31 - GPIO Port C Line 15 interrupt

As you can see in the list, the GPIO line interrupts are nested with other types of interrupts so GPIO controller and Interrupt controller are to be keept independant.

That's more or less the same here with my series, patch 1 implements an interrupt controller (documented in patch 6) and then the GPIO controllers consume the interrupts, for instance in gpiolib functions gpio_sysfs_request_irq() [drivers/gpio/gpiolib-sysfs.c] or edge_detector_setup() or debounce_setup() [drivers/gpio/gpiolib-cdev.c]

External drivers also use interrupts indirectly. For example driver sound/soc/soc-jack.c, it doesn't have any direct reference to an interrupt. The driver is given an array of GPIOs and then installs an IRQ in function snd_soc_jack_add_gpios() by doing

	request_any_context_irq(gpiod_to_irq(gpios[i].desc),
					      gpio_handler,
					      IRQF_SHARED |
					      IRQF_TRIGGER_RISING |
					      IRQF_TRIGGER_FALLING,
					      gpios[i].name,
					      &gpios[i]);
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 4 lines

Here is an exemple for port B of mpc8323 which has IRQs for

typo

Quoted 11 lines

GPIOs PB7, PB9, PB25 and PB27.

          qe_pio_b: gpio-controller@1418 {
                  compatible = "fsl,mpc8323-qe-pario-bank";
                  reg = <0x1418 0x18>;
                  interrupts = <4 5 6 7>;
                  interrupt-parent = <&qepic>;
                  gpio-controller;
                  #gpio-cells = <2>;
                  fsl,qe-gpio-irq-mask = <0x01400050>;
          };
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

You are missing #interrupt-cells and interrupt-controller properties.

The gpio controller is not an interrupt controller. The GPIO controller is brought by patch 1/6 and documented in patch 6/6.

Then the IRQ mask property is not right here. If you say "this GPIOs have IRQs" it means this is an interrupt controller.

The mask tells to the GPIO controller which GPIO line has an interrupt (so it can install the edge detector) and which doesn't have an interrupt. The "interrupts" property gives a flat list of interrupts, the mask in the above example tells: interrupt 4 is for line 7, interrupt 5 is for line 9, interrupt 6 is for line 25, interrupt 7 is for line 27. Other lines don't have interrupts.

Quoted 3 lines

If you say this is not an interrupt controller, then you cannot have here interrupts per some GPIOs, obviously.

It has been working that way on powerpc 8xx for 8 years, since commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO")

I don't understand why you say you cannot have here interrupts per some GPIOs. What am I missing ?

Thanks
Christophe

#16 lore raw

Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO

Quoted 60 lines · Christophe Leroy

Le 29/08/2025 à 09:47, Krzysztof Kozlowski a écrit :

Quoted 23 lines · Christophe Leroy
Quoted 13 lines

Le 28/08/2025 à 15:28, Rob Herring a écrit :

Quoted 10 lines
Quoted 7 lines · Christophe Leroy

In the QE, a few GPIOs are IRQ capable. Similarly to commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO"), add IRQ support to QE GPIO.

Add property 'fsl,qe-gpio-irq-mask' similar to 'fsl,cpm1-gpio-irq-mask' that define which of the GPIOs have IRQs.

Quoted 8 lines
Quoted 2 lines

Why do you need to know this? The ones that have interrupts will be referenced by an 'interrupts' property somewhere.

I don't follow you. The ones that have interrupts need to be reported by gc->qe_gpio_to_irq[] so that gpiod_to_irq() return the IRQ number, for instance to gpio_sysfs_request_irq() so that it can install an irq handler. I can't see where they would be referenced by an "interrupts" property.

Quoted 3 lines

They would be referenced by every consumer of these interrupts. IOW, this property is completely redundant, because DT holds this information already in other place.

But the gpio controller _is_ the consumer of these interrupts, it it _not_ the provider.

The interrupts are provided by a separate interrupt controller. Let's take the exemple of powerpc 8xx. Here is the list of interrupts handled by the CPM interrupt controller on the 8xx:

1 - GPIO Port C Line 4 interrupt
2 - GPIO Port C Line 5 interrupt
3 - SMC2 Serial controller interrupt
4 - SMC1 Serial controller interrupt
5 - SPI controller interrupt
6 - GPIO Port C Line 6 interrupt
7 - Timer 4 interrupt
8 - SCCd Serial controller interrupt
9 - GPIO Port C Line 7 interrupt
10 - GPIO Port C Line 8 interrupt
11 - GPIO Port C Line 9 interrupt
12 - Timer 3 interrupt
13 - SCCc Serial controller interrupt
14 - GPIO Port C Line 10 interrupt
15 - GPIO Port C Line 11 interrupt
16 - I2C Controller interrupt
17 - RISC timer table interrupt
18 - Timer 2 interrupt
19 - SCCb Serial controller interrupt
20 - IDMA2 interrupt
21 - IDMA1 interrupt
22 - SDMA channel bus error interrupt
23 - GPIO Port C Line 12 interrupt

Quoted 8 lines

24 - GPIO Port C Line 13 interrupt
25 - Timer 1 interrupt
26 - GPIO Port C Line 14 interrupt
27 - SCCd Serial controller interrupt
28 - SCCc Serial controller interrupt
29 - SCCb Serial controller interrupt
30 - SCCa Serial controller interrupt
31 - GPIO Port C Line 15 interrupt

That list is fixed per soc/device, so already implied by compatible.

Quoted 16 lines

As you can see in the list, the GPIO line interrupts are nested with other types of interrupts so GPIO controller and Interrupt controller are to be keept independant.

That's more or less the same here with my series, patch 1 implements an interrupt controller (documented in patch 6) and then the GPIO controllers consume the interrupts, for instance in gpiolib functions gpio_sysfs_request_irq() [drivers/gpio/gpiolib-sysfs.c] or edge_detector_setup() or debounce_setup() [drivers/gpio/gpiolib-cdev.c]

External drivers also use interrupts indirectly. For example driver sound/soc/soc-jack.c, it doesn't have any direct reference to an interrupt. The driver is given an array of GPIOs and then installs an IRQ in function snd_soc_jack_add_gpios() by doing

Quoted 7 lines
	request_any_context_irq(gpiod_to_irq(gpios[i].desc),
					      gpio_handler,
					      IRQF_SHARED |
					      IRQF_TRIGGER_RISING |
					      IRQF_TRIGGER_FALLING,
					      gpios[i].name,
					      &gpios[i]);

External drivers do not matter then. Your GPIO controller receives specific interrupts (that's the interrupt property) and knows exactly how each GPIO maps to it.

Quoted 36 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 5 lines

Here is an exemple for port B of mpc8323 which has IRQs for

typo

Quoted 11 lines

GPIOs PB7, PB9, PB25 and PB27.

          qe_pio_b: gpio-controller@1418 {
                  compatible = "fsl,mpc8323-qe-pario-bank";
                  reg = <0x1418 0x18>;
                  interrupts = <4 5 6 7>;
                  interrupt-parent = <&qepic>;
                  gpio-controller;
                  #gpio-cells = <2>;
                  fsl,qe-gpio-irq-mask = <0x01400050>;
          };
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

You are missing #interrupt-cells and interrupt-controller properties.

The gpio controller is not an interrupt controller. The GPIO controller is brought by patch 1/6 and documented in patch 6/6.

Then the IRQ mask property is not right here. If you say "this GPIOs have IRQs" it means this is an interrupt controller.

The mask tells to the GPIO controller which GPIO line has an interrupt (so it can install the edge detector) and which doesn't have an interrupt. The "interrupts" property gives a flat list of interrupts, the mask in the above example tells: interrupt 4 is for line 7, interrupt 5 is for line 9, interrupt 6 is for line 25, interrupt 7 is for line 27. Other lines don't have interrupts.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

If you say this is not an interrupt controller, then you cannot have here interrupts per some GPIOs, obviously.

It has been working that way on powerpc 8xx for 8 years, since commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO")

I don't understand why you say you cannot have here interrupts per some GPIOs. What am I missing ?

I used conditional. English conditional. If you claim this GPIO controller is not an interrupt controller, then obviously it is not an interrupt controller and cannot be used as interrupt controller.

If you use "foo" as interrupt controller, then clearly foo is an interrupt controller.

Best regards,
Krzysztof

#17 lore raw

Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO

Le 29/08/2025 à 11:16, Krzysztof Kozlowski a écrit :

Quoted 97 lines · Christophe Leroy
Quoted 60 lines

Le 29/08/2025 à 09:47, Krzysztof Kozlowski a écrit :

Quoted 23 lines · Christophe Leroy
Quoted 13 lines

Le 28/08/2025 à 15:28, Rob Herring a écrit :

Quoted 10 lines
Quoted 7 lines · Christophe Leroy

In the QE, a few GPIOs are IRQ capable. Similarly to commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO"), add IRQ support to QE GPIO.

Add property 'fsl,qe-gpio-irq-mask' similar to 'fsl,cpm1-gpio-irq-mask' that define which of the GPIOs have IRQs.

Quoted 8 lines
Quoted 2 lines

Why do you need to know this? The ones that have interrupts will be referenced by an 'interrupts' property somewhere.

I don't follow you. The ones that have interrupts need to be reported by gc->qe_gpio_to_irq[] so that gpiod_to_irq() return the IRQ number, for instance to gpio_sysfs_request_irq() so that it can install an irq handler. I can't see where they would be referenced by an "interrupts" property.

Quoted 3 lines

They would be referenced by every consumer of these interrupts. IOW, this property is completely redundant, because DT holds this information already in other place.

But the gpio controller _is_ the consumer of these interrupts, it it _not_ the provider.

The interrupts are provided by a separate interrupt controller. Let's take the exemple of powerpc 8xx. Here is the list of interrupts handled by the CPM interrupt controller on the 8xx:

1 - GPIO Port C Line 4 interrupt
2 - GPIO Port C Line 5 interrupt
3 - SMC2 Serial controller interrupt
4 - SMC1 Serial controller interrupt
5 - SPI controller interrupt
6 - GPIO Port C Line 6 interrupt
7 - Timer 4 interrupt
8 - SCCd Serial controller interrupt
9 - GPIO Port C Line 7 interrupt
10 - GPIO Port C Line 8 interrupt
11 - GPIO Port C Line 9 interrupt
12 - Timer 3 interrupt
13 - SCCc Serial controller interrupt
14 - GPIO Port C Line 10 interrupt
15 - GPIO Port C Line 11 interrupt
16 - I2C Controller interrupt
17 - RISC timer table interrupt
18 - Timer 2 interrupt
19 - SCCb Serial controller interrupt
20 - IDMA2 interrupt
21 - IDMA1 interrupt
22 - SDMA channel bus error interrupt
23 - GPIO Port C Line 12 interrupt

Quoted 8 lines

24 - GPIO Port C Line 13 interrupt
25 - Timer 1 interrupt
26 - GPIO Port C Line 14 interrupt
27 - SCCd Serial controller interrupt
28 - SCCc Serial controller interrupt
29 - SCCb Serial controller interrupt
30 - SCCa Serial controller interrupt
31 - GPIO Port C Line 15 interrupt

That list is fixed per soc/device, so already implied by compatible.

Quoted 16 lines

As you can see in the list, the GPIO line interrupts are nested with other types of interrupts so GPIO controller and Interrupt controller are to be keept independant.

That's more or less the same here with my series, patch 1 implements an interrupt controller (documented in patch 6) and then the GPIO controllers consume the interrupts, for instance in gpiolib functions gpio_sysfs_request_irq() [drivers/gpio/gpiolib-sysfs.c] or edge_detector_setup() or debounce_setup() [drivers/gpio/gpiolib-cdev.c]

External drivers also use interrupts indirectly. For example driver sound/soc/soc-jack.c, it doesn't have any direct reference to an interrupt. The driver is given an array of GPIOs and then installs an IRQ in function snd_soc_jack_add_gpios() by doing

Quoted 7 lines
	request_any_context_irq(gpiod_to_irq(gpios[i].desc),
					      gpio_handler,
					      IRQF_SHARED |
					      IRQF_TRIGGER_RISING |
					      IRQF_TRIGGER_FALLING,
					      gpios[i].name,
					      &gpios[i]);
Quoted 4 lines

External drivers do not matter then. Your GPIO controller receives specific interrupts (that's the interrupt property) and knows exactly how each GPIO maps to it.

Do you mean then that the GPIO driver should already know which line has an interrupt and which one doesn't ?

The interrupts are fixed per soc, but today the GPIO driver is generic and used on different SOCs that don't have interrupts on the same lines. And even on the given SOCs, not all ports have interrupts on the same lines. Should all possibilities be hard-coded inside the driver for each possible compatible ? The property 'fsl,qe-gpio-irq-mask' is there to avoid that and keep the GPIO driver as generic as possible with a single compatible 'fsl,mpc8323-qe-pario-bank' that is found in the DTS of 8323 but also in DTS of 8360, in DTS of 8569, etc... :

arch/powerpc/boot/dts/fsl/mpc8569mds.dts:

            "fsl,mpc8323-qe-pario-bank";
arch/powerpc/boot/dts/fsl/mpc8569mds.dts: 
            "fsl,mpc8323-qe-pario-bank";
arch/powerpc/boot/dts/kmeter1.dts: 
    "fsl,mpc8323-qe-pario-bank";

arch/powerpc/boot/dts/mpc832x_rdb.dts: compatible = "fsl,mpc8323-qe-pario-bank"; arch/powerpc/boot/dts/mpc836x_rdk.dts: "fsl,mpc8323-qe-pario-bank"; arch/powerpc/boot/dts/mpc836x_rdk.dts: "fsl,mpc8323-qe-pario-bank";

Do you mean we should define one compatible for each of the ports of each soc, and encode the mask of interrupts that define which line of the port has interrupts in the data field ?

Something like:

static const struct of_device_id qe_gpio_match[] = {
	{
		.compatible = "fsl,mpc8323-qe-pario-bank-a",
		.data = (void *)0x00a00028,
	},
	{
		.compatible = "fsl,mpc8323-qe-pario-bank-b",
		.data = (void *)0x01400050,
	},
	{
		.compatible = "fsl,mpc8323-qe-pario-bank-c",
		.data = (void *)0x00000084,
	},
	{
		.compatible = "fsl,mpc8323-qe-pario-bank-d",
		.data = (void *)0,
	},
	{
		.compatible = "fsl,mpc8360-qe-pario-bank-a",
		.data = (void *)0xXXXXXXXX,
	},
	{
		.compatible = "fsl,mpc8360-qe-pario-bank-b",
		.data = (void *)0xXXXXXXXX,
	},
....
	{},
};

MODULE_DEVICE_TABLE(of, qe_gpio_match);

That would be feasible but would mean updating the driver each time a new SOC is added.

Do you mean it should be done that way ?

Isn't the purpose of the device tree to keep drivers as generic as possible ?

Quoted 45 lines
Quoted 36 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 5 lines

Here is an exemple for port B of mpc8323 which has IRQs for

typo

Quoted 11 lines

GPIOs PB7, PB9, PB25 and PB27.

           qe_pio_b: gpio-controller@1418 {
                   compatible = "fsl,mpc8323-qe-pario-bank";
                   reg = <0x1418 0x18>;
                   interrupts = <4 5 6 7>;
                   interrupt-parent = <&qepic>;
                   gpio-controller;
                   #gpio-cells = <2>;
                   fsl,qe-gpio-irq-mask = <0x01400050>;
           };
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

You are missing #interrupt-cells and interrupt-controller properties.

The gpio controller is not an interrupt controller. The GPIO controller is brought by patch 1/6 and documented in patch 6/6.

Then the IRQ mask property is not right here. If you say "this GPIOs have IRQs" it means this is an interrupt controller.

The mask tells to the GPIO controller which GPIO line has an interrupt (so it can install the edge detector) and which doesn't have an interrupt. The "interrupts" property gives a flat list of interrupts, the mask in the above example tells: interrupt 4 is for line 7, interrupt 5 is for line 9, interrupt 6 is for line 25, interrupt 7 is for line 27. Other lines don't have interrupts.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

If you say this is not an interrupt controller, then you cannot have here interrupts per some GPIOs, obviously.

It has been working that way on powerpc 8xx for 8 years, since commit 726bd223105c ("powerpc/8xx: Adding support of IRQ in MPC8xx GPIO")

I don't understand why you say you cannot have here interrupts per some GPIOs. What am I missing ?

Quoted 7 lines

I used conditional. English conditional. If you claim this GPIO controller is not an interrupt controller, then obviously it is not an interrupt controller and cannot be used as interrupt controller.

If you use "foo" as interrupt controller, then clearly foo is an interrupt controller.

Ah ! ok. I didn't read it like that, sorry.

Thanks
Christophe

#18 lore raw

Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO

Quoted 21 lines · Christophe Leroy
Quoted 21 lines
Quoted 19 lines

That's more or less the same here with my series, patch 1 implements an interrupt controller (documented in patch 6) and then the GPIO controllers consume the interrupts, for instance in gpiolib functions gpio_sysfs_request_irq() [drivers/gpio/gpiolib-sysfs.c] or edge_detector_setup() or debounce_setup() [drivers/gpio/gpiolib-cdev.c]

External drivers also use interrupts indirectly. For example driver sound/soc/soc-jack.c, it doesn't have any direct reference to an interrupt. The driver is given an array of GPIOs and then installs an IRQ in function snd_soc_jack_add_gpios() by doing

	request_any_context_irq(gpiod_to_irq(gpios[i].desc),
					      gpio_handler,
					      IRQF_SHARED |
					      IRQF_TRIGGER_RISING |
					      IRQF_TRIGGER_FALLING,
					      gpios[i].name,
					      &gpios[i]);
Quoted 6 lines
Quoted 4 lines

External drivers do not matter then. Your GPIO controller receives specific interrupts (that's the interrupt property) and knows exactly how each GPIO maps to it.

Do you mean then that the GPIO driver should already know which line has

The SoC knows, that's fixed information, so shall GPIO driver know as well.

Quoted 4 lines

an interrupt and which one doesn't ?

The interrupts are fixed per soc, but today the GPIO driver is generic and used on different SOCs that don't have interrupts on the same lines.

How you write drivers is one thing, but that's never a reason alone to add properties to the DT.

Quoted 1 line

And even on the given SOCs, not all ports have interrupts on the same

That's pretty standard between all GPIO/pinctrl drivers. I would generalize that's pretty standard for all SoCs - they have differences within devices, some pins do that, some do different things.

Quoted 2 lines

lines. Should all possibilities be hard-coded inside the driver for each possible compatible ? The property 'fsl,qe-gpio-irq-mask' is there to

There are many ways how to do it in the driver, that feels like one of them, so yes, it should.

Quoted 1 line

avoid that and keep the GPIO driver as generic as possible with a single

Sorry, that approach, which leads to moving such stuff to DT, was many times on mailing list rejected. You use the same argument as that "one clock, one device node" TI approach. It got it way to kernel long time ago but since then was pretty discouraged (rejected for new SoCs). It re-appeared again few months ago in a form of "I have two registers, so I have two device nodes in DT", so it seems poor code keeps re-appearing.

Quoted 16 lines

compatible 'fsl,mpc8323-qe-pario-bank' that is found in the DTS of 8323 but also in DTS of 8360, in DTS of 8569, etc... :

arch/powerpc/boot/dts/fsl/mpc8569mds.dts:

             "fsl,mpc8323-qe-pario-bank";
arch/powerpc/boot/dts/fsl/mpc8569mds.dts: 
             "fsl,mpc8323-qe-pario-bank";
arch/powerpc/boot/dts/kmeter1.dts: 
     "fsl,mpc8323-qe-pario-bank";

arch/powerpc/boot/dts/mpc832x_rdb.dts:
compatible = "fsl,mpc8323-qe-pario-bank";
arch/powerpc/boot/dts/mpc836x_rdk.dts:
"fsl,mpc8323-qe-pario-bank";
arch/powerpc/boot/dts/mpc836x_rdk.dts:
"fsl,mpc8323-qe-pario-bank";

Quoted 3 lines

Do you mean we should define one compatible for each of the ports of each soc, and encode the mask of interrupts that define which line of the port has interrupts in the data field ?

I don't know that good your hardware to tell.

Quoted 7 lines

Something like:

static const struct of_device_id qe_gpio_match[] = {
	{
		.compatible = "fsl,mpc8323-qe-pario-bank-a",
		.data = (void *)0x00a00028,

There is no DTS in your patchset, so I cannot help really. I just don't have time to imagine such DTS and try to figure out how it can be written. Posting complete picture usually helps.

I don't follow what is the bank.

You have a device, yes?
It has some grouped GPIOs (banks?) and some within group/bank can handle interrupts?
Are these fixed per SoC? Yes. Well, that's standard and every other vendor has the same. They solve it in the drivers differently, though.

Quoted 24 lines
	},
	{
		.compatible = "fsl,mpc8323-qe-pario-bank-b",
		.data = (void *)0x01400050,
	},
	{
		.compatible = "fsl,mpc8323-qe-pario-bank-c",
		.data = (void *)0x00000084,
	},
	{
		.compatible = "fsl,mpc8323-qe-pario-bank-d",
		.data = (void *)0,
	},
	{
		.compatible = "fsl,mpc8360-qe-pario-bank-a",
		.data = (void *)0xXXXXXXXX,
	},
	{
		.compatible = "fsl,mpc8360-qe-pario-bank-b",
		.data = (void *)0xXXXXXXXX,
	},
....
	{},
};
Quoted 4 lines

MODULE_DEVICE_TABLE(of, qe_gpio_match);

That would be feasible but would mean updating the driver each time a new SOC is added.

BTW, like every other platform.

Quoted 5 lines

Do you mean it should be done that way ?

Isn't the purpose of the device tree to keep drivers as generic as possible ?

Not at all, sorry. The purpose of DT is not to keep drivers generic.

Best regards,
Krzysztof