mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Tomoya MORINAGA <tomoya-linux@dsn.okisemi.com>,
	linux-kernel@vger.kernel.org, toshiharu-linux@dsn.okisemi.com
Subject: Re: Question: GPIO driver how to get irq_base
Date: Thu, 21 Apr 2011 08:24:22 -0600	[thread overview]
Message-ID: <20110421142422.GC32725@ponder.secretlab.ca> (raw)
In-Reply-To: <4DB03A4B.9040807@metafoo.de>

On Thu, Apr 21, 2011 at 04:08:11PM +0200, Lars-Peter Clausen wrote:
> On 04/21/2011 03:45 PM, Grant Likely wrote:
> > On Thu, Apr 21, 2011 at 10:09:14AM +0200, Lars-Peter Clausen wrote:
> >> [...]
> >>
> >> In my opinion the best option for expander chips is to allocate a new irq_desc
> >> range by calling irq_alloc_descs. It will return the first irq number in the
> >> newly allocated range, which will be your irq_base.
> > 
> > Yes, irq_alloc_descs() will give you a range of irqs that the gpio
> > expander can use.  In many drivers, the irq_base is hard coded in the
> > board file and passed in via pdata, but as much as possible I
> > recommend avoiding that and letting Linux dynamically allocate the
> > irq_base for you.  Setting gpio_base to -1 will do this.
> > 
> > The ->to_irq() hook in your driver can translate
> > from a gpio number to an irq number for a specific gpio.
> > 
> >> But be aware that this will require SPARSE_IRQ to work.
> > 
> > Why?
> > 
> 
> Because in a non-SPARSE_IRQ setup all irq_descs will be allocated by default.
> See early_irq_init for the non-SPARSE_IRQ case in kernel/irq/irq_desc.c.

They'll be allocated, but not all need to be assigned.

> 
> Though platform code could make irq_descs explicitly available byfirst setting
> NR_IRQS to a larger number then it actually requires and then call
> irq_free_descs for those irqs which are not used by platform code, but using
> SPARSE_IRQ is in my opinion the better alternative in this case.

On the powerpc platforms, pretty much all irqs are dynamically
allocated and SPARSE_IRQ can be either on or off.  So, yes, you need
to make sure NR_IRQs is large enough if you don't want to use SPARSE,
but SPARSE is not a hard requirement.

g.


  reply	other threads:[~2011-04-21 14:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-21  7:32 Tomoya MORINAGA
2011-04-21  8:09 ` Lars-Peter Clausen
2011-04-21 13:45   ` Grant Likely
2011-04-21 14:08     ` Lars-Peter Clausen
2011-04-21 14:24       ` Grant Likely [this message]
2011-04-22  0:33         ` Tomoya MORINAGA
2011-04-22  1:12         ` Tomoya MORINAGA
2011-04-23 10:14           ` Lars-Peter Clausen
2011-04-25  4:04             ` Tomoya MORINAGA
2011-05-10  5:54               ` Tomoya MORINAGA
2011-05-11 19:20                 ` Lars-Peter Clausen
2011-05-12 12:01                   ` Tomoya MORINAGA
2011-05-12 19:43                     ` Lars-Peter Clausen
2011-05-13  2:40                       ` Tomoya MORINAGA
2011-05-13  3:18                         ` Lars-Peter Clausen
2011-05-13  5:42                           ` Tomoya MORINAGA
2011-05-16 10:38                           ` Tomoya MORINAGA
2011-05-17  2:06                             ` Tomoya MORINAGA

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=20110421142422.GC32725@ponder.secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tomoya-linux@dsn.okisemi.com \
    --cc=toshiharu-linux@dsn.okisemi.com \
    /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

all inboxes | Powered by JetHome®