iio:magnetometer: st_magn: add LSM9DS1 support
authorMartin Kelly <martin@martingkelly.com>
Fri, 26 Oct 2018 02:38:10 +0000 (19:38 -0700)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 11 Nov 2018 15:29:43 +0000 (15:29 +0000)
Update the sensor settings to support the LSM9DS1 sensor. Although the
LSM9DS1 accelerometer and gyroscope are coupled together to use the same
FIFO, the magnetometer is separate and can be cleanly supported without
refactoring the existing driver.

Signed-off-by: Martin Kelly <martin@martingkelly.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/magnetometer/st_magn.h
drivers/iio/magnetometer/st_magn_core.c
drivers/iio/magnetometer/st_magn_i2c.c
drivers/iio/magnetometer/st_magn_spi.c

index 8fe51ce427bd64f3e98f06062767dd100209f024..bc14ad4f1b262c4d9f2273db04f716415fc2ed55 100644 (file)
@@ -20,6 +20,7 @@
 #define LIS3MDL_MAGN_DEV_NAME          "lis3mdl"
 #define LSM303AGR_MAGN_DEV_NAME                "lsm303agr_magn"
 #define LIS2MDL_MAGN_DEV_NAME          "lis2mdl"
+#define LSM9DS1_MAGN_DEV_NAME          "lsm9ds1_magn"
 
 int st_magn_common_probe(struct iio_dev *indio_dev);
 void st_magn_common_remove(struct iio_dev *indio_dev);
index 880c11c7f1cb30b7bdddc4e111abccb93d0ac923..45c074e0d5b2b8c75a0ce2b195848cbd1c95e796 100644 (file)
@@ -267,6 +267,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
                .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
                .sensors_supported = {
                        [0] = LIS3MDL_MAGN_DEV_NAME,
+                       [1] = LSM9DS1_MAGN_DEV_NAME,
                },
                .ch = (struct iio_chan_spec *)st_magn_2_16bit_channels,
                .odr = {
index feaa28cf6a779fbe8c0cc1c80842c0afd7c615a5..68650f5f5c19b20eb0bfd758f87a55501e71e953 100644 (file)
@@ -44,6 +44,10 @@ static const struct of_device_id st_magn_of_match[] = {
                .compatible = "st,lis2mdl",
                .data = LIS2MDL_MAGN_DEV_NAME,
        },
+       {
+               .compatible = "st,lsm9ds1-magn",
+               .data = LSM9DS1_MAGN_DEV_NAME,
+       },
        {},
 };
 MODULE_DEVICE_TABLE(of, st_magn_of_match);
@@ -90,6 +94,7 @@ static const struct i2c_device_id st_magn_id_table[] = {
        { LIS3MDL_MAGN_DEV_NAME },
        { LSM303AGR_MAGN_DEV_NAME },
        { LIS2MDL_MAGN_DEV_NAME },
+       { LSM9DS1_MAGN_DEV_NAME },
        {},
 };
 MODULE_DEVICE_TABLE(i2c, st_magn_id_table);
index 15bb092670989df194c14e9eab9f92c65fe06c45..cb05fcd9ddfe2cfa872ee64fea65538d7c898610 100644 (file)
@@ -39,6 +39,10 @@ static const struct of_device_id st_magn_of_match[] = {
                .compatible = "st,lis2mdl",
                .data = LIS2MDL_MAGN_DEV_NAME,
        },
+       {
+               .compatible = "st,lsm9ds1-magn",
+               .data = LSM9DS1_MAGN_DEV_NAME,
+       },
        {}
 };
 MODULE_DEVICE_TABLE(of, st_magn_of_match);
@@ -81,6 +85,7 @@ static const struct spi_device_id st_magn_id_table[] = {
        { LIS3MDL_MAGN_DEV_NAME },
        { LSM303AGR_MAGN_DEV_NAME },
        { LIS2MDL_MAGN_DEV_NAME },
+       { LSM9DS1_MAGN_DEV_NAME },
        {},
 };
 MODULE_DEVICE_TABLE(spi, st_magn_id_table);