From: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Suresh Mangipudi
<smangipudi-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
Laxman Dewangan
<ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
"linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH v2] gpio: Add Tegra186 support
Date: Fri, 31 Mar 2017 15:59:40 +0200 [thread overview]
Message-ID: <CACRpkdZpev7op=4e7DwYfnRpNBPN6U_EXd6G3PqM-XQudLHqow@mail.gmail.com> (raw)
In-Reply-To: <20170310162629.31455-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On Fri, Mar 10, 2017 at 5:26 PM, Thierry Reding
<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>
> Tegra186 has two GPIO controllers that are largely register compatible
> between one another but are completely different from the controller
> found on earlier generations.
>
> Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
> Changes in v2:
So this still doesn't use GPIOLIB_IRQCHIP even though I pointed
out that you can assign several parent interrupts to the same
irqchip.
For a recent example see:
http://marc.info/?l=devicetree&m=149012117004066&w=2
(Notice Gregory's elegant manipulation of the mask.)
My earlier reply here:
----------------------
>> I would prefer if you could try to convert this driver to use
>> CONFIG_GPIOLIB_IRQCHIP and install a chained interrupt
>> handler with gpiochip_irqchio_add() + gpiolib_set_chained_irqchip().
>> It would save us so much trouble and so much complicated
>> code to maintain for this custom irqdomain.
>>
>> I suggest you to look into the mechanisms mentioned in my
>> previous mail for how to poke holes in the single linear
>> irqdomain used by this mechanism.
>>
>> As it seems, you only have one parent interrupt with all
>> these IRQs cascading off it as far as I can tell.
>
> Like I said in other email, I don't think this will work because the
> GPIOLIB_IRQCHIP support seems to be limited to cases where a single
> parent interrupt is used. We could possibly live with a single IRQ
> handler and data, but we definitely need to request multiple IRQs if
> we want to be able to use all GPIOs as interrupts.
Sorry if I missed that.
Actually it works.
If you look at gpiochip_set_chained_irqchip() it just calls
irq_set_chained_handler_and_data() for the parent interrupt.
------------------------
Just call gpiochip_set_chained_irqchip() for all the irqs, and
figure out a way to get the right interrupt hardware offset in the
interrupt handler.
(...)
> +config GPIO_TEGRA186
> + tristate "NVIDIA Tegra186 GPIO support"
> + default ARCH_TEGRA_186_SOC
> + depends on ARCH_TEGRA_186_SOC || COMPILE_TEST
> + depends on OF_GPIO
select GPIOLIB_IRQCHIP
> +#include <linux/gpio/driver.h>
> +#include <linux/gpio.h>
Only <linux/gpio/driver.h>
You should not use <linux/gpio.h> in drivers, then you are
doing something wrong.
> +struct tegra_gpio {
> + struct gpio_chip gpio;
> + struct irq_chip intc;
> + unsigned int num_irq;
> + unsigned int *irq;
Why are you keeping the irqs around after requesting?
Use devm_*
> +
> + const struct tegra_gpio_soc *soc;
> +
> + void __iomem *base;
> +
> + struct irq_domain *domain;
I don't like custom irq domains it is messy.
Please do your best to try to use GPIOLIB_IRQCHIP
If you still decide to go with a custom irqdomain, there is
stuff missing, especially the gpiochip_lock_as_irq()
calls from the irqchip .irq_request/release_resources()
callbacks, see the gpiolib.c implementation in the
helpers there for reference.
Yours,
Linus Walleij
next prev parent reply other threads:[~2017-03-31 13:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 16:26 [PATCH v2] gpio: Add Tegra186 support Thierry Reding
2017-03-13 7:06 ` Thierry Reding
[not found] ` <20170313070623.GA15513-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2017-03-14 15:20 ` Linus Walleij
[not found] ` <20170310162629.31455-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-13 16:22 ` Laxman Dewangan
[not found] ` <58C6C72C.4080408-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-03-13 17:44 ` Thierry Reding
2017-03-31 13:10 ` Thierry Reding
[not found] ` <20170331131006.GC29779-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2017-03-31 13:36 ` Linus Walleij
[not found] ` <CACRpkdZwb37kSgKDo=6v-G102KGs0NVB1CZg+MEOKDaA8dKuLg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-01 7:45 ` Laxman Dewangan
2017-03-31 13:59 ` Linus Walleij [this message]
[not found] ` <CACRpkdZpev7op=4e7DwYfnRpNBPN6U_EXd6G3PqM-XQudLHqow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-31 14:54 ` Thierry Reding
[not found] ` <20170331145437.GA16964-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2017-04-01 17:46 ` Linus Walleij
2017-04-03 5:28 ` Thierry Reding
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='CACRpkdZpev7op=4e7DwYfnRpNBPN6U_EXd6G3PqM-XQudLHqow@mail.gmail.com' \
--to=linus.walleij-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=smangipudi-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).