mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:46:16 +00:00
iio: chemical: ens160: add power management support
ENS160 supports a deep sleep mode for minimal power consumption. Use it to add PM sleep capability to the driver. Signed-off-by: Gustavo Silva <gustavograzs@gmail.com> Link: https://lore.kernel.org/r/20240604225747.7212-6-gustavograzs@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
0fc26596b4
commit
d12b7d6ede
@ -4,4 +4,7 @@
|
||||
|
||||
int devm_ens160_core_probe(struct device *dev, struct regmap *regmap, int irq,
|
||||
const char *name);
|
||||
|
||||
extern const struct dev_pm_ops ens160_pm_ops;
|
||||
|
||||
#endif
|
||||
|
@ -220,6 +220,29 @@ static const struct iio_info ens160_info = {
|
||||
.read_raw = ens160_read_raw,
|
||||
};
|
||||
|
||||
static int ens160_suspend(struct device *dev)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct ens160_data *data = iio_priv(indio_dev);
|
||||
|
||||
return ens160_set_mode(data, ENS160_REG_MODE_DEEP_SLEEP);
|
||||
}
|
||||
|
||||
static int ens160_resume(struct device *dev)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct ens160_data *data = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
ret = ens160_set_mode(data, ENS160_REG_MODE_IDLE);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return ens160_set_mode(data, ENS160_REG_MODE_STANDARD);
|
||||
}
|
||||
EXPORT_NS_SIMPLE_DEV_PM_OPS(ens160_pm_ops, ens160_suspend, ens160_resume,
|
||||
IIO_ENS160);
|
||||
|
||||
static irqreturn_t ens160_trigger_handler(int irq, void *p)
|
||||
{
|
||||
struct iio_poll_func *pf = p;
|
||||
|
@ -49,6 +49,7 @@ static struct i2c_driver ens160_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "ens160",
|
||||
.of_match_table = ens160_of_i2c_match,
|
||||
.pm = pm_sleep_ptr(&ens160_pm_ops),
|
||||
},
|
||||
.probe = ens160_i2c_probe,
|
||||
.id_table = ens160_i2c_id,
|
||||
|
@ -48,6 +48,7 @@ static struct spi_driver ens160_spi_driver = {
|
||||
.driver = {
|
||||
.name = "ens160",
|
||||
.of_match_table = ens160_spi_of_match,
|
||||
.pm = pm_sleep_ptr(&ens160_pm_ops),
|
||||
},
|
||||
.probe = ens160_spi_probe,
|
||||
.id_table = ens160_spi_id,
|
||||
|
Loading…
Reference in New Issue
Block a user