[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250227-04-gpio-irq-threecell-v1-2-4ae4d91baadc@gentoo.org>
Date: Thu, 27 Feb 2025 19:25:00 +0800
From: Yixun Lan <dlan@...too.org>
To: Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>, Thomas Gleixner <tglx@...utronix.de>
Cc: Alex Elder <elder@...cstar.com>, Inochi Amaoto <inochiama@...il.com>,
linux-kernel@...r.kernel.org, linux-gpio@...r.kernel.org,
linux-riscv@...ts.infradead.org, spacemit@...ts.linux.dev,
Yixun Lan <dlan@...too.org>
Subject: [PATCH 2/2] gpiolib: support parsing gpio three-cell interrupts
scheme
gpio irq which using three-cell scheme should always call
instance_match() function to find the correct irqdomain.
Signed-off-by: Yixun Lan <dlan@...too.org>
---
The select() function will be called with !DOMAIN_BUS_ANY,
kernel/irq/irqdomain.c:556: if (h->ops->select && bus_token != DOMAIN_BUS_ANY)
so vendor gpio driver need to explicitly set bus_token, something like:
drivers/gpio/gpio-spacemit-k1.c
irq_domain_update_bus_token(girq->domain, DOMAIN_BUS_WIRED);
I hope this is a feasible way..
---
drivers/gpio/gpiolib.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 679ed764cb143c4b3357106de1570e8d38441372..7912ae1d049d7c2574400c6ff53405d130521773 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1450,9 +1450,8 @@ static int gpiochip_hierarchy_irq_domain_translate(struct irq_domain *d,
unsigned int *type)
{
/* We support standard DT translation */
- if (is_of_node(fwspec->fwnode) && fwspec->param_count == 2) {
+ if (is_of_node(fwspec->fwnode) && fwspec->param_count <= 3)
return irq_domain_translate_twocell(d, fwspec, hwirq, type);
- }
/* This is for board files and others not using DT */
if (is_fwnode_irqchip(fwspec->fwnode)) {
@@ -1754,9 +1753,25 @@ static void gpiochip_irq_unmap(struct irq_domain *d, unsigned int irq)
irq_set_chip_data(irq, NULL);
}
+static int gpiochip_irq_select(struct irq_domain *d, struct irq_fwspec *fwspec,
+ enum irq_domain_bus_token bus_token)
+{
+ struct fwnode_handle *fwnode = fwspec->fwnode;
+ struct gpio_chip *gc = d->host_data;
+ unsigned int index = fwspec->param[0];
+
+ if ((gc->of_gpio_n_cells == 3) && gc->of_node_instance_match)
+ return gc->of_node_instance_match(gc, index);
+
+ /* Fallback for twocells */
+ return ((fwnode != NULL) && (d->fwnode == fwnode) &&
+ (d->bus_token == bus_token));
+}
+
static const struct irq_domain_ops gpiochip_domain_ops = {
.map = gpiochip_irq_map,
.unmap = gpiochip_irq_unmap,
+ .select = gpiochip_irq_select,
/* Virtually all GPIO irqchips are twocell:ed */
.xlate = irq_domain_xlate_twocell,
};
--
2.48.1
Powered by blists - more mailing lists