aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorDenis CIOCCA <denis.ciocca@st.com>2014-02-20 12:49:00 -0500
committerJonathan Cameron <jic23@kernel.org>2014-02-22 08:09:53 -0500
commit931878405b869093c90d57a0a34f0c2b3641c4ea (patch)
tree730ca969c45b1ab70d6aead19a4bd4ba19129813 /drivers/iio
parentf64a799b8a49e3e26497b26ea78af01fc6302874 (diff)
iio:pressure: Add support for LPS25H pressure sensor
This patch adds support for the new barometer sensor: LPS25H. Signed-off-by: Denis Ciocca <denis.ciocca@st.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/pressure/Kconfig2
-rw-r--r--drivers/iio/pressure/st_pressure.h1
-rw-r--r--drivers/iio/pressure/st_pressure_core.c87
-rw-r--r--drivers/iio/pressure/st_pressure_i2c.c1
-rw-r--r--drivers/iio/pressure/st_pressure_spi.c1
5 files changed, 84 insertions, 8 deletions
diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig
index 6215761b3c53..d88ff17fedb2 100644
--- a/drivers/iio/pressure/Kconfig
+++ b/drivers/iio/pressure/Kconfig
@@ -40,7 +40,7 @@ config IIO_ST_PRESS
40 select IIO_TRIGGERED_BUFFER if (IIO_BUFFER) 40 select IIO_TRIGGERED_BUFFER if (IIO_BUFFER)
41 help 41 help
42 Say yes here to build support for STMicroelectronics pressure 42 Say yes here to build support for STMicroelectronics pressure
43 sensors: LPS001WP, LPS331AP. 43 sensors: LPS001WP, LPS25H, LPS331AP.
44 44
45 This driver can also be built as a module. If so, these modules 45 This driver can also be built as a module. If so, these modules
46 will be created: 46 will be created:
diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h
index 049c21acf1f0..242943c0c4e4 100644
--- a/drivers/iio/pressure/st_pressure.h
+++ b/drivers/iio/pressure/st_pressure.h
@@ -15,6 +15,7 @@
15#include <linux/iio/common/st_sensors.h> 15#include <linux/iio/common/st_sensors.h>
16 16
17#define LPS001WP_PRESS_DEV_NAME "lps001wp" 17#define LPS001WP_PRESS_DEV_NAME "lps001wp"
18#define LPS25H_PRESS_DEV_NAME "lps25h"
18#define LPS331AP_PRESS_DEV_NAME "lps331ap" 19#define LPS331AP_PRESS_DEV_NAME "lps331ap"
19 20
20/** 21/**
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
index 58083f9d51c5..7418768ed49c 100644
--- a/drivers/iio/pressure/st_pressure_core.c
+++ b/drivers/iio/pressure/st_pressure_core.c
@@ -40,6 +40,9 @@
40/* FULLSCALE */ 40/* FULLSCALE */
41#define ST_PRESS_FS_AVL_1260MB 1260 41#define ST_PRESS_FS_AVL_1260MB 1260
42 42
43#define ST_PRESS_1_OUT_XL_ADDR 0x28
44#define ST_TEMP_1_OUT_L_ADDR 0x2b
45
43/* CUSTOM VALUES FOR LPS331AP SENSOR */ 46/* CUSTOM VALUES FOR LPS331AP SENSOR */
44#define ST_PRESS_LPS331AP_WAI_EXP 0xbb 47#define ST_PRESS_LPS331AP_WAI_EXP 0xbb
45#define ST_PRESS_LPS331AP_ODR_ADDR 0x20 48#define ST_PRESS_LPS331AP_ODR_ADDR 0x20
@@ -62,8 +65,6 @@
62#define ST_PRESS_LPS331AP_DRDY_IRQ_INT2_MASK 0x20 65#define ST_PRESS_LPS331AP_DRDY_IRQ_INT2_MASK 0x20
63#define ST_PRESS_LPS331AP_MULTIREAD_BIT true 66#define ST_PRESS_LPS331AP_MULTIREAD_BIT true
64#define ST_PRESS_LPS331AP_TEMP_OFFSET 42500 67#define ST_PRESS_LPS331AP_TEMP_OFFSET 42500
65#define ST_PRESS_LPS331AP_OUT_XL_ADDR 0x28
66#define ST_TEMP_LPS331AP_OUT_L_ADDR 0x2b
67 68
68/* CUSTOM VALUES FOR LPS001WP SENSOR */ 69/* CUSTOM VALUES FOR LPS001WP SENSOR */
69#define ST_PRESS_LPS001WP_WAI_EXP 0xba 70#define ST_PRESS_LPS001WP_WAI_EXP 0xba
@@ -80,11 +81,36 @@
80#define ST_PRESS_LPS001WP_OUT_L_ADDR 0x28 81#define ST_PRESS_LPS001WP_OUT_L_ADDR 0x28
81#define ST_TEMP_LPS001WP_OUT_L_ADDR 0x2a 82#define ST_TEMP_LPS001WP_OUT_L_ADDR 0x2a
82 83
83static const struct iio_chan_spec st_press_lps331ap_channels[] = { 84/* CUSTOM VALUES FOR LPS25H SENSOR */
85#define ST_PRESS_LPS25H_WAI_EXP 0xbd
86#define ST_PRESS_LPS25H_ODR_ADDR 0x20
87#define ST_PRESS_LPS25H_ODR_MASK 0x70
88#define ST_PRESS_LPS25H_ODR_AVL_1HZ_VAL 0x01
89#define ST_PRESS_LPS25H_ODR_AVL_7HZ_VAL 0x02
90#define ST_PRESS_LPS25H_ODR_AVL_13HZ_VAL 0x03
91#define ST_PRESS_LPS25H_ODR_AVL_25HZ_VAL 0x04
92#define ST_PRESS_LPS25H_PW_ADDR 0x20
93#define ST_PRESS_LPS25H_PW_MASK 0x80
94#define ST_PRESS_LPS25H_FS_ADDR 0x00
95#define ST_PRESS_LPS25H_FS_MASK 0x00
96#define ST_PRESS_LPS25H_FS_AVL_1260_VAL 0x00
97#define ST_PRESS_LPS25H_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE
98#define ST_PRESS_LPS25H_FS_AVL_TEMP_GAIN ST_PRESS_CELSIUS_NANO_SCALE
99#define ST_PRESS_LPS25H_BDU_ADDR 0x20
100#define ST_PRESS_LPS25H_BDU_MASK 0x04
101#define ST_PRESS_LPS25H_DRDY_IRQ_ADDR 0x23
102#define ST_PRESS_LPS25H_DRDY_IRQ_INT1_MASK 0x01
103#define ST_PRESS_LPS25H_DRDY_IRQ_INT2_MASK 0x10
104#define ST_PRESS_LPS25H_MULTIREAD_BIT true
105#define ST_PRESS_LPS25H_TEMP_OFFSET 42500
106#define ST_PRESS_LPS25H_OUT_XL_ADDR 0x28
107#define ST_TEMP_LPS25H_OUT_L_ADDR 0x2b
108
109static const struct iio_chan_spec st_press_1_channels[] = {
84 { 110 {
85 .type = IIO_PRESSURE, 111 .type = IIO_PRESSURE,
86 .channel2 = IIO_NO_MOD, 112 .channel2 = IIO_NO_MOD,
87 .address = ST_PRESS_LPS331AP_OUT_XL_ADDR, 113 .address = ST_PRESS_1_OUT_XL_ADDR,
88 .scan_index = ST_SENSORS_SCAN_X, 114 .scan_index = ST_SENSORS_SCAN_X,
89 .scan_type = { 115 .scan_type = {
90 .sign = 'u', 116 .sign = 'u',
@@ -99,7 +125,7 @@ static const struct iio_chan_spec st_press_lps331ap_channels[] = {
99 { 125 {
100 .type = IIO_TEMP, 126 .type = IIO_TEMP,
101 .channel2 = IIO_NO_MOD, 127 .channel2 = IIO_NO_MOD,
102 .address = ST_TEMP_LPS331AP_OUT_L_ADDR, 128 .address = ST_TEMP_1_OUT_L_ADDR,
103 .scan_index = -1, 129 .scan_index = -1,
104 .scan_type = { 130 .scan_type = {
105 .sign = 'u', 131 .sign = 'u',
@@ -156,8 +182,8 @@ static const struct st_sensors st_press_sensors[] = {
156 .sensors_supported = { 182 .sensors_supported = {
157 [0] = LPS331AP_PRESS_DEV_NAME, 183 [0] = LPS331AP_PRESS_DEV_NAME,
158 }, 184 },
159 .ch = (struct iio_chan_spec *)st_press_lps331ap_channels, 185 .ch = (struct iio_chan_spec *)st_press_1_channels,
160 .num_ch = ARRAY_SIZE(st_press_lps331ap_channels), 186 .num_ch = ARRAY_SIZE(st_press_1_channels),
161 .odr = { 187 .odr = {
162 .addr = ST_PRESS_LPS331AP_ODR_ADDR, 188 .addr = ST_PRESS_LPS331AP_ODR_ADDR,
163 .mask = ST_PRESS_LPS331AP_ODR_MASK, 189 .mask = ST_PRESS_LPS331AP_ODR_MASK,
@@ -233,6 +259,53 @@ static const struct st_sensors st_press_sensors[] = {
233 .multi_read_bit = ST_PRESS_LPS001WP_MULTIREAD_BIT, 259 .multi_read_bit = ST_PRESS_LPS001WP_MULTIREAD_BIT,
234 .bootime = 2, 260 .bootime = 2,
235 }, 261 },
262 {
263 .wai = ST_PRESS_LPS25H_WAI_EXP,
264 .sensors_supported = {
265 [0] = LPS25H_PRESS_DEV_NAME,
266 },
267 .ch = (struct iio_chan_spec *)st_press_1_channels,
268 .num_ch = ARRAY_SIZE(st_press_1_channels),
269 .odr = {
270 .addr = ST_PRESS_LPS25H_ODR_ADDR,
271 .mask = ST_PRESS_LPS25H_ODR_MASK,
272 .odr_avl = {
273 { 1, ST_PRESS_LPS25H_ODR_AVL_1HZ_VAL, },
274 { 7, ST_PRESS_LPS25H_ODR_AVL_7HZ_VAL, },
275 { 13, ST_PRESS_LPS25H_ODR_AVL_13HZ_VAL, },
276 { 25, ST_PRESS_LPS25H_ODR_AVL_25HZ_VAL, },
277 },
278 },
279 .pw = {
280 .addr = ST_PRESS_LPS25H_PW_ADDR,
281 .mask = ST_PRESS_LPS25H_PW_MASK,
282 .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
283 .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
284 },
285 .fs = {
286 .addr = ST_PRESS_LPS25H_FS_ADDR,
287 .mask = ST_PRESS_LPS25H_FS_MASK,
288 .fs_avl = {
289 [0] = {
290 .num = ST_PRESS_FS_AVL_1260MB,
291 .value = ST_PRESS_LPS25H_FS_AVL_1260_VAL,
292 .gain = ST_PRESS_LPS25H_FS_AVL_1260_GAIN,
293 .gain2 = ST_PRESS_LPS25H_FS_AVL_TEMP_GAIN,
294 },
295 },
296 },
297 .bdu = {
298 .addr = ST_PRESS_LPS25H_BDU_ADDR,
299 .mask = ST_PRESS_LPS25H_BDU_MASK,
300 },
301 .drdy_irq = {
302 .addr = ST_PRESS_LPS25H_DRDY_IRQ_ADDR,
303 .mask_int1 = ST_PRESS_LPS25H_DRDY_IRQ_INT1_MASK,
304 .mask_int2 = ST_PRESS_LPS25H_DRDY_IRQ_INT2_MASK,
305 },
306 .multi_read_bit = ST_PRESS_LPS25H_MULTIREAD_BIT,
307 .bootime = 2,
308 },
236}; 309};
237 310
238static int st_press_read_raw(struct iio_dev *indio_dev, 311static int st_press_read_raw(struct iio_dev *indio_dev,
diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c
index 51eab7fcb194..3cd73e39b840 100644
--- a/drivers/iio/pressure/st_pressure_i2c.c
+++ b/drivers/iio/pressure/st_pressure_i2c.c
@@ -50,6 +50,7 @@ static int st_press_i2c_remove(struct i2c_client *client)
50 50
51static const struct i2c_device_id st_press_id_table[] = { 51static const struct i2c_device_id st_press_id_table[] = {
52 { LPS001WP_PRESS_DEV_NAME }, 52 { LPS001WP_PRESS_DEV_NAME },
53 { LPS25H_PRESS_DEV_NAME },
53 { LPS331AP_PRESS_DEV_NAME }, 54 { LPS331AP_PRESS_DEV_NAME },
54 {}, 55 {},
55}; 56};
diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c
index 27322af6d665..f45d430ec529 100644
--- a/drivers/iio/pressure/st_pressure_spi.c
+++ b/drivers/iio/pressure/st_pressure_spi.c
@@ -49,6 +49,7 @@ static int st_press_spi_remove(struct spi_device *spi)
49 49
50static const struct spi_device_id st_press_id_table[] = { 50static const struct spi_device_id st_press_id_table[] = {
51 { LPS001WP_PRESS_DEV_NAME }, 51 { LPS001WP_PRESS_DEV_NAME },
52 { LPS25H_PRESS_DEV_NAME },
52 { LPS331AP_PRESS_DEV_NAME }, 53 { LPS331AP_PRESS_DEV_NAME },
53 {}, 54 {},
54}; 55};