iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZE
Subsystems (2)
PATCH 1/2 iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZE
Support for sensor with up to 8 different ODR settings. Required for supporting LIS3MDL as sensor hub slave device.
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +1 -1
@@ -111,7 +111,7 @@ struct st_lsm6dsx_odr {u8 val; }; -#define ST_LSM6DSX_ODR_LIST_SIZE 6 +#define ST_LSM6DSX_ODR_LIST_SIZE 8struct st_lsm6dsx_odr_table_entry {struct st_lsm6dsx_reg reg;
Signature · 1 line
2.25.0
PATCH 2/2 iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL
Add LIS3MDL register map to sensor hub device table. Tested with LSM6DSM.
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 63 ++++++++++++++++++++ 1 file changed, 63 insertions(+)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +63 -0
@@ -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)
Signature · 1 line
2.25.0
Re: [PATCH 2/2] iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL
Quoted 13 lines · Jimmy Assarsson
Add LIS3MDL register map to sensor hub device table. Tested with LSM6DSM.
Signed-off-by Jimmy Assarsson <[email protected]>--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 63 ++++++++++++++++++++ 1 file changed, 63 insertions(+)drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +0
-0
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = { · line 95
Quoted 8 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +5
-0@@ -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?
Quoted 62 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +58
-0+ .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)
Re: [PATCH 2/2] iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL
Quoted 1 line · Jimmy Assarsson
On 2020-03-24 22:52, Jimmy Assarsson wrote:
...
Quoted 5 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = { · line 95
Quoted 2 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +2
-0+ .wai = { + .addr = 0x0f,In
st_magn_core.cthis isST_SENSORS_DEFAULT_WAI_ADDRESS(fromlinux/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.
Quoted 3 lines
Quoted 3 lines
(quoted diff) +2
-0+ .val = 0x3d, + },
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 2/2] iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL
Quoted 6 lines · Andy Shevchenko
Quoted 1 line · Jimmy Assarsson
On 2020-03-24 22:52, Jimmy Assarsson wrote:
...
Quoted 7 lines
Quoted 5 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = { · line 95
Quoted 2 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +2
-0+ .wai = { + .addr = 0x0f,In
st_magn_core.cthis isST_SENSORS_DEFAULT_WAI_ADDRESS(fromlinux/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.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
(quoted diff) +2
-0+ .val = 0x3d, + },
Jonathan Cameron
maintainerQuoted 4 lines · On Tue, 24 Mar 2020 22:52:25 +0100 Jimmy Assarsson <[email protected]>…
Support for sensor with up to 8 different ODR settings. Required for supporting LIS3MDL as sensor hub slave device.
Signed-off-by Jimmy Assarsson <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to poke at it.
Thanks,
Jonathan
Quoted 17 lines
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +1
-1@@ -111,7 +111,7 @@ struct st_lsm6dsx_odr {u8 val; }; -#define ST_LSM6DSX_ODR_LIST_SIZE 6 +#define ST_LSM6DSX_ODR_LIST_SIZE 8struct st_lsm6dsx_odr_table_entry {struct st_lsm6dsx_reg reg;