[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1442223610-32257-3-git-send-email-21cnbao@gmail.com>
Date: Mon, 14 Sep 2015 09:40:09 +0000
From: Barry Song <21cnbao@...il.com>
To: broonie@...nel.org, gregkh@...uxfoundation.org,
sameo@...ux.intel.com, lee.jones@...aro.org
Cc: linux-kernel@...r.kernel.org, workgroup.linux@....com,
Guo Zeng <Guo.Zeng@....com>, Barry Song <Baohua.Song@....com>
Subject: [PATCH 2/3] regmap: irq: add ack_invert flag for chips using cleared bits as ack
From: Guo Zeng <Guo.Zeng@....com>
An user will be CSR SiRFSoC ARM chips.
Signed-off-by: Guo Zeng <Guo.Zeng@....com>
Signed-off-by: Barry Song <Baohua.Song@....com>
---
drivers/base/regmap/regmap-irq.c | 12 ++++++++++--
include/linux/regmap.h | 2 ++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 2d21abc..35cd13f 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -132,7 +132,11 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
if (d->mask_buf[i] && (d->chip->ack_base || d->chip->use_ack)) {
reg = d->chip->ack_base +
(i * map->reg_stride * d->irq_reg_stride);
- ret = regmap_write(map, reg, d->mask_buf[i]);
+ /* some chips ack by write 0 */
+ if (d->chip->ack_invert)
+ ret = regmap_write(map, reg, ~d->mask_buf[i]);
+ else
+ ret = regmap_write(map, reg, d->mask_buf[i]);
if (ret != 0)
dev_err(d->map->dev, "Failed to ack 0x%x: %d\n",
reg, ret);
@@ -469,7 +473,11 @@ int regmap_add_irq_chip(struct regmap *map, int irq, int irq_flags,
if (d->status_buf[i] && (chip->ack_base || chip->use_ack)) {
reg = chip->ack_base +
(i * map->reg_stride * d->irq_reg_stride);
- ret = regmap_write(map, reg,
+ if (chip->ack_invert)
+ ret = regmap_write(map, reg,
+ ~(d->status_buf[i] & d->mask_buf[i]));
+ else
+ 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",
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index bb5ba97..313c420 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -810,6 +810,7 @@ struct regmap_irq {
* @mask_invert: Inverted mask register: cleared bits are masked out.
* @unmask_separate: unmask is separate register from mask.
* @use_ack: Use @ack register even if it is zero.
+ * @ack_invert: Inverted ack register: cleared bits for ack.
* @wake_invert: Inverted wake register: cleared bits are wake enabled.
* @runtime_pm: Hold a runtime PM lock on the device when accessing it.
*
@@ -831,6 +832,7 @@ struct regmap_irq_chip {
bool mask_invert:1;
bool unmask_separate:1;
bool use_ack:1;
+ bool ack_invert:1;
bool wake_invert:1;
bool runtime_pm:1;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists