Re: [PATCH 2/2] gpiolib: support parsing gpio three-cell interrupts scheme

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Linus Walleij:

On 10:11 Fri 28 Feb     , Linus Walleij wrote:
> 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.
> 
ok, will do
> >         /* 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 */
not sure if non OF-specific driver will also support threecells mode?
we probably can adjust when it really does, so now I would simply make it

if (fwspec->param_count == 3 && is_of_node(fwnode))
	return of_gpiochip_instance_match(gc, index);

> }
> 
> 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.
> 
ok, I got your idea, thanks

-- 
Yixun Lan (dlan)
Gentoo Linux Developer
GPG Key ID AABEFD55




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux