diff options
author | Denis CIOCCA <denis.ciocca@st.com> | 2013-06-19 04:28:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-08-03 13:40:28 -0400 |
commit | 23cde4d65cc7d11e2048d2b240cdf13927ac50d0 (patch) | |
tree | 3fd2d23f8c092056244e14703bce9842c203ba13 /drivers/iio/accel | |
parent | 36e607a16b8def1b184d48a4489b716d6dbe3379 (diff) |
iio: Added ST-sensors platform data to select the DRDY interrupt pin
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>
Diffstat (limited to 'drivers/iio/accel')
-rw-r--r-- | drivers/iio/accel/st_accel.h | 11 | ||||
-rw-r--r-- | drivers/iio/accel/st_accel_core.c | 27 | ||||
-rw-r--r-- | drivers/iio/accel/st_accel_i2c.c | 2 | ||||
-rw-r--r-- | drivers/iio/accel/st_accel_spi.c | 2 |
4 files changed, 31 insertions, 11 deletions
diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h index 37949b94377d..c3877630b2e4 100644 --- a/drivers/iio/accel/st_accel.h +++ b/drivers/iio/accel/st_accel.h | |||
@@ -25,7 +25,16 @@ | |||
25 | #define LSM303DLM_ACCEL_DEV_NAME "lsm303dlm_accel" | 25 | #define LSM303DLM_ACCEL_DEV_NAME "lsm303dlm_accel" |
26 | #define LSM330_ACCEL_DEV_NAME "lsm330_accel" | 26 | #define LSM330_ACCEL_DEV_NAME "lsm330_accel" |
27 | 27 | ||
28 | int st_accel_common_probe(struct iio_dev *indio_dev); | 28 | /** |
29 | * struct st_sensors_platform_data - default accel platform data | ||
30 | * @drdy_int_pin: default accel DRDY is available on INT1 pin. | ||
31 | */ | ||
32 | static const struct st_sensors_platform_data default_accel_pdata = { | ||
33 | .drdy_int_pin = 1, | ||
34 | }; | ||
35 | |||
36 | int st_accel_common_probe(struct iio_dev *indio_dev, | ||
37 | struct st_sensors_platform_data *pdata); | ||
29 | void st_accel_common_remove(struct iio_dev *indio_dev); | 38 | void st_accel_common_remove(struct iio_dev *indio_dev); |
30 | 39 | ||
31 | #ifdef CONFIG_IIO_BUFFER | 40 | #ifdef CONFIG_IIO_BUFFER |
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 4aec121261d7..aef3c9be7366 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c | |||
@@ -65,7 +65,8 @@ | |||
65 | #define ST_ACCEL_1_BDU_ADDR 0x23 | 65 | #define ST_ACCEL_1_BDU_ADDR 0x23 |
66 | #define ST_ACCEL_1_BDU_MASK 0x80 | 66 | #define ST_ACCEL_1_BDU_MASK 0x80 |
67 | #define ST_ACCEL_1_DRDY_IRQ_ADDR 0x22 | 67 | #define ST_ACCEL_1_DRDY_IRQ_ADDR 0x22 |
68 | #define ST_ACCEL_1_DRDY_IRQ_MASK 0x10 | 68 | #define ST_ACCEL_1_DRDY_IRQ_INT1_MASK 0x10 |
69 | #define ST_ACCEL_1_DRDY_IRQ_INT2_MASK 0x08 | ||
69 | #define ST_ACCEL_1_MULTIREAD_BIT true | 70 | #define ST_ACCEL_1_MULTIREAD_BIT true |
70 | 71 | ||
71 | /* CUSTOM VALUES FOR SENSOR 2 */ | 72 | /* CUSTOM VALUES FOR SENSOR 2 */ |
@@ -89,7 +90,8 @@ | |||
89 | #define ST_ACCEL_2_BDU_ADDR 0x23 | 90 | #define ST_ACCEL_2_BDU_ADDR 0x23 |
90 | #define ST_ACCEL_2_BDU_MASK 0x80 | 91 | #define ST_ACCEL_2_BDU_MASK 0x80 |
91 | #define ST_ACCEL_2_DRDY_IRQ_ADDR 0x22 | 92 | #define ST_ACCEL_2_DRDY_IRQ_ADDR 0x22 |
92 | #define ST_ACCEL_2_DRDY_IRQ_MASK 0x02 | 93 | #define ST_ACCEL_2_DRDY_IRQ_INT1_MASK 0x02 |
94 | #define ST_ACCEL_2_DRDY_IRQ_INT2_MASK 0x10 | ||
93 | #define ST_ACCEL_2_MULTIREAD_BIT true | 95 | #define ST_ACCEL_2_MULTIREAD_BIT true |
94 | 96 | ||
95 | /* CUSTOM VALUES FOR SENSOR 3 */ | 97 | /* CUSTOM VALUES FOR SENSOR 3 */ |
@@ -121,7 +123,8 @@ | |||
121 | #define ST_ACCEL_3_BDU_ADDR 0x20 | 123 | #define ST_ACCEL_3_BDU_ADDR 0x20 |
122 | #define ST_ACCEL_3_BDU_MASK 0x08 | 124 | #define ST_ACCEL_3_BDU_MASK 0x08 |
123 | #define ST_ACCEL_3_DRDY_IRQ_ADDR 0x23 | 125 | #define ST_ACCEL_3_DRDY_IRQ_ADDR 0x23 |
124 | #define ST_ACCEL_3_DRDY_IRQ_MASK 0x80 | 126 | #define ST_ACCEL_3_DRDY_IRQ_INT1_MASK 0x80 |
127 | #define ST_ACCEL_3_DRDY_IRQ_INT2_MASK 0x00 | ||
125 | #define ST_ACCEL_3_IG1_EN_ADDR 0x23 | 128 | #define ST_ACCEL_3_IG1_EN_ADDR 0x23 |
126 | #define ST_ACCEL_3_IG1_EN_MASK 0x08 | 129 | #define ST_ACCEL_3_IG1_EN_MASK 0x08 |
127 | #define ST_ACCEL_3_MULTIREAD_BIT false | 130 | #define ST_ACCEL_3_MULTIREAD_BIT false |
@@ -224,7 +227,8 @@ static const struct st_sensors st_accel_sensors[] = { | |||
224 | }, | 227 | }, |
225 | .drdy_irq = { | 228 | .drdy_irq = { |
226 | .addr = ST_ACCEL_1_DRDY_IRQ_ADDR, | 229 | .addr = ST_ACCEL_1_DRDY_IRQ_ADDR, |
227 | .mask = ST_ACCEL_1_DRDY_IRQ_MASK, | 230 | .mask_int1 = ST_ACCEL_1_DRDY_IRQ_INT1_MASK, |
231 | .mask_int2 = ST_ACCEL_1_DRDY_IRQ_INT2_MASK, | ||
228 | }, | 232 | }, |
229 | .multi_read_bit = ST_ACCEL_1_MULTIREAD_BIT, | 233 | .multi_read_bit = ST_ACCEL_1_MULTIREAD_BIT, |
230 | .bootime = 2, | 234 | .bootime = 2, |
@@ -285,7 +289,8 @@ static const struct st_sensors st_accel_sensors[] = { | |||
285 | }, | 289 | }, |
286 | .drdy_irq = { | 290 | .drdy_irq = { |
287 | .addr = ST_ACCEL_2_DRDY_IRQ_ADDR, | 291 | .addr = ST_ACCEL_2_DRDY_IRQ_ADDR, |
288 | .mask = ST_ACCEL_2_DRDY_IRQ_MASK, | 292 | .mask_int1 = ST_ACCEL_2_DRDY_IRQ_INT1_MASK, |
293 | .mask_int2 = ST_ACCEL_2_DRDY_IRQ_INT2_MASK, | ||
289 | }, | 294 | }, |
290 | .multi_read_bit = ST_ACCEL_2_MULTIREAD_BIT, | 295 | .multi_read_bit = ST_ACCEL_2_MULTIREAD_BIT, |
291 | .bootime = 2, | 296 | .bootime = 2, |
@@ -358,7 +363,8 @@ static const struct st_sensors st_accel_sensors[] = { | |||
358 | }, | 363 | }, |
359 | .drdy_irq = { | 364 | .drdy_irq = { |
360 | .addr = ST_ACCEL_3_DRDY_IRQ_ADDR, | 365 | .addr = ST_ACCEL_3_DRDY_IRQ_ADDR, |
361 | .mask = ST_ACCEL_3_DRDY_IRQ_MASK, | 366 | .mask_int1 = ST_ACCEL_3_DRDY_IRQ_INT1_MASK, |
367 | .mask_int2 = ST_ACCEL_3_DRDY_IRQ_INT2_MASK, | ||
362 | .ig1 = { | 368 | .ig1 = { |
363 | .en_addr = ST_ACCEL_3_IG1_EN_ADDR, | 369 | .en_addr = ST_ACCEL_3_IG1_EN_ADDR, |
364 | .en_mask = ST_ACCEL_3_IG1_EN_MASK, | 370 | .en_mask = ST_ACCEL_3_IG1_EN_MASK, |
@@ -443,7 +449,8 @@ static const struct iio_trigger_ops st_accel_trigger_ops = { | |||
443 | #define ST_ACCEL_TRIGGER_OPS NULL | 449 | #define ST_ACCEL_TRIGGER_OPS NULL |
444 | #endif | 450 | #endif |
445 | 451 | ||
446 | int st_accel_common_probe(struct iio_dev *indio_dev) | 452 | int st_accel_common_probe(struct iio_dev *indio_dev, |
453 | struct st_sensors_platform_data *plat_data) | ||
447 | { | 454 | { |
448 | int err; | 455 | int err; |
449 | struct st_sensor_data *adata = iio_priv(indio_dev); | 456 | struct st_sensor_data *adata = iio_priv(indio_dev); |
@@ -465,7 +472,11 @@ int st_accel_common_probe(struct iio_dev *indio_dev) | |||
465 | &adata->sensor->fs.fs_avl[0]; | 472 | &adata->sensor->fs.fs_avl[0]; |
466 | adata->odr = adata->sensor->odr.odr_avl[0].hz; | 473 | adata->odr = adata->sensor->odr.odr_avl[0].hz; |
467 | 474 | ||
468 | err = st_sensors_init_sensor(indio_dev); | 475 | if (!plat_data) |
476 | plat_data = | ||
477 | (struct st_sensors_platform_data *)&default_accel_pdata; | ||
478 | |||
479 | err = st_sensors_init_sensor(indio_dev, plat_data); | ||
469 | if (err < 0) | 480 | if (err < 0) |
470 | goto st_accel_common_probe_error; | 481 | goto st_accel_common_probe_error; |
471 | 482 | ||
diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index ffc9d097e484..58d164d90dca 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c | |||
@@ -36,7 +36,7 @@ static int st_accel_i2c_probe(struct i2c_client *client, | |||
36 | 36 | ||
37 | st_sensors_i2c_configure(indio_dev, client, adata); | 37 | st_sensors_i2c_configure(indio_dev, client, adata); |
38 | 38 | ||
39 | err = st_accel_common_probe(indio_dev); | 39 | err = st_accel_common_probe(indio_dev, client->dev.platform_data); |
40 | if (err < 0) | 40 | if (err < 0) |
41 | goto st_accel_common_probe_error; | 41 | goto st_accel_common_probe_error; |
42 | 42 | ||
diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c index 22b35bfea7d2..21ed9296311f 100644 --- a/drivers/iio/accel/st_accel_spi.c +++ b/drivers/iio/accel/st_accel_spi.c | |||
@@ -35,7 +35,7 @@ static int st_accel_spi_probe(struct spi_device *spi) | |||
35 | 35 | ||
36 | st_sensors_spi_configure(indio_dev, spi, adata); | 36 | st_sensors_spi_configure(indio_dev, spi, adata); |
37 | 37 | ||
38 | err = st_accel_common_probe(indio_dev); | 38 | err = st_accel_common_probe(indio_dev, spi->dev.platform_data); |
39 | if (err < 0) | 39 | if (err < 0) |
40 | goto st_accel_common_probe_error; | 40 | goto st_accel_common_probe_error; |
41 | 41 | ||