From: Yixun Lan <dlan@gentoo.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
Thomas Gleixner <tglx@linutronix.de>,
Alex Elder <elder@riscstar.com>,
Inochi Amaoto <inochiama@gmail.com>,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-riscv@lists.infradead.org, spacemit@lists.linux.dev
Subject: Re: [PATCH 2/2] gpiolib: support parsing gpio three-cell interrupts scheme
Date: Fri, 28 Feb 2025 10:10:50 +0000 [thread overview]
Message-ID: <20250228101050-GYA52883@gentoo> (raw)
In-Reply-To: <CACRpkdZ1X5kF-AyRBg9BYMiJscv0v-SGzcdetS0XDK3oPSu9QQ@mail.gmail.com>
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@gentoo.org> 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@gentoo.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..
>
> 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
prev parent reply other threads:[~2025-02-28 10:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-27 11:24 [PATCH 0/2] gpio: irq: support describing three-cell interrupts Yixun Lan
2025-02-27 11:24 ` [PATCH 1/2] irqdomain: support three-cell scheme interrupts Yixun Lan
2025-02-27 16:12 ` Alex Elder
2025-02-27 20:41 ` Yixun Lan
2025-02-28 8:44 ` Linus Walleij
2025-02-28 10:52 ` Yixun Lan
2025-02-28 13:44 ` Thomas Gleixner
2025-02-27 11:25 ` [PATCH 2/2] gpiolib: support parsing gpio three-cell interrupts scheme Yixun Lan
2025-02-28 9:11 ` Linus Walleij
2025-02-28 10:10 ` Yixun Lan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250228101050-GYA52883@gentoo \
--to=dlan@gentoo.org \
--cc=brgl@bgdev.pl \
--cc=elder@riscstar.com \
--cc=inochiama@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=spacemit@lists.linux.dev \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox