genirq: irqchip: Add a mask calculation function
authorThomas Gleixner <tglx@linutronix.de>
Mon, 6 May 2013 14:30:24 +0000 (14:30 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 29 May 2013 08:57:10 +0000 (10:57 +0200)
Some chips have weird bit mask access patterns instead of the linear
you expect. Allow them to calculate the cached mask themself.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Jean-Francois Moine <moinejf@free.fr>
Cc: devicetree-discuss@lists.ozlabs.org
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Cc: Gregory Clement <gregory.clement@free-electrons.com>
Cc: Gerlando Falauto <gerlando.falauto@keymile.com>
Cc: Rob Landley <rob@landley.net>
Acked-by: Grant Likely <grant.likely@linaro.org>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Link: http://lkml.kernel.org/r/20130506142539.302898834@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
include/linux/irq.h
kernel/irq/generic-chip.c

index d5fc7f5a49b8ce302e081b183bb1e8f3c8a5b5c2..ab8169faaa65bd2b50e81c6c93c8df70112cfcc7 100644 (file)
@@ -296,6 +296,7 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
  * @irq_suspend:       function called from core code on suspend once per chip
  * @irq_resume:                function called from core code on resume once per chip
  * @irq_pm_shutdown:   function called from core code on shutdown once per chip
+ * @irq_calc_mask:     Optional function to set irq_data.mask for special cases
  * @irq_print_chip:    optional to print special chip info in show_interrupts
  * @flags:             chip specific flags
  */
@@ -327,6 +328,8 @@ struct irq_chip {
        void            (*irq_resume)(struct irq_data *data);
        void            (*irq_pm_shutdown)(struct irq_data *data);
 
+       void            (*irq_calc_mask)(struct irq_data *data);
+
        void            (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
 
        unsigned long   flags;
index 957155cebbac5b9d5e6f118927b8ab0b347ff5a7..5068fe3ae1afd2272e95bcc17c70452b0ab384ed 100644 (file)
@@ -240,6 +240,7 @@ void irq_setup_generic_chip(struct irq_chip_generic *gc, u32 msk,
                            unsigned int set)
 {
        struct irq_chip_type *ct = gc->chip_types;
+       struct irq_chip *chip = &ct->chip;
        unsigned int i;
        u32 *mskptr = &gc->mask_cache, mskreg = ct->regs.mask;
 
@@ -267,9 +268,12 @@ void irq_setup_generic_chip(struct irq_chip_generic *gc, u32 msk,
                if (!(flags & IRQ_GC_NO_MASK)) {
                        struct irq_data *d = irq_get_irq_data(i);
 
-                       d->mask = 1 << (i - gc->irq_base);
+                       if (chip->irq_calc_mask)
+                               chip->irq_calc_mask(d);
+                       else
+                               d->mask = 1 << (i - gc->irq_base);
                }
-               irq_set_chip_and_handler(i, &ct->chip, ct->handler);
+               irq_set_chip_and_handler(i, chip, ct->handler);
                irq_set_chip_data(i, gc);
                irq_modify_status(i, clr, set);
        }