linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZE
@ 2020-03-24 21:52 Jimmy Assarsson
  2020-03-24 21:52 ` [PATCH 2/2] iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL Jimmy Assarsson
  2020-04-04 15:36 ` [PATCH 1/2] iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZE Jonathan Cameron
  0 siblings, 2 replies; 6+ messages in thread
From: Jimmy Assarsson @ 2020-03-24 21:52 UTC (permalink / raw)
  To: linux-iio; +Cc: Lorenzo Bianconi

Support for sensor with up to 8 different ODR settings.
Required for supporting LIS3MDL as sensor hub slave device.

Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index f2113a63721a..38b613072da2 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -111,7 +111,7 @@ struct st_lsm6dsx_odr {
 	u8 val;
 };
 
-#define ST_LSM6DSX_ODR_LIST_SIZE	6
+#define ST_LSM6DSX_ODR_LIST_SIZE	8
 struct st_lsm6dsx_odr_table_entry {
 	struct st_lsm6dsx_reg reg;
 
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL
  2020-03-24 21:52 [PATCH 1/2] iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZE Jimmy Assarsson
@ 2020-03-24 21:52 ` Jimmy Assarsson
  2020-03-24 21:58   ` Jimmy Assarsson
  2020-04-04 15:36 ` [PATCH 1/2] iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZE Jonathan Cameron
  1 sibling, 1 reply; 6+ messages in thread
From: Jimmy Assarsson @ 2020-03-24 21:52 UTC (permalink / raw)
  To: linux-iio; +Cc: Lorenzo Bianconi

Add LIS3MDL register map to sensor hub device table.
Tested with LSM6DSM.

Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 63 ++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
index 95ddd19d1aa7..20fdef7a6ea2 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
@@ -88,6 +88,69 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = {
 			.len = 6,
 		},
 	},
+	/* LIS3MDL */
+	{
+		.i2c_addr = { 0x1e },
+		.wai = {
+			.addr = 0x0f,
+			.val = 0x3d,
+		},
+		.id = ST_LSM6DSX_ID_MAGN,
+		.odr_table = {
+			.reg = {
+				.addr = 0x20,
+				.mask = GENMASK(4, 2),
+			},
+			.odr_avl[0] = {  1000, 0x0 },
+			.odr_avl[1] = {  2000, 0x1 },
+			.odr_avl[2] = {  3000, 0x2 },
+			.odr_avl[3] = {  5000, 0x3 },
+			.odr_avl[4] = { 10000, 0x4 },
+			.odr_avl[5] = { 20000, 0x5 },
+			.odr_avl[6] = { 40000, 0x6 },
+			.odr_avl[7] = { 80000, 0x7 },
+			.odr_len = 8,
+		},
+		.fs_table = {
+			.reg = {
+				.addr = 0x21,
+				.mask = GENMASK(6, 5),
+			},
+			.fs_avl[0] = {
+				.gain = 146,
+				.val = 0x00,
+			}, /* 4000 uG/LSB */
+			.fs_avl[1] = {
+				.gain = 292,
+				.val = 0x01,
+			}, /* 8000 uG/LSB */
+			.fs_avl[2] = {
+				.gain = 438,
+				.val = 0x02,
+			}, /* 12000 uG/LSB */
+			.fs_avl[3] = {
+				.gain = 584,
+				.val = 0x03,
+			}, /* 16000 uG/LSB */
+			.fs_len = 4,
+		},
+		.pwr_table = {
+			.reg = {
+				.addr = 0x22,
+				.mask = GENMASK(1, 0),
+			},
+			.off_val = 0x2,
+			.on_val = 0x0,
+		},
+		.bdu = {
+			.addr = 0x24,
+			.mask = BIT(6),
+		},
+		.out = {
+			.addr = 0x28,
+			.len = 6,
+		},
+	},
 };
 
 static void st_lsm6dsx_shub_wait_complete(struct st_lsm6dsx_hw *hw)
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL
  2020-03-24 21:52 ` [PATCH 2/2] iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL Jimmy Assarsson
@ 2020-03-24 21:58   ` Jimmy Assarsson
  2020-03-25 11:02     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Jimmy Assarsson @ 2020-03-24 21:58 UTC (permalink / raw)
  To: linux-iio; +Cc: Lorenzo Bianconi

On 2020-03-24 22:52, Jimmy Assarsson wrote:
> Add LIS3MDL register map to sensor hub device table.
> Tested with LSM6DSM.
> 
> Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
> ---
>   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 63 ++++++++++++++++++++
>   1 file changed, 63 insertions(+)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> index 95ddd19d1aa7..20fdef7a6ea2 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> @@ -88,6 +88,69 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = {
>   			.len = 6,
>   		},
>   	},
> +	/* LIS3MDL */
> +	{
> +		.i2c_addr = { 0x1e },
> +		.wai = {
> +			.addr = 0x0f,

In st_magn_core.c this is ST_SENSORS_DEFAULT_WAI_ADDRESS
(from linux/iio/common/st_sensors.h). Is this OK, our should I change it?

> +			.val = 0x3d,
> +		},
> +		.id = ST_LSM6DSX_ID_MAGN,
> +		.odr_table = {
> +			.reg = {
> +				.addr = 0x20,
> +				.mask = GENMASK(4, 2),
> +			},
> +			.odr_avl[0] = {  1000, 0x0 },
> +			.odr_avl[1] = {  2000, 0x1 },
> +			.odr_avl[2] = {  3000, 0x2 },
> +			.odr_avl[3] = {  5000, 0x3 },
> +			.odr_avl[4] = { 10000, 0x4 },
> +			.odr_avl[5] = { 20000, 0x5 },
> +			.odr_avl[6] = { 40000, 0x6 },
> +			.odr_avl[7] = { 80000, 0x7 },
> +			.odr_len = 8,
> +		},
> +		.fs_table = {
> +			.reg = {
> +				.addr = 0x21,
> +				.mask = GENMASK(6, 5),
> +			},
> +			.fs_avl[0] = {
> +				.gain = 146,
> +				.val = 0x00,
> +			}, /* 4000 uG/LSB */
> +			.fs_avl[1] = {
> +				.gain = 292,
> +				.val = 0x01,
> +			}, /* 8000 uG/LSB */
> +			.fs_avl[2] = {
> +				.gain = 438,
> +				.val = 0x02,
> +			}, /* 12000 uG/LSB */
> +			.fs_avl[3] = {
> +				.gain = 584,
> +				.val = 0x03,
> +			}, /* 16000 uG/LSB */
> +			.fs_len = 4,
> +		},
> +		.pwr_table = {
> +			.reg = {
> +				.addr = 0x22,
> +				.mask = GENMASK(1, 0),
> +			},
> +			.off_val = 0x2,
> +			.on_val = 0x0,
> +		},
> +		.bdu = {
> +			.addr = 0x24,
> +			.mask = BIT(6),
> +		},
> +		.out = {
> +			.addr = 0x28,
> +			.len = 6,
> +		},
> +	},
>   };
>   
>   static void st_lsm6dsx_shub_wait_complete(struct st_lsm6dsx_hw *hw)
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL
  2020-03-24 21:58   ` Jimmy Assarsson
@ 2020-03-25 11:02     ` Andy Shevchenko
  2020-03-25 18:57       ` Jimmy Assarsson
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2020-03-25 11:02 UTC (permalink / raw)
  To: Jimmy Assarsson; +Cc: linux-iio, Lorenzo Bianconi

On Tue, Mar 24, 2020 at 11:59 PM Jimmy Assarsson
<jimmyassarsson@gmail.com> wrote:
> On 2020-03-24 22:52, Jimmy Assarsson wrote:

...

> > +             .wai = {
> > +                     .addr = 0x0f,
>
> In st_magn_core.c this is ST_SENSORS_DEFAULT_WAI_ADDRESS
> (from linux/iio/common/st_sensors.h). Is this OK, our should I change it?

I would rather use macro, Easier to grep what is being used with ST sensors.

>
> > +                     .val = 0x3d,
> > +             },


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL
  2020-03-25 11:02     ` Andy Shevchenko
@ 2020-03-25 18:57       ` Jimmy Assarsson
  0 siblings, 0 replies; 6+ messages in thread
From: Jimmy Assarsson @ 2020-03-25 18:57 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-iio, Lorenzo Bianconi

On 2020-03-25 12:02, Andy Shevchenko wrote:
> On Tue, Mar 24, 2020 at 11:59 PM Jimmy Assarsson
> <jimmyassarsson@gmail.com> wrote:
>> On 2020-03-24 22:52, Jimmy Assarsson wrote:
> 
> ...
> 
>>> +             .wai = {
>>> +                     .addr = 0x0f,
>>
>> In st_magn_core.c this is ST_SENSORS_DEFAULT_WAI_ADDRESS
>> (from linux/iio/common/st_sensors.h). Is this OK, our should I change it?
> 
> I would rather use macro, Easier to grep what is being used with ST sensors.

Sure, will fix it in v2.

>>
>>> +                     .val = 0x3d,
>>> +             },

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZE
  2020-03-24 21:52 [PATCH 1/2] iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZE Jimmy Assarsson
  2020-03-24 21:52 ` [PATCH 2/2] iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL Jimmy Assarsson
@ 2020-04-04 15:36 ` Jonathan Cameron
  1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2020-04-04 15:36 UTC (permalink / raw)
  To: Jimmy Assarsson; +Cc: linux-iio, Lorenzo Bianconi

On Tue, 24 Mar 2020 22:52:25 +0100
Jimmy Assarsson <jimmyassarsson@gmail.com> wrote:

> Support for sensor with up to 8 different ODR settings.
> Required for supporting LIS3MDL as sensor hub slave device.
> 
> Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to poke at it.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index f2113a63721a..38b613072da2 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -111,7 +111,7 @@ struct st_lsm6dsx_odr {
>  	u8 val;
>  };
>  
> -#define ST_LSM6DSX_ODR_LIST_SIZE	6
> +#define ST_LSM6DSX_ODR_LIST_SIZE	8
>  struct st_lsm6dsx_odr_table_entry {
>  	struct st_lsm6dsx_reg reg;
>  


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-04 15:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24 21:52 [PATCH 1/2] iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZE Jimmy Assarsson
2020-03-24 21:52 ` [PATCH 2/2] iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL Jimmy Assarsson
2020-03-24 21:58   ` Jimmy Assarsson
2020-03-25 11:02     ` Andy Shevchenko
2020-03-25 18:57       ` Jimmy Assarsson
2020-04-04 15:36 ` [PATCH 1/2] iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZE Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).