* [PATCH v3 0/6] Add support of IRQs to QUICC ENGINE GPIOs
@ 2025-08-25 6:53 Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 1/6] soc: fsl: qe: Add an interrupt controller for QUICC Engine Ports Christophe Leroy
` (5 more replies)
0 siblings, 6 replies; 21+ messages in thread
From: Christophe Leroy @ 2025-08-25 6:53 UTC (permalink / raw)
To: Qiang Zhao, Linus Walleij, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Christophe Leroy, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree
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
--
2.49.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v3 1/6] soc: fsl: qe: Add an interrupt controller for QUICC Engine Ports
2025-08-25 6:53 [PATCH v3 0/6] Add support of IRQs to QUICC ENGINE GPIOs Christophe Leroy
@ 2025-08-25 6:53 ` Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 2/6] soc: fsl: qe: Change GPIO driver to a proper platform driver Christophe Leroy
` (4 subsequent siblings)
5 siblings, 0 replies; 21+ messages in thread
From: Christophe Leroy @ 2025-08-25 6:53 UTC (permalink / raw)
To: Qiang Zhao, Linus Walleij, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Christophe Leroy, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree
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.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
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
diff --git a/drivers/soc/fsl/qe/Makefile b/drivers/soc/fsl/qe/Makefile
index ec8506e13113..901a9c40d5eb 100644
--- a/drivers/soc/fsl/qe/Makefile
+++ b/drivers/soc/fsl/qe/Makefile
@@ -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
diff --git a/drivers/soc/fsl/qe/qe_ports_ic.c b/drivers/soc/fsl/qe/qe_ports_ic.c
new file mode 100644
index 000000000000..9715643d36a6
--- /dev/null
+++ b/drivers/soc/fsl/qe/qe_ports_ic.c
@@ -0,0 +1,156 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * QUICC ENGINE I/O Ports Interrupt Controller
+ *
+ * Copyright (c) 2025 Christophe Leroy CS GROUP France (christophe.leroy@csgroup.eu)
+ */
+
+#include <linux/irq.h>
+#include <linux/irqdomain.h>
+#include <linux/platform_device.h>
+
+/* QE IC registers offset */
+#define CEPIER 0x0c
+#define CEPIMR 0x10
+#define CEPICR 0x14
+
+struct qepic_data {
+ void __iomem *reg;
+ struct irq_domain *host;
+};
+
+static void qepic_mask(struct irq_data *d)
+{
+ struct qepic_data *data = irq_data_get_irq_chip_data(d);
+
+ clrbits32(data->reg + CEPIMR, 1 << (31 - irqd_to_hwirq(d)));
+}
+
+static void qepic_unmask(struct irq_data *d)
+{
+ struct qepic_data *data = irq_data_get_irq_chip_data(d);
+
+ setbits32(data->reg + CEPIMR, 1 << (31 - irqd_to_hwirq(d)));
+}
+
+static void qepic_end(struct irq_data *d)
+{
+ struct qepic_data *data = irq_data_get_irq_chip_data(d);
+
+ out_be32(data->reg + CEPIER, 1 << (31 - irqd_to_hwirq(d)));
+}
+
+static int qepic_set_type(struct irq_data *d, unsigned int flow_type)
+{
+ struct qepic_data *data = irq_data_get_irq_chip_data(d);
+ unsigned int vec = (unsigned int)irqd_to_hwirq(d);
+
+ switch (flow_type & IRQ_TYPE_SENSE_MASK) {
+ case IRQ_TYPE_EDGE_FALLING:
+ setbits32(data->reg + CEPICR, 1 << (31 - vec));
+ return 0;
+ case IRQ_TYPE_EDGE_BOTH:
+ case IRQ_TYPE_NONE:
+ clrbits32(data->reg + CEPICR, 1 << (31 - vec));
+ return 0;
+ }
+ return -EINVAL;
+}
+
+static struct irq_chip qepic = {
+ .name = "QEPIC",
+ .irq_mask = qepic_mask,
+ .irq_unmask = qepic_unmask,
+ .irq_eoi = qepic_end,
+ .irq_set_type = qepic_set_type,
+};
+
+static int qepic_get_irq(struct irq_desc *desc)
+{
+ struct qepic_data *data = irq_desc_get_handler_data(desc);
+ u32 event = in_be32(data->reg + CEPIER);
+
+ if (!event)
+ return -1;
+
+ return irq_find_mapping(data->host, 32 - ffs(event));
+}
+
+static void qepic_cascade(struct irq_desc *desc)
+{
+ generic_handle_irq(qepic_get_irq(desc));
+}
+
+static int qepic_host_map(struct irq_domain *h, unsigned int virq, irq_hw_number_t hw)
+{
+ irq_set_chip_data(virq, h->host_data);
+ irq_set_chip_and_handler(virq, &qepic, handle_fasteoi_irq);
+ return 0;
+}
+
+static const struct irq_domain_ops qepic_host_ops = {
+ .map = qepic_host_map,
+};
+
+static int qepic_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct qepic_data *data;
+ unsigned long nb;
+ int irq;
+
+ nb = (unsigned long)of_device_get_match_data(dev);
+ if (nb < 1 || nb > 32)
+ return -EINVAL;
+
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ data->reg = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(data->reg))
+ return PTR_ERR(data->reg);
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return irq;
+
+ data->host = irq_domain_add_linear(dev->of_node, nb, &qepic_host_ops, data);
+ if (!data->host)
+ return -ENODEV;
+
+ irq_set_handler_data(irq, data);
+ irq_set_chained_handler(irq, qepic_cascade);
+
+ return 0;
+}
+
+static const struct of_device_id qepic_match[] = {
+ {
+ .compatible = "fsl,mpc8323-qe-ports-ic",
+ .data = (void *)10,
+ },
+ {
+ .compatible = "fsl,mpc8360-qe-ports-ic",
+ .data = (void *)28,
+ },
+ {
+ .compatible = "fsl,mpc8568-qe-ports-ic",
+ .data = (void *)18,
+ },
+ {},
+};
+
+static struct platform_driver qepic_driver = {
+ .driver = {
+ .name = "qe_ports_ic",
+ .of_match_table = qepic_match,
+ },
+ .probe = qepic_probe,
+};
+
+static int __init qepic_init(void)
+{
+ return platform_driver_register(&qepic_driver);
+}
+arch_initcall(qepic_init);
--
2.49.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 2/6] soc: fsl: qe: Change GPIO driver to a proper platform driver
2025-08-25 6:53 [PATCH v3 0/6] Add support of IRQs to QUICC ENGINE GPIOs Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 1/6] soc: fsl: qe: Add an interrupt controller for QUICC Engine Ports Christophe Leroy
@ 2025-08-25 6:53 ` Christophe Leroy
2025-08-25 12:56 ` Bartosz Golaszewski
2025-08-26 8:40 ` [PATCH v4] " Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 3/6] soc: fsl: qe: Drop legacy-of-mm-gpiochip.h header from GPIO driver Christophe Leroy
` (3 subsequent siblings)
5 siblings, 2 replies; 21+ messages in thread
From: Christophe Leroy @ 2025-08-25 6:53 UTC (permalink / raw)
To: Qiang Zhao, Linus Walleij, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Christophe Leroy, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree, Bartosz Golaszewski
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.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/soc/fsl/qe/gpio.c | 86 +++++++++++++++++++++------------------
1 file changed, 47 insertions(+), 39 deletions(-)
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
index 8df1e8fa86a5..93fcc6d85ac7 100644
--- a/drivers/soc/fsl/qe/gpio.c
+++ b/drivers/soc/fsl/qe/gpio.c
@@ -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);
--
2.49.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 3/6] soc: fsl: qe: Drop legacy-of-mm-gpiochip.h header from GPIO driver
2025-08-25 6:53 [PATCH v3 0/6] Add support of IRQs to QUICC ENGINE GPIOs Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 1/6] soc: fsl: qe: Add an interrupt controller for QUICC Engine Ports Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 2/6] soc: fsl: qe: Change GPIO driver to a proper platform driver Christophe Leroy
@ 2025-08-25 6:53 ` Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 4/6] soc: fsl: qe: Add support of IRQ in QE GPIO Christophe Leroy
` (2 subsequent siblings)
5 siblings, 0 replies; 21+ messages in thread
From: Christophe Leroy @ 2025-08-25 6:53 UTC (permalink / raw)
To: Qiang Zhao, Linus Walleij, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Christophe Leroy, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree
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")]
Suggested-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/platforms/Kconfig | 1 -
drivers/soc/fsl/qe/gpio.c | 51 ++++++++++++++++++----------------
2 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index fea3766eac0f..5b689bd3ddf4 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -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.
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
index 93fcc6d85ac7..a338469cebe4 100644
--- a/drivers/soc/fsl/qe/gpio.c
+++ b/drivers/soc/fsl/qe/gpio.c
@@ -13,7 +13,6 @@
#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>
@@ -24,7 +23,8 @@
#include <soc/fsl/qe/qe.h>
struct qe_gpio_chip {
- struct of_mm_gpio_chip mm_gc;
+ struct gpio_chip gc;
+ void __iomem *regs;
spinlock_t lock;
/* shadowed data register to clear/set bits safely */
@@ -34,11 +34,9 @@ struct qe_gpio_chip {
struct qe_pio_regs saved_regs;
};
-static void qe_gpio_save_regs(struct of_mm_gpio_chip *mm_gc)
+static void qe_gpio_save_regs(struct qe_gpio_chip *qe_gc)
{
- struct qe_gpio_chip *qe_gc =
- container_of(mm_gc, struct qe_gpio_chip, mm_gc);
- struct qe_pio_regs __iomem *regs = mm_gc->regs;
+ struct qe_pio_regs __iomem *regs = qe_gc->regs;
qe_gc->cpdata = ioread32be(®s->cpdata);
qe_gc->saved_regs.cpdata = qe_gc->cpdata;
@@ -51,8 +49,8 @@ static void qe_gpio_save_regs(struct of_mm_gpio_chip *mm_gc)
static int qe_gpio_get(struct gpio_chip *gc, unsigned int gpio)
{
- struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
- struct qe_pio_regs __iomem *regs = mm_gc->regs;
+ struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc);
+ struct qe_pio_regs __iomem *regs = qe_gc->regs;
u32 pin_mask = 1 << (QE_PIO_PINS - 1 - gpio);
return !!(ioread32be(®s->cpdata) & pin_mask);
@@ -60,9 +58,8 @@ static int qe_gpio_get(struct gpio_chip *gc, unsigned int gpio)
static int qe_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
{
- struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc);
- struct qe_pio_regs __iomem *regs = mm_gc->regs;
+ struct qe_pio_regs __iomem *regs = qe_gc->regs;
unsigned long flags;
u32 pin_mask = 1 << (QE_PIO_PINS - 1 - gpio);
@@ -83,9 +80,8 @@ static int qe_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
static int qe_gpio_set_multiple(struct gpio_chip *gc,
unsigned long *mask, unsigned long *bits)
{
- struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc);
- struct qe_pio_regs __iomem *regs = mm_gc->regs;
+ struct qe_pio_regs __iomem *regs = qe_gc->regs;
unsigned long flags;
int i;
@@ -111,13 +107,12 @@ static int qe_gpio_set_multiple(struct gpio_chip *gc,
static int qe_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
{
- struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc);
unsigned long flags;
spin_lock_irqsave(&qe_gc->lock, flags);
- __par_io_config_pin(mm_gc->regs, gpio, QE_PIO_DIR_IN, 0, 0, 0);
+ __par_io_config_pin(qe_gc->regs, gpio, QE_PIO_DIR_IN, 0, 0, 0);
spin_unlock_irqrestore(&qe_gc->lock, flags);
@@ -126,7 +121,6 @@ static int qe_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
static int qe_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
{
- struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc);
unsigned long flags;
@@ -134,7 +128,7 @@ static int qe_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
spin_lock_irqsave(&qe_gc->lock, flags);
- __par_io_config_pin(mm_gc->regs, gpio, QE_PIO_DIR_OUT, 0, 0, 0);
+ __par_io_config_pin(qe_gc->regs, gpio, QE_PIO_DIR_OUT, 0, 0, 0);
spin_unlock_irqrestore(&qe_gc->lock, flags);
@@ -240,7 +234,7 @@ EXPORT_SYMBOL(qe_pin_free);
void qe_pin_set_dedicated(struct qe_pin *qe_pin)
{
struct qe_gpio_chip *qe_gc = qe_pin->controller;
- struct qe_pio_regs __iomem *regs = qe_gc->mm_gc.regs;
+ struct qe_pio_regs __iomem *regs = qe_gc->regs;
struct qe_pio_regs *sregs = &qe_gc->saved_regs;
int pin = qe_pin->num;
u32 mask1 = 1 << (QE_PIO_PINS - (pin + 1));
@@ -269,7 +263,6 @@ void qe_pin_set_dedicated(struct qe_pin *qe_pin)
iowrite32be(qe_gc->cpdata, ®s->cpdata);
qe_clrsetbits_be32(®s->cpodr, mask1, sregs->cpodr & mask1);
-
spin_unlock_irqrestore(&qe_gc->lock, flags);
}
EXPORT_SYMBOL(qe_pin_set_dedicated);
@@ -284,7 +277,7 @@ EXPORT_SYMBOL(qe_pin_set_dedicated);
void qe_pin_set_gpio(struct qe_pin *qe_pin)
{
struct qe_gpio_chip *qe_gc = qe_pin->controller;
- struct qe_pio_regs __iomem *regs = qe_gc->mm_gc.regs;
+ struct qe_pio_regs __iomem *regs = qe_gc->regs;
unsigned long flags;
spin_lock_irqsave(&qe_gc->lock, flags);
@@ -301,7 +294,6 @@ static int qe_gpio_probe(struct platform_device *ofdev)
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;
qe_gc = devm_kzalloc(dev, sizeof(*qe_gc), GFP_KERNEL);
@@ -310,18 +302,29 @@ static int qe_gpio_probe(struct platform_device *ofdev)
spin_lock_init(&qe_gc->lock);
- mm_gc = &qe_gc->mm_gc;
- gc = &mm_gc->gc;
+ gc = &qe_gc->gc;
- mm_gc->save_regs = qe_gpio_save_regs;
+ gc->base = -1;
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;
+ gc->parent = dev;
+ gc->owner = THIS_MODULE;
+
+ gc->label = devm_kasprintf(dev, GFP_KERNEL, "%pOF", np);
+ if (!gc->label)
+ return -ENOMEM;
+
+ qe_gc->regs = devm_of_iomap(dev, np, 0, NULL);
+ if (IS_ERR(qe_gc->regs))
+ return PTR_ERR(qe_gc->regs);
+
+ qe_gpio_save_regs(qe_gc);
- return of_mm_gpiochip_add_data(np, mm_gc, qe_gc);
+ return devm_gpiochip_add_data(dev, gc, qe_gc);
}
static const struct of_device_id qe_gpio_match[] = {
--
2.49.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 4/6] soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-25 6:53 [PATCH v3 0/6] Add support of IRQs to QUICC ENGINE GPIOs Christophe Leroy
` (2 preceding siblings ...)
2025-08-25 6:53 ` [PATCH v3 3/6] soc: fsl: qe: Drop legacy-of-mm-gpiochip.h header from GPIO driver Christophe Leroy
@ 2025-08-25 6:53 ` Christophe Leroy
2025-08-25 13:02 ` Bartosz Golaszewski
2025-08-26 8:41 ` [PATCH v4] " Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 5/6] dt-bindings: " Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 6/6] dt-bindings: soc: fsl: qe: Add an interrupt controller for QUICC Engine Ports Christophe Leroy
5 siblings, 2 replies; 21+ messages in thread
From: Christophe Leroy @ 2025-08-25 6:53 UTC (permalink / raw)
To: Qiang Zhao, Linus Walleij, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Christophe Leroy, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree
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>;
};
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
drivers/soc/fsl/qe/gpio.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
index a338469cebe4..91d469403126 100644
--- a/drivers/soc/fsl/qe/gpio.c
+++ b/drivers/soc/fsl/qe/gpio.c
@@ -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;
--
2.49.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-25 6:53 [PATCH v3 0/6] Add support of IRQs to QUICC ENGINE GPIOs Christophe Leroy
` (3 preceding siblings ...)
2025-08-25 6:53 ` [PATCH v3 4/6] soc: fsl: qe: Add support of IRQ in QE GPIO Christophe Leroy
@ 2025-08-25 6:53 ` Christophe Leroy
2025-08-28 13:28 ` Rob Herring
2025-08-29 7:48 ` Krzysztof Kozlowski
2025-08-25 6:53 ` [PATCH v3 6/6] dt-bindings: soc: fsl: qe: Add an interrupt controller for QUICC Engine Ports Christophe Leroy
5 siblings, 2 replies; 21+ messages in thread
From: Christophe Leroy @ 2025-08-25 6:53 UTC (permalink / raw)
To: Qiang Zhao, Linus Walleij, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Christophe Leroy, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree
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>;
};
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
.../bindings/soc/fsl/cpm_qe/qe/par_io.txt | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/par_io.txt b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/par_io.txt
index 09b1b05fa677..829fe9a3d70c 100644
--- a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/par_io.txt
+++ b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/par_io.txt
@@ -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
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3 6/6] dt-bindings: soc: fsl: qe: Add an interrupt controller for QUICC Engine Ports
2025-08-25 6:53 [PATCH v3 0/6] Add support of IRQs to QUICC ENGINE GPIOs Christophe Leroy
` (4 preceding siblings ...)
2025-08-25 6:53 ` [PATCH v3 5/6] dt-bindings: " Christophe Leroy
@ 2025-08-25 6:53 ` Christophe Leroy
5 siblings, 0 replies; 21+ messages in thread
From: Christophe Leroy @ 2025-08-25 6:53 UTC (permalink / raw)
To: Qiang Zhao, Linus Walleij, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Christophe Leroy, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree, Conor Dooley
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.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
---
.../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
diff --git a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/fsl,qe-ports-ic.yaml b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/fsl,qe-ports-ic.yaml
new file mode 100644
index 000000000000..a356ad8b13f5
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/fsl,qe-ports-ic.yaml
@@ -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 <christophe.leroy@csgroup.eu>
+
+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>;
+ };
--
2.49.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v3 2/6] soc: fsl: qe: Change GPIO driver to a proper platform driver
2025-08-25 6:53 ` [PATCH v3 2/6] soc: fsl: qe: Change GPIO driver to a proper platform driver Christophe Leroy
@ 2025-08-25 12:56 ` Bartosz Golaszewski
2025-08-25 13:01 ` Bartosz Golaszewski
2025-08-26 8:40 ` [PATCH v4] " Christophe Leroy
1 sibling, 1 reply; 21+ messages in thread
From: Bartosz Golaszewski @ 2025-08-25 12:56 UTC (permalink / raw)
To: Christophe Leroy
Cc: Qiang Zhao, Linus Walleij, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree, Bartosz Golaszewski
On Mon, Aug 25, 2025 at 8:53 AM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
>
> 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.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Hi! I retracted my review tag under v1 because...
[snip]
> - 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);
... I believe this can be dropped now and replaced with
devm_gpiochip_add_data().
Bart
> +}
> +
> +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
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 2/6] soc: fsl: qe: Change GPIO driver to a proper platform driver
2025-08-25 12:56 ` Bartosz Golaszewski
@ 2025-08-25 13:01 ` Bartosz Golaszewski
0 siblings, 0 replies; 21+ messages in thread
From: Bartosz Golaszewski @ 2025-08-25 13:01 UTC (permalink / raw)
To: Christophe Leroy
Cc: Qiang Zhao, Linus Walleij, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree, Bartosz Golaszewski
On Mon, Aug 25, 2025 at 2:56 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> On Mon, Aug 25, 2025 at 8:53 AM Christophe Leroy
> <christophe.leroy@csgroup.eu> wrote:
> >
> > 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.
> >
> > Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> > Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> 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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 4/6] soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-25 6:53 ` [PATCH v3 4/6] soc: fsl: qe: Add support of IRQ in QE GPIO Christophe Leroy
@ 2025-08-25 13:02 ` Bartosz Golaszewski
2025-08-26 8:41 ` [PATCH v4] " Christophe Leroy
1 sibling, 0 replies; 21+ messages in thread
From: Bartosz Golaszewski @ 2025-08-25 13:02 UTC (permalink / raw)
To: Christophe Leroy
Cc: Qiang Zhao, Linus Walleij, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree
On Mon, Aug 25, 2025 at 8:53 AM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
>
> 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>;
> };
>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> drivers/soc/fsl/qe/gpio.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
> index a338469cebe4..91d469403126 100644
> --- a/drivers/soc/fsl/qe/gpio.c
> +++ b/drivers/soc/fsl/qe/gpio.c
> @@ -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)) {
Please use device_property_read_u32 and stop including of.h if
possible (it seems it is upon visual inspection).
Bart
> + 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
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4] soc: fsl: qe: Change GPIO driver to a proper platform driver
2025-08-25 6:53 ` [PATCH v3 2/6] soc: fsl: qe: Change GPIO driver to a proper platform driver Christophe Leroy
2025-08-25 12:56 ` Bartosz Golaszewski
@ 2025-08-26 8:40 ` Christophe Leroy
1 sibling, 0 replies; 21+ messages in thread
From: Christophe Leroy @ 2025-08-26 8:40 UTC (permalink / raw)
To: Qiang Zhao, Linus Walleij, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Christophe Leroy, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree, Bartosz Golaszewski
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.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
v4: Removed unused headers
---
drivers/soc/fsl/qe/gpio.c | 88 +++++++++++++++++++++------------------
1 file changed, 47 insertions(+), 41 deletions(-)
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
index 8df1e8fa86a5..fece644ce914 100644
--- a/drivers/soc/fsl/qe/gpio.c
+++ b/drivers/soc/fsl/qe/gpio.c
@@ -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);
--
2.49.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v4] soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-25 6:53 ` [PATCH v3 4/6] soc: fsl: qe: Add support of IRQ in QE GPIO Christophe Leroy
2025-08-25 13:02 ` Bartosz Golaszewski
@ 2025-08-26 8:41 ` Christophe Leroy
2025-08-26 9:57 ` Bartosz Golaszewski
1 sibling, 1 reply; 21+ messages in thread
From: Christophe Leroy @ 2025-08-26 8:41 UTC (permalink / raw)
To: Qiang Zhao, Linus Walleij, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Christophe Leroy, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree
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>;
};
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
v4: Using device_property_read_u32() instead of of_property_read_u32()
---
drivers/soc/fsl/qe/gpio.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
index 5bf073bbaac8..68bcd6048b1c 100644
--- a/drivers/soc/fsl/qe/gpio.c
+++ b/drivers/soc/fsl/qe/gpio.c
@@ -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;
--
2.49.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v4] soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-26 8:41 ` [PATCH v4] " Christophe Leroy
@ 2025-08-26 9:57 ` Bartosz Golaszewski
0 siblings, 0 replies; 21+ messages in thread
From: Bartosz Golaszewski @ 2025-08-26 9:57 UTC (permalink / raw)
To: Christophe Leroy
Cc: Qiang Zhao, Linus Walleij, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, linux-kernel, linuxppc-dev, linux-arm-kernel,
linux-gpio, devicetree
On Tue, Aug 26, 2025 at 10:41 AM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
>
> 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>;
> };
>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-25 6:53 ` [PATCH v3 5/6] dt-bindings: " Christophe Leroy
@ 2025-08-28 13:28 ` Rob Herring
2025-08-28 14:12 ` Christophe Leroy
2025-08-29 7:48 ` Krzysztof Kozlowski
1 sibling, 1 reply; 21+ messages in thread
From: Rob Herring @ 2025-08-28 13:28 UTC (permalink / raw)
To: Christophe Leroy
Cc: Qiang Zhao, Linus Walleij, Bartosz Golaszewski,
Krzysztof Kozlowski, Conor Dooley, linux-kernel, linuxppc-dev,
linux-arm-kernel, linux-gpio, devicetree
On Mon, Aug 25, 2025 at 2:20 AM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
>
> 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.
> Here is an exemple for port B of mpc8323 which has IRQs for
typo
> 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.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> .../bindings/soc/fsl/cpm_qe/qe/par_io.txt | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/par_io.txt b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/par_io.txt
> index 09b1b05fa677..829fe9a3d70c 100644
> --- a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/par_io.txt
> +++ b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/par_io.txt
> @@ -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
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-28 13:28 ` Rob Herring
@ 2025-08-28 14:12 ` Christophe Leroy
2025-08-29 7:47 ` Krzysztof Kozlowski
0 siblings, 1 reply; 21+ messages in thread
From: Christophe Leroy @ 2025-08-28 14:12 UTC (permalink / raw)
To: Rob Herring
Cc: Qiang Zhao, Linus Walleij, Bartosz Golaszewski,
Krzysztof Kozlowski, Conor Dooley, linux-kernel, linuxppc-dev,
linux-arm-kernel, linux-gpio, devicetree
Le 28/08/2025 à 15:28, Rob Herring a écrit :
> On Mon, Aug 25, 2025 at 2:20 AM Christophe Leroy
> <christophe.leroy@csgroup.eu> wrote:
>>
>> 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.
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.
>
>> Here is an exemple for port B of mpc8323 which has IRQs for
>
> typo
>
>> 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.
The gpio controller is not an interrupt controller. The GPIO controller
is brought by patch 1/6 and documented in patch 6/6.
>
> 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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-28 14:12 ` Christophe Leroy
@ 2025-08-29 7:47 ` Krzysztof Kozlowski
2025-08-29 8:35 ` Christophe Leroy
0 siblings, 1 reply; 21+ messages in thread
From: Krzysztof Kozlowski @ 2025-08-29 7:47 UTC (permalink / raw)
To: Christophe Leroy, Rob Herring
Cc: Qiang Zhao, Linus Walleij, Bartosz Golaszewski,
Krzysztof Kozlowski, Conor Dooley, linux-kernel, linuxppc-dev,
linux-arm-kernel, linux-gpio, devicetree
On 28/08/2025 16:12, Christophe Leroy wrote:
>
>
> Le 28/08/2025 à 15:28, Rob Herring a écrit :
>> On Mon, Aug 25, 2025 at 2:20 AM Christophe Leroy
>> <christophe.leroy@csgroup.eu> wrote:
>>>
>>> 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.
>
> 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.
>
>>
>>> Here is an exemple for port B of mpc8323 which has IRQs for
>>
>> typo
>>
>>> 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.
>
> 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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-25 6:53 ` [PATCH v3 5/6] dt-bindings: " Christophe Leroy
2025-08-28 13:28 ` Rob Herring
@ 2025-08-29 7:48 ` Krzysztof Kozlowski
1 sibling, 0 replies; 21+ messages in thread
From: Krzysztof Kozlowski @ 2025-08-29 7:48 UTC (permalink / raw)
To: Christophe Leroy, Qiang Zhao, Linus Walleij, Bartosz Golaszewski,
Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-kernel, linuxppc-dev, linux-arm-kernel, linux-gpio,
devicetree
On 25/08/2025 08:53, Christophe Leroy wrote:
> 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>;
We see this from the patch. No need to repeat the patch contents in the
commit msg.
> 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";
Please follow DTS coding style.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-29 7:47 ` Krzysztof Kozlowski
@ 2025-08-29 8:35 ` Christophe Leroy
2025-08-29 9:16 ` Krzysztof Kozlowski
0 siblings, 1 reply; 21+ messages in thread
From: Christophe Leroy @ 2025-08-29 8:35 UTC (permalink / raw)
To: Krzysztof Kozlowski, Rob Herring
Cc: Qiang Zhao, Linus Walleij, Bartosz Golaszewski,
Krzysztof Kozlowski, Conor Dooley, linux-kernel, linuxppc-dev,
linux-arm-kernel, linux-gpio, devicetree
Le 29/08/2025 à 09:47, Krzysztof Kozlowski a écrit :
> On 28/08/2025 16:12, Christophe Leroy wrote:
>>
>>
>> Le 28/08/2025 à 15:28, Rob Herring a écrit :
>>> On Mon, Aug 25, 2025 at 2:20 AM Christophe Leroy
>>> <christophe.leroy@csgroup.eu> wrote:
>>>>
>>>> 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.
>>
>> 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.
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]);
>
>>
>>>
>>>> Here is an exemple for port B of mpc8323 which has IRQs for
>>>
>>> typo
>>>
>>>> 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.
>>
>> 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.
>
> 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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-29 8:35 ` Christophe Leroy
@ 2025-08-29 9:16 ` Krzysztof Kozlowski
2025-08-29 9:41 ` Christophe Leroy
0 siblings, 1 reply; 21+ messages in thread
From: Krzysztof Kozlowski @ 2025-08-29 9:16 UTC (permalink / raw)
To: Christophe Leroy, Rob Herring
Cc: Qiang Zhao, Linus Walleij, Bartosz Golaszewski,
Krzysztof Kozlowski, Conor Dooley, linux-kernel, linuxppc-dev,
linux-arm-kernel, linux-gpio, devicetree
On 29/08/2025 10:35, Christophe Leroy wrote:
>
>
> Le 29/08/2025 à 09:47, Krzysztof Kozlowski a écrit :
>> On 28/08/2025 16:12, Christophe Leroy wrote:
>>>
>>>
>>> Le 28/08/2025 à 15:28, Rob Herring a écrit :
>>>> On Mon, Aug 25, 2025 at 2:20 AM Christophe Leroy
>>>> <christophe.leroy@csgroup.eu> wrote:
>>>>>
>>>>> 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.
>>>
>>> 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.
>
> 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
That list is fixed per soc/device, so already implied by compatible.
>
> 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]);
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.
>
>>
>>>
>>>>
>>>>> Here is an exemple for port B of mpc8323 which has IRQs for
>>>>
>>>> typo
>>>>
>>>>> 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.
>>>
>>> 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.
>
>>
>> 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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-29 9:16 ` Krzysztof Kozlowski
@ 2025-08-29 9:41 ` Christophe Leroy
2025-08-29 10:51 ` Krzysztof Kozlowski
0 siblings, 1 reply; 21+ messages in thread
From: Christophe Leroy @ 2025-08-29 9:41 UTC (permalink / raw)
To: Krzysztof Kozlowski, Rob Herring
Cc: Qiang Zhao, Linus Walleij, Bartosz Golaszewski,
Krzysztof Kozlowski, Conor Dooley, linux-kernel, linuxppc-dev,
linux-arm-kernel, linux-gpio, devicetree
Le 29/08/2025 à 11:16, Krzysztof Kozlowski a écrit :
> On 29/08/2025 10:35, Christophe Leroy wrote:
>>
>>
>> Le 29/08/2025 à 09:47, Krzysztof Kozlowski a écrit :
>>> On 28/08/2025 16:12, Christophe Leroy wrote:
>>>>
>>>>
>>>> Le 28/08/2025 à 15:28, Rob Herring a écrit :
>>>>> On Mon, Aug 25, 2025 at 2:20 AM Christophe Leroy
>>>>> <christophe.leroy@csgroup.eu> wrote:
>>>>>>
>>>>>> 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.
>>>>
>>>> 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.
>>
>> 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
>
> That list is fixed per soc/device, so already implied by compatible.
>
>>
>> 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]);
>
>
> 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 ?
>>
>>>
>>>>
>>>>>
>>>>>> Here is an exemple for port B of mpc8323 which has IRQs for
>>>>>
>>>>> typo
>>>>>
>>>>>> 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.
>>>>
>>>> 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.
>>
>>>
>>> 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.
>
Ah ! ok. I didn't read it like that, sorry.
Thanks
Christophe
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3 5/6] dt-bindings: soc: fsl: qe: Add support of IRQ in QE GPIO
2025-08-29 9:41 ` Christophe Leroy
@ 2025-08-29 10:51 ` Krzysztof Kozlowski
0 siblings, 0 replies; 21+ messages in thread
From: Krzysztof Kozlowski @ 2025-08-29 10:51 UTC (permalink / raw)
To: Christophe Leroy, Rob Herring
Cc: Qiang Zhao, Linus Walleij, Bartosz Golaszewski,
Krzysztof Kozlowski, Conor Dooley, linux-kernel, linuxppc-dev,
linux-arm-kernel, linux-gpio, devicetree
On 29/08/2025 11:41, Christophe Leroy wrote:
>>>
>>> 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]);
>>
>>
>> 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.
> 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.
> 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.
> 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.
> 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.
> 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 ?
I don't know that good your hardware to tell.
>
> 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.
> },
> {
> .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.
BTW, like every other platform.
>
> 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
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2025-08-29 10:51 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-25 6:53 [PATCH v3 0/6] Add support of IRQs to QUICC ENGINE GPIOs Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 1/6] soc: fsl: qe: Add an interrupt controller for QUICC Engine Ports Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 2/6] soc: fsl: qe: Change GPIO driver to a proper platform driver Christophe Leroy
2025-08-25 12:56 ` Bartosz Golaszewski
2025-08-25 13:01 ` Bartosz Golaszewski
2025-08-26 8:40 ` [PATCH v4] " Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 3/6] soc: fsl: qe: Drop legacy-of-mm-gpiochip.h header from GPIO driver Christophe Leroy
2025-08-25 6:53 ` [PATCH v3 4/6] soc: fsl: qe: Add support of IRQ in QE GPIO Christophe Leroy
2025-08-25 13:02 ` Bartosz Golaszewski
2025-08-26 8:41 ` [PATCH v4] " Christophe Leroy
2025-08-26 9:57 ` Bartosz Golaszewski
2025-08-25 6:53 ` [PATCH v3 5/6] dt-bindings: " Christophe Leroy
2025-08-28 13:28 ` Rob Herring
2025-08-28 14:12 ` Christophe Leroy
2025-08-29 7:47 ` Krzysztof Kozlowski
2025-08-29 8:35 ` Christophe Leroy
2025-08-29 9:16 ` Krzysztof Kozlowski
2025-08-29 9:41 ` Christophe Leroy
2025-08-29 10:51 ` Krzysztof Kozlowski
2025-08-29 7:48 ` Krzysztof Kozlowski
2025-08-25 6:53 ` [PATCH v3 6/6] dt-bindings: soc: fsl: qe: Add an interrupt controller for QUICC Engine Ports Christophe Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).