linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv3 1/2] mfd: cpcap: implement irq sense helper
@ 2017-03-21 22:50 Sebastian Reichel
  2017-03-21 22:50 ` [PATCHv3 2/2] input: cpcap-pwrbutton: new driver Sebastian Reichel
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Sebastian Reichel @ 2017-03-21 22:50 UTC (permalink / raw)
  To: Sebastian Reichel, Lee Jones
  Cc: Tony Lindgren, Dmitry Torokhov, Rob Herring, Mark Rutland,
	linux-input, devicetree, linux-kernel

CPCAP can sense if IRQ is currently set or not. This
functionality is required for a few subdevices, such
as the power button and usb phy modules.

Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
Changes since PATCHv2:
 - Collect Acked-by/Tested-by
 - Fix typo in EXPORT_SYMBOL_GPL
---
 drivers/mfd/motorola-cpcap.c       | 25 +++++++++++++++++++++++++
 include/linux/mfd/motorola-cpcap.h |  2 ++
 2 files changed, 27 insertions(+)

diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
index 6aeada7d7ce5..a1e364b42e47 100644
--- a/drivers/mfd/motorola-cpcap.c
+++ b/drivers/mfd/motorola-cpcap.c
@@ -32,6 +32,31 @@ struct cpcap_ddata {
 	struct regmap *regmap;
 };
 
+static int cpcap_sense_irq(struct regmap *regmap, int irq)
+{
+	int reg = CPCAP_REG_INTS1 + (irq / 16) * 4;
+	int mask = 1 << (irq % 16);
+	int err, val;
+
+	if (irq < 0 || irq > 64)
+		return -EINVAL;
+
+	err = regmap_read(regmap, reg, &val);
+	if (err)
+		return err;
+
+	return !!(val & mask);
+}
+
+int cpcap_sense_virq(struct regmap *regmap, int virq)
+{
+	struct regmap_irq_chip_data *d = irq_get_chip_data(virq);
+	int base = regmap_irq_chip_get_base(d);
+
+	return cpcap_sense_irq(regmap, virq - base);
+}
+EXPORT_SYMBOL_GPL(cpcap_sense_virq);
+
 static int cpcap_check_revision(struct cpcap_ddata *cpcap)
 {
 	u16 vendor, rev;
diff --git a/include/linux/mfd/motorola-cpcap.h b/include/linux/mfd/motorola-cpcap.h
index b4031c2b2214..7629e0d24d26 100644
--- a/include/linux/mfd/motorola-cpcap.h
+++ b/include/linux/mfd/motorola-cpcap.h
@@ -290,3 +290,5 @@ static inline int cpcap_get_vendor(struct device *dev,
 
 	return 0;
 }
+
+int cpcap_sense_virq(struct regmap *regmap, int virq);
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-04-11 14:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-21 22:50 [PATCHv3 1/2] mfd: cpcap: implement irq sense helper Sebastian Reichel
2017-03-21 22:50 ` [PATCHv3 2/2] input: cpcap-pwrbutton: new driver Sebastian Reichel
     [not found] ` <20170321225042.28057-1-sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-03-23 14:23   ` [PATCHv3 1/2] mfd: cpcap: implement irq sense helper Lee Jones
2017-03-24  8:42     ` [PATCHv4] " Sebastian Reichel
2017-03-28 10:27       ` Lee Jones
2017-03-28 14:54         ` Sebastian Reichel
2017-03-29  8:04           ` Lee Jones
2017-03-29 12:18             ` [PATCHv5] " Sebastian Reichel
2017-04-03 10:26               ` Lee Jones
2017-04-10 14:27                 ` Sebastian Reichel
2017-04-11 14:21                   ` Lee Jones
2017-04-11 14:21 ` [GIT PULL] Immutable branch between MFD and Input due for the v4.12 merge window Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).