diff options
Diffstat (limited to 'drivers/iio/imu')
-rw-r--r-- | drivers/iio/imu/bmi160/bmi160.h | 7 | ||||
-rw-r--r-- | drivers/iio/imu/bmi160/bmi160_core.c | 7 | ||||
-rw-r--r-- | drivers/iio/imu/kmx61.c | 10 | ||||
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/Kconfig | 4 | ||||
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 10 | ||||
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 2 | ||||
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 318 | ||||
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | 10 | ||||
-rw-r--r-- | drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | 10 |
9 files changed, 137 insertions, 241 deletions
diff --git a/drivers/iio/imu/bmi160/bmi160.h b/drivers/iio/imu/bmi160/bmi160.h index a82e040bd109..32c2ea2d7112 100644 --- a/drivers/iio/imu/bmi160/bmi160.h +++ b/drivers/iio/imu/bmi160/bmi160.h @@ -10,6 +10,13 @@ struct bmi160_data { struct iio_trigger *trig; struct regulator_bulk_data supplies[2]; struct iio_mount_matrix orientation; + /* + * Ensure natural alignment for timestamp if present. + * Max length needed: 2 * 3 channels + 4 bytes padding + 8 byte ts. + * If fewer channels are enabled, less space may be needed, as + * long as the timestamp is still aligned to 8 bytes. + */ + __le16 buf[12] __aligned(8); }; extern const struct regmap_config bmi160_regmap_config; diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index 222ebb26f013..290b5ef83f77 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -427,8 +427,6 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct bmi160_data *data = iio_priv(indio_dev); - __le16 buf[16]; - /* 3 sens x 3 axis x __le16 + 3 x __le16 pad + 4 x __le16 tstamp */ int i, ret, j = 0, base = BMI160_REG_DATA_MAGN_XOUT_L; __le16 sample; @@ -438,10 +436,10 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p) &sample, sizeof(sample)); if (ret) goto done; - buf[j++] = sample; + data->buf[j++] = sample; } - iio_push_to_buffers_with_timestamp(indio_dev, buf, pf->timestamp); + iio_push_to_buffers_with_timestamp(indio_dev, data->buf, pf->timestamp); done: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; @@ -486,7 +484,6 @@ static int bmi160_write_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: return bmi160_set_scale(data, bmi160_to_sensor(chan->type), val2); - break; case IIO_CHAN_INFO_SAMP_FREQ: return bmi160_set_odr(data, bmi160_to_sensor(chan->type), val, val2); diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c index 61885e99d3fc..4377047d503a 100644 --- a/drivers/iio/imu/kmx61.c +++ b/drivers/iio/imu/kmx61.c @@ -1063,24 +1063,20 @@ err_unlock: return ret; } -static int kmx61_trig_try_reenable(struct iio_trigger *trig) +static void kmx61_trig_reenable(struct iio_trigger *trig) { struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); struct kmx61_data *data = kmx61_get_data(indio_dev); int ret; ret = i2c_smbus_read_byte_data(data->client, KMX61_REG_INL); - if (ret < 0) { + if (ret < 0) dev_err(&data->client->dev, "Error reading reg_inl\n"); - return ret; - } - - return 0; } static const struct iio_trigger_ops kmx61_trigger_ops = { .set_trigger_state = kmx61_data_rdy_trigger_set_state, - .try_reenable = kmx61_trig_try_reenable, + .reenable = kmx61_trig_reenable, }; static irqreturn_t kmx61_event_handler(int irq, void *private) diff --git a/drivers/iio/imu/st_lsm6dsx/Kconfig b/drivers/iio/imu/st_lsm6dsx/Kconfig index 28f59d09208a..85860217aaf3 100644 --- a/drivers/iio/imu/st_lsm6dsx/Kconfig +++ b/drivers/iio/imu/st_lsm6dsx/Kconfig @@ -12,8 +12,8 @@ config IIO_ST_LSM6DSX Say yes here to build support for STMicroelectronics LSM6DSx imu sensor. Supported devices: lsm6ds3, lsm6ds3h, lsm6dsl, lsm6dsm, ism330dlc, lsm6dso, lsm6dsox, asm330lhh, lsm6dsr, lsm6ds3tr-c, - ism330dhcx, lsm6dsrx, lsm6ds0 and the accelerometer/gyroscope - of lsm9ds1. + ism330dhcx, lsm6dsrx, lsm6ds0, lsm6dsop, the accelerometer/gyroscope + of lsm9ds1 and lsm6dst. To compile this driver as a module, choose M here: the module will be called st_lsm6dsx. diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 9275346a9cc1..5ef55763a6cc 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -13,6 +13,7 @@ #include <linux/device.h> #include <linux/iio/iio.h> +#include <linux/regulator/consumer.h> #define ST_LSM6DS3_DEV_NAME "lsm6ds3" #define ST_LSM6DS3H_DEV_NAME "lsm6ds3h" @@ -28,6 +29,8 @@ #define ST_LSM9DS1_DEV_NAME "lsm9ds1-imu" #define ST_LSM6DS0_DEV_NAME "lsm6ds0" #define ST_LSM6DSRX_DEV_NAME "lsm6dsrx" +#define ST_LSM6DST_DEV_NAME "lsm6dst" +#define ST_LSM6DSOP_DEV_NAME "lsm6dsop" enum st_lsm6dsx_hw_id { ST_LSM6DS3_ID, @@ -44,6 +47,8 @@ enum st_lsm6dsx_hw_id { ST_LSM9DS1_ID, ST_LSM6DS0_ID, ST_LSM6DSRX_ID, + ST_LSM6DST_ID, + ST_LSM6DSOP_ID, ST_LSM6DSX_MAX_ID, }; @@ -263,7 +268,6 @@ struct st_lsm6dsx_ext_dev_settings { /** * struct st_lsm6dsx_settings - ST IMU sensor settings - * @wai: Sensor WhoAmI default value. * @reset: register address for reset. * @boot: register address for boot. * @bdu: register address for Block Data Update. @@ -281,7 +285,6 @@ struct st_lsm6dsx_ext_dev_settings { * @shub_settings: i2c controller related settings. */ struct st_lsm6dsx_settings { - u8 wai; struct st_lsm6dsx_reg reset; struct st_lsm6dsx_reg boot; struct st_lsm6dsx_reg bdu; @@ -289,6 +292,7 @@ struct st_lsm6dsx_settings { struct { enum st_lsm6dsx_hw_id hw_id; const char *name; + u8 wai; } id[ST_LSM6DSX_MAX_ID]; struct { const struct iio_chan_spec *chan; @@ -366,6 +370,7 @@ struct st_lsm6dsx_sensor { * struct st_lsm6dsx_hw - ST IMU MEMS hw instance * @dev: Pointer to instance of struct device (I2C or SPI). * @regmap: Register map of the device. + * @regulators: VDD/VDDIO voltage regulators. * @irq: Device interrupt line (I2C or SPI). * @fifo_lock: Mutex to prevent concurrent access to the hw FIFO. * @conf_lock: Mutex to prevent concurrent FIFO configuration update. @@ -388,6 +393,7 @@ struct st_lsm6dsx_sensor { struct st_lsm6dsx_hw { struct device *dev; struct regmap *regmap; + struct regulator_bulk_data regulators[2]; int irq; struct mutex fifo_lock; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index 12ed0a2e55e4..f1103ecedd64 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -14,7 +14,7 @@ * (e.g. Gx, Gy, Gz, Ax, Ay, Az), then data are repeated depending on the * value of the decimation factor and ODR set for each FIFO data set. * - * LSM6DSO/LSM6DSOX/ASM330LHH/LSM6DSR/LSM6DSRX/ISM330DHCX: + * LSM6DSO/LSM6DSOX/ASM330LHH/LSM6DSR/LSM6DSRX/ISM330DHCX/LSM6DST/LSM6DSOP: * The FIFO buffer can be configured to store data from gyroscope and * accelerometer. Each sample is queued with a tag (1B) indicating data * source (gyroscope, accelerometer, hw timer). diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 42f485634d04..7cedaab096a7 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -26,7 +26,7 @@ * - Gyroscope supported full-scale [dps]: +-125/+-245/+-500/+-1000/+-2000 * - FIFO size: 4KB * - * - LSM6DSO/LSM6DSOX/ASM330LHH/LSM6DSR/ISM330DHCX: + * - LSM6DSO/LSM6DSOX/ASM330LHH/LSM6DSR/ISM330DHCX/LSM6DST/LSM6DSOP: * - Accelerometer/Gyroscope supported ODR [Hz]: 13, 26, 52, 104, 208, 416, * 833 * - Accelerometer supported full-scale [g]: +-2/+-4/+-8/+-16 @@ -90,7 +90,6 @@ static const struct iio_chan_spec st_lsm6ds0_gyro_channels[] = { static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { - .wai = 0x68, .reset = { .addr = 0x22, .mask = BIT(0), @@ -108,9 +107,11 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .hw_id = ST_LSM9DS1_ID, .name = ST_LSM9DS1_DEV_NAME, + .wai = 0x68, }, { .hw_id = ST_LSM6DS0_ID, .name = ST_LSM6DS0_DEV_NAME, + .wai = 0x68, }, }, .channels = { @@ -195,7 +196,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, { - .wai = 0x69, .reset = { .addr = 0x12, .mask = BIT(0), @@ -213,6 +213,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .hw_id = ST_LSM6DS3_ID, .name = ST_LSM6DS3_DEV_NAME, + .wai = 0x69, }, }, .channels = { @@ -361,7 +362,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, { - .wai = 0x69, .reset = { .addr = 0x12, .mask = BIT(0), @@ -379,6 +379,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .hw_id = ST_LSM6DS3H_ID, .name = ST_LSM6DS3H_DEV_NAME, + .wai = 0x69, }, }, .channels = { @@ -527,7 +528,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, { - .wai = 0x6a, .reset = { .addr = 0x12, .mask = BIT(0), @@ -545,15 +545,19 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .hw_id = ST_LSM6DSL_ID, .name = ST_LSM6DSL_DEV_NAME, + .wai = 0x6a, }, { .hw_id = ST_LSM6DSM_ID, .name = ST_LSM6DSM_DEV_NAME, + .wai = 0x6a, }, { .hw_id = ST_ISM330DLC_ID, .name = ST_ISM330DLC_DEV_NAME, + .wai = 0x6a, }, { .hw_id = ST_LSM6DS3TRC_ID, .name = ST_LSM6DS3TRC_DEV_NAME, + .wai = 0x6a, }, }, .channels = { @@ -743,7 +747,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, { - .wai = 0x6c, .reset = { .addr = 0x12, .mask = BIT(0), @@ -759,11 +762,29 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .max_fifo_size = 512, .id = { { + .hw_id = ST_LSM6DSR_ID, + .name = ST_LSM6DSR_DEV_NAME, + .wai = 0x6b, + }, { + .hw_id = ST_ISM330DHCX_ID, + .name = ST_ISM330DHCX_DEV_NAME, + .wai = 0x6b, + }, { + .hw_id = ST_LSM6DSRX_ID, + .name = ST_LSM6DSRX_DEV_NAME, + .wai = 0x6b, + }, { .hw_id = ST_LSM6DSO_ID, .name = ST_LSM6DSO_DEV_NAME, + .wai = 0x6c, }, { .hw_id = ST_LSM6DSOX_ID, .name = ST_LSM6DSOX_DEV_NAME, + .wai = 0x6c, + }, { + .hw_id = ST_LSM6DST_ID, + .name = ST_LSM6DST_DEV_NAME, + .wai = 0x6d, }, }, .channels = { @@ -951,7 +972,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, { - .wai = 0x6b, .reset = { .addr = 0x12, .mask = BIT(0), @@ -969,185 +989,11 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .hw_id = ST_ASM330LHH_ID, .name = ST_ASM330LHH_DEV_NAME, - }, - }, - .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), - }, - }, - .drdy_mask = { - .addr = 0x13, - .mask = BIT(3), - }, - .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 = { - .irq1 = { - .addr = 0x0d, - .mask = BIT(3), - }, - .irq2 = { - .addr = 0x0e, - .mask = BIT(3), - }, - .lir = { - .addr = 0x56, - .mask = BIT(0), - }, - .clear_on_read = { - .addr = 0x56, - .mask = BIT(6), - }, - .irq1_func = { - .addr = 0x5e, - .mask = BIT(5), - }, - .irq2_func = { - .addr = 0x5f, - .mask = BIT(5), - }, - .hla = { - .addr = 0x12, - .mask = BIT(5), - }, - .od = { - .addr = 0x12, - .mask = BIT(4), - }, - }, - .batch = { - [ST_LSM6DSX_ID_ACC] = { - .addr = 0x09, - .mask = GENMASK(3, 0), - }, - [ST_LSM6DSX_ID_GYRO] = { - .addr = 0x09, - .mask = GENMASK(7, 4), - }, - }, - .fifo_ops = { - .update_fifo = st_lsm6dsx_update_fifo, - .read_fifo = st_lsm6dsx_read_tagged_fifo, - .fifo_th = { - .addr = 0x07, - .mask = GENMASK(8, 0), - }, - .fifo_diff = { - .addr = 0x3a, - .mask = GENMASK(9, 0), - }, - .th_wl = 1, - }, - .ts_settings = { - .timer_en = { - .addr = 0x19, - .mask = BIT(5), - }, - .decimator = { - .addr = 0x0a, - .mask = GENMASK(7, 6), - }, - .freq_fine = 0x63, - }, - .event_settings = { - .enable_reg = { - .addr = 0x58, - .mask = BIT(7), - }, - .wakeup_reg = { - .addr = 0x5B, - .mask = GENMASK(5, 0), - }, - .wakeup_src_reg = 0x1b, - .wakeup_src_status_mask = BIT(3), - .wakeup_src_z_mask = BIT(0), - .wakeup_src_y_mask = BIT(1), - .wakeup_src_x_mask = BIT(2), - }, - }, - { - .wai = 0x6b, - .reset = { - .addr = 0x12, - .mask = BIT(0), - }, - .boot = { - .addr = 0x12, - .mask = BIT(7), - }, - .bdu = { - .addr = 0x12, - .mask = BIT(6), - }, - .max_fifo_size = 512, - .id = { - { - .hw_id = ST_LSM6DSR_ID, - .name = ST_LSM6DSR_DEV_NAME, + .wai = 0x6b, }, { - .hw_id = ST_ISM330DHCX_ID, - .name = ST_ISM330DHCX_DEV_NAME, - }, { - .hw_id = ST_LSM6DSRX_ID, - .name = ST_LSM6DSRX_DEV_NAME, + .hw_id = ST_LSM6DSOP_ID, + .name = ST_LSM6DSOP_DEV_NAME, + .wai = 0x6c, }, }, .channels = { @@ -1286,38 +1132,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, .freq_fine = 0x63, }, - .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, - .batch_en = BIT(3), - }, .event_settings = { .enable_reg = { .addr = 0x58, @@ -1332,7 +1146,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .wakeup_src_z_mask = BIT(0), .wakeup_src_y_mask = BIT(1), .wakeup_src_x_mask = BIT(2), - } + }, }, }; @@ -1377,7 +1191,7 @@ static int st_lsm6dsx_check_whoami(struct st_lsm6dsx_hw *hw, int id, return err; } - if (data != st_lsm6dsx_sensor_settings[i].wai) { + if (data != st_lsm6dsx_sensor_settings[i].id[j].wai) { dev_err(hw->dev, "unsupported whoami [%02x]\n", data); return -ENODEV; } @@ -2255,19 +2069,35 @@ st_lsm6dsx_report_motion_event(struct st_lsm6dsx_hw *hw) static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) { struct st_lsm6dsx_hw *hw = private; + int fifo_len = 0, len; bool event; - int count; event = st_lsm6dsx_report_motion_event(hw); if (!hw->settings->fifo_ops.read_fifo) return event ? IRQ_HANDLED : IRQ_NONE; - mutex_lock(&hw->fifo_lock); - count = hw->settings->fifo_ops.read_fifo(hw); - mutex_unlock(&hw->fifo_lock); + /* + * If we are using edge IRQs, new samples can arrive while + * processing current interrupt since there are no hw + * guarantees the irq line stays "low" long enough to properly + * detect the new interrupt. In this case the new sample will + * be missed. + * Polling FIFO status register allow us to read new + * samples even if the interrupt arrives while processing + * previous data and the timeslot where the line is "low" is + * too short to be properly detected. + */ + do { + mutex_lock(&hw->fifo_lock); + len = hw->settings->fifo_ops.read_fifo(hw); + mutex_unlock(&hw->fifo_lock); + + if (len > 0) + fifo_len += len; + } while (len > 0); - return count || event ? IRQ_HANDLED : IRQ_NONE; + return fifo_len || event ? IRQ_HANDLED : IRQ_NONE; } static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw) @@ -2328,6 +2158,38 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw) return 0; } +static int st_lsm6dsx_init_regulators(struct device *dev) +{ + struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev); + int err; + + /* vdd-vddio power regulators */ + hw->regulators[0].supply = "vdd"; + hw->regulators[1].supply = "vddio"; + err = devm_regulator_bulk_get(dev, ARRAY_SIZE(hw->regulators), + hw->regulators); + if (err) + return dev_err_probe(dev, err, "failed to get regulators\n"); + + err = regulator_bulk_enable(ARRAY_SIZE(hw->regulators), + hw->regulators); + if (err) { + dev_err(dev, "failed to enable regulators: %d\n", err); + return err; + } + + msleep(50); + + return 0; +} + +static void st_lsm6dsx_chip_uninit(void *data) +{ + struct st_lsm6dsx_hw *hw = data; + + regulator_bulk_disable(ARRAY_SIZE(hw->regulators), hw->regulators); +} + int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, struct regmap *regmap) { @@ -2347,6 +2209,14 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, mutex_init(&hw->conf_lock); mutex_init(&hw->page_lock); + err = st_lsm6dsx_init_regulators(dev); + if (err) + return err; + + err = devm_add_action_or_reset(dev, st_lsm6dsx_chip_uninit, hw); + if (err) + return err; + hw->buff = devm_kzalloc(dev, ST_LSM6DSX_BUFF_SIZE, GFP_KERNEL); if (!hw->buff) return -ENOMEM; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c index 0fb32131afce..ec8d4351390a 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c @@ -94,6 +94,14 @@ static const struct of_device_id st_lsm6dsx_i2c_of_match[] = { .compatible = "st,lsm6dsrx", .data = (void *)ST_LSM6DSRX_ID, }, + { + .compatible = "st,lsm6dst", + .data = (void *)ST_LSM6DST_ID, + }, + { + .compatible = "st,lsm6dsop", + .data = (void *)ST_LSM6DSOP_ID, + }, {}, }; MODULE_DEVICE_TABLE(of, st_lsm6dsx_i2c_of_match); @@ -113,6 +121,8 @@ static const struct i2c_device_id st_lsm6dsx_i2c_id_table[] = { { ST_LSM9DS1_DEV_NAME, ST_LSM9DS1_ID }, { ST_LSM6DS0_DEV_NAME, ST_LSM6DS0_ID }, { ST_LSM6DSRX_DEV_NAME, ST_LSM6DSRX_ID }, + { ST_LSM6DST_DEV_NAME, ST_LSM6DST_ID }, + { ST_LSM6DSOP_DEV_NAME, ST_LSM6DSOP_ID }, {}, }; MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table); diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c index eb1086e4a951..349ec9c1890d 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c @@ -94,6 +94,14 @@ static const struct of_device_id st_lsm6dsx_spi_of_match[] = { .compatible = "st,lsm6dsrx", .data = (void *)ST_LSM6DSRX_ID, }, + { + .compatible = "st,lsm6dst", + .data = (void *)ST_LSM6DST_ID, + }, + { + .compatible = "st,lsm6dsop", + .data = (void *)ST_LSM6DSOP_ID, + }, {}, }; MODULE_DEVICE_TABLE(of, st_lsm6dsx_spi_of_match); @@ -113,6 +121,8 @@ static const struct spi_device_id st_lsm6dsx_spi_id_table[] = { { ST_LSM9DS1_DEV_NAME, ST_LSM9DS1_ID }, { ST_LSM6DS0_DEV_NAME, ST_LSM6DS0_ID }, { ST_LSM6DSRX_DEV_NAME, ST_LSM6DSRX_ID }, + { ST_LSM6DST_DEV_NAME, ST_LSM6DST_ID }, + { ST_LSM6DSOP_DEV_NAME, ST_LSM6DSOP_ID }, {}, }; MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table); |