mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 02:24:24 +02:00
iio: accel: bma220: add i2c watchdog feature
Sometimes the sensor gets stuck and enters a condition in which it pulls SDA low, thus making the entire i2c bus unusable. This problem is mitigated by activating a 1ms watchdog implemented in the sensor. Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
7a23e6d922
commit
3499375209
|
|
@ -11,6 +11,7 @@
|
|||
#include <linux/cleanup.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mutex.h>
|
||||
|
|
@ -356,6 +357,12 @@ static int bma220_power(struct bma220_data *data, bool up)
|
|||
return -EBUSY;
|
||||
}
|
||||
|
||||
static int bma220_set_wdt(struct bma220_data *data, const u8 val)
|
||||
{
|
||||
return regmap_update_bits(data->regmap, BMA220_REG_WDT, BMA220_WDT_MASK,
|
||||
FIELD_PREP(BMA220_WDT_MASK, val));
|
||||
}
|
||||
|
||||
static int bma220_init(struct device *dev, struct bma220_data *data)
|
||||
{
|
||||
int ret;
|
||||
|
|
@ -384,6 +391,13 @@ static int bma220_init(struct device *dev, struct bma220_data *data)
|
|||
if (ret)
|
||||
return dev_err_probe(dev, ret, "Failed to soft reset chip\n");
|
||||
|
||||
if (i2c_verify_client(dev)) {
|
||||
ret = bma220_set_wdt(data, BMA220_WDT_1MS);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret,
|
||||
"Failed to set i2c watchdog\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user