aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2013-07-22 11:15:52 -0400
committerMark Brown <broonie@linaro.org>2013-07-23 15:39:12 -0400
commit2753e6f8207355ab72574d48287cec187272a151 (patch)
tree55ff653ff5f419c4a7950166b3e3c7ad86470814
parent3b2f64d00c46e1e4e9bd0bb9bb12619adac27a4b (diff)
regmap: irq: Allow to acknowledge masked interrupts during initialization
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> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/base/regmap/regmap-irq.c25
-rw-r--r--include/linux/regmap.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 1643e889bafc..d10456ffd811 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,
418 reg, ret); 418 reg, ret);
419 goto err_alloc; 419 goto err_alloc;
420 } 420 }
421
422 if (!chip->init_ack_masked)
423 continue;
424
425 /* Ack masked but set interrupts */
426 reg = chip->status_base +
427 (i * map->reg_stride * d->irq_reg_stride);
428 ret = regmap_read(map, reg, &d->status_buf[i]);
429 if (ret != 0) {
430 dev_err(map->dev, "Failed to read IRQ status: %d\n",
431 ret);
432 goto err_alloc;
433 }
434
435 if (d->status_buf[i] && chip->ack_base) {
436 reg = chip->ack_base +
437 (i * map->reg_stride * d->irq_reg_stride);
438 ret = regmap_write(map, reg,
439 d->status_buf[i] & d->mask_buf[i]);
440 if (ret != 0) {
441 dev_err(map->dev, "Failed to ack 0x%x: %d\n",
442 reg, ret);
443 goto err_alloc;
444 }
445 }
421 } 446 }
422 447
423 /* Wake is disabled by default */ 448 /* Wake is disabled by default */
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 75981d0b57dc..34ebe7778033 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -470,6 +470,7 @@ struct regmap_irq {
470 * @ack_base: Base ack address. If zero then the chip is clear on read. 470 * @ack_base: Base ack address. If zero then the chip is clear on read.
471 * @wake_base: Base address for wake enables. If zero unsupported. 471 * @wake_base: Base address for wake enables. If zero unsupported.
472 * @irq_reg_stride: Stride to use for chips where registers are not contiguous. 472 * @irq_reg_stride: Stride to use for chips where registers are not contiguous.
473 * @init_ack_masked: Ack all masked interrupts once during initalization.
473 * @runtime_pm: Hold a runtime PM lock on the device when accessing it. 474 * @runtime_pm: Hold a runtime PM lock on the device when accessing it.
474 * 475 *
475 * @num_regs: Number of registers in each control bank. 476 * @num_regs: Number of registers in each control bank.
@@ -485,6 +486,7 @@ struct regmap_irq_chip {
485 unsigned int ack_base; 486 unsigned int ack_base;
486 unsigned int wake_base; 487 unsigned int wake_base;
487 unsigned int irq_reg_stride; 488 unsigned int irq_reg_stride;
489 bool init_ack_masked;
488 unsigned int mask_invert; 490 unsigned int mask_invert;
489 unsigned int wake_invert; 491 unsigned int wake_invert;
490 bool runtime_pm; 492 bool runtime_pm;