iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL
Subsystems (2)
PATCH v2 2/2 iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL
Add LIS3MDL register map to sensor hub device table. Tested with LSM6DSM.
---
Changes in v2:
- Use ST_SENSORS_DEFAULT_WAI_ADDRESS
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 64 ++++++++++++++++++++ 1 file changed, 64 insertions(+)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +64 -0
@@ -28,6 +28,7 @@#include <linux/iio/sysfs.h> #include <linux/bitfield.h> +#include <linux/iio/common/st_sensors.h> #include "st_lsm6dsx.h" #define ST_LSM6DSX_SLV_ADDR (n, base) ((base) + (n) * 3)
@@ -88,6 +89,69 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = { .len = 6, }, }, +/* LIS3MDL */ + { + .i2c_addr = { 0x1e }, + .wai = { + .addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, + .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.26.0
Quoted 4 lines · On Sat, 28 Mar 2020 19:45:19 +0100 Jimmy Assarsson <[email protected]>…
Add LIS3MDL register map to sensor hub device table. Tested with LSM6DSM.
Signed-off-by Jimmy Assarsson <[email protected]>
Please always repost the entire series. On this occasion I can find patch 1 but sometimes it's not so easy :)
Looks fine to me, but lets' leave it on list for a while longer to see if others wish to comment.
Quoted 89 lines
---
Changes in v2:
- UseST_SENSORS_DEFAULT_WAI_ADDRESSdrivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 64 ++++++++++++++++++++ 1 file changed, 64 insertions(+)drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +64
-0@@ -28,6 +28,7 @@#include <linux/iio/sysfs.h> #include <linux/bitfield.h> +#include <linux/iio/common/st_sensors.h> #include "st_lsm6dsx.h" #define ST_LSM6DSX_SLV_ADDR (n, base) ((base) + (n) * 3)@@ -88,6 +89,69 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = { .len = 6, }, }, +/* LIS3MDL */ + { + .i2c_addr = { 0x1e }, + .wai = { + .addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, + .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)
Jonathan Cameron
maintainerQuoted 6 lines · On Sun, 29 Mar 2020 10:42:40 +0100 Jonathan Cameron…
Quoted 3 lines · On Sat, 28 Mar 2020 19:45:19 +0100 Jimmy Assarsson <[email protected]>…
Add LIS3MDL register map to sensor hub device table. Tested with LSM6DSM.
Quoted 8 lines
Quoted 1 line
Signed-off-by Jimmy Assarsson <[email protected]>Please always repost the entire series. On this occasion I can find patch 1 but sometimes it's not so easy :)
Looks fine to me, but lets' leave it on list for a while longer to see if others wish to comment.
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 90 lines
Quoted 89 lines
---
Changes in v2:
- UseST_SENSORS_DEFAULT_WAI_ADDRESSdrivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 64 ++++++++++++++++++++ 1 file changed, 64 insertions(+)drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +64
-0@@ -28,6 +28,7 @@#include <linux/iio/sysfs.h> #include <linux/bitfield.h> +#include <linux/iio/common/st_sensors.h> #include "st_lsm6dsx.h" #define ST_LSM6DSX_SLV_ADDR (n, base) ((base) + (n) * 3)@@ -88,6 +89,69 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = { .len = 6, }, }, +/* LIS3MDL */ + { + .i2c_addr = { 0x1e }, + .wai = { + .addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, + .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)