* [PATCH v2 0/3] accel: adxl380: Add support for 1 kHz sampling frequency
@ 2026-01-15 17:53 Francesco Lavra
2026-01-15 17:53 ` [PATCH v2 1/3] iio: accel: adxl380: Store sampling frequency index in odr struct member Francesco Lavra
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Francesco Lavra @ 2026-01-15 17:53 UTC (permalink / raw)
To: Ramona Gradinariu, Antoniu Miclaus, Lars-Peter Clausen,
Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
This series adds support for 1kHz sampling frequency for sensor variants
that implement low-power mode.
The first patch is a preparatory step to decouple sampling frequency values
from decimation filter settings, the second patch introduces a new helper
function to check whether activity/inactivity detection is enabled, and the
last patch adds support for the new sampling frequency value.
Tested on ADXL382.
Changes from v1 [1]:
- added Nuno's reviewed-by tag to patch 1
- modified reporting of available frequencies and setting of current
frequency to reflect activity detection status (Jonathan)
[1] https://lore.kernel.org/linux-iio/20260107123518.4017292-1-flavra@baylibre.com/T/
Francesco Lavra (3):
iio: accel: adxl380: Store sampling frequency index in odr struct
member
iio: accel: adxl380: Introduce helper function for activity detection
iio: accel: adxl380: Add support for 1 kHz sampling frequency
drivers/iio/accel/adxl380.c | 122 +++++++++++++++++++++++++-----------
drivers/iio/accel/adxl380.h | 10 ++-
2 files changed, 95 insertions(+), 37 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/3] iio: accel: adxl380: Store sampling frequency index in odr struct member
2026-01-15 17:53 [PATCH v2 0/3] accel: adxl380: Add support for 1 kHz sampling frequency Francesco Lavra
@ 2026-01-15 17:53 ` Francesco Lavra
2026-01-15 17:53 ` [PATCH v2 2/3] iio: accel: adxl380: Introduce helper function for activity detection Francesco Lavra
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Francesco Lavra @ 2026-01-15 17:53 UTC (permalink / raw)
To: Ramona Gradinariu, Antoniu Miclaus, Lars-Peter Clausen,
Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
The ADXL380 driver assumes that acceleration samples are always retrieved
via the high-performance DSM signal path; as a result, the sampling
frequency value depends exclusively on the decimation filter settings in
the TRIG_CFG register.
In preparation for adding support for sampling frequency values that rely
on the low-power SAR signal path (on which the decimation filters are not
supported), use the (currently unused) 'odr' member of struct adxl380_state
to store the sampling frequency value, and when userspace requests the
current frequency value, retrieve it from the struct instead of calculating
it from the decimation filter settings.
Signed-off-by: Francesco Lavra <flavra@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/accel/adxl380.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c
index ce3643c5deb8..bbf1f88ca781 100644
--- a/drivers/iio/accel/adxl380.c
+++ b/drivers/iio/accel/adxl380.c
@@ -417,17 +417,7 @@ static int adxl380_read_chn(struct adxl380_state *st, u8 addr)
static int adxl380_get_odr(struct adxl380_state *st, int *odr)
{
- int ret;
- unsigned int trig_cfg, odr_idx;
-
- ret = regmap_read(st->regmap, ADXL380_TRIG_CFG_REG, &trig_cfg);
- if (ret)
- return ret;
-
- odr_idx = (FIELD_GET(ADXL380_TRIG_CFG_SINC_RATE_MSK, trig_cfg) << 1) |
- (FIELD_GET(ADXL380_TRIG_CFG_DEC_2X_MSK, trig_cfg) & 1);
-
- *odr = st->chip_info->samp_freq_tbl[odr_idx];
+ *odr = st->chip_info->samp_freq_tbl[st->odr];
return 0;
}
@@ -500,6 +490,7 @@ static int adxl380_set_odr(struct adxl380_state *st, u8 odr)
if (ret)
return ret;
+ st->odr = odr;
ret = adxl380_set_measure_en(st, true);
if (ret)
return ret;
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] iio: accel: adxl380: Introduce helper function for activity detection
2026-01-15 17:53 [PATCH v2 0/3] accel: adxl380: Add support for 1 kHz sampling frequency Francesco Lavra
2026-01-15 17:53 ` [PATCH v2 1/3] iio: accel: adxl380: Store sampling frequency index in odr struct member Francesco Lavra
@ 2026-01-15 17:53 ` Francesco Lavra
2026-01-15 20:28 ` Andy Shevchenko
2026-01-15 17:53 ` [PATCH v2 3/3] iio: accel: adxl380: Add support for 1 kHz sampling frequency Francesco Lavra
2026-01-16 19:43 ` [PATCH v2 0/3] " Jonathan Cameron
3 siblings, 1 reply; 8+ messages in thread
From: Francesco Lavra @ 2026-01-15 17:53 UTC (permalink / raw)
To: Ramona Gradinariu, Antoniu Miclaus, Lars-Peter Clausen,
Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
Motion detection functionalities (such as activity and inactivity
detection) are only available when the chip is in a low-power mode; this
affects the available sampling frequency values.
In preparation for adding support for a new frequency value, introduce a
helper function that checks whether activity/inactivity detection is
currently enabled; this function will be reused in a future commit to
determine what frequency values are available at any given time.
No functional changes.
Signed-off-by: Francesco Lavra <flavra@baylibre.com>
---
drivers/iio/accel/adxl380.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c
index bbf1f88ca781..b99458a5eae3 100644
--- a/drivers/iio/accel/adxl380.c
+++ b/drivers/iio/accel/adxl380.c
@@ -232,14 +232,33 @@ bool adxl380_readable_noinc_reg(struct device *dev, unsigned int reg)
}
EXPORT_SYMBOL_NS_GPL(adxl380_readable_noinc_reg, "IIO_ADXL380");
+static int adxl380_act_inact_enabled(struct adxl380_state *st, bool *enabled)
+{
+ unsigned int act_inact_ctl;
+ int ret;
+
+ if (!st->chip_info->has_low_power) {
+ *enabled = false;
+ return 0;
+ }
+
+ ret = regmap_read(st->regmap, ADXL380_ACT_INACT_CTL_REG, &act_inact_ctl);
+ if (!ret)
+ *enabled = FIELD_GET(ADXL380_ACT_EN_MSK, act_inact_ctl) ||
+ FIELD_GET(ADXL380_INACT_EN_MSK, act_inact_ctl);
+
+ return ret;
+}
+
static int adxl380_set_measure_en(struct adxl380_state *st, bool en)
{
int ret;
- unsigned int act_inact_ctl;
u8 op_mode = ADXL380_OP_MODE_STANDBY;
if (en) {
- ret = regmap_read(st->regmap, ADXL380_ACT_INACT_CTL_REG, &act_inact_ctl);
+ bool act_inact_enabled;
+
+ ret = adxl380_act_inact_enabled(st, &act_inact_enabled);
if (ret)
return ret;
@@ -248,9 +267,7 @@ static int adxl380_set_measure_en(struct adxl380_state *st, bool en)
* mode and for devices that support low power modes. Otherwise
* go straight to measure mode (same bits as ADXL380_OP_MODE_HP).
*/
- if (st->chip_info->has_low_power &&
- (FIELD_GET(ADXL380_ACT_EN_MSK, act_inact_ctl) ||
- FIELD_GET(ADXL380_INACT_EN_MSK, act_inact_ctl)))
+ if (act_inact_enabled)
op_mode = ADXL380_OP_MODE_VLP;
else
op_mode = ADXL380_OP_MODE_HP;
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] iio: accel: adxl380: Add support for 1 kHz sampling frequency
2026-01-15 17:53 [PATCH v2 0/3] accel: adxl380: Add support for 1 kHz sampling frequency Francesco Lavra
2026-01-15 17:53 ` [PATCH v2 1/3] iio: accel: adxl380: Store sampling frequency index in odr struct member Francesco Lavra
2026-01-15 17:53 ` [PATCH v2 2/3] iio: accel: adxl380: Introduce helper function for activity detection Francesco Lavra
@ 2026-01-15 17:53 ` Francesco Lavra
2026-01-16 19:42 ` Jonathan Cameron
2026-01-16 19:43 ` [PATCH v2 0/3] " Jonathan Cameron
3 siblings, 1 reply; 8+ messages in thread
From: Francesco Lavra @ 2026-01-15 17:53 UTC (permalink / raw)
To: Ramona Gradinariu, Antoniu Miclaus, Lars-Peter Clausen,
Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
In sensor variants (such as ADXL380 and ADXL382) that support low-power
mode, the SAR signal path allows sampling acceleration data at lower rates;
more specifically, when the sensor operates in VLP mode, the sampling
frequency is 1 kHz.
To add support for the 1kHz sampling frequency value, modify the operating
mode selection logic to take into account the sampling frequency, and
configure the decimation filters only when applicable (i.e. when using a
sampling frequency that relies on the DSM signal path); in addition,
constrain the available sampling frequency values based on whether the
sensor is operating in low-power mode.
Signed-off-by: Francesco Lavra <flavra@baylibre.com>
---
drivers/iio/accel/adxl380.c | 82 ++++++++++++++++++++++++++++---------
drivers/iio/accel/adxl380.h | 10 ++++-
2 files changed, 71 insertions(+), 21 deletions(-)
diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c
index b99458a5eae3..7fe94e5cce0f 100644
--- a/drivers/iio/accel/adxl380.c
+++ b/drivers/iio/accel/adxl380.c
@@ -264,10 +264,12 @@ static int adxl380_set_measure_en(struct adxl380_state *st, bool en)
/*
* Activity/Inactivity detection available only in VLP/ULP
- * mode and for devices that support low power modes. Otherwise
- * go straight to measure mode (same bits as ADXL380_OP_MODE_HP).
+ * mode and for devices that support low power modes.
*/
if (act_inact_enabled)
+ st->odr = ADXL380_ODR_VLP;
+
+ if (st->odr == ADXL380_ODR_VLP)
op_mode = ADXL380_OP_MODE_VLP;
else
op_mode = ADXL380_OP_MODE_HP;
@@ -495,17 +497,22 @@ static int adxl380_set_odr(struct adxl380_state *st, u8 odr)
if (ret)
return ret;
- ret = regmap_update_bits(st->regmap, ADXL380_TRIG_CFG_REG,
- ADXL380_TRIG_CFG_DEC_2X_MSK,
- FIELD_PREP(ADXL380_TRIG_CFG_DEC_2X_MSK, odr & 1));
- if (ret)
- return ret;
+ if (odr >= ADXL380_ODR_DSM) {
+ u8 mul = odr - ADXL380_ODR_DSM;
+ u8 field;
- ret = regmap_update_bits(st->regmap, ADXL380_TRIG_CFG_REG,
- ADXL380_TRIG_CFG_SINC_RATE_MSK,
- FIELD_PREP(ADXL380_TRIG_CFG_SINC_RATE_MSK, odr >> 1));
- if (ret)
- return ret;
+ field = FIELD_PREP(ADXL380_TRIG_CFG_DEC_2X_MSK, mul & 1);
+ ret = regmap_update_bits(st->regmap, ADXL380_TRIG_CFG_REG,
+ ADXL380_TRIG_CFG_DEC_2X_MSK, field);
+ if (ret)
+ return ret;
+
+ field = FIELD_PREP(ADXL380_TRIG_CFG_SINC_RATE_MSK, mul >> 1);
+ ret = regmap_update_bits(st->regmap, ADXL380_TRIG_CFG_REG,
+ ADXL380_TRIG_CFG_SINC_RATE_MSK, field);
+ if (ret)
+ return ret;
+ }
st->odr = odr;
ret = adxl380_set_measure_en(st, true);
@@ -1145,6 +1152,31 @@ static const struct iio_buffer_setup_ops adxl380_buffer_ops = {
.predisable = adxl380_buffer_predisable,
};
+static int adxl380_samp_freq_avail(struct adxl380_state *st, const int **vals,
+ int *length)
+{
+ bool act_inact_enabled;
+ int ret;
+
+ if (!st->chip_info->has_low_power) {
+ *vals = st->chip_info->samp_freq_tbl + ADXL380_ODR_DSM;
+ *length = ADXL380_ODR_MAX - ADXL380_ODR_DSM;
+ return 0;
+ }
+
+ ret = adxl380_act_inact_enabled(st, &act_inact_enabled);
+ if (!ret) {
+ /*
+ * Motion detection is only functional in low-power mode, and
+ * this affects the available sampling frequencies.
+ */
+ *vals = st->chip_info->samp_freq_tbl;
+ *length = act_inact_enabled ? ADXL380_ODR_DSM : ADXL380_ODR_MAX;
+ }
+
+ return ret;
+}
+
static int adxl380_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long info)
@@ -1225,6 +1257,7 @@ static int adxl380_read_avail(struct iio_dev *indio_dev,
long mask)
{
struct adxl380_state *st = iio_priv(indio_dev);
+ int ret;
if (chan->type != IIO_ACCEL)
return -EINVAL;
@@ -1236,9 +1269,11 @@ static int adxl380_read_avail(struct iio_dev *indio_dev,
*length = ARRAY_SIZE(st->chip_info->scale_tbl) * 2;
return IIO_AVAIL_LIST;
case IIO_CHAN_INFO_SAMP_FREQ:
- *vals = (const int *)st->chip_info->samp_freq_tbl;
+ ret = adxl380_samp_freq_avail(st, vals, length);
+ if (ret)
+ return ret;
+
*type = IIO_VAL_INT;
- *length = ARRAY_SIZE(st->chip_info->samp_freq_tbl);
return IIO_AVAIL_LIST;
case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
*vals = (const int *)st->lpf_tbl;
@@ -1261,12 +1296,18 @@ static int adxl380_write_raw(struct iio_dev *indio_dev,
int val, int val2, long info)
{
struct adxl380_state *st = iio_priv(indio_dev);
+ const int *freq_vals;
+ int freq_count;
int odr_index, lpf_index, hpf_index, range_index;
+ int ret;
switch (info) {
case IIO_CHAN_INFO_SAMP_FREQ:
- odr_index = adxl380_find_match_1d_tbl(st->chip_info->samp_freq_tbl,
- ARRAY_SIZE(st->chip_info->samp_freq_tbl),
+ ret = adxl380_samp_freq_avail(st, &freq_vals, &freq_count);
+ if (ret)
+ return ret;
+
+ odr_index = adxl380_find_match_1d_tbl(freq_vals, freq_count,
val);
return adxl380_set_odr(st, odr_index);
case IIO_CHAN_INFO_CALIBBIAS:
@@ -1628,7 +1669,7 @@ const struct adxl380_chip_info adxl318_chip_info = {
[ADXL380_OP_MODE_8G_RANGE] = { 0, 2615434 },
[ADXL380_OP_MODE_16G_RANGE] = { 0, 5229886 },
},
- .samp_freq_tbl = { 8000, 16000, 32000 },
+ .samp_freq_tbl = { 0, 8000, 16000, 32000 },
/*
* The datasheet defines an intercept of 550 LSB at 25 degC
* and a sensitivity of 10.2 LSB/C.
@@ -1646,7 +1687,7 @@ const struct adxl380_chip_info adxl319_chip_info = {
[ADXL382_OP_MODE_30G_RANGE] = { 0, 9806650 },
[ADXL382_OP_MODE_60G_RANGE] = { 0, 19613300 },
},
- .samp_freq_tbl = { 16000, 32000, 64000 },
+ .samp_freq_tbl = { 0, 16000, 32000, 64000 },
/*
* The datasheet defines an intercept of 550 LSB at 25 degC
* and a sensitivity of 10.2 LSB/C.
@@ -1664,7 +1705,7 @@ const struct adxl380_chip_info adxl380_chip_info = {
[ADXL380_OP_MODE_8G_RANGE] = { 0, 2615434 },
[ADXL380_OP_MODE_16G_RANGE] = { 0, 5229886 },
},
- .samp_freq_tbl = { 8000, 16000, 32000 },
+ .samp_freq_tbl = { 1000, 8000, 16000, 32000 },
/*
* The datasheet defines an intercept of 470 LSB at 25 degC
* and a sensitivity of 10.2 LSB/C.
@@ -1684,7 +1725,7 @@ const struct adxl380_chip_info adxl382_chip_info = {
[ADXL382_OP_MODE_30G_RANGE] = { 0, 9806650 },
[ADXL382_OP_MODE_60G_RANGE] = { 0, 19613300 },
},
- .samp_freq_tbl = { 16000, 32000, 64000 },
+ .samp_freq_tbl = { 1000, 16000, 32000, 64000 },
/*
* The datasheet defines an intercept of 570 LSB at 25 degC
* and a sensitivity of 10.2 LSB/C.
@@ -1923,6 +1964,7 @@ int adxl380_probe(struct device *dev, struct regmap *regmap,
st->dev = dev;
st->regmap = regmap;
st->chip_info = chip_info;
+ st->odr = ADXL380_ODR_DSM;
mutex_init(&st->lock);
diff --git a/drivers/iio/accel/adxl380.h b/drivers/iio/accel/adxl380.h
index e67c5aab8efc..d2c260c8b2fa 100644
--- a/drivers/iio/accel/adxl380.h
+++ b/drivers/iio/accel/adxl380.h
@@ -8,10 +8,18 @@
#ifndef _ADXL380_H_
#define _ADXL380_H_
+enum adxl380_odr {
+ ADXL380_ODR_VLP,
+ ADXL380_ODR_DSM,
+ ADXL380_ODR_DSM_2X,
+ ADXL380_ODR_DSM_4X,
+ ADXL380_ODR_MAX
+};
+
struct adxl380_chip_info {
const char *name;
const int scale_tbl[3][2];
- const int samp_freq_tbl[3];
+ const int samp_freq_tbl[ADXL380_ODR_MAX];
const struct iio_info *info;
const int temp_offset;
const u16 chip_id;
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] iio: accel: adxl380: Introduce helper function for activity detection
2026-01-15 17:53 ` [PATCH v2 2/3] iio: accel: adxl380: Introduce helper function for activity detection Francesco Lavra
@ 2026-01-15 20:28 ` Andy Shevchenko
2026-01-16 19:32 ` Jonathan Cameron
0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2026-01-15 20:28 UTC (permalink / raw)
To: Francesco Lavra
Cc: Ramona Gradinariu, Antoniu Miclaus, Lars-Peter Clausen,
Michael Hennerich, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel
On Thu, Jan 15, 2026 at 06:53:49PM +0100, Francesco Lavra wrote:
> Motion detection functionalities (such as activity and inactivity
> detection) are only available when the chip is in a low-power mode; this
> affects the available sampling frequency values.
> In preparation for adding support for a new frequency value, introduce a
> helper function that checks whether activity/inactivity detection is
> currently enabled; this function will be reused in a future commit to
> determine what frequency values are available at any given time.
> No functional changes.
...
> +static int adxl380_act_inact_enabled(struct adxl380_state *st, bool *enabled)
> +{
> + unsigned int act_inact_ctl;
> + int ret;
> +
> + if (!st->chip_info->has_low_power) {
> + *enabled = false;
> + return 0;
> + }
> +
> + ret = regmap_read(st->regmap, ADXL380_ACT_INACT_CTL_REG, &act_inact_ctl);
> + if (!ret)
What's wrong with the standard pattern?
if (ret)
return ret;
> + *enabled = FIELD_GET(ADXL380_ACT_EN_MSK, act_inact_ctl) ||
> + FIELD_GET(ADXL380_INACT_EN_MSK, act_inact_ctl);
> +
> + return ret;
return 0;
> +}
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] iio: accel: adxl380: Introduce helper function for activity detection
2026-01-15 20:28 ` Andy Shevchenko
@ 2026-01-16 19:32 ` Jonathan Cameron
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2026-01-16 19:32 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Francesco Lavra, Ramona Gradinariu, Antoniu Miclaus,
Lars-Peter Clausen, Michael Hennerich, David Lechner,
Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel
On Thu, 15 Jan 2026 22:28:05 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Thu, Jan 15, 2026 at 06:53:49PM +0100, Francesco Lavra wrote:
> > Motion detection functionalities (such as activity and inactivity
> > detection) are only available when the chip is in a low-power mode; this
> > affects the available sampling frequency values.
> > In preparation for adding support for a new frequency value, introduce a
> > helper function that checks whether activity/inactivity detection is
> > currently enabled; this function will be reused in a future commit to
> > determine what frequency values are available at any given time.
> > No functional changes.
>
> ...
>
> > +static int adxl380_act_inact_enabled(struct adxl380_state *st, bool *enabled)
> > +{
> > + unsigned int act_inact_ctl;
> > + int ret;
> > +
> > + if (!st->chip_info->has_low_power) {
> > + *enabled = false;
> > + return 0;
> > + }
> > +
> > + ret = regmap_read(st->regmap, ADXL380_ACT_INACT_CTL_REG, &act_inact_ctl);
>
> > + if (!ret)
>
> What's wrong with the standard pattern?
>
> if (ret)
> return ret;
>
> > + *enabled = FIELD_GET(ADXL380_ACT_EN_MSK, act_inact_ctl) ||
> > + FIELD_GET(ADXL380_INACT_EN_MSK, act_inact_ctl);
> > +
> > + return ret;
>
> return 0;
>
Fully agreed. Whilst it's a tiny bit longer, it is a lot more consistent
to always handle errors out of line and good flow inline.
Jonathan
> > +}
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/3] iio: accel: adxl380: Add support for 1 kHz sampling frequency
2026-01-15 17:53 ` [PATCH v2 3/3] iio: accel: adxl380: Add support for 1 kHz sampling frequency Francesco Lavra
@ 2026-01-16 19:42 ` Jonathan Cameron
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2026-01-16 19:42 UTC (permalink / raw)
To: Francesco Lavra
Cc: Ramona Gradinariu, Antoniu Miclaus, Lars-Peter Clausen,
Michael Hennerich, David Lechner, Nuno Sá, Andy Shevchenko,
linux-iio, linux-kernel
On Thu, 15 Jan 2026 18:53:50 +0100
Francesco Lavra <flavra@baylibre.com> wrote:
> In sensor variants (such as ADXL380 and ADXL382) that support low-power
> mode, the SAR signal path allows sampling acceleration data at lower rates;
> more specifically, when the sensor operates in VLP mode, the sampling
> frequency is 1 kHz.
> To add support for the 1kHz sampling frequency value, modify the operating
> mode selection logic to take into account the sampling frequency, and
> configure the decimation filters only when applicable (i.e. when using a
> sampling frequency that relies on the DSM signal path); in addition,
> constrain the available sampling frequency values based on whether the
> sensor is operating in low-power mode.
>
> Signed-off-by: Francesco Lavra <flavra@baylibre.com>
Hi Francesco,
A similar case to the one Andy pointed out in the earlier patch plus
a trivial comment. Given how trivial they are and where we are in the
cycle, I'll make them whilst applying.
Thanks,
Jonathan
>
> +static int adxl380_samp_freq_avail(struct adxl380_state *st, const int **vals,
> + int *length)
> +{
> + bool act_inact_enabled;
> + int ret;
> +
> + if (!st->chip_info->has_low_power) {
> + *vals = st->chip_info->samp_freq_tbl + ADXL380_ODR_DSM;
> + *length = ADXL380_ODR_MAX - ADXL380_ODR_DSM;
> + return 0;
> + }
> +
> + ret = adxl380_act_inact_enabled(st, &act_inact_enabled);
> + if (!ret) {
if (ret)
return ret;
/*
* Motion detection is only functional in low-power mode, and this
* affects the available sampling frequencies.
*/
*vals = st->chip_info->samp_freq_tbl;
*length = act_inact_enabled ? ADXL380_ODR_DSM : ADXL380_ODR_MAX;
return 0;
> + /*
> + * Motion detection is only functional in low-power mode, and
> + * this affects the available sampling frequencies.
> + */
> + *vals = st->chip_info->samp_freq_tbl;
> + *length = act_inact_enabled ? ADXL380_ODR_DSM : ADXL380_ODR_MAX;
> + }
> +
> + return ret;
> +}
> @@ -1261,12 +1296,18 @@ static int adxl380_write_raw(struct iio_dev *indio_dev,
> int val, int val2, long info)
> {
> struct adxl380_state *st = iio_priv(indio_dev);
> + const int *freq_vals;
> + int freq_count;
> int odr_index, lpf_index, hpf_index, range_index;
> + int ret;
Might as well combine the new variables on one line or even
int odr_index, lpf_index, hpf_index, range_index, freq_count, ret;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] accel: adxl380: Add support for 1 kHz sampling frequency
2026-01-15 17:53 [PATCH v2 0/3] accel: adxl380: Add support for 1 kHz sampling frequency Francesco Lavra
` (2 preceding siblings ...)
2026-01-15 17:53 ` [PATCH v2 3/3] iio: accel: adxl380: Add support for 1 kHz sampling frequency Francesco Lavra
@ 2026-01-16 19:43 ` Jonathan Cameron
3 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2026-01-16 19:43 UTC (permalink / raw)
To: Francesco Lavra
Cc: Ramona Gradinariu, Antoniu Miclaus, Lars-Peter Clausen,
Michael Hennerich, David Lechner, Nuno Sá, Andy Shevchenko,
linux-iio, linux-kernel
On Thu, 15 Jan 2026 18:53:47 +0100
Francesco Lavra <flavra@baylibre.com> wrote:
> This series adds support for 1kHz sampling frequency for sensor variants
> that implement low-power mode.
> The first patch is a preparatory step to decouple sampling frequency values
> from decimation filter settings, the second patch introduces a new helper
> function to check whether activity/inactivity detection is enabled, and the
> last patch adds support for the new sampling frequency value.
> Tested on ADXL382.
Applied with tweaks as called out in replies to individual patches to
the testing branch of iio.git. I'm rushing this a bit as I'm not sure how
early next week I'll get to IIO stuff but if Nuno or anyone else wants to
take a look (+ give tags or ask me to drop it for a v3) then that is fine!
Jonathan
>
> Changes from v1 [1]:
> - added Nuno's reviewed-by tag to patch 1
> - modified reporting of available frequencies and setting of current
> frequency to reflect activity detection status (Jonathan)
>
> [1] https://lore.kernel.org/linux-iio/20260107123518.4017292-1-flavra@baylibre.com/T/
>
> Francesco Lavra (3):
> iio: accel: adxl380: Store sampling frequency index in odr struct
> member
> iio: accel: adxl380: Introduce helper function for activity detection
> iio: accel: adxl380: Add support for 1 kHz sampling frequency
>
> drivers/iio/accel/adxl380.c | 122 +++++++++++++++++++++++++-----------
> drivers/iio/accel/adxl380.h | 10 ++-
> 2 files changed, 95 insertions(+), 37 deletions(-)
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-01-16 19:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-15 17:53 [PATCH v2 0/3] accel: adxl380: Add support for 1 kHz sampling frequency Francesco Lavra
2026-01-15 17:53 ` [PATCH v2 1/3] iio: accel: adxl380: Store sampling frequency index in odr struct member Francesco Lavra
2026-01-15 17:53 ` [PATCH v2 2/3] iio: accel: adxl380: Introduce helper function for activity detection Francesco Lavra
2026-01-15 20:28 ` Andy Shevchenko
2026-01-16 19:32 ` Jonathan Cameron
2026-01-15 17:53 ` [PATCH v2 3/3] iio: accel: adxl380: Add support for 1 kHz sampling frequency Francesco Lavra
2026-01-16 19:42 ` Jonathan Cameron
2026-01-16 19:43 ` [PATCH v2 0/3] " Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox