]> git.karo-electronics.de Git - linux-beck.git/commitdiff
mfd: arizona: Try to use interrupt flags from interrupt controller
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Sun, 24 Mar 2013 23:16:56 +0000 (23:16 +0000)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 8 Apr 2013 13:20:58 +0000 (15:20 +0200)
If no irq_flags are passed in platform data then query the interrupt
controller for the trigger type and try to use that. This provides
default operation with a wider range of hardware and will be needed
for device tree support where the interrupt flags are configured on
the interrupt controller.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/arizona-irq.c

index f761cc119c01a14081930916599cdfc8ff16a76e..64cd9b6dac92df6a425fcbc74eef0f01f153100b 100644 (file)
@@ -189,6 +189,7 @@ int arizona_irq_init(struct arizona *arizona)
        int ret, i;
        const struct regmap_irq_chip *aod, *irq;
        bool ctrlif_error = true;
+       struct irq_data *irq_data;
 
        switch (arizona->type) {
 #ifdef CONFIG_MFD_WM5102
@@ -215,8 +216,30 @@ int arizona_irq_init(struct arizona *arizona)
        /* Disable all wake sources by default */
        regmap_write(arizona->regmap, ARIZONA_WAKE_CONTROL, 0);
 
-       if (!arizona->pdata.irq_flags)
-               arizona->pdata.irq_flags = IRQF_TRIGGER_LOW;
+       /* Read the flags from the interrupt controller if not specified */
+       if (!arizona->pdata.irq_flags) {
+               irq_data = irq_get_irq_data(arizona->irq);
+               if (!irq_data) {
+                       dev_err(arizona->dev, "Invalid IRQ: %d\n",
+                               arizona->irq);
+                       return -EINVAL;
+               }
+
+               arizona->pdata.irq_flags = irqd_get_trigger_type(irq_data);
+               switch (arizona->pdata.irq_flags) {
+               case IRQF_TRIGGER_LOW:
+               case IRQF_TRIGGER_HIGH:
+               case IRQF_TRIGGER_RISING:
+               case IRQF_TRIGGER_FALLING:
+                       break;
+
+               case IRQ_TYPE_NONE:
+               default:
+                       /* Device default */
+                       arizona->pdata.irq_flags = IRQF_TRIGGER_LOW;
+                       break;
+               }
+       }
 
        if (arizona->pdata.irq_flags & (IRQF_TRIGGER_HIGH |
                                        IRQF_TRIGGER_RISING)) {