Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Petre Rodan <petre.rodan@subdimension.ro>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>
Subject: Re: [PATCH 05/10] iio: accel: BMA220 make use of the watchdog functionality
Date: Sun, 7 Sep 2025 13:48:19 +0100	[thread overview]
Message-ID: <20250907134819.5289f4fa@jic23-huawei> (raw)
In-Reply-To: <20250901194742.11599-6-petre.rodan@subdimension.ro>

On Mon,  1 Sep 2025 22:47:31 +0300
Petre Rodan <petre.rodan@subdimension.ro> wrote:

> Sometimes the sensor gets stuck and enters a condition in which it pulls
> SDA low, thus making the entire i2c bus unusable.
> The optional bosch,watchdog property mitigates this problem by clearing
> the condition after a period of 1 or 10ms.

As I think was discussed with the binding, I'd turn this on by default
and we can figure out if we want to change that if it causes anyone
problems long run.

> 
> Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
> ---
>  drivers/iio/accel/bma220_core.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/drivers/iio/accel/bma220_core.c b/drivers/iio/accel/bma220_core.c
> index fae84823d52b..86347cf8ab1e 100644
> --- a/drivers/iio/accel/bma220_core.c
> +++ b/drivers/iio/accel/bma220_core.c
> @@ -158,6 +158,12 @@ enum bma220_axis {
>  	AXIS_Z,
>  };
> 
> +enum bma220_prop_wdt {
> +	BMA220_PROP_WDT_OFF,
> +	BMA220_PROP_WDT_1MS,
> +	BMA220_PROP_WDT_10MS,
> +};
> +
>  static const int bma220_scale_table[][2] = {
>  	{0, 623000}, {1, 248000}, {2, 491000}, {4, 983000},
>  };
> @@ -428,10 +434,17 @@ static int bma220_power(struct bma220_data *data, bool up)
>  	return -EBUSY;
>  }
> 
> +static int bma220_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)
>  {
>  	int ret;
>  	unsigned int val;
> +	u32 watchdog;
>  	static const char * const regulator_names[] = { "vddd", "vddio", "vdda" };
> 
>  	ret = devm_regulator_bulk_get_enable(data->dev,
> @@ -462,6 +475,25 @@ static int bma220_init(struct bma220_data *data)
>  		return ret;
>  	}
> 
> +	ret = device_property_read_u32(data->dev, "bosch,watchdog", &watchdog);
> +	if (!ret) {
> +		switch (watchdog) {
> +		case BMA220_PROP_WDT_1MS:
> +			ret = bma220_wdt(data, BMA220_WDT_1MS);
> +			break;
> +		case BMA220_PROP_WDT_10MS:
> +			ret = bma220_wdt(data, BMA220_WDT_10MS);
> +			break;
> +		default:
> +			ret = bma220_wdt(data, BMA220_WDT_OFF);
> +			break;
> +		}
> +		if (ret) {
> +			dev_err(data->dev, "Failed to set watchdog\n");

dev_err_probe()

> +			return ret;
> +		}
> +	}
> +
>  	return 0;
>  }
> 
> --
> 2.49.1
> 
> 


  reply	other threads:[~2025-09-07 12:48 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-01 19:47 [PATCH 0/10] iio: accel: BMA220 improvements Petre Rodan
2025-09-01 19:47 ` [PATCH 01/10] dt-bindings: iio: accel: bosch,BMA220 improvements Petre Rodan
2025-09-02  5:57   ` Krzysztof Kozlowski
2025-09-02 16:02     ` Petre Rodan
2025-09-02 16:14       ` David Lechner
2025-09-02 19:22       ` Krzysztof Kozlowski
2025-09-05 20:15   ` David Lechner
2025-09-06  2:46     ` Petre Rodan
2025-09-06 14:36       ` David Lechner
2025-09-01 19:47 ` [PATCH 02/10] iio: accel: BMA220 split original spi driver Petre Rodan
2025-09-07 12:29   ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 03/10] iio: accel: BMA220 migrate to regmap API Petre Rodan
2025-09-07 12:45   ` Jonathan Cameron
2025-09-08  3:27     ` Petre Rodan
2025-09-09 16:15       ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 04/10] iio: accel: BMA220 add i2c module Petre Rodan
2025-09-07 12:46   ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 05/10] iio: accel: BMA220 make use of the watchdog functionality Petre Rodan
2025-09-07 12:48   ` Jonathan Cameron [this message]
2025-09-01 19:47 ` [PATCH 06/10] iio: accel: BMA220 add LPF cut-off frequency mapping Petre Rodan
2025-09-05 19:59   ` David Lechner
2025-09-07 12:50     ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 07/10] iio: accel: BMA220 add debugfs reg access Petre Rodan
2025-09-01 19:47 ` [PATCH 08/10] iio: accel: BMA220 add events Petre Rodan
2025-09-07 13:02   ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 09/10] iio: accel: BMA220 add event attrs Petre Rodan
2025-09-07 13:15   ` Jonathan Cameron
2025-09-07 13:28     ` Petre Rodan
2025-09-09 16:20       ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 10/10] iio: accel: BMA220 add maintainer Petre Rodan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250907134819.5289f4fa@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=petre.rodan@subdimension.ro \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox