Merge branch 'next' into for-linus
[sfrench/cifs-2.6.git] / drivers / input / keyboard / imx_keypad.c
index 539cb670de41d6955e6ea5353749dac27d96b798..97500a2de2d5123a7f1c7a9dd40abdcc54ba4e3a 100644 (file)
@@ -422,7 +422,6 @@ static int imx_keypad_probe(struct platform_device *pdev)
                        dev_get_platdata(&pdev->dev);
        struct imx_keypad *keypad;
        struct input_dev *input_dev;
-       struct resource *res;
        int irq, error, i, row, col;
 
        if (!keymap_data && !pdev->dev.of_node) {
@@ -455,8 +454,7 @@ static int imx_keypad_probe(struct platform_device *pdev)
        timer_setup(&keypad->check_matrix_timer,
                    imx_keypad_check_for_events, 0);
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res);
+       keypad->mmio_base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(keypad->mmio_base))
                return PTR_ERR(keypad->mmio_base);
 
@@ -526,11 +524,12 @@ static int imx_keypad_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int __maybe_unused imx_kbd_suspend(struct device *dev)
+static int __maybe_unused imx_kbd_noirq_suspend(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct imx_keypad *kbd = platform_get_drvdata(pdev);
        struct input_dev *input_dev = kbd->input_dev;
+       unsigned short reg_val = readw(kbd->mmio_base + KPSR);
 
        /* imx kbd can wake up system even clock is disabled */
        mutex_lock(&input_dev->mutex);
@@ -540,13 +539,20 @@ static int __maybe_unused imx_kbd_suspend(struct device *dev)
 
        mutex_unlock(&input_dev->mutex);
 
-       if (device_may_wakeup(&pdev->dev))
+       if (device_may_wakeup(&pdev->dev)) {
+               if (reg_val & KBD_STAT_KPKD)
+                       reg_val |= KBD_STAT_KRIE;
+               if (reg_val & KBD_STAT_KPKR)
+                       reg_val |= KBD_STAT_KDIE;
+               writew(reg_val, kbd->mmio_base + KPSR);
+
                enable_irq_wake(kbd->irq);
+       }
 
        return 0;
 }
 
-static int __maybe_unused imx_kbd_resume(struct device *dev)
+static int __maybe_unused imx_kbd_noirq_resume(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct imx_keypad *kbd = platform_get_drvdata(pdev);
@@ -570,7 +576,9 @@ err_clk:
        return ret;
 }
 
-static SIMPLE_DEV_PM_OPS(imx_kbd_pm_ops, imx_kbd_suspend, imx_kbd_resume);
+static const struct dev_pm_ops imx_kbd_pm_ops = {
+       SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(imx_kbd_noirq_suspend, imx_kbd_noirq_resume)
+};
 
 static struct platform_driver imx_keypad_driver = {
        .driver         = {