ARM: 6103/1: nomadik: define clocks statically
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / plat-nomadik / gpio.c
index a8ac545ddadc6f9993d9fa6cb6e80abf0b872127..eac9c9a7fbf9b682b750ee868e72c2afe6c9cf08 100644 (file)
@@ -162,6 +162,7 @@ static void nmk_gpio_irq_unmask(unsigned int irq)
 
 static int nmk_gpio_irq_set_type(unsigned int irq, unsigned int type)
 {
+       bool enabled = !(irq_to_desc(irq)->status & IRQ_DISABLED);
        int gpio;
        struct nmk_gpio_chip *nmk_chip;
        unsigned long flags;
@@ -180,19 +181,21 @@ static int nmk_gpio_irq_set_type(unsigned int irq, unsigned int type)
 
        spin_lock_irqsave(&nmk_chip->lock, flags);
 
+       if (enabled)
+               __nmk_gpio_irq_modify(nmk_chip, gpio, false);
+
        nmk_chip->edge_rising &= ~bitmask;
        if (type & IRQ_TYPE_EDGE_RISING)
                nmk_chip->edge_rising |= bitmask;
-       writel(nmk_chip->edge_rising, nmk_chip->addr + NMK_GPIO_RIMSC);
 
        nmk_chip->edge_falling &= ~bitmask;
        if (type & IRQ_TYPE_EDGE_FALLING)
                nmk_chip->edge_falling |= bitmask;
-       writel(nmk_chip->edge_falling, nmk_chip->addr + NMK_GPIO_FIMSC);
 
-       spin_unlock_irqrestore(&nmk_chip->lock, flags);
+       if (enabled)
+               __nmk_gpio_irq_modify(nmk_chip, gpio, true);
 
-       nmk_gpio_irq_unmask(irq);
+       spin_unlock_irqrestore(&nmk_chip->lock, flags);
 
        return 0;
 }
@@ -242,6 +245,7 @@ static int nmk_gpio_init_irq(struct nmk_gpio_chip *nmk_chip)
                set_irq_handler(i, handle_edge_irq);
                set_irq_flags(i, IRQF_VALID);
                set_irq_chip_data(i, nmk_chip);
+               set_irq_type(i, IRQ_TYPE_EDGE_FALLING);
        }
        set_irq_chained_handler(nmk_chip->parent_irq, nmk_gpio_irq_handler);
        set_irq_data(nmk_chip->parent_irq, nmk_chip);