]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/video/via/via-gpio.c
viafb: suspend/resume for GPIOs
[mirror_ubuntu-zesty-kernel.git] / drivers / video / via / via-gpio.c
index 595516aea6917dc5f19d5e725e139b07c7f00512..c2a0a1cfd3b3fe6c9f2da44e8574fe9a20591be5 100644 (file)
@@ -73,7 +73,7 @@ struct viafb_gpio_cfg {
        struct gpio_chip gpio_chip;
        struct viafb_dev *vdev;
        struct viafb_gpio *active_gpios[VIAFB_NUM_GPIOS];
-       char *gpio_names[VIAFB_NUM_GPIOS];
+       const char *gpio_names[VIAFB_NUM_GPIOS];
 };
 
 /*
@@ -172,6 +172,28 @@ static void viafb_gpio_disable(struct viafb_gpio *gpio)
        via_write_reg_mask(VIASR, gpio->vg_port_index, 0, 0x02);
 }
 
+#ifdef CONFIG_PM
+
+static int viafb_gpio_suspend(void *private)
+{
+       return 0;
+}
+
+static int viafb_gpio_resume(void *private)
+{
+       int i;
+
+       for (i = 0; i < gpio_config.gpio_chip.ngpio; i += 2)
+               viafb_gpio_enable(gpio_config.active_gpios[i]);
+       return 0;
+}
+
+static struct viafb_pm_hooks viafb_gpio_pm_hooks = {
+       .suspend = viafb_gpio_suspend,
+       .resume = viafb_gpio_resume
+};
+#endif /* CONFIG_PM */
+
 /*
  * Look up a specific gpio and return the number it was assigned.
  */
@@ -236,6 +258,9 @@ static __devinit int viafb_gpio_probe(struct platform_device *platdev)
                printk(KERN_ERR "viafb: failed to add gpios (%d)\n", ret);
                gpio_config.gpio_chip.ngpio = 0;
        }
+#ifdef CONFIG_PM
+       viafb_pm_register(&viafb_gpio_pm_hooks);
+#endif
        return ret;
 }
 
@@ -245,6 +270,10 @@ static int viafb_gpio_remove(struct platform_device *platdev)
        unsigned long flags;
        int ret = 0, i;
 
+#ifdef CONFIG_PM
+       viafb_pm_unregister(&viafb_gpio_pm_hooks);
+#endif
+
        /*
         * Get unregistered.
         */