]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
iio: imu: st_lsm6dsx: add support to ASM330LHH
authorLorenzo Bianconi <lorenzo@kernel.org>
Thu, 21 Feb 2019 15:20:20 +0000 (16:20 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 4 Apr 2019 19:19:49 +0000 (20:19 +0100)
Add support to STM ASM330LHH 6-axis (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/asm330lhh.pdf

Tested-by: Mario Tesi <mario.tesi@st.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/st_lsm6dsx/Kconfig
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c

index 094fd006b63d36f24abb747418f3d71231117757..36048bf0455ad7fc487e43d110432262a867cd31 100644 (file)
@@ -9,7 +9,7 @@ config IIO_ST_LSM6DSX
        help
          Say yes here to build support for STMicroelectronics LSM6DSx imu
          sensor. Supported devices: lsm6ds3, lsm6ds3h, lsm6dsl, lsm6dsm,
-         ism330dlc, lsm6dso
+         ism330dlc, lsm6dso, asm330lhh
 
          To compile this driver as a module, choose M here: the module
          will be called st_lsm6dsx.
index d1d8d07a07143d45e5c713206cd04008b23f4819..de2a0dc3935343f354d44850139fbb72419fa8c9 100644 (file)
@@ -20,6 +20,7 @@
 #define ST_LSM6DSM_DEV_NAME    "lsm6dsm"
 #define ST_ISM330DLC_DEV_NAME  "ism330dlc"
 #define ST_LSM6DSO_DEV_NAME    "lsm6dso"
+#define ST_ASM330LHH_DEV_NAME  "asm330lhh"
 
 enum st_lsm6dsx_hw_id {
        ST_LSM6DS3_ID,
@@ -28,6 +29,7 @@ enum st_lsm6dsx_hw_id {
        ST_LSM6DSM_ID,
        ST_ISM330DLC_ID,
        ST_LSM6DSO_ID,
+       ST_ASM330LHH_ID,
        ST_LSM6DSX_MAX_ID,
 };
 
index 2c0d3763405ad69fdaf23ce14aca241d327d6b7a..8f443bdb5b51cd105a655018b02c89b8049be949 100644 (file)
@@ -13,9 +13,9 @@
  * (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: 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).
+ * LSM6DSO/ASM330LHH: 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).
  *
  * FIFO supported modes:
  *  - BYPASS: FIFO disabled
@@ -506,7 +506,7 @@ st_lsm6dsx_push_tagged_data(struct st_lsm6dsx_hw *hw, u8 tag,
 }
 
 /**
- * st_lsm6dsx_read_tagged_fifo() - LSM6DSO read FIFO routine
+ * st_lsm6dsx_read_tagged_fifo() - LSM6DSO/ASM330LHH read FIFO routine
  * @hw: Pointer to instance of struct st_lsm6dsx_hw.
  *
  * Read samples from the hw FIFO and push them to IIO buffers.
index 12e29dda9b98f9c3e41ef8b068f0cedcc06c4911..50cab3531b1106c910bcfa698912f570a401722f 100644 (file)
@@ -23,7 +23,7 @@
  *   - Gyroscope supported full-scale [dps]: +-125/+-245/+-500/+-1000/+-2000
  *   - FIFO size: 4KB
  *
- * - LSM6DSO
+ * - LSM6DSO/ASM330LHH
  *   - Accelerometer/Gyroscope supported ODR [Hz]: 13, 26, 52, 104, 208, 416
  *   - Accelerometer supported full-scale [g]: +-2/+-4/+-8/+-16
  *   - Gyroscope supported full-scale [dps]: +-125/+-245/+-500/+-1000/+-2000
@@ -347,6 +347,45 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
                        .batch_en = BIT(3),
                }
        },
+       {
+               .wai = 0x6b,
+               .max_fifo_size = 512,
+               .id = {
+                       [0] = ST_ASM330LHH_ID,
+               },
+               .batch = {
+                       [ST_LSM6DSX_ID_ACC] = {
+                               .addr = 0x09,
+                               .mask = GENMASK(3, 0),
+                       },
+                       [ST_LSM6DSX_ID_GYRO] = {
+                               .addr = 0x09,
+                               .mask = GENMASK(7, 4),
+                       },
+               },
+               .fifo_ops = {
+                       .read_fifo = st_lsm6dsx_read_tagged_fifo,
+                       .fifo_th = {
+                               .addr = 0x07,
+                               .mask = GENMASK(8, 0),
+                       },
+                       .fifo_diff = {
+                               .addr = 0x3a,
+                               .mask = GENMASK(8, 0),
+                       },
+                       .th_wl = 1,
+               },
+               .ts_settings = {
+                       .timer_en = {
+                               .addr = 0x19,
+                               .mask = BIT(5),
+                       },
+                       .decimator = {
+                               .addr = 0x0a,
+                               .mask = GENMASK(7, 6),
+                       },
+               },
+       },
 };
 
 static const struct iio_chan_spec st_lsm6dsx_acc_channels[] = {
index 448b7bc1e57818c744b4f791fa0137a04184bed7..00b4b702645a1005432097c6693687f3878e52e1 100644 (file)
@@ -65,6 +65,10 @@ static const struct of_device_id st_lsm6dsx_i2c_of_match[] = {
                .compatible = "st,lsm6dso",
                .data = (void *)ST_LSM6DSO_ID,
        },
+       {
+               .compatible = "st,asm330lhh",
+               .data = (void *)ST_ASM330LHH_ID,
+       },
        {},
 };
 MODULE_DEVICE_TABLE(of, st_lsm6dsx_i2c_of_match);
@@ -76,6 +80,7 @@ static const struct i2c_device_id st_lsm6dsx_i2c_id_table[] = {
        { ST_LSM6DSM_DEV_NAME, ST_LSM6DSM_ID },
        { ST_ISM330DLC_DEV_NAME, ST_ISM330DLC_ID },
        { ST_LSM6DSO_DEV_NAME, ST_LSM6DSO_ID },
+       { ST_ASM330LHH_DEV_NAME, ST_ASM330LHH_ID },
        {},
 };
 MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table);
index b1df8a6973e6f4d019abae7b669347220e97d4e1..836256c2ac7d4e41f670e6ec3cc61bfec6808acd 100644 (file)
@@ -65,6 +65,10 @@ static const struct of_device_id st_lsm6dsx_spi_of_match[] = {
                .compatible = "st,lsm6dso",
                .data = (void *)ST_LSM6DSO_ID,
        },
+       {
+               .compatible = "st,asm330lhh",
+               .data = (void *)ST_ASM330LHH_ID,
+       },
        {},
 };
 MODULE_DEVICE_TABLE(of, st_lsm6dsx_spi_of_match);
@@ -76,6 +80,7 @@ static const struct spi_device_id st_lsm6dsx_spi_id_table[] = {
        { ST_LSM6DSM_DEV_NAME, ST_LSM6DSM_ID },
        { ST_ISM330DLC_DEV_NAME, ST_ISM330DLC_ID },
        { ST_LSM6DSO_DEV_NAME, ST_LSM6DSO_ID },
+       { ST_ASM330LHH_DEV_NAME, ST_ASM330LHH_ID },
        {},
 };
 MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table);