From: Barry Song <21cnbao@gmail.com>
To: broonie@kernel.org, gregkh@linuxfoundation.org,
sameo@linux.intel.com, lee.jones@linaro.org
Cc: linux-kernel@vger.kernel.org, workgroup.linux@csr.com,
Guo Zeng <Guo.Zeng@csr.com>, Barry Song <Baohua.Song@csr.com>
Subject: [PATCH 2/3] regmap: irq: add ack_invert flag for chips using cleared bits as ack
Date: Mon, 14 Sep 2015 09:40:09 +0000 [thread overview]
Message-ID: <1442223610-32257-3-git-send-email-21cnbao@gmail.com> (raw)
In-Reply-To: <1442223610-32257-1-git-send-email-21cnbao@gmail.com>
From: Guo Zeng <Guo.Zeng@csr.com>
An user will be CSR SiRFSoC ARM chips.
Signed-off-by: Guo Zeng <Guo.Zeng@csr.com>
Signed-off-by: Barry Song <Baohua.Song@csr.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
next prev parent reply other threads:[~2015-09-14 9:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-14 9:40 [PATCH 0/3] add CSR SiRFSoC power control module MFD driver Barry Song
2015-09-14 9:40 ` [PATCH 1/3] regmap: irq: add support for chips who have separate unmask registers Barry Song
2015-09-16 19:37 ` Mark Brown
2015-09-14 9:40 ` Barry Song [this message]
2015-09-16 19:39 ` [PATCH 2/3] regmap: irq: add ack_invert flag for chips using cleared bits as ack Mark Brown
2015-09-14 9:40 ` [PATCH 3/3] mfd: add CSR SiRFSoC on-chip power management module driver Barry Song
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=1442223610-32257-3-git-send-email-21cnbao@gmail.com \
--to=21cnbao@gmail.com \
--cc=Baohua.Song@csr.com \
--cc=Guo.Zeng@csr.com \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sameo@linux.intel.com \
--cc=workgroup.linux@csr.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®