]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
mfd/mc13783: new function reading irq mask and status register
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 5 Mar 2010 21:44:29 +0000 (13:44 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 6 Mar 2010 19:26:47 +0000 (11:26 -0800)
The driver for the mc13783 rtc needs to know if the TODA irq is pending.

Instead of tracking in the rtc driver if the irq is enabled provide that
information, too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Paul Gortmaker <p_gortmaker@yahoo.com>
Cc: Valentin Longchamp <valentin.longchamp@epfl.ch>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Luotao Fu <l.fu@pengutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/mfd/mc13783-core.c
include/linux/mfd/mc13783.h

index a2bd445520425f32b6fa5fbb3cf5096d75121117..62a847e4c2d840f8f6c28c06785a0c49a1604c57 100644 (file)
@@ -269,6 +269,41 @@ int mc13783_irq_unmask(struct mc13783 *mc13783, int irq)
 }
 EXPORT_SYMBOL(mc13783_irq_unmask);
 
+int mc13783_irq_status(struct mc13783 *mc13783, int irq,
+               int *enabled, int *pending)
+{
+       int ret;
+       unsigned int offmask = irq < 24 ? MC13783_IRQMASK0 : MC13783_IRQMASK1;
+       unsigned int offstat = irq < 24 ? MC13783_IRQSTAT0 : MC13783_IRQSTAT1;
+       u32 irqbit = 1 << (irq < 24 ? irq : irq - 24);
+
+       if (irq < 0 || irq >= MC13783_NUM_IRQ)
+               return -EINVAL;
+
+       if (enabled) {
+               u32 mask;
+
+               ret = mc13783_reg_read(mc13783, offmask, &mask);
+               if (ret)
+                       return ret;
+
+               *enabled = mask & irqbit;
+       }
+
+       if (pending) {
+               u32 stat;
+
+               ret = mc13783_reg_read(mc13783, offstat, &stat);
+               if (ret)
+                       return ret;
+
+               *pending = stat & irqbit;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL(mc13783_irq_status);
+
 int mc13783_irq_ack(struct mc13783 *mc13783, int irq)
 {
        unsigned int offstat = irq < 24 ? MC13783_IRQSTAT0 : MC13783_IRQSTAT1;
index b8b9f3b4f3e2f0adb650582b560618897e845a14..8895d9d8879cb12b164d28f5f22da38905d122cb 100644 (file)
@@ -29,6 +29,8 @@ int mc13783_irq_free(struct mc13783 *mc13783, int irq, void *dev);
 
 int mc13783_irq_mask(struct mc13783 *mc13783, int irq);
 int mc13783_irq_unmask(struct mc13783 *mc13783, int irq);
+int mc13783_irq_status(struct mc13783 *mc13783, int irq,
+               int *enabled, int *pending);
 int mc13783_irq_ack(struct mc13783 *mc13783, int irq);
 
 static inline int mc13783_mask(struct mc13783 *mc13783, int irq) __deprecated;