diff options
-rw-r--r-- | drivers/mfd/mc13783-core.c | 35 | ||||
-rw-r--r-- | include/linux/mfd/mc13783.h | 2 |
2 files changed, 37 insertions, 0 deletions
diff --git a/drivers/mfd/mc13783-core.c b/drivers/mfd/mc13783-core.c index a2bd44552042..62a847e4c2d8 100644 --- a/drivers/mfd/mc13783-core.c +++ b/drivers/mfd/mc13783-core.c | |||
@@ -269,6 +269,41 @@ int mc13783_irq_unmask(struct mc13783 *mc13783, int irq) | |||
269 | } | 269 | } |
270 | EXPORT_SYMBOL(mc13783_irq_unmask); | 270 | EXPORT_SYMBOL(mc13783_irq_unmask); |
271 | 271 | ||
272 | int mc13783_irq_status(struct mc13783 *mc13783, int irq, | ||
273 | int *enabled, int *pending) | ||
274 | { | ||
275 | int ret; | ||
276 | unsigned int offmask = irq < 24 ? MC13783_IRQMASK0 : MC13783_IRQMASK1; | ||
277 | unsigned int offstat = irq < 24 ? MC13783_IRQSTAT0 : MC13783_IRQSTAT1; | ||
278 | u32 irqbit = 1 << (irq < 24 ? irq : irq - 24); | ||
279 | |||
280 | if (irq < 0 || irq >= MC13783_NUM_IRQ) | ||
281 | return -EINVAL; | ||
282 | |||
283 | if (enabled) { | ||
284 | u32 mask; | ||
285 | |||
286 | ret = mc13783_reg_read(mc13783, offmask, &mask); | ||
287 | if (ret) | ||
288 | return ret; | ||
289 | |||
290 | *enabled = mask & irqbit; | ||
291 | } | ||
292 | |||
293 | if (pending) { | ||
294 | u32 stat; | ||
295 | |||
296 | ret = mc13783_reg_read(mc13783, offstat, &stat); | ||
297 | if (ret) | ||
298 | return ret; | ||
299 | |||
300 | *pending = stat & irqbit; | ||
301 | } | ||
302 | |||
303 | return 0; | ||
304 | } | ||
305 | EXPORT_SYMBOL(mc13783_irq_status); | ||
306 | |||
272 | int mc13783_irq_ack(struct mc13783 *mc13783, int irq) | 307 | int mc13783_irq_ack(struct mc13783 *mc13783, int irq) |
273 | { | 308 | { |
274 | unsigned int offstat = irq < 24 ? MC13783_IRQSTAT0 : MC13783_IRQSTAT1; | 309 | unsigned int offstat = irq < 24 ? MC13783_IRQSTAT0 : MC13783_IRQSTAT1; |
diff --git a/include/linux/mfd/mc13783.h b/include/linux/mfd/mc13783.h index b8b9f3b4f3e2..8895d9d8879c 100644 --- a/include/linux/mfd/mc13783.h +++ b/include/linux/mfd/mc13783.h | |||
@@ -29,6 +29,8 @@ int mc13783_irq_free(struct mc13783 *mc13783, int irq, void *dev); | |||
29 | 29 | ||
30 | int mc13783_irq_mask(struct mc13783 *mc13783, int irq); | 30 | int mc13783_irq_mask(struct mc13783 *mc13783, int irq); |
31 | int mc13783_irq_unmask(struct mc13783 *mc13783, int irq); | 31 | int mc13783_irq_unmask(struct mc13783 *mc13783, int irq); |
32 | int mc13783_irq_status(struct mc13783 *mc13783, int irq, | ||
33 | int *enabled, int *pending); | ||
32 | int mc13783_irq_ack(struct mc13783 *mc13783, int irq); | 34 | int mc13783_irq_ack(struct mc13783 *mc13783, int irq); |
33 | 35 | ||
34 | static inline int mc13783_mask(struct mc13783 *mc13783, int irq) __deprecated; | 36 | static inline int mc13783_mask(struct mc13783 *mc13783, int irq) __deprecated; |