The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Antoniu Miclaus <antoniu.miclaus@analog.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Marcelo Schmitt" <marcelo.schmitt@analog.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Petre Rodan" <petre.rodan@subdimension.ro>,
	"Jorge Marques" <jorge.marques@analog.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] iio: accel: adxl372: add support for ADXL371
Date: Mon, 2 Mar 2026 20:36:39 +0000	[thread overview]
Message-ID: <20260302203639.1fcec771@jic23-huawei> (raw)
In-Reply-To: <20260302122116.1282-4-antoniu.miclaus@analog.com>

On Mon, 2 Mar 2026 14:20:59 +0200
Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:

> Add support for the Analog Devices ADXL371, a +-200g 3-axis MEMS
> accelerometer sharing the same register map as the ADXL372 but with
> different ODR values (320/640/1280/2560/5120 Hz vs 400/800/1600/3200/
> 6400 Hz), different bandwidth values, and different timer scale
> factors for activity/inactivity detection.
> 
> Due to a silicon anomaly (er001) causing FIFO data misalignment on
> all current ADXL371 silicon, FIFO and triggered buffer support is
> disabled for the ADXL371 - only direct mode reads are supported.

Ouch.

> 

> diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
> index d1f957adea64..10eb5bf14dad 100644
> --- a/drivers/iio/accel/adxl372.c
> +++ b/drivers/iio/accel/adxl372.c
> @@ -1,6 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
> - * ADXL372 3-Axis Digital Accelerometer core driver
> + * ADXL371/ADXL372 3-Axis Digital Accelerometer core driver
>   *
>   * Copyright 2018 Analog Devices Inc.
>   */
> @@ -182,6 +182,14 @@ enum adxl372_odr {
>  	ADXL372_ODR_6400HZ,
>  };
>  
> +enum adxl371_odr {
> +	ADXL371_ODR_320HZ,
> +	ADXL371_ODR_640HZ,
> +	ADXL371_ODR_1280HZ,
> +	ADXL371_ODR_2560HZ,
> +	ADXL371_ODR_5120HZ,
> +};
> +
>  enum adxl372_bandwidth {
>  	ADXL372_BW_200HZ,
>  	ADXL372_BW_400HZ,
> @@ -222,6 +230,29 @@ static const int adxl372_bw_freq_tbl[5] = {
>  	200, 400, 800, 1600, 3200,
>  };
>  
> +static const int adxl371_samp_freq_tbl[5] = {
> +	320, 640, 1280, 2560, 5120,
It might be a good idea to make the association of ordering an element
explicit via
	[ADXL371_ODR_320HZ] = 320,
etc

> +};
> +
> +static const int adxl371_bw_freq_tbl[5] = {

I assume these are indexed off the odr enum. If so then
	[ADXL371_ODR_320HZ] = 160, 
etc here may make sense as well.

> +	160, 320, 640, 1280, 2560,
> +};

> +		if (st->irq) {
It might be worth factoring out this block (maybe the earlier bit as well)
as a helper function in a precursor patch.  
The indent is getting rather large for such long lines.

> +			st->dready_trig = devm_iio_trigger_alloc(dev,
> +								 "%s-dev%d",
> +								 indio_dev->name,
> +								 iio_device_id(indio_dev));
> +			if (!st->dready_trig)
> +				return -ENOMEM;
> +
> +			st->peak_datardy_trig = devm_iio_trigger_alloc(dev,
> +								       "%s-dev%d-peak",
> +								       indio_dev->name,
> +								       iio_device_id(indio_dev));
> +			if (!st->peak_datardy_trig)
> +				return -ENOMEM;
> +
> +			st->dready_trig->ops = &adxl372_trigger_ops;
> +			st->peak_datardy_trig->ops = &adxl372_peak_data_trigger_ops;
> +			iio_trigger_set_drvdata(st->dready_trig, indio_dev);
> +			iio_trigger_set_drvdata(st->peak_datardy_trig, indio_dev);
> +			ret = devm_iio_trigger_register(dev, st->dready_trig);
> +			if (ret < 0)
> +				return ret;
> +
> +			ret = devm_iio_trigger_register(dev, st->peak_datardy_trig);
> +			if (ret < 0)
> +				return ret;
>  
> -		indio_dev->trig = iio_trigger_get(st->dready_trig);
> +			indio_dev->trig = iio_trigger_get(st->dready_trig);
>  
> -		ret = devm_request_irq(dev, st->irq,
> -				       iio_trigger_generic_data_rdy_poll,
> -				       IRQF_TRIGGER_RISING | IRQF_NO_THREAD,
> -				       indio_dev->name, st->dready_trig);
> -		if (ret < 0)
> -			return ret;
> +			ret = devm_request_irq(dev, st->irq,
> +					       iio_trigger_generic_data_rdy_poll,
> +					       IRQF_TRIGGER_RISING | IRQF_NO_THREAD,
> +					       indio_dev->name, st->dready_trig);
> +			if (ret < 0)
> +				return ret;
> +		}
>  	}
>  
>  	return devm_iio_device_register(dev, indio_dev);

      reply	other threads:[~2026-03-02 20:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02 12:20 [PATCH 0/3] iio: accel: adxl372: add ADXL371 support Antoniu Miclaus
2026-03-02 12:20 ` [PATCH 1/3] iio: accel: adxl372: introduce chip_info structure Antoniu Miclaus
2026-03-02 12:59   ` Andy Shevchenko
2026-03-02 20:28     ` Jonathan Cameron
2026-03-02 12:20 ` [PATCH 2/3] dt-bindings: iio: accel: adi,adxl372: add ADXL371 compatible Antoniu Miclaus
2026-03-02 20:10   ` Conor Dooley
2026-03-02 12:20 ` [PATCH 3/3] iio: accel: adxl372: add support for ADXL371 Antoniu Miclaus
2026-03-02 20:36   ` Jonathan Cameron [this message]

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=20260302203639.1fcec771@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jorge.marques@analog.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=nuno.sa@analog.com \
    --cc=petre.rodan@subdimension.ro \
    --cc=robh@kernel.org \
    /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