Merge branch 'merge'
[pandora-kernel.git] / sound / aoa / core / snd-aoa-gpio-feature.c
index 2c6eb77..7c26089 100644 (file)
@@ -56,7 +56,7 @@ static struct device_node *get_gpio(char *name,
 {
        struct device_node *np, *gpio;
        u32 *reg;
-       char *audio_gpio;
+       const char *audio_gpio;
 
        *gpioptr = -1;
 
@@ -112,12 +112,10 @@ static struct device_node *get_gpio(char *name,
 
 static void get_irq(struct device_node * np, int *irqptr)
 {
-       *irqptr = -1;
-       if (!np)
-               return;
-       if (np->n_intrs != 1)
-               return;
-       *irqptr = np->intrs[0].line;
+       if (np)
+               *irqptr = irq_of_parse_and_map(np, 0);
+       else
+               *irqptr = NO_IRQ;
 }
 
 /* 0x4 is outenable, 0x1 is out, thus 4 or 5 */
@@ -207,6 +205,17 @@ static void ftr_handle_notify(void *data)
        mutex_unlock(&notif->mutex);
 }
 
+static void gpio_enable_dual_edge(int gpio)
+{
+       int v;
+
+       if (gpio == -1)
+               return;
+       v = pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, gpio, 0);
+       v |= 0x80; /* enable dual edge */
+       pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, gpio, v);
+}
+
 static void ftr_gpio_init(struct gpio_runtime *rt)
 {
        get_gpio("headphone-mute", NULL,
@@ -234,6 +243,10 @@ static void ftr_gpio_init(struct gpio_runtime *rt)
                                      &linein_detect_gpio,
                                      &linein_detect_gpio_activestate);
 
+       gpio_enable_dual_edge(headphone_detect_gpio);
+       gpio_enable_dual_edge(lineout_detect_gpio);
+       gpio_enable_dual_edge(linein_detect_gpio);
+
        get_irq(headphone_detect_node, &headphone_detect_irq);
        get_irq(lineout_detect_node, &lineout_detect_irq);
        get_irq(linein_detect_node, &linein_detect_irq);
@@ -312,7 +325,7 @@ static int ftr_set_notify(struct gpio_runtime *rt,
                return -EINVAL;
        }
 
-       if (irq == -1)
+       if (irq == NO_IRQ)
                return -ENODEV;
 
        mutex_lock(&notif->mutex);