+#ifdef CONFIG_PM
+static int nmk_gpio_pm(struct platform_device *dev, bool suspend)
+{
+ struct nmk_gpio_chip *nmk_chip = platform_get_drvdata(dev);
+ int i;
+ static const unsigned int regs[] = {
+ NMK_GPIO_DAT,
+ NMK_GPIO_PDIS,
+ NMK_GPIO_DIR,
+ NMK_GPIO_AFSLA,
+ NMK_GPIO_AFSLB,
+ NMK_GPIO_SLPC,
+ NMK_GPIO_RIMSC,
+ NMK_GPIO_FIMSC,
+ NMK_GPIO_RWIMSC,
+ NMK_GPIO_FWIMSC,
+ };
+
+ BUILD_BUG_ON(ARRAY_SIZE(nmk_chip->backup) != ARRAY_SIZE(regs));
+
+ /* XXX: is this sufficient? what about pull-up/down configuration? */
+
+ for (i = 0; i < ARRAY_SIZE(regs); i++) {
+ if (suspend)
+ nmk_chip->backup[i] = readl(nmk_chip->addr + regs[i]);
+ else
+ writel(nmk_chip->backup[i], nmk_chip->addr + regs[i]);
+ }
+
+ return 0;
+}
+
+static int nmk_gpio_suspend(struct platform_device *dev, pm_message_t state)
+{
+ return nmk_gpio_pm(dev, true);
+}
+
+static int nmk_gpio_resume(struct platform_device *dev)
+{
+ return nmk_gpio_pm(dev, false);
+}
+#else
+#define nmk_gpio_suspend NULL
+#define nmk_gpio_resume NULL
+#endif
+