]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
i2c: xilinx_i2cps: Implement supend/resume callbacks
authorSoren Brinkmann <soren.brinkmann@xilinx.com>
Mon, 26 Nov 2012 17:28:46 +0000 (09:28 -0800)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 27 Nov 2012 12:11:58 +0000 (13:11 +0100)
In order to support system suspend the corresponding callbacks
are implemented.

Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
drivers/i2c/busses/i2c-xilinx_ps.c

index 32cff5abc30cfe3241def76b608072a7cd073582..50744aedcae723407d1335c45cfd9bb2fed9d12a 100644 (file)
@@ -737,6 +737,57 @@ static int xi2cps_clk_notifier_cb(struct notifier_block *nb, unsigned long
        }
 }
 
+#ifdef CONFIG_PM_SLEEP
+/**
+ * xi2cps_suspend - Suspend method for the driver
+ * @dev:       Address of the platform_device structure
+ * Returns 0 on success and error value on error
+ *
+ * Put the driver into low power mode.
+ */
+static int xi2cps_suspend(struct device *_dev)
+{
+       struct platform_device *pdev = container_of(_dev,
+                       struct platform_device, dev);
+       struct xi2cps *xi2c = platform_get_drvdata(pdev);
+
+       clk_disable(xi2c->clk);
+
+       return 0;
+}
+
+/**
+ * xi2cps_resume - Resume from suspend
+ * @dev:       Address of the platform_device structure
+ * Returns 0 on success and error value on error
+ *
+ * Resume operation after suspend.
+ */
+static int xi2cps_resume(struct device *_dev)
+{
+       struct platform_device *pdev = container_of(_dev,
+                       struct platform_device, dev);
+       struct xi2cps *xi2c = platform_get_drvdata(pdev);
+       int ret;
+
+       ret = clk_enable(xi2c->clk);
+       if (ret) {
+               dev_err(_dev, "Cannot enable clock.\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+static const struct dev_pm_ops xi2cps_dev_pm_ops = {
+       SET_SYSTEM_SLEEP_PM_OPS(xi2cps_suspend, xi2cps_resume)
+};
+#define XI2CPS_PM      (&xi2cps_dev_pm_ops)
+
+#else /* ! CONFIG_PM_SLEEP */
+#define XI2CPS_PM      NULL
+#endif /* ! CONFIG_PM_SLEEP */
+
 /************************/
 /* Platform bus binding */
 /************************/
@@ -924,6 +975,7 @@ static struct platform_driver xi2cps_drv = {
                .name  = DRIVER_NAME,
                .owner = THIS_MODULE,
                .of_match_table = xi2cps_of_match,
+               .pm = XI2CPS_PM,
        },
        .probe  = xi2cps_probe,
        .remove = __devexit_p(xi2cps_remove),