Hi Yixun, thanks for working so hard on this! I'm really happy to see the threecell support integrated into gpiolib. On Thu, Feb 27, 2025 at 12:25 PM Yixun Lan <dlan@xxxxxxxxxx> wrote: > gpio irq which using three-cell scheme should always call > instance_match() function to find the correct irqdomain. > > Signed-off-by: Yixun Lan <dlan@xxxxxxxxxx> > --- > 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.. Yes this looks fair, I think you can put the description into the commit message. > /* 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 looks good. > +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); We need to hide the OF-specific things into gpiolib-of.c|h so systems not using OF does not need to see it. Something like: if (fwspec->param_count == 3) { if (is_of_node(fwnode)) return of_gpiochip_instance_match(gc, index); /* Add other threeparam handlers here */ } Then add of_gpiochip_instance_match() into gpiolib-of.h as a static inline (no need to an entire extern function...) static inline bool of_gpiochip_instance_match(struct gpio_chip *gc, int index) { if ((gc->of_gpio_n_cells == 3) && gc->of_node_instance_match) return gc->of_node_instance_match(gc, index); } And also an empty stub for !CONFIG_OF_GPIO so we get this compiled out if OF is not configured in. Yours, Linus Walleij