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

iio: imu: st_lsm6dsx: add support to multiple devices with the same settings

Add capability to support multiple devices with the same
st_lsm6dsx_settings like LSM6DSM/LSM6DSL
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent feda2840
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
enum st_lsm6dsx_hw_id { enum st_lsm6dsx_hw_id {
ST_LSM6DS3_ID, ST_LSM6DS3_ID,
ST_LSM6DSM_ID, ST_LSM6DSM_ID,
ST_LSM6DSX_MAX_ID,
}; };
#define ST_LSM6DSX_CHAN_SIZE 2 #define ST_LSM6DSX_CHAN_SIZE 2
...@@ -50,7 +51,7 @@ struct st_lsm6dsx_reg { ...@@ -50,7 +51,7 @@ struct st_lsm6dsx_reg {
struct st_lsm6dsx_settings { struct st_lsm6dsx_settings {
u8 wai; u8 wai;
u16 max_fifo_size; u16 max_fifo_size;
enum st_lsm6dsx_hw_id id; enum st_lsm6dsx_hw_id id[ST_LSM6DSX_MAX_ID];
}; };
enum st_lsm6dsx_sensor_id { enum st_lsm6dsx_sensor_id {
......
...@@ -74,12 +74,6 @@ ...@@ -74,12 +74,6 @@
#define ST_LSM6DSX_REG_GYRO_OUT_Y_L_ADDR 0x24 #define ST_LSM6DSX_REG_GYRO_OUT_Y_L_ADDR 0x24
#define ST_LSM6DSX_REG_GYRO_OUT_Z_L_ADDR 0x26 #define ST_LSM6DSX_REG_GYRO_OUT_Z_L_ADDR 0x26
#define ST_LSM6DS3_WHOAMI 0x69
#define ST_LSM6DSM_WHOAMI 0x6a
#define ST_LSM6DS3_MAX_FIFO_SIZE 8192
#define ST_LSM6DSM_MAX_FIFO_SIZE 4096
#define ST_LSM6DSX_ACC_FS_2G_GAIN IIO_G_TO_M_S_2(61) #define ST_LSM6DSX_ACC_FS_2G_GAIN IIO_G_TO_M_S_2(61)
#define ST_LSM6DSX_ACC_FS_4G_GAIN IIO_G_TO_M_S_2(122) #define ST_LSM6DSX_ACC_FS_4G_GAIN IIO_G_TO_M_S_2(122)
#define ST_LSM6DSX_ACC_FS_8G_GAIN IIO_G_TO_M_S_2(244) #define ST_LSM6DSX_ACC_FS_8G_GAIN IIO_G_TO_M_S_2(244)
...@@ -164,14 +158,18 @@ static const struct st_lsm6dsx_fs_table_entry st_lsm6dsx_fs_table[] = { ...@@ -164,14 +158,18 @@ static const struct st_lsm6dsx_fs_table_entry st_lsm6dsx_fs_table[] = {
static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
{ {
.wai = ST_LSM6DS3_WHOAMI, .wai = 0x69,
.max_fifo_size = ST_LSM6DS3_MAX_FIFO_SIZE, .max_fifo_size = 8192,
.id = ST_LSM6DS3_ID, .id = {
[0] = ST_LSM6DS3_ID,
},
}, },
{ {
.wai = ST_LSM6DSM_WHOAMI, .wai = 0x6a,
.max_fifo_size = ST_LSM6DSM_MAX_FIFO_SIZE, .max_fifo_size = 4096,
.id = ST_LSM6DSM_ID, .id = {
[0] = ST_LSM6DSM_ID,
},
}, },
}; };
...@@ -241,11 +239,15 @@ int st_lsm6dsx_write_with_mask(struct st_lsm6dsx_hw *hw, u8 addr, u8 mask, ...@@ -241,11 +239,15 @@ int st_lsm6dsx_write_with_mask(struct st_lsm6dsx_hw *hw, u8 addr, u8 mask,
static int st_lsm6dsx_check_whoami(struct st_lsm6dsx_hw *hw, int id) static int st_lsm6dsx_check_whoami(struct st_lsm6dsx_hw *hw, int id)
{ {
int err, i; int err, i, j;
u8 data; u8 data;
for (i = 0; i < ARRAY_SIZE(st_lsm6dsx_sensor_settings); i++) { for (i = 0; i < ARRAY_SIZE(st_lsm6dsx_sensor_settings); i++) {
if (id == st_lsm6dsx_sensor_settings[i].id) for (j = 0; j < ST_LSM6DSX_MAX_ID; j++) {
if (id == st_lsm6dsx_sensor_settings[i].id[j])
break;
}
if (j < ST_LSM6DSX_MAX_ID)
break; break;
} }
......
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