Commit 66b662a1 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Jonathan Cameron

iio: imu: st_lsm6dsx: move bdu/boot and reset register info in hw_settings

Move bdu, boot and reset register definitions in hw_settings register
map since not all supported sensors (e.g lsm9ds1) rely on the same
definitions

Fixes: 52f4b1f1 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 31fe8d4e
...@@ -238,7 +238,9 @@ struct st_lsm6dsx_ext_dev_settings { ...@@ -238,7 +238,9 @@ struct st_lsm6dsx_ext_dev_settings {
/** /**
* struct st_lsm6dsx_settings - ST IMU sensor settings * struct st_lsm6dsx_settings - ST IMU sensor settings
* @wai: Sensor WhoAmI default value. * @wai: Sensor WhoAmI default value.
* @reset_addr: register address for reset/reboot * @reset: register address for reset.
* @boot: register address for boot.
* @bdu: register address for Block Data Update.
* @max_fifo_size: Sensor max fifo length in FIFO words. * @max_fifo_size: Sensor max fifo length in FIFO words.
* @id: List of hw id/device name supported by the driver configuration. * @id: List of hw id/device name supported by the driver configuration.
* @channels: IIO channels supported by the device. * @channels: IIO channels supported by the device.
...@@ -253,7 +255,9 @@ struct st_lsm6dsx_ext_dev_settings { ...@@ -253,7 +255,9 @@ struct st_lsm6dsx_ext_dev_settings {
*/ */
struct st_lsm6dsx_settings { struct st_lsm6dsx_settings {
u8 wai; u8 wai;
u8 reset_addr; struct st_lsm6dsx_reg reset;
struct st_lsm6dsx_reg boot;
struct st_lsm6dsx_reg bdu;
u16 max_fifo_size; u16 max_fifo_size;
struct { struct {
enum st_lsm6dsx_hw_id hw_id; enum st_lsm6dsx_hw_id hw_id;
......
...@@ -62,10 +62,6 @@ ...@@ -62,10 +62,6 @@
#include "st_lsm6dsx.h" #include "st_lsm6dsx.h"
#define ST_LSM6DSX_REG_WHOAMI_ADDR 0x0f #define ST_LSM6DSX_REG_WHOAMI_ADDR 0x0f
#define ST_LSM6DSX_REG_RESET_MASK BIT(0)
#define ST_LSM6DSX_REG_BOOT_MASK BIT(7)
#define ST_LSM6DSX_REG_BDU_ADDR 0x12
#define ST_LSM6DSX_REG_BDU_MASK BIT(6)
static const struct iio_chan_spec st_lsm6dsx_acc_channels[] = { static const struct iio_chan_spec st_lsm6dsx_acc_channels[] = {
ST_LSM6DSX_CHANNEL_ACC(IIO_ACCEL, 0x28, IIO_MOD_X, 0), ST_LSM6DSX_CHANNEL_ACC(IIO_ACCEL, 0x28, IIO_MOD_X, 0),
...@@ -91,7 +87,18 @@ static const struct iio_chan_spec st_lsm6ds0_gyro_channels[] = { ...@@ -91,7 +87,18 @@ static const struct iio_chan_spec st_lsm6ds0_gyro_channels[] = {
static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
{ {
.wai = 0x68, .wai = 0x68,
.reset_addr = 0x22, .reset = {
.addr = 0x22,
.mask = BIT(0),
},
.boot = {
.addr = 0x22,
.mask = BIT(7),
},
.bdu = {
.addr = 0x22,
.mask = BIT(6),
},
.max_fifo_size = 32, .max_fifo_size = 32,
.id = { .id = {
{ {
...@@ -179,7 +186,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { ...@@ -179,7 +186,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
}, },
{ {
.wai = 0x69, .wai = 0x69,
.reset_addr = 0x12, .reset = {
.addr = 0x12,
.mask = BIT(0),
},
.boot = {
.addr = 0x12,
.mask = BIT(7),
},
.bdu = {
.addr = 0x12,
.mask = BIT(6),
},
.max_fifo_size = 1365, .max_fifo_size = 1365,
.id = { .id = {
{ {
...@@ -332,7 +350,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { ...@@ -332,7 +350,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
}, },
{ {
.wai = 0x69, .wai = 0x69,
.reset_addr = 0x12, .reset = {
.addr = 0x12,
.mask = BIT(0),
},
.boot = {
.addr = 0x12,
.mask = BIT(7),
},
.bdu = {
.addr = 0x12,
.mask = BIT(6),
},
.max_fifo_size = 682, .max_fifo_size = 682,
.id = { .id = {
{ {
...@@ -485,7 +514,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { ...@@ -485,7 +514,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
}, },
{ {
.wai = 0x6a, .wai = 0x6a,
.reset_addr = 0x12, .reset = {
.addr = 0x12,
.mask = BIT(0),
},
.boot = {
.addr = 0x12,
.mask = BIT(7),
},
.bdu = {
.addr = 0x12,
.mask = BIT(6),
},
.max_fifo_size = 682, .max_fifo_size = 682,
.id = { .id = {
{ {
...@@ -651,7 +691,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { ...@@ -651,7 +691,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
}, },
{ {
.wai = 0x6c, .wai = 0x6c,
.reset_addr = 0x12, .reset = {
.addr = 0x12,
.mask = BIT(0),
},
.boot = {
.addr = 0x12,
.mask = BIT(7),
},
.bdu = {
.addr = 0x12,
.mask = BIT(6),
},
.max_fifo_size = 512, .max_fifo_size = 512,
.id = { .id = {
{ {
...@@ -810,7 +861,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { ...@@ -810,7 +861,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
}, },
{ {
.wai = 0x6b, .wai = 0x6b,
.reset_addr = 0x12, .reset = {
.addr = 0x12,
.mask = BIT(0),
},
.boot = {
.addr = 0x12,
.mask = BIT(7),
},
.bdu = {
.addr = 0x12,
.mask = BIT(6),
},
.max_fifo_size = 512, .max_fifo_size = 512,
.id = { .id = {
{ {
...@@ -963,7 +1025,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { ...@@ -963,7 +1025,18 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
}, },
{ {
.wai = 0x6b, .wai = 0x6b,
.reset_addr = 0x12, .reset = {
.addr = 0x12,
.mask = BIT(0),
},
.boot = {
.addr = 0x12,
.mask = BIT(7),
},
.bdu = {
.addr = 0x12,
.mask = BIT(6),
},
.max_fifo_size = 512, .max_fifo_size = 512,
.id = { .id = {
{ {
...@@ -1788,27 +1861,27 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw) ...@@ -1788,27 +1861,27 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw)
int err; int err;
/* device sw reset */ /* device sw reset */
err = regmap_update_bits(hw->regmap, hw->settings->reset_addr, reg = &hw->settings->reset;
ST_LSM6DSX_REG_RESET_MASK, err = regmap_update_bits(hw->regmap, reg->addr, reg->mask,
FIELD_PREP(ST_LSM6DSX_REG_RESET_MASK, 1)); ST_LSM6DSX_SHIFT_VAL(1, reg->mask));
if (err < 0) if (err < 0)
return err; return err;
msleep(50); msleep(50);
/* reload trimming parameter */ /* reload trimming parameter */
err = regmap_update_bits(hw->regmap, hw->settings->reset_addr, reg = &hw->settings->boot;
ST_LSM6DSX_REG_BOOT_MASK, err = regmap_update_bits(hw->regmap, reg->addr, reg->mask,
FIELD_PREP(ST_LSM6DSX_REG_BOOT_MASK, 1)); ST_LSM6DSX_SHIFT_VAL(1, reg->mask));
if (err < 0) if (err < 0)
return err; return err;
msleep(50); msleep(50);
/* enable Block Data Update */ /* enable Block Data Update */
err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_BDU_ADDR, reg = &hw->settings->bdu;
ST_LSM6DSX_REG_BDU_MASK, err = regmap_update_bits(hw->regmap, reg->addr, reg->mask,
FIELD_PREP(ST_LSM6DSX_REG_BDU_MASK, 1)); ST_LSM6DSX_SHIFT_VAL(1, reg->mask));
if (err < 0) if (err < 0)
return err; return err;
......
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