From: Tim Harvey <tharvey@gateworks.com>
To: linux-kernel@vger.kernel.org, Mark Brown <broonie@kernel.org>,
Benjamin Gaignard <benjamin.gaignard@linaro.org>,
Lee Jones <lee.jones@linaro.org>,
Tony Lindgren <tony@atomide.com>
Subject: [PATCH] regmap: irq: fix ack-invert
Date: Tue, 27 Feb 2018 08:05:58 -0800 [thread overview]
Message-ID: <1519747558-17257-1-git-send-email-tharvey@gateworks.com> (raw)
When acking irqs we need to take into account the ack-invert case. Without
this chips that require 0's to ACK interrupts will never clear the interrupt.
I am working on an mfd driver that will use ack-invert and discovered
this issue. The only user of ack_invert currently appears to be the
motorola-cpcap driver. I'm not clear why that driver doesn't appear affected
so I'm cc'ing those involved with that driver for review and testing.
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
drivers/base/regmap/regmap-irq.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 429ca8e..abfed41 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -355,16 +355,25 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
* doing a write per register.
*/
for (i = 0; i < data->chip->num_regs; i++) {
- data->status_buf[i] &= ~data->mask_buf[i];
-
- if (data->status_buf[i] && (chip->ack_base || chip->use_ack)) {
+ if ( (data->status_buf[i] & ~data->mask_buf[i]) &&
+ (chip->ack_base || chip->use_ack) ) {
reg = chip->ack_base +
(i * map->reg_stride * data->irq_reg_stride);
- ret = regmap_write(map, reg, data->status_buf[i]);
+ /* some chips ack by write 0 */
+ if (chip->ack_invert)
+ ret = regmap_write(map, reg,
+ ~data->status_buf[i] &
+ ~data->mask_buf[i]);
+
+ else
+ ret = regmap_write(map, reg,
+ data->status_buf[i] &
+ ~data->mask_buf[i]);
if (ret != 0)
dev_err(map->dev, "Failed to ack 0x%x: %d\n",
reg, ret);
}
+ data->status_buf[i] &= ~data->mask_buf[i];
}
for (i = 0; i < chip->num_irqs; i++) {
--
2.7.4
next reply other threads:[~2018-02-27 16:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-27 16:05 Tim Harvey [this message]
2018-02-27 18:39 ` Tony Lindgren
2018-02-28 21:17 ` Tim Harvey
2018-02-28 22:04 ` Tony Lindgren
2018-03-03 17:01 ` Tim Harvey
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=1519747558-17257-1-git-send-email-tharvey@gateworks.com \
--to=tharvey@gateworks.com \
--cc=benjamin.gaignard@linaro.org \
--cc=broonie@kernel.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony@atomide.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®