summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorXiaofan Tian <tianxf@marvell.com>2012-08-30 17:03:35 +0800
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-08-30 11:13:41 -0700
commit36ac914ba2a5f1a14c5e0bf5d33bc20016d50940 (patch)
tree44535bd6b9ddab5abf4a354d6b3bbe46a1ab03a1 /drivers/base
parent7a97637988c355646e730bcf0e6d548619112cdd (diff)
downloadlinux-3.10-36ac914ba2a5f1a14c5e0bf5d33bc20016d50940.tar.gz
linux-3.10-36ac914ba2a5f1a14c5e0bf5d33bc20016d50940.tar.bz2
linux-3.10-36ac914ba2a5f1a14c5e0bf5d33bc20016d50940.zip
regmap: irq: Add mask invert flag for enable register
Currently, regmap will write 1 to mask_base to mask an interrupt and write 0 to unmask it. But some chips do not have an interrupt mask register, and only have interrupt enable register. Then we should write 0 to disable interrupt and 1 to enable. So add an mask_invert flag to handle this. If it is not set, behavior is same as previous. If set it to 1, the mask value will be inverted before written to mask_base Signed-off-by: Xiaofan Tian <tianxf@marvell.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/regmap-irq.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index bb5e1030519..094f9988fdf 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -78,7 +78,11 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
for (i = 0; i < d->chip->num_regs; i++) {
reg = d->chip->mask_base +
(i * map->reg_stride * d->irq_reg_stride);
- ret = regmap_update_bits(d->map, reg,
+ if (d->chip->mask_invert)
+ ret = regmap_update_bits(d->map, reg,
+ d->mask_buf_def[i], ~d->mask_buf[i]);
+ else
+ ret = regmap_update_bits(d->map, reg,
d->mask_buf_def[i], d->mask_buf[i]);
if (ret != 0)
dev_err(d->map->dev, "Failed to sync masks in %x\n",
@@ -338,7 +342,11 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
d->mask_buf[i] = d->mask_buf_def[i];
reg = chip->mask_base +
(i * map->reg_stride * d->irq_reg_stride);
- ret = regmap_update_bits(map, reg,
+ if (chip->mask_invert)
+ ret = regmap_update_bits(map, reg,
+ d->mask_buf[i], ~d->mask_buf[i]);
+ else
+ ret = regmap_update_bits(map, reg,
d->mask_buf[i], d->mask_buf[i]);
if (ret != 0) {
dev_err(map->dev, "Failed to set masks in 0x%x: %d\n",