aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2015-03-18 05:52:06 -0400
committerJonathan Cameron <jic23@kernel.org>2015-03-28 06:55:36 -0400
commit3acddf74f807778f0593ab4aaf26189c93e55ff1 (patch)
treec0472480a57867e2bcc982810a65ca49dca24892 /drivers/iio
parent153fe946412b5da1a8808f79d4f7f4ebfa7586b0 (diff)
iio: st-sensors: add support for lis3lv02d accelerometer
This adds support for the LIS3LV02 accelerometer found in the ST Microelectronics Nomadik board series. Cc: devicetree@vger.kernel.org Cc: Denis CIOCCA <denis.ciocca@st.com> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/accel/st_accel.h1
-rw-r--r--drivers/iio/accel/st_accel_core.c81
-rw-r--r--drivers/iio/accel/st_accel_i2c.c4
3 files changed, 86 insertions, 0 deletions
diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index fa9646034305..7ee9724b1428 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.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 LIS3LV02DL_ACCEL_DEV_NAME "lis3lv02dl_accel"
17#define LSM303DLHC_ACCEL_DEV_NAME "lsm303dlhc_accel" 18#define LSM303DLHC_ACCEL_DEV_NAME "lsm303dlhc_accel"
18#define LIS3DH_ACCEL_DEV_NAME "lis3dh" 19#define LIS3DH_ACCEL_DEV_NAME "lis3dh"
19#define LSM330D_ACCEL_DEV_NAME "lsm330d_accel" 20#define LSM330D_ACCEL_DEV_NAME "lsm330d_accel"
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 53f32629283a..58d1d13d552a 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -129,6 +129,30 @@
129#define ST_ACCEL_3_IG1_EN_MASK 0x08 129#define ST_ACCEL_3_IG1_EN_MASK 0x08
130#define ST_ACCEL_3_MULTIREAD_BIT false 130#define ST_ACCEL_3_MULTIREAD_BIT false
131 131
132/* CUSTOM VALUES FOR SENSOR 4 */
133#define ST_ACCEL_4_WAI_EXP 0x3a
134#define ST_ACCEL_4_ODR_ADDR 0x20
135#define ST_ACCEL_4_ODR_MASK 0x30 /* DF1 and DF0 */
136#define ST_ACCEL_4_ODR_AVL_40HZ_VAL 0x00
137#define ST_ACCEL_4_ODR_AVL_160HZ_VAL 0x01
138#define ST_ACCEL_4_ODR_AVL_640HZ_VAL 0x02
139#define ST_ACCEL_4_ODR_AVL_2560HZ_VAL 0x03
140#define ST_ACCEL_4_PW_ADDR 0x20
141#define ST_ACCEL_4_PW_MASK 0xc0
142#define ST_ACCEL_4_FS_ADDR 0x21
143#define ST_ACCEL_4_FS_MASK 0x80
144#define ST_ACCEL_4_FS_AVL_2_VAL 0X00
145#define ST_ACCEL_4_FS_AVL_6_VAL 0X01
146#define ST_ACCEL_4_FS_AVL_2_GAIN IIO_G_TO_M_S_2(1024)
147#define ST_ACCEL_4_FS_AVL_6_GAIN IIO_G_TO_M_S_2(340)
148#define ST_ACCEL_4_BDU_ADDR 0x21
149#define ST_ACCEL_4_BDU_MASK 0x40
150#define ST_ACCEL_4_DRDY_IRQ_ADDR 0x21
151#define ST_ACCEL_4_DRDY_IRQ_INT1_MASK 0x04
152#define ST_ACCEL_4_IG1_EN_ADDR 0x21
153#define ST_ACCEL_4_IG1_EN_MASK 0x08
154#define ST_ACCEL_4_MULTIREAD_BIT true
155
132static const struct iio_chan_spec st_accel_12bit_channels[] = { 156static const struct iio_chan_spec st_accel_12bit_channels[] = {
133 ST_SENSORS_LSM_CHANNELS(IIO_ACCEL, 157 ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
134 BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), 158 BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
@@ -373,6 +397,63 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
373 .multi_read_bit = ST_ACCEL_3_MULTIREAD_BIT, 397 .multi_read_bit = ST_ACCEL_3_MULTIREAD_BIT,
374 .bootime = 2, 398 .bootime = 2,
375 }, 399 },
400 {
401 .wai = ST_ACCEL_4_WAI_EXP,
402 .sensors_supported = {
403 [0] = LIS3LV02DL_ACCEL_DEV_NAME,
404 },
405 .ch = (struct iio_chan_spec *)st_accel_12bit_channels,
406 .odr = {
407 .addr = ST_ACCEL_4_ODR_ADDR,
408 .mask = ST_ACCEL_4_ODR_MASK,
409 .odr_avl = {
410 { 40, ST_ACCEL_4_ODR_AVL_40HZ_VAL },
411 { 160, ST_ACCEL_4_ODR_AVL_160HZ_VAL, },
412 { 640, ST_ACCEL_4_ODR_AVL_640HZ_VAL, },
413 { 2560, ST_ACCEL_4_ODR_AVL_2560HZ_VAL, },
414 },
415 },
416 .pw = {
417 .addr = ST_ACCEL_4_PW_ADDR,
418 .mask = ST_ACCEL_4_PW_MASK,
419 .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
420 .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
421 },
422 .enable_axis = {
423 .addr = ST_SENSORS_DEFAULT_AXIS_ADDR,
424 .mask = ST_SENSORS_DEFAULT_AXIS_MASK,
425 },
426 .fs = {
427 .addr = ST_ACCEL_4_FS_ADDR,
428 .mask = ST_ACCEL_4_FS_MASK,
429 .fs_avl = {
430 [0] = {
431 .num = ST_ACCEL_FS_AVL_2G,
432 .value = ST_ACCEL_4_FS_AVL_2_VAL,
433 .gain = ST_ACCEL_4_FS_AVL_2_GAIN,
434 },
435 [1] = {
436 .num = ST_ACCEL_FS_AVL_6G,
437 .value = ST_ACCEL_4_FS_AVL_6_VAL,
438 .gain = ST_ACCEL_4_FS_AVL_6_GAIN,
439 },
440 },
441 },
442 .bdu = {
443 .addr = ST_ACCEL_4_BDU_ADDR,
444 .mask = ST_ACCEL_4_BDU_MASK,
445 },
446 .drdy_irq = {
447 .addr = ST_ACCEL_4_DRDY_IRQ_ADDR,
448 .mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK,
449 .ig1 = {
450 .en_addr = ST_ACCEL_4_IG1_EN_ADDR,
451 .en_mask = ST_ACCEL_4_IG1_EN_MASK,
452 },
453 },
454 .multi_read_bit = ST_ACCEL_4_MULTIREAD_BIT,
455 .bootime = 2, /* guess */
456 },
376}; 457};
377 458
378static int st_accel_read_raw(struct iio_dev *indio_dev, 459static int st_accel_read_raw(struct iio_dev *indio_dev,
diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
index c7246bdd30b9..6b720c190b2d 100644
--- a/drivers/iio/accel/st_accel_i2c.c
+++ b/drivers/iio/accel/st_accel_i2c.c
@@ -21,6 +21,10 @@
21#ifdef CONFIG_OF 21#ifdef CONFIG_OF
22static const struct of_device_id st_accel_of_match[] = { 22static const struct of_device_id st_accel_of_match[] = {
23 { 23 {
24 .compatible = "st,lis3lv02dl-accel",
25 .data = LIS3LV02DL_ACCEL_DEV_NAME,
26 },
27 {
24 .compatible = "st,lsm303dlh-accel", 28 .compatible = "st,lsm303dlh-accel",
25 .data = LSM303DLH_ACCEL_DEV_NAME, 29 .data = LSM303DLH_ACCEL_DEV_NAME,
26 }, 30 },