[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250910-bma220_improvements-v2-10-e23f4f2b9745@subdimension.ro>
Date: Wed, 10 Sep 2025 10:57:15 +0300
From: Petre Rodan <petre.rodan@...dimension.ro>
To: Jonathan Cameron <jic23@...nel.org>,
David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>
Cc: Jonathan Cameron <Jonathan.Cameron@...wei.com>,
linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, Petre Rodan <petre.rodan@...dimension.ro>
Subject: [PATCH v2 10/14] 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@...dimension.ro>
---
ChangeLog:
- hardcode 1ms timer watchdog to any i2c-based sensor instead of
configuring a dt-based property
- rename bma220_wdt() to bma220_set_wdt()
---
drivers/iio/accel/bma220_core.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/iio/accel/bma220_core.c b/drivers/iio/accel/bma220_core.c
index 191074d8618ea2638f69283781b8677921876681..b619f5a0bf713b4d386a5d4fc1d919e144798f02 100644
--- a/drivers/iio/accel/bma220_core.c
+++ b/drivers/iio/accel/bma220_core.c
@@ -10,6 +10,7 @@
#include <linux/bitfield.h>
#include <linux/cleanup.h>
#include <linux/device.h>
+#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
@@ -359,6 +360,11 @@ 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 bma220_data *data)
{
@@ -390,6 +396,13 @@ static int bma220_init(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;
}
--
2.49.1
Powered by blists - more mailing lists