Merge branch 'acpi-hotplug'
[deliverable/linux.git] / arch / arm / mach-ixp4xx / dsmg600-setup.c
index 63de1b3fd06bf0327549cf7670761ac7bccf7298..736dc692d54047b7f56e0b409fda416662252ad1 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/reboot.h>
 #include <linux/i2c.h>
 #include <linux/i2c-gpio.h>
+#include <linux/gpio.h>
 
 #include <mach/hardware.h>
 
@@ -161,11 +162,8 @@ static struct platform_device *dsmg600_devices[] __initdata = {
 
 static void dsmg600_power_off(void)
 {
-       /* enable the pwr cntl gpio */
-       gpio_line_config(DSMG600_PO_GPIO, IXP4XX_GPIO_OUT);
-
-       /* poweroff */
-       gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH);
+       /* enable the pwr cntl and drive it high */
+       gpio_direction_output(DSMG600_PO_GPIO, 1);
 }
 
 /* This is used to make sure the power-button pusher is serious.  The button
@@ -202,7 +200,7 @@ static void dsmg600_power_handler(unsigned long data)
                        ctrl_alt_del();
 
                        /* Change the state of the power LED to "blink" */
-                       gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
+                       gpio_set_value(DSMG600_LED_PWR_GPIO, 0);
                } else {
                        power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
                }
@@ -228,6 +226,40 @@ static void __init dsmg600_timer_init(void)
     ixp4xx_timer_init();
 }
 
+static int __init dsmg600_gpio_init(void)
+{
+       if (!machine_is_dsmg600())
+               return 0;
+
+       gpio_request(DSMG600_RB_GPIO, "reset button");
+       if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
+               IRQF_DISABLED | IRQF_TRIGGER_LOW,
+               "DSM-G600 reset button", NULL) < 0) {
+
+               printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
+                       gpio_to_irq(DSMG600_RB_GPIO));
+       }
+
+       /*
+        * The power button on the D-Link DSM-G600 is on GPIO 15, but
+        * it cannot handle interrupts on that GPIO line.  So we'll
+        * have to poll it with a kernel timer.
+        */
+
+       /* Make sure that the power button GPIO is set up as an input */
+       gpio_request(DSMG600_PB_GPIO, "power button");
+       gpio_direction_input(DSMG600_PB_GPIO);
+       /* Request poweroff GPIO line */
+       gpio_request(DSMG600_PO_GPIO, "power off button");
+
+       /* Set the initial value for the power button IRQ handler */
+       power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
+
+       mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
+       return 0;
+}
+device_initcall(dsmg600_gpio_init);
+
 static void __init dsmg600_init(void)
 {
        ixp4xx_sys_init();
@@ -251,27 +283,6 @@ static void __init dsmg600_init(void)
        platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
 
        pm_power_off = dsmg600_power_off;
-
-       if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
-               IRQF_DISABLED | IRQF_TRIGGER_LOW,
-               "DSM-G600 reset button", NULL) < 0) {
-
-               printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
-                       gpio_to_irq(DSMG600_RB_GPIO));
-       }
-
-       /* The power button on the D-Link DSM-G600 is on GPIO 15, but
-        * it cannot handle interrupts on that GPIO line.  So we'll
-        * have to poll it with a kernel timer.
-        */
-
-       /* Make sure that the power button GPIO is set up as an input */
-       gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN);
-
-       /* Set the initial value for the power button IRQ handler */
-       power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
-
-       mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
 }
 
 MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
This page took 0.030846 seconds and 5 git commands to generate.