devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Gregory Fong <gregory.0xf0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Alexandre Courbot
	<gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	bcm-kernel-feedback-list
	<bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	Brian Norris
	<computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Florian Fainelli
	<f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Ian Campbell
	<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
	Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Russell King <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
Subject: Re: [PATCH 0/3] GPIO support for BRCMSTB
Date: Wed, 13 May 2015 10:59:30 +0200	[thread overview]
Message-ID: <CACRpkdaTYAr-7K5_QZh1CyeyA1224obqEB2Sz8UHZmrWcfv+ow@mail.gmail.com> (raw)
In-Reply-To: <CADtm3G45-u82Rp_0dHf2EfdMokf8E4FaQ84PHnocpvXxU+5_+g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Tue, May 12, 2015 at 9:38 PM, Gregory Fong <gregory.0xf0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> On Tue, May 12, 2015 at 3:59 AM, Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
>> On Wed, May 6, 2015 at 10:37 AM, Gregory Fong <gregory.0xf0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>
>>> There is only one IRQ for each GIO IP block (i.e. several register banks share
>>> an IRQ).  After briefly looking into the generic IRQ chip implementation, it
>>> seemed like in this case that using it would result in the driver being more
>>> complex than necessary because AFAICT it expects a 1:1 mapping of
>>> irq_chip_generic to gpio_chip.  It seemed like less of a pain to have a single
>>> irq_chip since we have a single IRQ for all register banks (multiple
>>> gpio_chips).  I might be missing something, maybe using a shared IRQ across
>>> multiple irq_chips is easier than I think?  Suggestions welcome.
>>
>> What is needed is a 1:1 mapping between GPIO offsets and IRQ
>> offsets.
>>
>> If you just number your GPIOs 0...n and your IRQs 0...n
>> it should work just fine with one irqchip for all banks.
>>
>> What screws things up is likely that the hardware supports
>> 32 lines per bank and not all are used.
>>
>> I suggest you enable 32 line and 32 IRQs per bank,
>> so that hwirq maps nicely 1:1 on the GPIO offsets,
>> then just use the width thing to NACK operations on
>> GPIO lines you are not using. This way you can also
>> decode and warn on spurious IRQs on the unused lines.
>
> For having 32 lines per bank, the big problem here is the upper limit
> of 256 GPIOs.

Which arch is this?
Usually this limit comes from
arch/*/include/asm/gpio.h

For ARM that was bumped to 512 a while back. It is also possible
to define a custom value for your system by defining
ARCH_NR_GPIOS

> Anyway, I don't think I understand IRQ domains and irq_chip_generic
> very well.  One possibility _might_ be to use multiple irq_chips.

That is probably not possible if there is just one IRQ for all
banks.

The task of the irqdomain is a 1-to-1 translation from one
hardware numberspace to the Linux IRQ number space.

In your case the hardware IRQ (hwirq) numberspace
should be:

bank0: 0..31
bank1: 32..63
....
bankn: 32*n..32*n+31

I think the gpiolib irqchip code can translate that properly
as it is just a simple 0...x mapping, the irq handler need
some magic to loop over all banks from 0..n though.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-05-13  8:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06  8:37 [PATCH 0/3] GPIO support for BRCMSTB Gregory Fong
2015-05-06  8:37 ` [PATCH 1/3] dt-bindings: add brcmstb-gpio GPIO binding Gregory Fong
     [not found]   ` <1430901477-10678-2-git-send-email-gregory.0xf0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-12 10:43     ` Linus Walleij
     [not found] ` <1430901477-10678-1-git-send-email-gregory.0xf0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-06  8:37   ` [PATCH 2/3] gpio: Add GPIO support for Broadcom STB SoCs Gregory Fong
2015-05-07  8:18     ` Paul Bolle
2015-05-08  4:19       ` Gregory Fong
2015-05-12 10:55     ` Linus Walleij
2015-05-12 18:46       ` Gregory Fong
2015-05-13  8:52         ` Linus Walleij
2015-05-06  8:37 ` [PATCH 3/3] gpio: brcmstb: Add interrupt support Gregory Fong
2015-05-12 10:59 ` [PATCH 0/3] GPIO support for BRCMSTB Linus Walleij
2015-05-12 19:38   ` Gregory Fong
     [not found]     ` <CADtm3G45-u82Rp_0dHf2EfdMokf8E4FaQ84PHnocpvXxU+5_+g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-13  8:59       ` Linus Walleij [this message]
2015-05-27  3:26         ` Gregory Fong
     [not found]           ` <CADtm3G4ao=3sHx2F1+V9rwS=jWf6ZdEQi4d24HxQ6MEc+CQ8CQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-02  9:05             ` Linus Walleij
     [not found]               ` <CACRpkdY_-zq-1srBC213MK_RoVvPsfTpRTQyx-4yRvCOV5JdxQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-02 16:28                 ` Russell King - ARM Linux
2015-06-03 12:46                   ` Linus Walleij
2015-06-03  4:13                 ` Gregory Fong

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=CACRpkdaTYAr-7K5_QZh1CyeyA1224obqEB2Sz8UHZmrWcfv+ow@mail.gmail.com \
    --to=linus.walleij-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
    --cc=bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=gregory.0xf0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@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).