mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-06 05:02:31 +00:00
iio: humidity: hdc3020: add reset management
The HDC3020 provides an active low reset signal that must be handled if connected. Asserting this signal turns the device into Trigger-on Demand measurement mode, reducing its power consumption when no measurements are required like in low-power modes. According to the datasheet, the longest "Reset Ready" is 3 ms, which is only taken into account if the reset signal is defined. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://lore.kernel.org/r/20240303-hdc3020-pm-v3-3-48bc02b5241b@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
137166ef5f
commit
e264b086f4
@ -15,6 +15,7 @@
|
|||||||
#include <linux/cleanup.h>
|
#include <linux/cleanup.h>
|
||||||
#include <linux/crc8.h>
|
#include <linux/crc8.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
@ -70,6 +71,7 @@
|
|||||||
|
|
||||||
struct hdc3020_data {
|
struct hdc3020_data {
|
||||||
struct i2c_client *client;
|
struct i2c_client *client;
|
||||||
|
struct gpio_desc *reset_gpio;
|
||||||
struct regulator *vdd_supply;
|
struct regulator *vdd_supply;
|
||||||
/*
|
/*
|
||||||
* Ensure that the sensor configuration (currently only heater is
|
* Ensure that the sensor configuration (currently only heater is
|
||||||
@ -558,6 +560,9 @@ static int hdc3020_power_off(struct hdc3020_data *data)
|
|||||||
{
|
{
|
||||||
hdc3020_exec_cmd(data, HDC3020_EXIT_AUTO);
|
hdc3020_exec_cmd(data, HDC3020_EXIT_AUTO);
|
||||||
|
|
||||||
|
if (data->reset_gpio)
|
||||||
|
gpiod_set_value_cansleep(data->reset_gpio, 1);
|
||||||
|
|
||||||
return regulator_disable(data->vdd_supply);
|
return regulator_disable(data->vdd_supply);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,6 +576,11 @@ static int hdc3020_power_on(struct hdc3020_data *data)
|
|||||||
|
|
||||||
fsleep(5000);
|
fsleep(5000);
|
||||||
|
|
||||||
|
if (data->reset_gpio) {
|
||||||
|
gpiod_set_value_cansleep(data->reset_gpio, 0);
|
||||||
|
fsleep(3000);
|
||||||
|
}
|
||||||
|
|
||||||
if (data->client->irq) {
|
if (data->client->irq) {
|
||||||
/*
|
/*
|
||||||
* The alert output is activated by default upon power up,
|
* The alert output is activated by default upon power up,
|
||||||
@ -627,6 +637,12 @@ static int hdc3020_probe(struct i2c_client *client)
|
|||||||
return dev_err_probe(&client->dev, PTR_ERR(data->vdd_supply),
|
return dev_err_probe(&client->dev, PTR_ERR(data->vdd_supply),
|
||||||
"Unable to get VDD regulator\n");
|
"Unable to get VDD regulator\n");
|
||||||
|
|
||||||
|
data->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
|
||||||
|
GPIOD_OUT_HIGH);
|
||||||
|
if (IS_ERR(data->reset_gpio))
|
||||||
|
return dev_err_probe(&client->dev, PTR_ERR(data->reset_gpio),
|
||||||
|
"Cannot get reset GPIO\n");
|
||||||
|
|
||||||
ret = hdc3020_power_on(data);
|
ret = hdc3020_power_on(data);
|
||||||
if (ret)
|
if (ret)
|
||||||
return dev_err_probe(&client->dev, ret, "Power on failed\n");
|
return dev_err_probe(&client->dev, ret, "Power on failed\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user