IIO: Add support for L3GD20H gyroscope
authorRobert Dolca <robert.dolca@intel.com>
Mon, 23 Mar 2015 13:40:25 +0000 (15:40 +0200)
committerJonathan Cameron <jic23@kernel.org>
Sat, 28 Mar 2015 11:13:35 +0000 (11:13 +0000)
It can be used exactly like L3GD20 but it has a different WhoAmI
register value.

Signed-off-by: Robert Dolca <robert.dolca@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/gyro/st_gyro_core.c

index f07a2336f7dc705d4c328ac5d5caefe310516229..21395f26d2276548567dfd118f37c22087a0d1ce 100644 (file)
 #define ST_GYRO_2_DRDY_IRQ_INT2_MASK           0x08
 #define ST_GYRO_2_MULTIREAD_BIT                        true
 
+/* CUSTOM VALUES FOR SENSOR 3 */
+#define ST_GYRO_3_WAI_EXP                      0xd7
+#define ST_GYRO_3_ODR_ADDR                     0x20
+#define ST_GYRO_3_ODR_MASK                     0xc0
+#define ST_GYRO_3_ODR_AVL_95HZ_VAL             0x00
+#define ST_GYRO_3_ODR_AVL_190HZ_VAL            0x01
+#define ST_GYRO_3_ODR_AVL_380HZ_VAL            0x02
+#define ST_GYRO_3_ODR_AVL_760HZ_VAL            0x03
+#define ST_GYRO_3_PW_ADDR                      0x20
+#define ST_GYRO_3_PW_MASK                      0x08
+#define ST_GYRO_3_FS_ADDR                      0x23
+#define ST_GYRO_3_FS_MASK                      0x30
+#define ST_GYRO_3_FS_AVL_250_VAL               0x00
+#define ST_GYRO_3_FS_AVL_500_VAL               0x01
+#define ST_GYRO_3_FS_AVL_2000_VAL              0x02
+#define ST_GYRO_3_FS_AVL_250_GAIN              IIO_DEGREE_TO_RAD(8750)
+#define ST_GYRO_3_FS_AVL_500_GAIN              IIO_DEGREE_TO_RAD(17500)
+#define ST_GYRO_3_FS_AVL_2000_GAIN             IIO_DEGREE_TO_RAD(70000)
+#define ST_GYRO_3_BDU_ADDR                     0x23
+#define ST_GYRO_3_BDU_MASK                     0x80
+#define ST_GYRO_3_DRDY_IRQ_ADDR                        0x22
+#define ST_GYRO_3_DRDY_IRQ_INT2_MASK           0x08
+#define ST_GYRO_3_MULTIREAD_BIT                        true
+
+
 static const struct iio_chan_spec st_gyro_16bit_channels[] = {
        ST_SENSORS_LSM_CHANNELS(IIO_ANGL_VEL,
                        BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
@@ -225,6 +250,64 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
                .multi_read_bit = ST_GYRO_2_MULTIREAD_BIT,
                .bootime = 2,
        },
+       {
+               .wai = ST_GYRO_3_WAI_EXP,
+               .sensors_supported = {
+                       [0] = L3GD20_GYRO_DEV_NAME,
+               },
+               .ch = (struct iio_chan_spec *)st_gyro_16bit_channels,
+               .odr = {
+                       .addr = ST_GYRO_3_ODR_ADDR,
+                       .mask = ST_GYRO_3_ODR_MASK,
+                       .odr_avl = {
+                               { 95, ST_GYRO_3_ODR_AVL_95HZ_VAL, },
+                               { 190, ST_GYRO_3_ODR_AVL_190HZ_VAL, },
+                               { 380, ST_GYRO_3_ODR_AVL_380HZ_VAL, },
+                               { 760, ST_GYRO_3_ODR_AVL_760HZ_VAL, },
+                       },
+               },
+               .pw = {
+                       .addr = ST_GYRO_3_PW_ADDR,
+                       .mask = ST_GYRO_3_PW_MASK,
+                       .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
+                       .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
+               },
+               .enable_axis = {
+                       .addr = ST_SENSORS_DEFAULT_AXIS_ADDR,
+                       .mask = ST_SENSORS_DEFAULT_AXIS_MASK,
+               },
+               .fs = {
+                       .addr = ST_GYRO_3_FS_ADDR,
+                       .mask = ST_GYRO_3_FS_MASK,
+                       .fs_avl = {
+                               [0] = {
+                                       .num = ST_GYRO_FS_AVL_250DPS,
+                                       .value = ST_GYRO_3_FS_AVL_250_VAL,
+                                       .gain = ST_GYRO_3_FS_AVL_250_GAIN,
+                               },
+                               [1] = {
+                                       .num = ST_GYRO_FS_AVL_500DPS,
+                                       .value = ST_GYRO_3_FS_AVL_500_VAL,
+                                       .gain = ST_GYRO_3_FS_AVL_500_GAIN,
+                               },
+                               [2] = {
+                                       .num = ST_GYRO_FS_AVL_2000DPS,
+                                       .value = ST_GYRO_3_FS_AVL_2000_VAL,
+                                       .gain = ST_GYRO_3_FS_AVL_2000_GAIN,
+                               },
+                       },
+               },
+               .bdu = {
+                       .addr = ST_GYRO_3_BDU_ADDR,
+                       .mask = ST_GYRO_3_BDU_MASK,
+               },
+               .drdy_irq = {
+                       .addr = ST_GYRO_3_DRDY_IRQ_ADDR,
+                       .mask_int2 = ST_GYRO_3_DRDY_IRQ_INT2_MASK,
+               },
+               .multi_read_bit = ST_GYRO_3_MULTIREAD_BIT,
+               .bootime = 2,
+       },
 };
 
 static int st_gyro_read_raw(struct iio_dev *indio_dev,