diff options
author | Daniel Baluta <daniel.baluta@intel.com> | 2014-12-03 08:31:51 -0500 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-12-12 08:45:14 -0500 |
commit | 3b9c40e604ee61e69a8aff6e1a426a6250ff4361 (patch) | |
tree | 1d7eabf139797a6e9918ddc38a8b497494d4a163 /drivers/iio | |
parent | aff8609addd00efa3d907f3523823693f95686fd (diff) |
iio: imu: kmx61: Add PM sleep support
Per sensor state (ACTIVE/STANDBY) is saved in driver's
private data (acc_stby/mag_stby) and restored when
resume is called.
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/imu/kmx61.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c index f3007dd664fc..98d58e1b6c6b 100644 --- a/drivers/iio/imu/kmx61.c +++ b/drivers/iio/imu/kmx61.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/acpi.h> | 16 | #include <linux/acpi.h> |
17 | #include <linux/gpio/consumer.h> | 17 | #include <linux/gpio/consumer.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/pm.h> | ||
19 | #include <linux/pm_runtime.h> | 20 | #include <linux/pm_runtime.h> |
20 | #include <linux/iio/iio.h> | 21 | #include <linux/iio/iio.h> |
21 | #include <linux/iio/sysfs.h> | 22 | #include <linux/iio/sysfs.h> |
@@ -796,6 +797,33 @@ static int kmx61_remove(struct i2c_client *client) | |||
796 | return 0; | 797 | return 0; |
797 | } | 798 | } |
798 | 799 | ||
800 | #ifdef CONFIG_PM_SLEEP | ||
801 | static int kmx61_suspend(struct device *dev) | ||
802 | { | ||
803 | int ret; | ||
804 | struct kmx61_data *data = i2c_get_clientdata(to_i2c_client(dev)); | ||
805 | |||
806 | mutex_lock(&data->lock); | ||
807 | ret = kmx61_set_mode(data, KMX61_ALL_STBY, KMX61_ACC | KMX61_MAG, | ||
808 | false); | ||
809 | mutex_unlock(&data->lock); | ||
810 | |||
811 | return ret; | ||
812 | } | ||
813 | |||
814 | static int kmx61_resume(struct device *dev) | ||
815 | { | ||
816 | u8 stby = 0; | ||
817 | struct kmx61_data *data = i2c_get_clientdata(to_i2c_client(dev)); | ||
818 | |||
819 | if (data->acc_stby) | ||
820 | stby |= KMX61_ACC_STBY_BIT; | ||
821 | if (data->mag_stby) | ||
822 | stby |= KMX61_MAG_STBY_BIT; | ||
823 | |||
824 | return kmx61_set_mode(data, stby, KMX61_ACC | KMX61_MAG, true); | ||
825 | } | ||
826 | #endif | ||
799 | 827 | ||
800 | #ifdef CONFIG_PM_RUNTIME | 828 | #ifdef CONFIG_PM_RUNTIME |
801 | static int kmx61_runtime_suspend(struct device *dev) | 829 | static int kmx61_runtime_suspend(struct device *dev) |
@@ -825,6 +853,7 @@ static int kmx61_runtime_resume(struct device *dev) | |||
825 | #endif | 853 | #endif |
826 | 854 | ||
827 | static const struct dev_pm_ops kmx61_pm_ops = { | 855 | static const struct dev_pm_ops kmx61_pm_ops = { |
856 | SET_SYSTEM_SLEEP_PM_OPS(kmx61_suspend, kmx61_resume) | ||
828 | SET_RUNTIME_PM_OPS(kmx61_runtime_suspend, kmx61_runtime_resume, NULL) | 857 | SET_RUNTIME_PM_OPS(kmx61_runtime_suspend, kmx61_runtime_resume, NULL) |
829 | }; | 858 | }; |
830 | 859 | ||