diff options
author | Lee Jones <lee.jones@linaro.org> | 2013-09-16 12:02:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-09-21 14:24:05 -0400 |
commit | 7885a8ce6800ec37147902b316cd73790865dc1d (patch) | |
tree | 59bd36172a3f51e4c31298ef652cec8bfc776971 /drivers/iio/pressure | |
parent | a6cc5b250c88930c47a0a231107844b69f086428 (diff) |
iio: pressure: st: Add support for new LPS001WP pressure sensor
Here we use existing practices to introduce support for another
pressure/temperature sensor, the LPS001WP.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/pressure')
-rw-r--r-- | drivers/iio/pressure/st_pressure.h | 1 | ||||
-rw-r--r-- | drivers/iio/pressure/st_pressure_core.c | 84 | ||||
-rw-r--r-- | drivers/iio/pressure/st_pressure_i2c.c | 1 |
3 files changed, 86 insertions, 0 deletions
diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h index b0b630688da6..049c21acf1f0 100644 --- a/drivers/iio/pressure/st_pressure.h +++ b/drivers/iio/pressure/st_pressure.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
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 LPS331AP_PRESS_DEV_NAME "lps331ap" | 18 | #define LPS331AP_PRESS_DEV_NAME "lps331ap" |
18 | 19 | ||
19 | /** | 20 | /** |
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 453995310d48..e8795420957c 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c | |||
@@ -64,6 +64,21 @@ | |||
64 | #define ST_PRESS_LPS331AP_OUT_XL_ADDR 0x28 | 64 | #define ST_PRESS_LPS331AP_OUT_XL_ADDR 0x28 |
65 | #define ST_TEMP_LPS331AP_OUT_L_ADDR 0x2b | 65 | #define ST_TEMP_LPS331AP_OUT_L_ADDR 0x2b |
66 | 66 | ||
67 | /* CUSTOM VALUES FOR LPS001WP SENSOR */ | ||
68 | #define ST_PRESS_LPS001WP_WAI_EXP 0xba | ||
69 | #define ST_PRESS_LPS001WP_ODR_ADDR 0x20 | ||
70 | #define ST_PRESS_LPS001WP_ODR_MASK 0x30 | ||
71 | #define ST_PRESS_LPS001WP_ODR_AVL_1HZ_VAL 0x01 | ||
72 | #define ST_PRESS_LPS001WP_ODR_AVL_7HZ_VAL 0x02 | ||
73 | #define ST_PRESS_LPS001WP_ODR_AVL_13HZ_VAL 0x03 | ||
74 | #define ST_PRESS_LPS001WP_PW_ADDR 0x20 | ||
75 | #define ST_PRESS_LPS001WP_PW_MASK 0x40 | ||
76 | #define ST_PRESS_LPS001WP_BDU_ADDR 0x20 | ||
77 | #define ST_PRESS_LPS001WP_BDU_MASK 0x04 | ||
78 | #define ST_PRESS_LPS001WP_MULTIREAD_BIT true | ||
79 | #define ST_PRESS_LPS001WP_OUT_L_ADDR 0x28 | ||
80 | #define ST_TEMP_LPS001WP_OUT_L_ADDR 0x2a | ||
81 | |||
67 | static const struct iio_chan_spec st_press_lps331ap_channels[] = { | 82 | static const struct iio_chan_spec st_press_lps331ap_channels[] = { |
68 | { | 83 | { |
69 | .type = IIO_PRESSURE, | 84 | .type = IIO_PRESSURE, |
@@ -100,6 +115,40 @@ static const struct iio_chan_spec st_press_lps331ap_channels[] = { | |||
100 | IIO_CHAN_SOFT_TIMESTAMP(1) | 115 | IIO_CHAN_SOFT_TIMESTAMP(1) |
101 | }; | 116 | }; |
102 | 117 | ||
118 | static const struct iio_chan_spec st_press_lps001wp_channels[] = { | ||
119 | { | ||
120 | .type = IIO_PRESSURE, | ||
121 | .channel2 = IIO_NO_MOD, | ||
122 | .address = ST_PRESS_LPS001WP_OUT_L_ADDR, | ||
123 | .scan_index = ST_SENSORS_SCAN_X, | ||
124 | .scan_type = { | ||
125 | .sign = 'u', | ||
126 | .realbits = 16, | ||
127 | .storagebits = 16, | ||
128 | .endianness = IIO_LE, | ||
129 | }, | ||
130 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), | ||
131 | .modified = 0, | ||
132 | }, | ||
133 | { | ||
134 | .type = IIO_TEMP, | ||
135 | .channel2 = IIO_NO_MOD, | ||
136 | .address = ST_TEMP_LPS001WP_OUT_L_ADDR, | ||
137 | .scan_index = -1, | ||
138 | .scan_type = { | ||
139 | .sign = 'u', | ||
140 | .realbits = 16, | ||
141 | .storagebits = 16, | ||
142 | .endianness = IIO_LE, | ||
143 | }, | ||
144 | .info_mask_separate = | ||
145 | BIT(IIO_CHAN_INFO_RAW) | | ||
146 | BIT(IIO_CHAN_INFO_OFFSET), | ||
147 | .modified = 0, | ||
148 | }, | ||
149 | IIO_CHAN_SOFT_TIMESTAMP(1) | ||
150 | }; | ||
151 | |||
103 | static const struct st_sensors st_press_sensors[] = { | 152 | static const struct st_sensors st_press_sensors[] = { |
104 | { | 153 | { |
105 | .wai = ST_PRESS_LPS331AP_WAI_EXP, | 154 | .wai = ST_PRESS_LPS331AP_WAI_EXP, |
@@ -148,6 +197,41 @@ static const struct st_sensors st_press_sensors[] = { | |||
148 | .multi_read_bit = ST_PRESS_LPS331AP_MULTIREAD_BIT, | 197 | .multi_read_bit = ST_PRESS_LPS331AP_MULTIREAD_BIT, |
149 | .bootime = 2, | 198 | .bootime = 2, |
150 | }, | 199 | }, |
200 | { | ||
201 | .wai = ST_PRESS_LPS001WP_WAI_EXP, | ||
202 | .sensors_supported = { | ||
203 | [0] = LPS001WP_PRESS_DEV_NAME, | ||
204 | }, | ||
205 | .ch = (struct iio_chan_spec *)st_press_lps001wp_channels, | ||
206 | .num_ch = ARRAY_SIZE(st_press_lps001wp_channels), | ||
207 | .odr = { | ||
208 | .addr = ST_PRESS_LPS001WP_ODR_ADDR, | ||
209 | .mask = ST_PRESS_LPS001WP_ODR_MASK, | ||
210 | .odr_avl = { | ||
211 | { 1, ST_PRESS_LPS001WP_ODR_AVL_1HZ_VAL, }, | ||
212 | { 7, ST_PRESS_LPS001WP_ODR_AVL_7HZ_VAL, }, | ||
213 | { 13, ST_PRESS_LPS001WP_ODR_AVL_13HZ_VAL, }, | ||
214 | }, | ||
215 | }, | ||
216 | .pw = { | ||
217 | .addr = ST_PRESS_LPS001WP_PW_ADDR, | ||
218 | .mask = ST_PRESS_LPS001WP_PW_MASK, | ||
219 | .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE, | ||
220 | .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, | ||
221 | }, | ||
222 | .fs = { | ||
223 | .addr = 0, | ||
224 | }, | ||
225 | .bdu = { | ||
226 | .addr = ST_PRESS_LPS001WP_BDU_ADDR, | ||
227 | .mask = ST_PRESS_LPS001WP_BDU_MASK, | ||
228 | }, | ||
229 | .drdy_irq = { | ||
230 | .addr = 0, | ||
231 | }, | ||
232 | .multi_read_bit = ST_PRESS_LPS001WP_MULTIREAD_BIT, | ||
233 | .bootime = 2, | ||
234 | }, | ||
151 | }; | 235 | }; |
152 | 236 | ||
153 | static int st_press_read_raw(struct iio_dev *indio_dev, | 237 | static 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 08aac5e6251d..51eab7fcb194 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c | |||
@@ -49,6 +49,7 @@ static int st_press_i2c_remove(struct i2c_client *client) | |||
49 | } | 49 | } |
50 | 50 | ||
51 | static const struct i2c_device_id st_press_id_table[] = { | 51 | static const struct i2c_device_id st_press_id_table[] = { |
52 | { LPS001WP_PRESS_DEV_NAME }, | ||
52 | { LPS331AP_PRESS_DEV_NAME }, | 53 | { LPS331AP_PRESS_DEV_NAME }, |
53 | {}, | 54 | {}, |
54 | }; | 55 | }; |