On Thu, 29 May 2025 18:22:50 +0200 Lothar Rubusch <l.rubusch@xxxxxxxxx> wrote: > Hi Jonathan, > > On Sun, May 25, 2025 at 3:04 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote: > > > > On Fri, 23 May 2025 22:35:20 +0000 > > Lothar Rubusch <l.rubusch@xxxxxxxxx> wrote: > > > > > Add possibilities to set a threshold for activity sensing. Extend the > > > interrupt handler to process activity interrupts. Provide functions to set > > > the activity threshold and to enable/disable activity sensing. Further add > > > a fake channel for having x, y and z axis anded on the iio channel. > > > > > > This is a preparatory patch. Some of the definitions and functions are > > > supposed to be extended for inactivity later on. > > > > > > Signed-off-by: Lothar Rubusch <l.rubusch@xxxxxxxxx> > > One comment I found confusing. > > > > I see this hardware is similar to our friend the axl345 so some of the outcomes > > of final reviews on that series may apply here as well. > > Yes. To be honest with you, I already saw several places, where I > probably need to send you some refac for the ADXL345 as well. > Implementing the same type of source a second time, sometimes leads > [me] to different[/better?] solutions and brings different insights. > > > > > > --- > > > drivers/iio/accel/adxl313_core.c | 229 ++++++++++++++++++++++++++++++- > > > 1 file changed, 227 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/iio/accel/adxl313_core.c b/drivers/iio/accel/adxl313_core.c > > > index 80991cd9bd79..74bb7cfe8a55 100644 > > > --- a/drivers/iio/accel/adxl313_core.c > > > +++ b/drivers/iio/accel/adxl313_core.c > > > > > static const unsigned long adxl313_scan_masks[] = { > > > @@ -300,6 +334,60 @@ static int adxl313_read_freq_avail(struct iio_dev *indio_dev, > > > } > > > } > > > > > > +static int adxl313_is_act_inact_en(struct adxl313_data *data, > > > + enum adxl313_activity_type type) > > > +{ > > > + unsigned int axis_ctrl; > > > + unsigned int regval; > > > + int axis_en, int_en, ret; > > > + > > > + ret = regmap_read(data->regmap, ADXL313_REG_ACT_INACT_CTL, &axis_ctrl); > > > + if (ret) > > > + return ret; > > > + > > > + /* Check if axis for activity are enabled */ > > > > If all 3 axis perhaps? Or If any axis? I'm not sure what intent is here. > > For the ADXL313 I do generally all axis, i.e. x-, y-, z-axis - enabled > and disabled, respectively. I'll modify the comment. > > Sry about spamming the ML with my emails about the reset function. I > oversaw your other mail. Patches will be merged. Lol. I did the same thing just now. Don't worry about it! J > > Best, > L > > > > > > + if (type != ADXL313_ACTIVITY) > > > + return 0; > > > + > > > + axis_en = FIELD_GET(ADXL313_ACT_XYZ_EN, axis_ctrl); > > > + > > > + /* The axis are enabled, now check if specific interrupt is enabled */ > > > + ret = regmap_read(data->regmap, ADXL313_REG_INT_ENABLE, ®val); > > > + if (ret) > > > + return ret; > > > + > > > + int_en = adxl313_act_int_reg[type] & regval; > > > + > > > + return axis_en && int_en; > > > +} > >