Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/upstream-linus
[pandora-kernel.git] / arch / arm / mach-pxa / mioa701.c
index dd13bb6..aa67637 100644 (file)
@@ -22,7 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/sysdev.h>
+#include <linux/syscore_ops.h>
 #include <linux/input.h>
 #include <linux/delay.h>
 #include <linux/gpio_keys.h>
@@ -177,50 +177,6 @@ static unsigned long mioa701_pin_config[] = {
        MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH),
 };
 
-#define MIO_GPIO_IN(num, _desc) \
-       { .gpio = (num), .dir = 0, .desc = (_desc) }
-#define MIO_GPIO_OUT(num, _init, _desc) \
-       { .gpio = (num), .dir = 1, .init = (_init), .desc = (_desc) }
-struct gpio_ress {
-       unsigned gpio : 8;
-       unsigned dir : 1;
-       unsigned init : 1;
-       char *desc;
-};
-
-static int mio_gpio_request(struct gpio_ress *gpios, int size)
-{
-       int i, rc = 0;
-       int gpio;
-       int dir;
-
-       for (i = 0; (!rc) && (i < size); i++) {
-               gpio = gpios[i].gpio;
-               dir = gpios[i].dir;
-               rc = gpio_request(gpio, gpios[i].desc);
-               if (rc) {
-                       printk(KERN_ERR "Error requesting GPIO %d(%s) : %d\n",
-                              gpio, gpios[i].desc, rc);
-                       continue;
-               }
-               if (dir)
-                       gpio_direction_output(gpio, gpios[i].init);
-               else
-                       gpio_direction_input(gpio);
-       }
-       while ((rc) && (--i >= 0))
-               gpio_free(gpios[i].gpio);
-       return rc;
-}
-
-static void mio_gpio_free(struct gpio_ress *gpios, int size)
-{
-       int i;
-
-       for (i = 0; i < size; i++)
-               gpio_free(gpios[i].gpio);
-}
-
 /* LCD Screen and Backlight */
 static struct platform_pwm_backlight_data mioa701_backlight_data = {
        .pwm_id         = 0,
@@ -346,16 +302,16 @@ irqreturn_t gsm_on_irq(int irq, void *p)
        return IRQ_HANDLED;
 }
 
-struct gpio_ress gsm_gpios[] = {
-       MIO_GPIO_IN(GPIO25_GSM_MOD_ON_STATE, "GSM state"),
-       MIO_GPIO_IN(GPIO113_GSM_EVENT, "GSM event"),
+static struct gpio gsm_gpios[] = {
+       { GPIO25_GSM_MOD_ON_STATE, GPIOF_IN, "GSM state" },
+       { GPIO113_GSM_EVENT, GPIOF_IN, "GSM event" },
 };
 
 static int __init gsm_init(void)
 {
        int rc;
 
-       rc = mio_gpio_request(ARRAY_AND_SIZE(gsm_gpios));
+       rc = gpio_request_array(ARRAY_AND_SIZE(gsm_gpios));
        if (rc)
                goto err_gpio;
        rc = request_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), gsm_on_irq,
@@ -369,7 +325,7 @@ static int __init gsm_init(void)
 
 err_irq:
        printk(KERN_ERR "Mioa701: Can't request GSM_ON irq\n");
-       mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios));
+       gpio_free_array(ARRAY_AND_SIZE(gsm_gpios));
 err_gpio:
        printk(KERN_ERR "Mioa701: gsm not available\n");
        return rc;
@@ -378,7 +334,7 @@ err_gpio:
 static void gsm_exit(void)
 {
        free_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), NULL);
-       mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios));
+       gpio_free_array(ARRAY_AND_SIZE(gsm_gpios));
 }
 
 /*
@@ -458,7 +414,7 @@ static struct platform_device strataflash = {
 /*
  * Suspend/Resume bootstrap management
  *
- * MIO A701 reboot sequence is highly ROM dependant. From the one dissassembled,
+ * MIO A701 reboot sequence is highly ROM dependent. From the one dissassembled,
  * this sequence is as follows :
  *   - disables interrupts
  *   - initialize SDRAM (self refresh RAM into active RAM)
@@ -488,7 +444,7 @@ static void install_bootstrap(void)
 }
 
 
-static int mioa701_sys_suspend(struct sys_device *sysdev, pm_message_t state)
+static int mioa701_sys_suspend(void)
 {
        int i = 0, is_bt_on;
        u32 *mem_resume_vector  = phys_to_virt(RESUME_VECTOR_ADDR);
@@ -514,7 +470,7 @@ static int mioa701_sys_suspend(struct sys_device *sysdev, pm_message_t state)
        return 0;
 }
 
-static int mioa701_sys_resume(struct sys_device *sysdev)
+static void mioa701_sys_resume(void)
 {
        int i = 0;
        u32 *mem_resume_vector  = phys_to_virt(RESUME_VECTOR_ADDR);
@@ -527,43 +483,18 @@ static int mioa701_sys_resume(struct sys_device *sysdev)
        *mem_resume_enabler = save_buffer[i++];
        *mem_resume_bt      = save_buffer[i++];
        *mem_resume_unknown = save_buffer[i++];
-
-       return 0;
 }
 
-static struct sysdev_class mioa701_sysclass = {
-       .name = "mioa701",
-};
-
-static struct sys_device sysdev_bootstrap = {
-       .cls            = &mioa701_sysclass,
-};
-
-static struct sysdev_driver driver_bootstrap = {
-       .suspend        = &mioa701_sys_suspend,
-       .resume         = &mioa701_sys_resume,
+static struct syscore_ops mioa701_syscore_ops = {
+       .suspend        = mioa701_sys_suspend,
+       .resume         = mioa701_sys_resume,
 };
 
 static int __init bootstrap_init(void)
 {
-       int rc;
        int save_size = mioa701_bootstrap_lg + (sizeof(u32) * 3);
 
-       rc = sysdev_class_register(&mioa701_sysclass);
-       if (rc) {
-               printk(KERN_ERR "Failed registering mioa701 sys class\n");
-               return -ENODEV;
-       }
-       rc = sysdev_register(&sysdev_bootstrap);
-       if (rc) {
-               printk(KERN_ERR "Failed registering mioa701 sys device\n");
-               return -ENODEV;
-       }
-       rc = sysdev_driver_register(&mioa701_sysclass, &driver_bootstrap);
-       if (rc) {
-               printk(KERN_ERR "Failed registering PMU sys driver\n");
-               return -ENODEV;
-       }
+       register_syscore_ops(&mioa701_syscore_ops);
 
        save_buffer = kmalloc(save_size, GFP_KERNEL);
        if (!save_buffer)
@@ -576,9 +507,7 @@ static int __init bootstrap_init(void)
 static void bootstrap_exit(void)
 {
        kfree(save_buffer);
-       sysdev_driver_unregister(&mioa701_sysclass, &driver_bootstrap);
-       sysdev_unregister(&sysdev_bootstrap);
-       sysdev_class_unregister(&mioa701_sysclass);
+       unregister_syscore_ops(&mioa701_syscore_ops);
 
        printk(KERN_CRIT "Unregistering mioa701 suspend will hang next"
               "resume !!!\n");
@@ -776,14 +705,16 @@ static void mioa701_restart(char c, const char *cmd)
        arm_machine_restart('s', cmd);
 }
 
-static struct gpio_ress global_gpios[] = {
-       MIO_GPIO_OUT(GPIO9_CHARGE_EN, 1, "Charger enable"),
-       MIO_GPIO_OUT(GPIO18_POWEROFF, 0, "Power Off"),
-       MIO_GPIO_OUT(GPIO87_LCD_POWER, 0, "LCD Power"),
+static struct gpio global_gpios[] = {
+       { GPIO9_CHARGE_EN, GPIOF_OUT_INIT_HIGH, "Charger enable" },
+       { GPIO18_POWEROFF, GPIOF_OUT_INIT_LOW, "Power Off" },
+       { GPIO87_LCD_POWER, GPIOF_OUT_INIT_LOW, "LCD Power" },
 };
 
 static void __init mioa701_machine_init(void)
 {
+       int rc;
+
        PSLR  = 0xff100000; /* SYSDEL=125ms, PWRDEL=125ms, PSLR_SL_ROD=1 */
        PCFR = PCFR_DC_EN | PCFR_GPR_EN | PCFR_OPDE;
        RTTR = 32768 - 1; /* Reset crazy WinCE value */
@@ -793,7 +724,9 @@ static void __init mioa701_machine_init(void)
        pxa_set_ffuart_info(NULL);
        pxa_set_btuart_info(NULL);
        pxa_set_stuart_info(NULL);
-       mio_gpio_request(ARRAY_AND_SIZE(global_gpios));
+       rc = gpio_request_array(ARRAY_AND_SIZE(global_gpios));
+       if (rc)
+               pr_err("MioA701: Failed to request GPIOs: %d", rc);
        bootstrap_init();
        pxa_set_fb_info(NULL, &mioa701_pxafb_info);
        pxa_set_mci_info(&mioa701_mci_info);