summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhash Jha <abhashkumarjha123@gmail.com>2024-09-14 23:42:44 +0530
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2024-10-05 12:09:14 +0100
commit288ce72fb5fce63792d90b74bee4379cc2938ff9 (patch)
treeb5654b5c54ee675c22c92c27cef001d72a2728c7
parentbd7057bb94887f475f1cbedbc77cede274be7547 (diff)
iio: light: ltr390: Suspend and Resume support
Added support for suspend and resume PM ops. We suspend the sensor by clearing the ALS_UVS_EN bit in the MAIN CONTROL register. And we resume it by setting that bit. Signed-off-by: Abhash Jha <abhashkumarjha123@gmail.com> Link: https://patch.msgid.link/20240914181246.504450-3-abhashkumarjha123@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/light/ltr390.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/iio/light/ltr390.c b/drivers/iio/light/ltr390.c
index c50ea31e2316..6c2425f0ba22 100644
--- a/drivers/iio/light/ltr390.c
+++ b/drivers/iio/light/ltr390.c
@@ -18,6 +18,7 @@
* - Interrupt support
*/
+#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/math.h>
#include <linux/module.h>
@@ -430,6 +431,26 @@ static int ltr390_probe(struct i2c_client *client)
return devm_iio_device_register(dev, indio_dev);
}
+static int ltr390_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct ltr390_data *data = iio_priv(indio_dev);
+
+ return regmap_clear_bits(data->regmap, LTR390_MAIN_CTRL,
+ LTR390_SENSOR_ENABLE);
+}
+
+static int ltr390_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct ltr390_data *data = iio_priv(indio_dev);
+
+ return regmap_set_bits(data->regmap, LTR390_MAIN_CTRL,
+ LTR390_SENSOR_ENABLE);
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(ltr390_pm_ops, ltr390_suspend, ltr390_resume);
+
static const struct i2c_device_id ltr390_id[] = {
{ "ltr390" },
{ /* Sentinel */ }
@@ -446,6 +467,7 @@ static struct i2c_driver ltr390_driver = {
.driver = {
.name = "ltr390",
.of_match_table = ltr390_of_table,
+ .pm = pm_sleep_ptr(&ltr390_pm_ops),
},
.probe = ltr390_probe,
.id_table = ltr390_id,