public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jack Stone <jwjstone@fastmail.fm>
To: Margarita Olaya <magi@slimlogic.co.uk>
Cc: linux-kernel@vger.kernel.org, Liam Girdwood <lrg@slimlogic.co.uk>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	sameo@linux.intel.com
Subject: Re: [PATCHv2 2/4] tps65912: irq: add interrupt controller
Date: Thu, 12 May 2011 20:56:10 +0100	[thread overview]
Message-ID: <4DCC3B5A.7090908@fastmail.fm> (raw)
In-Reply-To: <BANLkTimZkNa4_N8=7=H8JThZgjtocN0gFg@mail.gmail.com>

Hi Margarita,

I'm no irq expert so the following might be wrong.

This comment seems to contradict the code - the comment states that all
interrupts are clear on read but the irq handler explicitly writes the
value back to the interrupt register.

Did you mean the comment to say that the irq handler explicitly clears
the interrupts it handles?

On 12/05/2011 19:43, Margarita Olaya wrote:
> +++ b/drivers/mfd/tps65912-irq.c
> +/*
> + * This is a threaded IRQ handler so can access I2C/SPI.  Since all
> + * interrupts are clear on read the IRQ line will be reasserted and
> + * the physical IRQ will be handled again if another interrupt is
> + * asserted while we run - in the normal course of events this is a
> + * rare occurrence so we save I2C/SPI reads.  We're also assuming that
> + * it's rare to get lots of interrupts firing simultaneously so try to
> + * minimise I/O.
> + */
> +static irqreturn_t tps65912_irq(int irq, void *irq_data)
> +{
> +	struct tps65912 *tps65912 = irq_data;
> +	u32 irq_sts;
> +	u32 irq_mask;
> +	u8 reg;
> +	int i;
> +
> +
> +	tps65912->read(tps65912, TPS65912_INT_STS, 1, &reg);
> +	irq_sts = reg;
> +	tps65912->read(tps65912, TPS65912_INT_STS2, 1, &reg);
> +	irq_sts |= reg << 8;
> +	tps65912->read(tps65912, TPS65912_INT_STS3, 1, &reg);
> +	irq_sts |= reg << 16;
> +	tps65912->read(tps65912, TPS65912_INT_STS4, 1, &reg);
> +	irq_sts |= reg << 24;
> +
> +	tps65912->read(tps65912, TPS65912_INT_MSK, 1, &reg);
> +	irq_mask = reg;
> +	tps65912->read(tps65912, TPS65912_INT_MSK2, 1, &reg);
> +	irq_mask |= reg << 8;
> +	tps65912->read(tps65912, TPS65912_INT_MSK3, 1, &reg);
> +	irq_mask |= reg << 16;
> +	tps65912->read(tps65912, TPS65912_INT_MSK4, 1, &reg);
> +	irq_mask |= reg << 24;
> +
> +	irq_sts &= ~irq_mask;
> +	if (!irq_sts)
> +		return IRQ_NONE;
> +
> +	for (i = 0; i < tps65912->irq_num; i++) {
> +		if (!(irq_sts & (1 << i)))
> +			continue;
> +
> +		handle_nested_irq(tps65912->irq_base + i);
> +	}
> +
> +	/* Write the STS register back to clear IRQs we handled */
> +	reg = irq_sts & 0xFF;
> +	irq_sts >>= 8;
> +	if (reg)
> +		tps65912->write(tps65912, TPS65912_INT_STS, 1, &reg);
> +	reg = irq_sts & 0xFF;
> +	irq_sts >>= 8;
> +	if (reg)
> +		tps65912->write(tps65912, TPS65912_INT_STS2, 1, &reg);
> +	reg = irq_sts & 0xFF;
> +	irq_sts >>= 8;
> +	if (reg)
> +		tps65912->write(tps65912, TPS65912_INT_STS3, 1, &reg);
> +	reg = irq_sts & 0xFF;
> +	if (reg)
> +		tps65912->write(tps65912, TPS65912_INT_STS4, 1, &reg);
> +
> +	return IRQ_HANDLED;
> +}

Thanks,

Jack

  reply	other threads:[~2011-05-12 19:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-12 18:43 [PATCHv2 2/4] tps65912: irq: add interrupt controller Margarita Olaya
2011-05-12 19:56 ` Jack Stone [this message]
2011-05-13 18:23   ` Margarita Olaya
2011-05-14 16:14 ` 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=4DCC3B5A.7090908@fastmail.fm \
    --to=jwjstone@fastmail.fm \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    --cc=magi@slimlogic.co.uk \
    --cc=sameo@linux.intel.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