linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: jamie@jamieiles.com (Jamie Iles)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] gpio: add a driver for the Synopsys DesignWare APB GPIO block
Date: Mon, 19 Dec 2011 00:44:31 +0000	[thread overview]
Message-ID: <20111219004431.GE2376@gallagher> (raw)
In-Reply-To: <CACRpkdYu7HCBdAzqNr1pwZMgvZFyBYpcJXYo-RUx5R-U3CJ1BA@mail.gmail.com>

Hi Linus,

On Sun, Dec 18, 2011 at 11:01:38PM +0100, Linus Walleij wrote:
> On Sun, Dec 18, 2011 at 11:13 AM, Jamie Iles <jamie@jamieiles.com> wrote:
> 
> > The Synopsys DesignWare block is used in some ARM devices (picoxcell)
> > and can be configured to provide multiple banks of GPIO pins. ?The first
> > bank (A) can also provide IRQ capabilities.
> 
> Overall this is looking good.
> 
> Here is a problem (I think):
> 
> > +static int dwapb_irq_set_type(struct irq_data *d, u32 type)
> > +{
> > + ? ? ? struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
> > + ? ? ? struct dwapb_gpio *gpio = gc->private;
> > + ? ? ? int bit = d->hwirq;
> > + ? ? ? unsigned long level, polarity;
> > +
> > + ? ? ? if (type & ~(IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING |
> > + ? ? ? ? ? ? ? ? ? ?IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW))
> > + ? ? ? ? ? ? ? return -EINVAL;
> > +
> > + ? ? ? level = readl(gpio->regs + INT_TYPE_REG_OFFS);
> > + ? ? ? polarity = readl(gpio->regs + INT_POLARITY_REG_OFFS);
> > +
> > + ? ? ? if (type & IRQ_TYPE_EDGE_RISING) {
> > + ? ? ? ? ? ? ? level |= (1 << bit);
> > + ? ? ? ? ? ? ? polarity |= (1 << bit);
> > + ? ? ? } else if (type & IRQ_TYPE_EDGE_FALLING) {
> > + ? ? ? ? ? ? ? level |= (1 << bit);
> > + ? ? ? ? ? ? ? polarity &= ~(1 << bit);
> 
> So what if you get request for *both* falling and rising edges?
> 
> This is not uncommon at all, for example a GPIO which detecs
> MMC card insertions and removals like drivers/host/mmc/mmci.c
> will want interrupts on both edges since we want to change state
> whenever the card is inserted *or* removed.
> 
> If you check drivers/gpio/gpio-u300.c you can see how I handled
> this on another hardware where triggering on falling and rising
> edges was a binary choice and thus mutually exclusive: I toggle
> for each interrupt.
> 
> See u300_toggle_trigger(), u300_gpio_irq_type().
> 
> So either you do something like that, or you detect both set
> and return an error, else the poor caller will just get falling
> edges in this driver...

Hmm, I hadn't thought of that.  I've had a quick once-over your u300 
gpio driver and that looks pretty neat.  I'll give that a go over the 
next day or two and repost.

Thanks for the pointer!

Jamie

  reply	other threads:[~2011-12-19  0:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-18 10:13 [PATCH 1/2] gpio: add a driver for the Synopsys DesignWare APB GPIO block Jamie Iles
2011-12-18 10:13 ` [PATCH 2/2] ARM: picoxcell: use new Synopsys Designware GPIO binding Jamie Iles
2011-12-18 22:01 ` [PATCH 1/2] gpio: add a driver for the Synopsys DesignWare APB GPIO block Linus Walleij
2011-12-19  0:44   ` Jamie Iles [this message]
2011-12-20 14:50   ` Mark Brown
2011-12-19  3:03 ` Rob Herring
2011-12-19  9:56   ` Jamie Iles
2011-12-20 14:48 ` Mark Brown

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=20111219004431.GE2376@gallagher \
    --to=jamie@jamieiles.com \
    --cc=linux-arm-kernel@lists.infradead.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).