From: Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org>
To: Linus Walleij
<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Prabhakar Lad
<prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
DLOS
<davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org>,
Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
"linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
"linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Rob Landley <rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org>,
Grant Likely
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Ian Campbell
<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
LAK
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH v5 3/7] gpio: davinci: use irqdomain
Date: Mon, 18 Nov 2013 16:34:13 +0200 [thread overview]
Message-ID: <528A2565.4000802@ti.com> (raw)
In-Reply-To: <CACRpkdaJg4wqtD5xhPVrHJHxFoVwau6jidbOuQ9xFSK_6drxPQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Hi Linus,
On 11/18/2013 03:11 PM, Linus Walleij wrote:
> On Fri, Nov 8, 2013 at 11:11 AM, Prabhakar Lad
> <prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> From: "Lad, Prabhakar" <prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>
>> This patch converts the davinci gpio driver to use irqdomain
>> support.
>>
>> Signed-off-by: Lad, Prabhakar <prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> (...)
>> @@ -282,8 +283,7 @@ gpio_irq_handler(unsigned irq, struct irq_desc *desc)
>> desc->irq_data.chip->irq_ack(&desc->irq_data);
>> while (1) {
>> u32 status;
>> - int n;
>> - int res;
>> + int bit;
>
> Why is this an int? I think u8 would suffice.
>
>> /* now demux them to the right lowlevel handler */
>> - n = d->irq_base;
>> - if (irq & 1) {
>> - n += 16;
>> - status >>= 16;
>> - }
>> -
>> while (status) {
>> - res = ffs(status);
>> - n += res;
>> - generic_handle_irq(n - 1);
>> - status >>= res;
>> + bit = __ffs(status);
>> + status &= ~(1 << bit);
>> + generic_handle_irq(irq_find_mapping(d->irq_domain,
>> + bit));
>
> This is a nice hunk of the patch.
>
> I would use <linux/bitops.h> and do:
> status &= ~BIT(bit);
>
>
>> @@ -313,10 +307,7 @@ static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset)
>> {
>> struct davinci_gpio_controller *d = chip2controller(chip);
>>
>> - if (d->irq_base >= 0)
>> - return d->irq_base + offset;
>> - else
>> - return -ENODEV;
>> + return irq_create_mapping(d->irq_domain, offset);
>> }
>
> I think we recently established that map creating cannot be done
> in gpio_to_irq* functions as that will not work properly if you request
> an IRQ from device tree without first obtaining the IRQ from the GPIO
> number with this function.
Why? Could you point on corresponding thread, pls?
Current call tree is:
irq_create_of_mapping()
|-hwirq = omain->ops->xlate()
|-irq_create_mapping(domain, hwirq)
>
> Instead call irq_create_mapping() on *all* used IRQ lines in the
> probe function and use irq_find_mapping() here too.
>
>> + for (gpio = 0, bank = 0; gpio < ngpio; bank++, bank_irq++, gpio += 16) {
>> /* disabled by default, enabled only as needed */
>> g = gpio2regs(gpio);
>> writel(~0, &g->clr_falling);
>> @@ -467,14 +483,6 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
>> */
>> irq_set_handler_data(bank_irq, &chips[gpio / 32]);
>
> So for example here you could call iurq_create_mapping();
>
> Also: please write a patch that marks the IRQ lines.
> Call gpio_lock_as_irq(*gpio_chip, offset); in the
> irqchip startup/shutdown functions. (Can be a separate
> patch.)
It seems, some misunderstanding is here. So I'd like to clarify few
points and would be very appreciate for your comments:
1) This patch itself will work unless we switch to DT (as in the
following patch)
2) After this patch the following object structure will be created
during Davinci GPIO driver initialization (DA850 has 144 IRQ lines):
- gpio_chip0(0..31)
|- irq_domain1
- gpio_chip1(32..63)
|- irq_domain2
- gpio_chip2(64..95)
|- irq_domain3
- gpio_chip3(96..127)
|- irq_domain4
- gpio_chip4(128..143)
|- irq_domain5
3) But in case of DT only one GPIO controller node will be created
Example:
gpio: gpio@1e26000 {
compatible = "ti,dm6441-gpio";
gpio-controller;
reg = <0x226000 0x1000>;
interrupt-parent = <&intc>;
interrupts = <42 IRQ_TYPE_EDGE_BOTH 43 IRQ_TYPE_EDGE_BOTH
44 IRQ_TYPE_EDGE_BOTH 45 IRQ_TYPE_EDGE_BOTH
46 IRQ_TYPE_EDGE_BOTH 47 IRQ_TYPE_EDGE_BOTH
48 IRQ_TYPE_EDGE_BOTH 49 IRQ_TYPE_EDGE_BOTH
50 IRQ_TYPE_EDGE_BOTH>;
interrupt-controller;
#interrupt-cells = <2>;
ti,ngpio = <144>;
ti,davinci-gpio-unbanked = <0>;
}
4) As result, to make GPIO bindings/mappings work - we'll need to
implement .of_xlate() callback per GPIO chip, which will provide us with
valid valid gpio_chip and offset of gpio inside chip
(It was discussed before and supposed to be done as next step).
For example, gpio_chip3 and offset=15 should be selected:
devA {
gpios = <&gpio 111 GPIO_ACTIVE_HIGH>;
}
5) What should be done to make GPIO IRQ bindings/mappings work?
Example:
devB {
interrupt-parent = <&gpio>;
interrupts = <111 IRQ_TYPE_EDGE_BOTH>;
}
Should we implement one IRQ domain per all GPIO chips (per GPIO controller)?
Thanks.
Regards,
-Grygorii
next prev parent reply other threads:[~2013-11-18 14:34 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-08 10:11 [PATCH v5 0/7] gpio: daVinci: cleanup and feature enhancement Prabhakar Lad
2013-11-08 10:11 ` [PATCH v5 1/7] gpio: davinci: remove unnecessary printk Prabhakar Lad
[not found] ` <1383905510-31760-2-git-send-email-prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-11-08 15:39 ` Grygorii Strashko
2013-11-11 15:39 ` Prabhakar Lad
2013-11-08 10:11 ` [PATCH v5 2/7] gpio: davinci: use readl/writel instead of __raw_* Prabhakar Lad
2013-11-18 13:01 ` Linus Walleij
2013-11-08 10:11 ` [PATCH v5 3/7] gpio: davinci: use irqdomain Prabhakar Lad
2013-11-18 13:11 ` Linus Walleij
2013-11-18 13:56 ` Russell King - ARM Linux
[not found] ` <CACRpkdaJg4wqtD5xhPVrHJHxFoVwau6jidbOuQ9xFSK_6drxPQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-18 14:34 ` Grygorii Strashko [this message]
2013-11-18 23:06 ` Linus Walleij
[not found] ` <CACRpkda7h4hsMYv_2gdrY+JB80kHu3BkS5OOGyGhEZFc_UkCig-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-19 16:22 ` Grygorii Strashko
2013-11-19 20:34 ` Linus Walleij
2013-11-08 10:11 ` [PATCH v5 4/7] gpio: davinci: remove unused variable intc_irq_num Prabhakar Lad
2013-11-08 10:11 ` [PATCH v5 5/7] gpio: davinci: add OF support Prabhakar Lad
[not found] ` <1383905510-31760-6-git-send-email-prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-11-11 15:18 ` Grygorii Strashko
2013-11-11 15:37 ` Prabhakar Lad
2013-11-11 15:44 ` Grygorii Strashko
2013-11-18 13:13 ` Linus Walleij
2013-11-18 13:42 ` Rob Herring
2013-11-08 10:11 ` [PATCH v5 6/7] ARM: davinci: da850: add GPIO DT node Prabhakar Lad
2013-11-08 10:11 ` [PATCH v5 7/7] ARM: davinci: da850 evm: add GPIO pinumux entries " Prabhakar Lad
[not found] ` <1383905510-31760-1-git-send-email-prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-11-11 15:52 ` [PATCH v5 0/7] gpio: daVinci: cleanup and feature enhancement Grygorii Strashko
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=528A2565.4000802@ti.com \
--to=grygorii.strashko-l0cymroini0@public.gmane.org \
--cc=davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
--cc=prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org \
--cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
--cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@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).