* [PATCH 1/2] regmap: irq: Allow to acknowledge masked interrupts during initialization
@ 2013-07-22 15:15 Philipp Zabel
2013-07-22 15:15 ` [PATCH 2/2] regmap: irq: document mask/wake_invert, make them bool for consistency Philipp Zabel
2013-07-23 19:39 ` [PATCH 1/2] regmap: irq: Allow to acknowledge masked interrupts during initialization Mark Brown
0 siblings, 2 replies; 4+ messages in thread
From: Philipp Zabel @ 2013-07-22 15:15 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Brown, Philipp Zabel
In case the hardware interrupt mask register does not prevent the chip level
irq from being asserted by the corresponding interrupt status bit, already
set interrupt bits should to be cleared once after masking them during
initialization. Add a flag to let drivers enable this behavior.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
drivers/base/regmap/regmap-irq.c | 25 +++++++++++++++++++++++++
include/linux/regmap.h | 2 ++
2 files changed, 27 insertions(+)
diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 1643e88..d10456f 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -418,6 +418,31 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
reg, ret);
goto err_alloc;
}
+
+ if (!chip->init_ack_masked)
+ continue;
+
+ /* Ack masked but set interrupts */
+ reg = chip->status_base +
+ (i * map->reg_stride * d->irq_reg_stride);
+ ret = regmap_read(map, reg, &d->status_buf[i]);
+ if (ret != 0) {
+ dev_err(map->dev, "Failed to read IRQ status: %d\n",
+ ret);
+ goto err_alloc;
+ }
+
+ if (d->status_buf[i] && chip->ack_base) {
+ reg = chip->ack_base +
+ (i * map->reg_stride * d->irq_reg_stride);
+ ret = regmap_write(map, reg,
+ d->status_buf[i] & d->mask_buf[i]);
+ if (ret != 0) {
+ dev_err(map->dev, "Failed to ack 0x%x: %d\n",
+ reg, ret);
+ goto err_alloc;
+ }
+ }
}
/* Wake is disabled by default */
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 75981d0..34ebe77 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -470,6 +470,7 @@ struct regmap_irq {
* @ack_base: Base ack address. If zero then the chip is clear on read.
* @wake_base: Base address for wake enables. If zero unsupported.
* @irq_reg_stride: Stride to use for chips where registers are not contiguous.
+ * @init_ack_masked: Ack all masked interrupts once during initalization.
* @runtime_pm: Hold a runtime PM lock on the device when accessing it.
*
* @num_regs: Number of registers in each control bank.
@@ -485,6 +486,7 @@ struct regmap_irq_chip {
unsigned int ack_base;
unsigned int wake_base;
unsigned int irq_reg_stride;
+ bool init_ack_masked;
unsigned int mask_invert;
unsigned int wake_invert;
bool runtime_pm;
--
1.8.3.2
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/2] regmap: irq: document mask/wake_invert, make them bool for consistency
2013-07-22 15:15 [PATCH 1/2] regmap: irq: Allow to acknowledge masked interrupts during initialization Philipp Zabel
@ 2013-07-22 15:15 ` Philipp Zabel
2013-07-23 19:39 ` Mark Brown
2013-07-23 19:39 ` [PATCH 1/2] regmap: irq: Allow to acknowledge masked interrupts during initialization Mark Brown
1 sibling, 1 reply; 4+ messages in thread
From: Philipp Zabel @ 2013-07-22 15:15 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Brown, Philipp Zabel
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
include/linux/regmap.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 34ebe77..5a29fff 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -471,6 +471,8 @@ struct regmap_irq {
* @wake_base: Base address for wake enables. If zero unsupported.
* @irq_reg_stride: Stride to use for chips where registers are not contiguous.
* @init_ack_masked: Ack all masked interrupts once during initalization.
+ * @mask_invert: Inverted mask register: cleared bits are masked out.
+ * @wake_invert: Inverted wake register: cleared bits are wake enabled.
* @runtime_pm: Hold a runtime PM lock on the device when accessing it.
*
* @num_regs: Number of registers in each control bank.
@@ -487,8 +489,8 @@ struct regmap_irq_chip {
unsigned int wake_base;
unsigned int irq_reg_stride;
bool init_ack_masked;
- unsigned int mask_invert;
- unsigned int wake_invert;
+ bool mask_invert;
+ bool wake_invert;
bool runtime_pm;
int num_regs;
--
1.8.3.2
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] regmap: irq: Allow to acknowledge masked interrupts during initialization
2013-07-22 15:15 [PATCH 1/2] regmap: irq: Allow to acknowledge masked interrupts during initialization Philipp Zabel
2013-07-22 15:15 ` [PATCH 2/2] regmap: irq: document mask/wake_invert, make them bool for consistency Philipp Zabel
@ 2013-07-23 19:39 ` Mark Brown
1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2013-07-23 19:39 UTC (permalink / raw)
To: Philipp Zabel; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 376 bytes --]
On Mon, Jul 22, 2013 at 05:15:52PM +0200, Philipp Zabel wrote:
> In case the hardware interrupt mask register does not prevent the chip level
> irq from being asserted by the corresponding interrupt status bit, already
> set interrupt bits should to be cleared once after masking them during
> initialization. Add a flag to let drivers enable this behavior.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-07-23 19:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-22 15:15 [PATCH 1/2] regmap: irq: Allow to acknowledge masked interrupts during initialization Philipp Zabel
2013-07-22 15:15 ` [PATCH 2/2] regmap: irq: document mask/wake_invert, make them bool for consistency Philipp Zabel
2013-07-23 19:39 ` Mark Brown
2013-07-23 19:39 ` [PATCH 1/2] regmap: irq: Allow to acknowledge masked interrupts during initialization Mark Brown
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®