iio: Added ST-sensors platform data to select the DRDY interrupt pin
authorDenis CIOCCA <denis.ciocca@st.com>
Wed, 19 Jun 2013 08:28:00 +0000 (09:28 +0100)
committerJonathan Cameron <jic23@kernel.org>
Sat, 3 Aug 2013 17:40:28 +0000 (18:40 +0100)
This patch add support to redirect the DRDY interrupt on INT1 or INT2
on accelerometer and pressure sensors.

Signed-off-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
19 files changed:
drivers/iio/accel/st_accel.h
drivers/iio/accel/st_accel_core.c
drivers/iio/accel/st_accel_i2c.c
drivers/iio/accel/st_accel_spi.c
drivers/iio/common/st_sensors/st_sensors_core.c
drivers/iio/gyro/st_gyro.h
drivers/iio/gyro/st_gyro_core.c
drivers/iio/gyro/st_gyro_i2c.c
drivers/iio/gyro/st_gyro_spi.c
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
drivers/iio/pressure/st_pressure.h
drivers/iio/pressure/st_pressure_core.c
drivers/iio/pressure/st_pressure_i2c.c
drivers/iio/pressure/st_pressure_spi.c
include/linux/iio/common/st_sensors.h
include/linux/platform_data/st_sensors_pdata.h [new file with mode: 0644]

index 37949b94377db4994b9a67794b90cb0f41ea9eb0..c3877630b2e4cfa0fdf652183d9388183541a83a 100644 (file)
 #define LSM303DLM_ACCEL_DEV_NAME       "lsm303dlm_accel"
 #define LSM330_ACCEL_DEV_NAME          "lsm330_accel"
 
-int st_accel_common_probe(struct iio_dev *indio_dev);
+/**
+* struct st_sensors_platform_data - default accel platform data
+* @drdy_int_pin: default accel DRDY is available on INT1 pin.
+*/
+static const struct st_sensors_platform_data default_accel_pdata = {
+       .drdy_int_pin = 1,
+};
+
+int st_accel_common_probe(struct iio_dev *indio_dev,
+                                       struct st_sensors_platform_data *pdata);
 void st_accel_common_remove(struct iio_dev *indio_dev);
 
 #ifdef CONFIG_IIO_BUFFER
index 4aec121261d7bdd00993af55381c7371d8eb0ce1..aef3c9be73665ee4c4d3d434d23dd626ad6e724d 100644 (file)
@@ -65,7 +65,8 @@
 #define ST_ACCEL_1_BDU_ADDR                    0x23
 #define ST_ACCEL_1_BDU_MASK                    0x80
 #define ST_ACCEL_1_DRDY_IRQ_ADDR               0x22
-#define ST_ACCEL_1_DRDY_IRQ_MASK               0x10
+#define ST_ACCEL_1_DRDY_IRQ_INT1_MASK          0x10
+#define ST_ACCEL_1_DRDY_IRQ_INT2_MASK          0x08
 #define ST_ACCEL_1_MULTIREAD_BIT               true
 
 /* CUSTOM VALUES FOR SENSOR 2 */
@@ -89,7 +90,8 @@
 #define ST_ACCEL_2_BDU_ADDR                    0x23
 #define ST_ACCEL_2_BDU_MASK                    0x80
 #define ST_ACCEL_2_DRDY_IRQ_ADDR               0x22
-#define ST_ACCEL_2_DRDY_IRQ_MASK               0x02
+#define ST_ACCEL_2_DRDY_IRQ_INT1_MASK          0x02
+#define ST_ACCEL_2_DRDY_IRQ_INT2_MASK          0x10
 #define ST_ACCEL_2_MULTIREAD_BIT               true
 
 /* CUSTOM VALUES FOR SENSOR 3 */
 #define ST_ACCEL_3_BDU_ADDR                    0x20
 #define ST_ACCEL_3_BDU_MASK                    0x08
 #define ST_ACCEL_3_DRDY_IRQ_ADDR               0x23
-#define ST_ACCEL_3_DRDY_IRQ_MASK               0x80
+#define ST_ACCEL_3_DRDY_IRQ_INT1_MASK          0x80
+#define ST_ACCEL_3_DRDY_IRQ_INT2_MASK          0x00
 #define ST_ACCEL_3_IG1_EN_ADDR                 0x23
 #define ST_ACCEL_3_IG1_EN_MASK                 0x08
 #define ST_ACCEL_3_MULTIREAD_BIT               false
@@ -224,7 +227,8 @@ static const struct st_sensors st_accel_sensors[] = {
                },
                .drdy_irq = {
                        .addr = ST_ACCEL_1_DRDY_IRQ_ADDR,
-                       .mask = ST_ACCEL_1_DRDY_IRQ_MASK,
+                       .mask_int1 = ST_ACCEL_1_DRDY_IRQ_INT1_MASK,
+                       .mask_int2 = ST_ACCEL_1_DRDY_IRQ_INT2_MASK,
                },
                .multi_read_bit = ST_ACCEL_1_MULTIREAD_BIT,
                .bootime = 2,
@@ -285,7 +289,8 @@ static const struct st_sensors st_accel_sensors[] = {
                },
                .drdy_irq = {
                        .addr = ST_ACCEL_2_DRDY_IRQ_ADDR,
-                       .mask = ST_ACCEL_2_DRDY_IRQ_MASK,
+                       .mask_int1 = ST_ACCEL_2_DRDY_IRQ_INT1_MASK,
+                       .mask_int2 = ST_ACCEL_2_DRDY_IRQ_INT2_MASK,
                },
                .multi_read_bit = ST_ACCEL_2_MULTIREAD_BIT,
                .bootime = 2,
@@ -358,7 +363,8 @@ static const struct st_sensors st_accel_sensors[] = {
                },
                .drdy_irq = {
                        .addr = ST_ACCEL_3_DRDY_IRQ_ADDR,
-                       .mask = ST_ACCEL_3_DRDY_IRQ_MASK,
+                       .mask_int1 = ST_ACCEL_3_DRDY_IRQ_INT1_MASK,
+                       .mask_int2 = ST_ACCEL_3_DRDY_IRQ_INT2_MASK,
                        .ig1 = {
                                .en_addr = ST_ACCEL_3_IG1_EN_ADDR,
                                .en_mask = ST_ACCEL_3_IG1_EN_MASK,
@@ -443,7 +449,8 @@ static const struct iio_trigger_ops st_accel_trigger_ops = {
 #define ST_ACCEL_TRIGGER_OPS NULL
 #endif
 
-int st_accel_common_probe(struct iio_dev *indio_dev)
+int st_accel_common_probe(struct iio_dev *indio_dev,
+                               struct st_sensors_platform_data *plat_data)
 {
        int err;
        struct st_sensor_data *adata = iio_priv(indio_dev);
@@ -465,7 +472,11 @@ int st_accel_common_probe(struct iio_dev *indio_dev)
                                                &adata->sensor->fs.fs_avl[0];
        adata->odr = adata->sensor->odr.odr_avl[0].hz;
 
-       err = st_sensors_init_sensor(indio_dev);
+       if (!plat_data)
+               plat_data =
+                       (struct st_sensors_platform_data *)&default_accel_pdata;
+
+       err = st_sensors_init_sensor(indio_dev, plat_data);
        if (err < 0)
                goto st_accel_common_probe_error;
 
index ffc9d097e484b81a96b78fe422eb948b29a23f67..58d164d90dca17328c6fdc7a9a3c79fc883116df 100644 (file)
@@ -36,7 +36,7 @@ static int st_accel_i2c_probe(struct i2c_client *client,
 
        st_sensors_i2c_configure(indio_dev, client, adata);
 
-       err = st_accel_common_probe(indio_dev);
+       err = st_accel_common_probe(indio_dev, client->dev.platform_data);
        if (err < 0)
                goto st_accel_common_probe_error;
 
index 22b35bfea7d2b9765bed7e72cd4070a398835ff6..21ed9296311fcfb3301034b6023a3d9709122cc1 100644 (file)
@@ -35,7 +35,7 @@ static int st_accel_spi_probe(struct spi_device *spi)
 
        st_sensors_spi_configure(indio_dev, spi, adata);
 
-       err = st_accel_common_probe(indio_dev);
+       err = st_accel_common_probe(indio_dev, spi->dev.platform_data);
        if (err < 0)
                goto st_accel_common_probe_error;
 
index 865b1781df6602db631dacdee3218c90308c6712..965ee22d3ac80ef1ae98d26da17d3a44528b43db 100644 (file)
@@ -22,7 +22,7 @@
 
 static inline u32 st_sensors_get_unaligned_le24(const u8 *p)
 {
-       return ((s32)((p[0] | p[1] << 8 | p[2] << 16) << 8) >> 8);
+       return (s32)((p[0] | p[1] << 8 | p[2] << 16) << 8) >> 8;
 }
 
 static int st_sensors_write_data_with_mask(struct iio_dev *indio_dev,
@@ -118,7 +118,7 @@ st_sensors_match_odr_error:
 }
 
 static int st_sensors_set_fullscale(struct iio_dev *indio_dev,
-                                                       unsigned int fs)
+                                                               unsigned int fs)
 {
        int err, i = 0;
        struct st_sensor_data *sdata = iio_priv(indio_dev);
@@ -198,13 +198,39 @@ int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable)
 }
 EXPORT_SYMBOL(st_sensors_set_axis_enable);
 
-int st_sensors_init_sensor(struct iio_dev *indio_dev)
+int st_sensors_init_sensor(struct iio_dev *indio_dev,
+                                       struct st_sensors_platform_data *pdata)
 {
        int err;
        struct st_sensor_data *sdata = iio_priv(indio_dev);
 
        mutex_init(&sdata->tb.buf_lock);
 
+       switch (pdata->drdy_int_pin) {
+       case 1:
+               if (sdata->sensor->drdy_irq.mask_int1 == 0) {
+                       dev_err(&indio_dev->dev,
+                                       "DRDY on INT1 not available.\n");
+                       err = -EINVAL;
+                       goto init_error;
+               }
+               sdata->drdy_int_pin = 1;
+               break;
+       case 2:
+               if (sdata->sensor->drdy_irq.mask_int2 == 0) {
+                       dev_err(&indio_dev->dev,
+                                       "DRDY on INT2 not available.\n");
+                       err = -EINVAL;
+                       goto init_error;
+               }
+               sdata->drdy_int_pin = 2;
+               break;
+       default:
+               dev_err(&indio_dev->dev, "DRDY on pdata not valid.\n");
+               err = -EINVAL;
+               goto init_error;
+       }
+
        err = st_sensors_set_enable(indio_dev, false);
        if (err < 0)
                goto init_error;
@@ -234,6 +260,7 @@ EXPORT_SYMBOL(st_sensors_init_sensor);
 int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable)
 {
        int err;
+       u8 drdy_mask;
        struct st_sensor_data *sdata = iio_priv(indio_dev);
 
        /* Enable/Disable the interrupt generator 1. */
@@ -245,10 +272,14 @@ int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable)
                        goto st_accel_set_dataready_irq_error;
        }
 
+       if (sdata->drdy_int_pin == 1)
+               drdy_mask = sdata->sensor->drdy_irq.mask_int1;
+       else
+               drdy_mask = sdata->sensor->drdy_irq.mask_int2;
+
        /* Enable/Disable the interrupt generator for data ready. */
        err = st_sensors_write_data_with_mask(indio_dev,
-                       sdata->sensor->drdy_irq.addr,
-                       sdata->sensor->drdy_irq.mask, (int)enable);
+                       sdata->sensor->drdy_irq.addr, drdy_mask, (int)enable);
 
 st_accel_set_dataready_irq_error:
        return err;
index 3ad9907bb154d759f398928efb6a8f1a3570a33e..f8f2bf84a5a281f9d9cff04eeb4af3d81de6c5be 100644 (file)
 #define L3G4IS_GYRO_DEV_NAME           "l3g4is_ui"
 #define LSM330_GYRO_DEV_NAME           "lsm330_gyro"
 
-int st_gyro_common_probe(struct iio_dev *indio_dev);
+/**
+ * struct st_sensors_platform_data - gyro platform data
+ * @drdy_int_pin: DRDY on gyros is available only on INT2 pin.
+ */
+static const struct st_sensors_platform_data gyro_pdata = {
+       .drdy_int_pin = 2,
+};
+
+int st_gyro_common_probe(struct iio_dev *indio_dev,
+                                       struct st_sensors_platform_data *pdata);
 void st_gyro_common_remove(struct iio_dev *indio_dev);
 
 #ifdef CONFIG_IIO_BUFFER
index f9ed3488c3145125b4c6a5709180fc4fa32dbbce..85fa8d343bb285357e74ebdfe7404a0026fe144a 100644 (file)
@@ -60,7 +60,7 @@
 #define ST_GYRO_1_BDU_ADDR                     0x23
 #define ST_GYRO_1_BDU_MASK                     0x80
 #define ST_GYRO_1_DRDY_IRQ_ADDR                        0x22
-#define ST_GYRO_1_DRDY_IRQ_MASK                        0x08
+#define ST_GYRO_1_DRDY_IRQ_INT2_MASK           0x08
 #define ST_GYRO_1_MULTIREAD_BIT                        true
 
 /* CUSTOM VALUES FOR SENSOR 2 */
@@ -84,7 +84,7 @@
 #define ST_GYRO_2_BDU_ADDR                     0x23
 #define ST_GYRO_2_BDU_MASK                     0x80
 #define ST_GYRO_2_DRDY_IRQ_ADDR                        0x22
-#define ST_GYRO_2_DRDY_IRQ_MASK                        0x08
+#define ST_GYRO_2_DRDY_IRQ_INT2_MASK           0x08
 #define ST_GYRO_2_MULTIREAD_BIT                        true
 
 static const struct iio_chan_spec st_gyro_16bit_channels[] = {
@@ -158,7 +158,7 @@ static const struct st_sensors st_gyro_sensors[] = {
                },
                .drdy_irq = {
                        .addr = ST_GYRO_1_DRDY_IRQ_ADDR,
-                       .mask = ST_GYRO_1_DRDY_IRQ_MASK,
+                       .mask_int2 = ST_GYRO_1_DRDY_IRQ_INT2_MASK,
                },
                .multi_read_bit = ST_GYRO_1_MULTIREAD_BIT,
                .bootime = 2,
@@ -221,7 +221,7 @@ static const struct st_sensors st_gyro_sensors[] = {
                },
                .drdy_irq = {
                        .addr = ST_GYRO_2_DRDY_IRQ_ADDR,
-                       .mask = ST_GYRO_2_DRDY_IRQ_MASK,
+                       .mask_int2 = ST_GYRO_2_DRDY_IRQ_INT2_MASK,
                },
                .multi_read_bit = ST_GYRO_2_MULTIREAD_BIT,
                .bootime = 2,
@@ -302,7 +302,8 @@ static const struct iio_trigger_ops st_gyro_trigger_ops = {
 #define ST_GYRO_TRIGGER_OPS NULL
 #endif
 
-int st_gyro_common_probe(struct iio_dev *indio_dev)
+int st_gyro_common_probe(struct iio_dev *indio_dev,
+                                       struct st_sensors_platform_data *pdata)
 {
        int err;
        struct st_sensor_data *gdata = iio_priv(indio_dev);
@@ -324,7 +325,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev)
                                                &gdata->sensor->fs.fs_avl[0];
        gdata->odr = gdata->sensor->odr.odr_avl[0].hz;
 
-       err = st_sensors_init_sensor(indio_dev);
+       err = st_sensors_init_sensor(indio_dev, pdata);
        if (err < 0)
                goto st_gyro_common_probe_error;
 
index 8a310500573d964b7b5b8b164e8c4aab31b22a85..c7a29a4d7e829dd83c3450277b75bfd00e7ba582 100644 (file)
@@ -36,7 +36,8 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
 
        st_sensors_i2c_configure(indio_dev, client, gdata);
 
-       err = st_gyro_common_probe(indio_dev);
+       err = st_gyro_common_probe(indio_dev,
+                               (struct st_sensors_platform_data *)&gyro_pdata);
        if (err < 0)
                goto st_gyro_common_probe_error;
 
index f3540390eb22047ab6e11a95a449436ad15a86a2..14b0762847f5b6267966365ca4ae888b65e9565d 100644 (file)
@@ -35,7 +35,8 @@ static int st_gyro_spi_probe(struct spi_device *spi)
 
        st_sensors_spi_configure(indio_dev, spi, gdata);
 
-       err = st_gyro_common_probe(indio_dev);
+       err = st_gyro_common_probe(indio_dev,
+                               (struct st_sensors_platform_data *)&gyro_pdata);
        if (err < 0)
                goto st_gyro_common_probe_error;
 
index 7e81d00ef0c3d4129a4fe90fbffd9d50549ac7b5..694e33e0fb722f4d210904984c227a26dc4e4af1 100644 (file)
@@ -18,7 +18,8 @@
 #define LSM303DLM_MAGN_DEV_NAME                "lsm303dlm_magn"
 #define LIS3MDL_MAGN_DEV_NAME          "lis3mdl"
 
-int st_magn_common_probe(struct iio_dev *indio_dev);
+int st_magn_common_probe(struct iio_dev *indio_dev,
+                                       struct st_sensors_platform_data *pdata);
 void st_magn_common_remove(struct iio_dev *indio_dev);
 
 #ifdef CONFIG_IIO_BUFFER
index ebfe8f11a0c26e62df3457bce88168a8ebc9620a..7cd784f522e5526d7a8c20c91e98ae034e419d8c 100644 (file)
@@ -345,7 +345,8 @@ static const struct iio_info magn_info = {
        .write_raw = &st_magn_write_raw,
 };
 
-int st_magn_common_probe(struct iio_dev *indio_dev)
+int st_magn_common_probe(struct iio_dev *indio_dev,
+                                       struct st_sensors_platform_data *pdata)
 {
        int err;
        struct st_sensor_data *mdata = iio_priv(indio_dev);
@@ -367,7 +368,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev)
                                                &mdata->sensor->fs.fs_avl[0];
        mdata->odr = mdata->sensor->odr.odr_avl[0].hz;
 
-       err = st_sensors_init_sensor(indio_dev);
+       err = st_sensors_init_sensor(indio_dev, pdata);
        if (err < 0)
                goto st_magn_common_probe_error;
 
index e6adc4a8642519c69c96de7b93b71856cd757c47..1bed117714c584b3bdd91bb1fa7b477f1f67c5a6 100644 (file)
@@ -36,7 +36,7 @@ static int st_magn_i2c_probe(struct i2c_client *client,
 
        st_sensors_i2c_configure(indio_dev, client, mdata);
 
-       err = st_magn_common_probe(indio_dev);
+       err = st_magn_common_probe(indio_dev, NULL);
        if (err < 0)
                goto st_magn_common_probe_error;
 
index 51adb797cb7d7621ae6bf863fd73e90cc8fa1b42..a2333a1e6061d0566b706f905ca0a99f2c30176a 100644 (file)
@@ -35,7 +35,7 @@ static int st_magn_spi_probe(struct spi_device *spi)
 
        st_sensors_spi_configure(indio_dev, spi, mdata);
 
-       err = st_magn_common_probe(indio_dev);
+       err = st_magn_common_probe(indio_dev, NULL);
        if (err < 0)
                goto st_magn_common_probe_error;
 
index 414e45ac9b9b443e071cb1b811822441c4c83c36..b0b630688da665138a97e3afbf33c1f387dda323 100644 (file)
 
 #define LPS331AP_PRESS_DEV_NAME                "lps331ap"
 
-int st_press_common_probe(struct iio_dev *indio_dev);
+/**
+ * struct st_sensors_platform_data - default press platform data
+ * @drdy_int_pin: default press DRDY is available on INT1 pin.
+ */
+static const struct st_sensors_platform_data default_press_pdata = {
+       .drdy_int_pin = 1,
+};
+
+int st_press_common_probe(struct iio_dev *indio_dev,
+                                       struct st_sensors_platform_data *pdata);
 void st_press_common_remove(struct iio_dev *indio_dev);
 
 #ifdef CONFIG_IIO_BUFFER
index 3ffbc56917b48256d1654145e899556d7f191ba5..81e2d5b030a60866c7c63f1f1e0b49c1798425fb 100644 (file)
@@ -58,7 +58,8 @@
 #define ST_PRESS_1_BDU_ADDR                    0x20
 #define ST_PRESS_1_BDU_MASK                    0x04
 #define ST_PRESS_1_DRDY_IRQ_ADDR               0x22
-#define ST_PRESS_1_DRDY_IRQ_MASK               0x04
+#define ST_PRESS_1_DRDY_IRQ_INT1_MASK          0x04
+#define ST_PRESS_1_DRDY_IRQ_INT2_MASK          0x20
 #define ST_PRESS_1_MULTIREAD_BIT               true
 #define ST_PRESS_1_TEMP_OFFSET                 42500
 
@@ -116,7 +117,8 @@ static const struct st_sensors st_press_sensors[] = {
                },
                .drdy_irq = {
                        .addr = ST_PRESS_1_DRDY_IRQ_ADDR,
-                       .mask = ST_PRESS_1_DRDY_IRQ_MASK,
+                       .mask_int1 = ST_PRESS_1_DRDY_IRQ_INT1_MASK,
+                       .mask_int2 = ST_PRESS_1_DRDY_IRQ_INT2_MASK,
                },
                .multi_read_bit = ST_PRESS_1_MULTIREAD_BIT,
                .bootime = 2,
@@ -202,7 +204,8 @@ static const struct iio_trigger_ops st_press_trigger_ops = {
 #define ST_PRESS_TRIGGER_OPS NULL
 #endif
 
-int st_press_common_probe(struct iio_dev *indio_dev)
+int st_press_common_probe(struct iio_dev *indio_dev,
+                               struct st_sensors_platform_data *plat_data)
 {
        int err;
        struct st_sensor_data *pdata = iio_priv(indio_dev);
@@ -224,7 +227,11 @@ int st_press_common_probe(struct iio_dev *indio_dev)
                                                &pdata->sensor->fs.fs_avl[0];
        pdata->odr = pdata->sensor->odr.odr_avl[0].hz;
 
-       err = st_sensors_init_sensor(indio_dev);
+       if (!plat_data)
+               plat_data =
+                       (struct st_sensors_platform_data *)&default_press_pdata;
+
+       err = st_sensors_init_sensor(indio_dev, plat_data);
        if (err < 0)
                goto st_press_common_probe_error;
 
index 7cebcc73bfb097addeed57bed2494f560c9c54be..306599307a962b81834e6abf92619be665f4cc69 100644 (file)
@@ -36,7 +36,7 @@ static int st_press_i2c_probe(struct i2c_client *client,
 
        st_sensors_i2c_configure(indio_dev, client, pdata);
 
-       err = st_press_common_probe(indio_dev);
+       err = st_press_common_probe(indio_dev, client->dev.platform_data);
        if (err < 0)
                goto st_press_common_probe_error;
 
index 17a14907940a29a24d1760c572d2ff16105eaf28..b2aded6d2108d5f4fd96b4aa4fb3b0994aff3435 100644 (file)
@@ -35,7 +35,7 @@ static int st_press_spi_probe(struct spi_device *spi)
 
        st_sensors_spi_configure(indio_dev, spi, pdata);
 
-       err = st_press_common_probe(indio_dev);
+       err = st_press_common_probe(indio_dev, spi->dev.platform_data);
        if (err < 0)
                goto st_press_common_probe_error;
 
index 72b26940730d715e9ea0c3802b2b65fcd1ea922a..e51f65480ea5a895828433444e0d3ec6348ca785 100644 (file)
@@ -17,6 +17,8 @@
 #include <linux/iio/trigger.h>
 #include <linux/bitops.h>
 
+#include <linux/platform_data/st_sensors_pdata.h>
+
 #define ST_SENSORS_TX_MAX_LENGTH               2
 #define ST_SENSORS_RX_MAX_LENGTH               6
 
@@ -118,14 +120,16 @@ struct st_sensor_bdu {
 /**
  * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt
  * @addr: address of the register.
- * @mask: mask to write the on/off value.
+ * @mask_int1: mask to enable/disable IRQ on INT1 pin.
+ * @mask_int2: mask to enable/disable IRQ on INT2 pin.
  * struct ig1 - represents the Interrupt Generator 1 of sensors.
  * @en_addr: address of the enable ig1 register.
  * @en_mask: mask to write the on/off value for enable.
  */
 struct st_sensor_data_ready_irq {
        u8 addr;
-       u8 mask;
+       u8 mask_int1;
+       u8 mask_int2;
        struct {
                u8 en_addr;
                u8 en_mask;
@@ -201,6 +205,7 @@ struct st_sensors {
  * @buffer_data: Data used by buffer part.
  * @odr: Output data rate of the sensor [Hz].
  * num_data_channels: Number of data channels used in buffer.
+ * @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2).
  * @get_irq_data_ready: Function to get the IRQ used for data ready signal.
  * @tf: Transfer function structure used by I/O operations.
  * @tb: Transfer buffers and mutex used by I/O operations.
@@ -219,6 +224,8 @@ struct st_sensor_data {
        unsigned int odr;
        unsigned int num_data_channels;
 
+       u8 drdy_int_pin;
+
        unsigned int (*get_irq_data_ready) (struct iio_dev *indio_dev);
 
        const struct st_sensor_transfer_function *tf;
@@ -249,7 +256,8 @@ static inline void st_sensors_deallocate_trigger(struct iio_dev *indio_dev)
 }
 #endif
 
-int st_sensors_init_sensor(struct iio_dev *indio_dev);
+int st_sensors_init_sensor(struct iio_dev *indio_dev,
+                                       struct st_sensors_platform_data *pdata);
 
 int st_sensors_set_enable(struct iio_dev *indio_dev, bool enable);
 
diff --git a/include/linux/platform_data/st_sensors_pdata.h b/include/linux/platform_data/st_sensors_pdata.h
new file mode 100644 (file)
index 0000000..7538391
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * STMicroelectronics sensors platform-data driver
+ *
+ * Copyright 2013 STMicroelectronics Inc.
+ *
+ * Denis Ciocca <denis.ciocca@st.com>
+ *
+ * Licensed under the GPL-2.
+ */
+
+#ifndef ST_SENSORS_PDATA_H
+#define ST_SENSORS_PDATA_H
+
+/**
+ * struct st_sensors_platform_data - Platform data for the ST sensors
+ * @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2).
+ *     Available only for accelerometer and pressure sensors.
+ *     Accelerometer DRDY on LSM330 available only on pin 1 (see datasheet).
+ */
+struct st_sensors_platform_data {
+       u8 drdy_int_pin;
+};
+
+#endif /* ST_SENSORS_PDATA_H */