public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Alexandru Tachici <alexandru.tachici@analog.com>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 4/6] iio: accel: adxl372: add iio events
Date: Sat, 7 Mar 2020 12:12:06 +0000	[thread overview]
Message-ID: <20200307121206.2d92521a@archlinux> (raw)
In-Reply-To: <20200225120909.12629-5-alexandru.tachici@analog.com>

On Tue, 25 Feb 2020 14:09:07 +0200
Alexandru Tachici <alexandru.tachici@analog.com> wrote:

> Set INT1 interrupts to fire when activity/inactivity
> is detected by the device. On irq, push event code by calling
> iio_push_event().
> 
> Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
> ---
>  drivers/iio/accel/adxl372.c | 37 +++++++++++++++++++++++++++++++++++--
>  1 file changed, 35 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c
> index 775dc4f0aaf4..e669eaaaa07e 100644
> --- a/drivers/iio/accel/adxl372.c
> +++ b/drivers/iio/accel/adxl372.c
> @@ -114,6 +114,11 @@
>  #define ADXL372_STATUS_1_AWAKE(x)		(((x) >> 6) & 0x1)
>  #define ADXL372_STATUS_1_ERR_USR_REGS(x)	(((x) >> 7) & 0x1)
>  
> +/* ADXL372_STATUS_2 */
> +#define ADXL372_STATUS_2_INACT(x)		(((x) >> 4) & 0x1)
> +#define ADXL372_STATUS_2_ACT(x)			(((x) >> 5) & 0x1)
> +#define ADXL372_STATUS_2_AC2(x)			(((x) >> 6) & 0x1)
> +
>  /* ADXL372_INT1_MAP */
>  #define ADXL372_INT1_MAP_DATA_RDY_MSK		BIT(0)
>  #define ADXL372_INT1_MAP_DATA_RDY_MODE(x)	(((x) & 0x1) << 0)
> @@ -585,6 +590,27 @@ static int adxl372_get_status(struct adxl372_state *st,
>  	return ret;
>  }
>  
> +static void adxl372_push_event(struct iio_dev *indio_dev, s64 timestamp,
> +			       u8 status2)
> +{
> +	unsigned int ev_dir;
> +
> +	if (ADXL372_STATUS_2_ACT(status2))
> +		ev_dir = IIO_EV_DIR_RISING;
> +
> +	if (ADXL372_STATUS_2_INACT(status2))
> +		ev_dir = IIO_EV_DIR_FALLING;
> +
> +	if (ev_dir != IIO_EV_DIR_NONE)

Unless I'm missing something we don't have an enable / disable control for this
event.  Can we add one?

> +		iio_push_event(indio_dev,
> +			       IIO_MOD_EVENT_CODE(IIO_ACCEL,
> +						  0,
> +						  IIO_MOD_X_OR_Y_OR_Z,
> +						  IIO_EV_TYPE_THRESH,
> +						  ev_dir),
> +						  timestamp);
> +}
> +
>  static irqreturn_t adxl372_trigger_handler(int irq, void  *p)
>  {
>  	struct iio_poll_func *pf = p;
> @@ -598,6 +624,8 @@ static irqreturn_t adxl372_trigger_handler(int irq, void  *p)
>  	if (ret < 0)
>  		goto err;
>  
> +	adxl372_push_event(indio_dev, iio_get_time_ns(indio_dev), status2);
> +
>  	if (st->fifo_mode != ADXL372_FIFO_BYPASSED &&
>  	    ADXL372_STATUS_1_FIFO_FULL(status1)) {
>  		/*
> @@ -989,7 +1017,10 @@ static int adxl372_buffer_postenable(struct iio_dev *indio_dev)
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = adxl372_set_interrupts(st, ADXL372_INT1_MAP_FIFO_FULL_MSK, 0);
> +	mask = ADXL372_INT1_MAP_FIFO_FULL_MSK |
> +	       ADXL372_INT1_MAP_ACT_MSK	 |
> +	       ADXL372_INT1_MAP_INACT_MSK;
> +	ret = adxl372_set_interrupts(st, mask, 0);
>  	if (ret < 0)
>  		goto err;
>  
> @@ -1067,7 +1098,9 @@ static int adxl372_dready_trig_set_state(struct iio_trigger *trig,
>  	unsigned long int mask = 0;
>  
>  	if (state)
> -		mask = ADXL372_INT1_MAP_FIFO_FULL_MSK;
> +		mask = ADXL372_INT1_MAP_FIFO_FULL_MSK |
> +		       ADXL372_INT1_MAP_ACT_MSK	 |
> +		       ADXL372_INT1_MAP_INACT_MSK;
>  
>  	return adxl372_set_interrupts(st, mask, 0);
>  }


  reply	other threads:[~2020-03-07 12:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-25 12:09 [PATCH v2 0/6] iio: accel: adxl372: add peak mode Alexandru Tachici
2020-02-25 12:09 ` [PATCH v2 1/6] iio: accel: adxl372: Add support for FIFO " Alexandru Tachici
2020-03-07 12:02   ` Jonathan Cameron
2020-02-25 12:09 ` [PATCH v2 2/6] iio: accel: adxl372: add sysfs for time registers Alexandru Tachici
2020-03-07 12:15   ` Jonathan Cameron
2020-02-25 12:09 ` [PATCH v2 3/6] iio: accel: adxl372: Add sysfs for g thresholds Alexandru Tachici
2020-02-25 12:09 ` [PATCH v2 4/6] iio: accel: adxl372: add iio events Alexandru Tachici
2020-03-07 12:12   ` Jonathan Cameron [this message]
2020-02-25 12:09 ` [PATCH v2 5/6] iio: accel: adxl372: add additional events ABIs Alexandru Tachici
2020-02-25 12:09 ` [PATCH v2 6/6] iio: accel: adxl372: Update sysfs docs Alexandru Tachici
2020-03-07 12:09   ` Jonathan Cameron

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=20200307121206.2d92521a@archlinux \
    --to=jic23@kernel.org \
    --cc=alexandru.tachici@analog.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.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