summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark A. Greer <mgreer@animalcreek.com>2014-09-02 22:12:37 (GMT)
committerSamuel Ortiz <sameo@linux.intel.com>2014-09-07 21:13:44 (GMT)
commit77c9539dc1284677539af442ac3629c9baf01202 (patch)
treef986216ebf2a7fb67124595023d3476b5bd793ca
parentb528281b8b7a9c379baf37720191a799fbc9800c (diff)
downloadlinux-77c9539dc1284677539af442ac3629c9baf01202.tar.xz
NFC: trf7970a: Add System Suspend/Resume support
Add system suspend/resume support by gracefully shutting things down when suspending and bringing the device back to full power when resuming. Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/nfc/trf7970a.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index a42675d..3859e02 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -1594,6 +1594,42 @@ static int trf7970a_remove(struct spi_device *spi)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int trf7970a_suspend(struct device *dev)
+{
+ struct spi_device *spi = container_of(dev, struct spi_device, dev);
+ struct trf7970a *trf = spi_get_drvdata(spi);
+ int ret = 0;
+
+ dev_dbg(dev, "Suspend\n");
+
+ mutex_lock(&trf->lock);
+
+ trf7970a_shutdown(trf);
+
+ mutex_unlock(&trf->lock);
+
+ return ret;
+}
+
+static int trf7970a_resume(struct device *dev)
+{
+ struct spi_device *spi = container_of(dev, struct spi_device, dev);
+ struct trf7970a *trf = spi_get_drvdata(spi);
+ int ret = 0;
+
+ dev_dbg(dev, "Resume\n");
+
+ mutex_lock(&trf->lock);
+
+ ret = trf7970a_startup(trf);
+
+ mutex_unlock(&trf->lock);
+
+ return ret;
+}
+#endif
+
#ifdef CONFIG_PM_RUNTIME
static int trf7970a_pm_runtime_suspend(struct device *dev)
{
@@ -1629,6 +1665,7 @@ static int trf7970a_pm_runtime_resume(struct device *dev)
#endif
static const struct dev_pm_ops trf7970a_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(trf7970a_suspend, trf7970a_resume)
SET_RUNTIME_PM_OPS(trf7970a_pm_runtime_suspend,
trf7970a_pm_runtime_resume, NULL)
};