Linux-IIO Archive on lore.kernel.org
 help / color / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Sean Nyekjaer <sean@geanix.com>,
	linux-iio@vger.kernel.org, lorenzo.bianconi83@gmail.com,
	denis.ciocca@st.com, mario.tesi@st.com, armando.visconti@st.com,
	martin@geanix.com
Subject: Re: [PATCH v8 5/5] iio: imu: st_lsm6dsx: add motion report function and call from interrupt
Date: Sun, 15 Sep 2019 15:41:11 +0200
Message-ID: <20190915134111.GD15634@lore-desk-wlan.lan> (raw)
In-Reply-To: <20190915141808.6ca04f0f@archlinux>

[-- Attachment #1: Type: text/plain, Size: 7364 bytes --]

> On Sun, 15 Sep 2019 15:05:08 +0200
> Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> 
> > > On Fri, 13 Sep 2019 11:07:08 +0200
> > > Sean Nyekjaer <sean@geanix.com> wrote:
> > >   
> > > > Report iio motion events to iio subsystem
> > > > 
> > > > Signed-off-by: Sean Nyekjaer <sean@geanix.com>  
> > > I got to the earlier thread rather late so hadn't replied to your
> > > question on filtering events that haven't been enabled.  
> > 
> > IIUC, how is possible to filter events? it seems not currently supported in
> > hw, right?
> Filter them in software on their way to userspace.  So you'll get an interrupt
> either way, but no need to tell userspace about event's it's not interested
> in.

ack

> > 
> > > 
> > > Hence I think it's just that change outstanding
> > > + I want to give Lorenzo time for a final look.  
> > 
> > Jonathan the series seems fine to me now, there are some leftover nitpicks we can
> > cover with some follow-up patches.
> 
> Acks/Reviewed-bys?  Let's do this formally!

I will look at v9 and then I will add my acked-by.

Regards,
Lorenzo

> 
> Jonathan
> 
> > 
> > Regards,
> > Lorenzo
> > 
> > > 
> > > Thanks,
> > > 
> > > Jonathan
> > >   
> > > > ---
> > > > Changes since v4:
> > > >  * Updated bitmask as pr Jonathans comments
> > > > 
> > > > Changes since v5:
> > > >  * None
> > > > 
> > > > Changes since v6:
> > > >  * None
> > > > 
> > > > Changes since v7:
> > > >  * None
> > > > 
> > > >  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  5 ++
> > > >  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 70 ++++++++++++++++++++
> > > >  2 files changed, 75 insertions(+)
> > > > 
> > > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > > > index 449c2798f7ed..7c50fac7b85c 100644
> > > > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > > > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > > > @@ -186,6 +186,11 @@ struct st_lsm6dsx_shub_settings {
> > > >  struct st_lsm6dsx_event_settings {
> > > >  	struct st_lsm6dsx_reg enable_reg;
> > > >  	struct st_lsm6dsx_reg wakeup_reg;
> > > > +	u8 wakeup_src_reg;
> > > > +	u8 wakeup_src_status_mask;
> > > > +	u8 wakeup_src_z_mask;
> > > > +	u8 wakeup_src_y_mask;
> > > > +	u8 wakeup_src_x_mask;
> > > >  };
> > > >  
> > > >  enum st_lsm6dsx_ext_sensor_id {
> > > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > > > index 80a94335175f..66700c20920d 100644
> > > > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > > > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> > > > @@ -48,6 +48,7 @@
> > > >  #include <linux/kernel.h>
> > > >  #include <linux/module.h>
> > > >  #include <linux/delay.h>
> > > > +#include <linux/iio/events.h>
> > > >  #include <linux/iio/iio.h>
> > > >  #include <linux/iio/sysfs.h>
> > > >  #include <linux/interrupt.h>
> > > > @@ -287,6 +288,11 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> > > >  				.addr = 0x5B,
> > > >  				.mask = GENMASK(5, 0),
> > > >  			},
> > > > +			.wakeup_src_reg = 0x1b,
> > > > +			.wakeup_src_status_mask = BIT(3),
> > > > +			.wakeup_src_z_mask = BIT(0),
> > > > +			.wakeup_src_y_mask = BIT(1),
> > > > +			.wakeup_src_x_mask = BIT(2),
> > > >  		},
> > > >  	},
> > > >  	{
> > > > @@ -412,6 +418,11 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> > > >  				.addr = 0x5B,
> > > >  				.mask = GENMASK(5, 0),
> > > >  			},
> > > > +			.wakeup_src_reg = 0x1b,
> > > > +			.wakeup_src_status_mask = BIT(3),
> > > > +			.wakeup_src_z_mask = BIT(0),
> > > > +			.wakeup_src_y_mask = BIT(1),
> > > > +			.wakeup_src_x_mask = BIT(2),
> > > >  		},
> > > >  	},
> > > >  	{
> > > > @@ -550,6 +561,11 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> > > >  				.addr = 0x5B,
> > > >  				.mask = GENMASK(5, 0),
> > > >  			},
> > > > +			.wakeup_src_reg = 0x1b,
> > > > +			.wakeup_src_status_mask = BIT(3),
> > > > +			.wakeup_src_z_mask = BIT(0),
> > > > +			.wakeup_src_y_mask = BIT(1),
> > > > +			.wakeup_src_x_mask = BIT(2),
> > > >  		},
> > > >  	},
> > > >  	{
> > > > @@ -816,6 +832,11 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> > > >  				.addr = 0x5B,
> > > >  				.mask = GENMASK(5, 0),
> > > >  			},
> > > > +			.wakeup_src_reg = 0x1b,
> > > > +			.wakeup_src_status_mask = BIT(3),
> > > > +			.wakeup_src_z_mask = BIT(0),
> > > > +			.wakeup_src_y_mask = BIT(1),
> > > > +			.wakeup_src_x_mask = BIT(2),
> > > >  		},
> > > >  	},
> > > >  	{
> > > > @@ -970,6 +991,11 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> > > >  				.addr = 0x5B,
> > > >  				.mask = GENMASK(5, 0),
> > > >  			},
> > > > +			.wakeup_src_reg = 0x1b,
> > > > +			.wakeup_src_status_mask = BIT(3),
> > > > +			.wakeup_src_z_mask = BIT(0),
> > > > +			.wakeup_src_y_mask = BIT(1),
> > > > +			.wakeup_src_x_mask = BIT(2),
> > > >  		}
> > > >  	},
> > > >  };
> > > > @@ -1715,6 +1741,38 @@ static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw,
> > > >  	return iio_dev;
> > > >  }
> > > >  
> > > > +void st_lsm6dsx_report_motion_event(struct st_lsm6dsx_hw *hw, int data)
> > > > +{
> > > > +	s64 timestamp = iio_get_time_ns(hw->iio_devs[ST_LSM6DSX_ID_ACC]);
> > > > +
> > > > +	if (data & hw->settings->event_settings.wakeup_src_z_mask)
> > > > +		iio_push_event(hw->iio_devs[ST_LSM6DSX_ID_ACC],
> > > > +			       IIO_MOD_EVENT_CODE(IIO_ACCEL,
> > > > +						  0,
> > > > +						  IIO_MOD_Z,
> > > > +						  IIO_EV_TYPE_THRESH,
> > > > +						  IIO_EV_DIR_EITHER),
> > > > +						  timestamp);
> > > > +
> > > > +	if (data & hw->settings->event_settings.wakeup_src_x_mask)
> > > > +		iio_push_event(hw->iio_devs[ST_LSM6DSX_ID_ACC],
> > > > +			       IIO_MOD_EVENT_CODE(IIO_ACCEL,
> > > > +						  0,
> > > > +						  IIO_MOD_Y,
> > > > +						  IIO_EV_TYPE_THRESH,
> > > > +						  IIO_EV_DIR_EITHER),
> > > > +						  timestamp);
> > > > +
> > > > +	if (data & hw->settings->event_settings.wakeup_src_x_mask)
> > > > +		iio_push_event(hw->iio_devs[ST_LSM6DSX_ID_ACC],
> > > > +			       IIO_MOD_EVENT_CODE(IIO_ACCEL,
> > > > +						  0,
> > > > +						  IIO_MOD_X,
> > > > +						  IIO_EV_TYPE_THRESH,
> > > > +						  IIO_EV_DIR_EITHER),
> > > > +						  timestamp);
> > > > +}
> > > > +
> > > >  static irqreturn_t st_lsm6dsx_handler_irq(int irq, void *private)
> > > >  {
> > > >  	return IRQ_WAKE_THREAD;
> > > > @@ -1724,6 +1782,18 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private)
> > > >  {
> > > >  	struct st_lsm6dsx_hw *hw = private;
> > > >  	int count;
> > > > +	int data, err;
> > > > +
> > > > +	if (hw->enable_event) {
> > > > +		err = regmap_read(hw->regmap,
> > > > +				  hw->settings->event_settings.wakeup_src_reg,
> > > > +				  &data);
> > > > +		if (err < 0)
> > > > +			return IRQ_NONE;
> > > > +
> > > > +		if (data & hw->settings->event_settings.wakeup_src_status_mask)
> > > > +			st_lsm6dsx_report_motion_event(hw, data);
> > > > +	}
> > > >  
> > > >  	mutex_lock(&hw->fifo_lock);
> > > >  	count = hw->settings->fifo_ops.read_fifo(hw);  
> > >   
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      parent reply index

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-13  9:07 [PATCH v8 0/5] enable motion events for st_lsm6dsx Sean Nyekjaer
2019-09-13  9:07 ` [PATCH v8 1/5] iio: imu: st_lsm6dsx: move interrupt thread to core Sean Nyekjaer
2019-09-13  9:07 ` [PATCH v8 2/5] iio: imu: st_lsm6dsx: add motion events Sean Nyekjaer
2019-09-13  9:07 ` [PATCH v8 3/5] iio: imu: st_lsm6dsx: add wakeup-source option Sean Nyekjaer
2019-09-15 13:42   ` Lorenzo Bianconi
2019-09-13  9:07 ` [PATCH v8 4/5] iio: imu: st_lsm6dsx: always enter interrupt thread Sean Nyekjaer
2019-09-15 12:33   ` Jonathan Cameron
2019-09-15 12:48     ` Lorenzo Bianconi
2019-09-15 13:00       ` Jonathan Cameron
2019-09-15 13:07         ` Lorenzo Bianconi
2019-09-13  9:07 ` [PATCH v8 5/5] iio: imu: st_lsm6dsx: add motion report function and call from interrupt Sean Nyekjaer
2019-09-15 12:30   ` Jonathan Cameron
2019-09-15 13:05     ` Lorenzo Bianconi
2019-09-15 13:18       ` Jonathan Cameron
2019-09-15 13:22         ` Sean Nyekjaer
2019-09-15 13:35           ` Jonathan Cameron
2019-09-16  9:02             ` [RFC PATCH] iio: imu: st_lsm6dsx: filter motion events in driver Sean Nyekjaer
2019-09-16  9:16               ` Lorenzo Bianconi
2019-09-16 11:29                 ` Sean Nyekjaer
2019-09-16 11:55                   ` Lorenzo Bianconi
2019-09-16 12:09                     ` Sean Nyekjaer
2019-09-16 12:22                       ` Lorenzo Bianconi
2019-09-15 13:41         ` Lorenzo Bianconi [this message]

Reply instructions:

You may reply publically 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=20190915134111.GD15634@lore-desk-wlan.lan \
    --to=lorenzo@kernel.org \
    --cc=armando.visconti@st.com \
    --cc=denis.ciocca@st.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=lorenzo.bianconi83@gmail.com \
    --cc=mario.tesi@st.com \
    --cc=martin@geanix.com \
    --cc=sean@geanix.com \
    /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

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org linux-iio@archiver.kernel.org
	public-inbox-index linux-iio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/ public-inbox