Commit f35e1ee9 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Jonathan Cameron

iio: imu: st_lsm6dsx: add support to LSM6DSO16IS

Add support to STM LSM6DSO16IS (accelerometer and gyroscope) Mems sensor.

Datasheet: https://www.st.com/resource/en/datasheet/lsm6dso16is.pdfTested-by: default avatarMario Tesi <mario.tesi@st.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/df6a9d4653cd69f7204190f8b6a9b618fd48bd23.1668605631.git.lorenzo@kernel.orgSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 48ea7559
...@@ -13,8 +13,8 @@ config IIO_ST_LSM6DSX ...@@ -13,8 +13,8 @@ config IIO_ST_LSM6DSX
sensor. Supported devices: lsm6ds3, lsm6ds3h, lsm6dsl, lsm6dsm, sensor. Supported devices: lsm6ds3, lsm6ds3h, lsm6dsl, lsm6dsm,
ism330dlc, lsm6dso, lsm6dsox, asm330lhh, asm330lhhx, lsm6dsr, ism330dlc, lsm6dso, lsm6dsox, asm330lhh, asm330lhhx, lsm6dsr,
lsm6ds3tr-c, ism330dhcx, lsm6dsrx, lsm6ds0, lsm6dsop, lsm6dstx, lsm6ds3tr-c, ism330dhcx, lsm6dsrx, lsm6ds0, lsm6dsop, lsm6dstx,
lsm6dsv, lsm6dsv16x, the accelerometer/gyroscope of lsm9ds1 lsm6dsv, lsm6dsv16x, lsm6dso16is, the accelerometer/gyroscope
and lsm6dst. of lsm9ds1 and lsm6dst.
To compile this driver as a module, choose M here: the module To compile this driver as a module, choose M here: the module
will be called st_lsm6dsx. will be called st_lsm6dsx.
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#define ST_LSM6DSTX_DEV_NAME "lsm6dstx" #define ST_LSM6DSTX_DEV_NAME "lsm6dstx"
#define ST_LSM6DSV_DEV_NAME "lsm6dsv" #define ST_LSM6DSV_DEV_NAME "lsm6dsv"
#define ST_LSM6DSV16X_DEV_NAME "lsm6dsv16x" #define ST_LSM6DSV16X_DEV_NAME "lsm6dsv16x"
#define ST_LSM6DSO16IS_DEV_NAME "lsm6dso16is"
enum st_lsm6dsx_hw_id { enum st_lsm6dsx_hw_id {
ST_LSM6DS3_ID, ST_LSM6DS3_ID,
...@@ -57,6 +58,7 @@ enum st_lsm6dsx_hw_id { ...@@ -57,6 +58,7 @@ enum st_lsm6dsx_hw_id {
ST_LSM6DSTX_ID, ST_LSM6DSTX_ID,
ST_LSM6DSV_ID, ST_LSM6DSV_ID,
ST_LSM6DSV16X_ID, ST_LSM6DSV16X_ID,
ST_LSM6DSO16IS_ID,
ST_LSM6DSX_MAX_ID, ST_LSM6DSX_MAX_ID,
}; };
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* - FIFO size: 4KB * - FIFO size: 4KB
* *
* - LSM6DSO/LSM6DSOX/ASM330LHH/ASM330LHHX/LSM6DSR/ISM330DHCX/LSM6DST/LSM6DSOP/ * - LSM6DSO/LSM6DSOX/ASM330LHH/ASM330LHHX/LSM6DSR/ISM330DHCX/LSM6DST/LSM6DSOP/
* LSM6DSTX: * LSM6DSTX/LSM6DSO16IS:
* - Accelerometer/Gyroscope supported ODR [Hz]: 12.5, 26, 52, 104, 208, 416, * - Accelerometer/Gyroscope supported ODR [Hz]: 12.5, 26, 52, 104, 208, 416,
* 833 * 833
* - Accelerometer supported full-scale [g]: +-2/+-4/+-8/+-16 * - Accelerometer supported full-scale [g]: +-2/+-4/+-8/+-16
...@@ -1375,6 +1375,132 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { ...@@ -1375,6 +1375,132 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
.wakeup_src_x_mask = BIT(2), .wakeup_src_x_mask = BIT(2),
}, },
}, },
{
.reset = {
.addr = 0x12,
.mask = BIT(0),
},
.boot = {
.addr = 0x12,
.mask = BIT(7),
},
.bdu = {
.addr = 0x12,
.mask = BIT(6),
},
.id = {
{
.hw_id = ST_LSM6DSO16IS_ID,
.name = ST_LSM6DSO16IS_DEV_NAME,
.wai = 0x22,
},
},
.channels = {
[ST_LSM6DSX_ID_ACC] = {
.chan = st_lsm6dsx_acc_channels,
.len = ARRAY_SIZE(st_lsm6dsx_acc_channels),
},
[ST_LSM6DSX_ID_GYRO] = {
.chan = st_lsm6dsx_gyro_channels,
.len = ARRAY_SIZE(st_lsm6dsx_gyro_channels),
},
},
.odr_table = {
[ST_LSM6DSX_ID_ACC] = {
.reg = {
.addr = 0x10,
.mask = GENMASK(7, 4),
},
.odr_avl[0] = { 12500, 0x01 },
.odr_avl[1] = { 26000, 0x02 },
.odr_avl[2] = { 52000, 0x03 },
.odr_avl[3] = { 104000, 0x04 },
.odr_avl[4] = { 208000, 0x05 },
.odr_avl[5] = { 416000, 0x06 },
.odr_avl[6] = { 833000, 0x07 },
.odr_len = 7,
},
[ST_LSM6DSX_ID_GYRO] = {
.reg = {
.addr = 0x11,
.mask = GENMASK(7, 4),
},
.odr_avl[0] = { 12500, 0x01 },
.odr_avl[1] = { 26000, 0x02 },
.odr_avl[2] = { 52000, 0x03 },
.odr_avl[3] = { 104000, 0x04 },
.odr_avl[4] = { 208000, 0x05 },
.odr_avl[5] = { 416000, 0x06 },
.odr_avl[6] = { 833000, 0x07 },
.odr_len = 7,
},
},
.fs_table = {
[ST_LSM6DSX_ID_ACC] = {
.reg = {
.addr = 0x10,
.mask = GENMASK(3, 2),
},
.fs_avl[0] = { IIO_G_TO_M_S_2(61000), 0x0 },
.fs_avl[1] = { IIO_G_TO_M_S_2(122000), 0x2 },
.fs_avl[2] = { IIO_G_TO_M_S_2(244000), 0x3 },
.fs_avl[3] = { IIO_G_TO_M_S_2(488000), 0x1 },
.fs_len = 4,
},
[ST_LSM6DSX_ID_GYRO] = {
.reg = {
.addr = 0x11,
.mask = GENMASK(3, 2),
},
.fs_avl[0] = { IIO_DEGREE_TO_RAD(8750000), 0x0 },
.fs_avl[1] = { IIO_DEGREE_TO_RAD(17500000), 0x1 },
.fs_avl[2] = { IIO_DEGREE_TO_RAD(35000000), 0x2 },
.fs_avl[3] = { IIO_DEGREE_TO_RAD(70000000), 0x3 },
.fs_len = 4,
},
},
.irq_config = {
.hla = {
.addr = 0x12,
.mask = BIT(5),
},
.od = {
.addr = 0x12,
.mask = BIT(4),
},
},
.shub_settings = {
.page_mux = {
.addr = 0x01,
.mask = BIT(6),
},
.master_en = {
.sec_page = true,
.addr = 0x14,
.mask = BIT(2),
},
.pullup_en = {
.sec_page = true,
.addr = 0x14,
.mask = BIT(3),
},
.aux_sens = {
.addr = 0x14,
.mask = GENMASK(1, 0),
},
.wr_once = {
.addr = 0x14,
.mask = BIT(6),
},
.num_ext_dev = 3,
.shub_out = {
.sec_page = true,
.addr = 0x02,
},
.slv0_addr = 0x15,
.dw_slv0_addr = 0x21,
},
},
}; };
int st_lsm6dsx_set_page(struct st_lsm6dsx_hw *hw, bool enable) int st_lsm6dsx_set_page(struct st_lsm6dsx_hw *hw, bool enable)
......
...@@ -117,6 +117,10 @@ static const struct of_device_id st_lsm6dsx_i2c_of_match[] = { ...@@ -117,6 +117,10 @@ static const struct of_device_id st_lsm6dsx_i2c_of_match[] = {
.compatible = "st,lsm6dsv16x", .compatible = "st,lsm6dsv16x",
.data = (void *)ST_LSM6DSV16X_ID, .data = (void *)ST_LSM6DSV16X_ID,
}, },
{
.compatible = "st,lsm6dso16is",
.data = (void *)ST_LSM6DSO16IS_ID,
},
{}, {},
}; };
MODULE_DEVICE_TABLE(of, st_lsm6dsx_i2c_of_match); MODULE_DEVICE_TABLE(of, st_lsm6dsx_i2c_of_match);
...@@ -142,6 +146,7 @@ static const struct i2c_device_id st_lsm6dsx_i2c_id_table[] = { ...@@ -142,6 +146,7 @@ static const struct i2c_device_id st_lsm6dsx_i2c_id_table[] = {
{ ST_LSM6DSTX_DEV_NAME, ST_LSM6DSTX_ID }, { ST_LSM6DSTX_DEV_NAME, ST_LSM6DSTX_ID },
{ ST_LSM6DSV_DEV_NAME, ST_LSM6DSV_ID }, { ST_LSM6DSV_DEV_NAME, ST_LSM6DSV_ID },
{ ST_LSM6DSV16X_DEV_NAME, ST_LSM6DSV16X_ID }, { ST_LSM6DSV16X_DEV_NAME, ST_LSM6DSV16X_ID },
{ ST_LSM6DSO16IS_DEV_NAME, ST_LSM6DSO16IS_ID },
{}, {},
}; };
MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table); MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table);
......
...@@ -117,6 +117,10 @@ static const struct of_device_id st_lsm6dsx_spi_of_match[] = { ...@@ -117,6 +117,10 @@ static const struct of_device_id st_lsm6dsx_spi_of_match[] = {
.compatible = "st,lsm6dsv16x", .compatible = "st,lsm6dsv16x",
.data = (void *)ST_LSM6DSV16X_ID, .data = (void *)ST_LSM6DSV16X_ID,
}, },
{
.compatible = "st,lsm6dso16is",
.data = (void *)ST_LSM6DSO16IS_ID,
},
{}, {},
}; };
MODULE_DEVICE_TABLE(of, st_lsm6dsx_spi_of_match); MODULE_DEVICE_TABLE(of, st_lsm6dsx_spi_of_match);
...@@ -142,6 +146,7 @@ static const struct spi_device_id st_lsm6dsx_spi_id_table[] = { ...@@ -142,6 +146,7 @@ static const struct spi_device_id st_lsm6dsx_spi_id_table[] = {
{ ST_LSM6DSTX_DEV_NAME, ST_LSM6DSTX_ID }, { ST_LSM6DSTX_DEV_NAME, ST_LSM6DSTX_ID },
{ ST_LSM6DSV_DEV_NAME, ST_LSM6DSV_ID }, { ST_LSM6DSV_DEV_NAME, ST_LSM6DSV_ID },
{ ST_LSM6DSV16X_DEV_NAME, ST_LSM6DSV16X_ID }, { ST_LSM6DSV16X_DEV_NAME, ST_LSM6DSV16X_ID },
{ ST_LSM6DSO16IS_DEV_NAME, ST_LSM6DSO16IS_ID },
{}, {},
}; };
MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table); MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment