]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/plat-omap/gpio-switch.c
Merge branch 'omap-clock-fixes' of git://git.pwsan.com/linux-2.6
[linux-2.6-omap-h63xx.git] / arch / arm / plat-omap / gpio-switch.c
index f18f6df6212c77baf5c4b1135af716fb262aa0a6..9053ea08696d5c7c33d2ec25559abdc661f1ace5 100644 (file)
@@ -19,8 +19,8 @@
 #include <linux/platform_device.h>
 #include <linux/timer.h>
 #include <linux/err.h>
+#include <linux/gpio.h>
 #include <mach/hardware.h>
-#include <mach/gpio.h>
 #include <mach/irqs.h>
 #include <mach/mux.h>
 #include <mach/board.h>
@@ -278,7 +278,7 @@ static int __init new_switch(struct gpio_switch *sw)
        }
        dev_set_drvdata(&sw->pdev.dev, sw);
 
-       r = omap_request_gpio(sw->gpio);
+       r = gpio_request(sw->gpio, sw->name);
        if (r < 0) {
                platform_device_unregister(&sw->pdev);
                return r;
@@ -286,12 +286,17 @@ static int __init new_switch(struct gpio_switch *sw)
 
        /* input: 1, output: 0 */
        direction = !(sw->flags & OMAP_GPIO_SWITCH_FLAG_OUTPUT);
-       if (direction)
+       if (direction) {
                gpio_direction_input(sw->gpio);
-       else
-               gpio_direction_output(sw->gpio, true);
+               sw->state = gpio_sw_get_state(sw);
+       } else {
+               int state = sw->state = !!(sw->flags &
+                       OMAP_GPIO_SWITCH_FLAG_OUTPUT_INIT_ACTIVE);
 
-       sw->state = gpio_sw_get_state(sw);
+               if (sw->flags & OMAP_GPIO_SWITCH_FLAG_INVERTED)
+                       state = !state;
+               gpio_direction_output(sw->gpio, state);
+       }
 
        r = 0;
        r |= device_create_file(&sw->pdev.dev, &dev_attr_state);
@@ -319,7 +324,7 @@ static int __init new_switch(struct gpio_switch *sw)
                printk(KERN_ERR "gpio-switch: request_irq() failed "
                       "for GPIO %d\n", sw->gpio);
                platform_device_unregister(&sw->pdev);
-               omap_free_gpio(sw->gpio);
+               gpio_free(sw->gpio);
                return r;
        }
 
@@ -455,7 +460,7 @@ static void gpio_sw_cleanup(void)
                device_remove_file(&sw->pdev.dev, &dev_attr_direction);
 
                platform_device_unregister(&sw->pdev);
-               omap_free_gpio(sw->gpio);
+               gpio_free(sw->gpio);
                old = sw;
        }
        kfree(old);