[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240910045030.266946-3-abhashkumarjha123@gmail.com>
Date: Tue, 10 Sep 2024 10:20:27 +0530
From: Abhash Jha <abhashkumarjha123@...il.com>
To: linux-iio@...r.kernel.org
Cc: anshulusr@...il.com,
jic23@...nel.org,
lars@...afoo.de,
linux-kernel@...r.kernel.org,
Abhash Jha <abhashkumarjha123@...il.com>
Subject: [PATCH v2 2/4] 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@...il.com>
---
drivers/iio/light/ltr390.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/iio/light/ltr390.c b/drivers/iio/light/ltr390.c
index 73ef4a5a0..c4ff26d68 100644
--- a/drivers/iio/light/ltr390.c
+++ b/drivers/iio/light/ltr390.c
@@ -432,6 +432,24 @@ static int ltr390_probe(struct i2c_client *client)
return devm_iio_device_register(dev, indio_dev);
}
+static int ltr390_suspend(struct device *dev)
+{
+ struct ltr390_data *data = iio_priv(i2c_get_clientdata(
+ to_i2c_client(dev)));
+
+ return regmap_clear_bits(data->regmap, LTR390_MAIN_CTRL, LTR390_SENSOR_ENABLE);
+}
+
+static int ltr390_resume(struct device *dev)
+{
+ struct ltr390_data *data = iio_priv(i2c_get_clientdata(
+ to_i2c_client(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 */ }
@@ -448,6 +466,7 @@ static struct i2c_driver ltr390_driver = {
.driver = {
.name = "ltr390",
.of_match_table = ltr390_of_table,
+ .pm = pm_sleep_ptr(<r390_pm_ops),
},
.probe = ltr390_probe,
.id_table = ltr390_id,
--
2.43.0
Powered by blists - more mailing lists