mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 22:51:42 +00:00
iio: accel: Add support for the h3lis331dl accelerometer
This commit adds support for STMicroelectronics h3lis331dl high-g accelerometer. The datasheet for this device can be found here: http://www.st.com/web/en/resource/technical/document/ datasheet/DM00053090.pdf Signed-off-by: Tiberiu Breana <tiberiu.a.breana@intel.com> Reviewed-by: Denis Ciocca <denis.ciocca@st.com> Acked-by: Denis Ciocca <denis.ciocca@st.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
2bcdb3f2e0
commit
1e52fefc9b
@ -37,6 +37,7 @@ Accelerometers:
|
||||
- st,lsm330-accel
|
||||
- st,lsm303agr-accel
|
||||
- st,lis2dh12-accel
|
||||
- st,h3lis331dl-accel
|
||||
|
||||
Gyroscopes:
|
||||
- st,l3g4200d-gyro
|
||||
|
@ -64,7 +64,7 @@ config IIO_ST_ACCEL_3AXIS
|
||||
help
|
||||
Say yes here to build support for STMicroelectronics accelerometers:
|
||||
LSM303DLH, LSM303DLHC, LIS3DH, LSM330D, LSM330DL, LSM330DLC,
|
||||
LIS331DLH, LSM303DL, LSM303DLM, LSM330, LIS2DH12.
|
||||
LIS331DLH, LSM303DL, LSM303DLM, LSM330, LIS2DH12, H3LIS331DL.
|
||||
|
||||
This driver can also be built as a module. If so, these modules
|
||||
will be created:
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/iio/common/st_sensors.h>
|
||||
|
||||
#define H3LIS331DL_DRIVER_NAME "h3lis331dl_accel"
|
||||
#define LIS3LV02DL_ACCEL_DEV_NAME "lis3lv02dl_accel"
|
||||
#define LSM303DLHC_ACCEL_DEV_NAME "lsm303dlhc_accel"
|
||||
#define LIS3DH_ACCEL_DEV_NAME "lis3dh"
|
||||
|
@ -39,6 +39,9 @@
|
||||
#define ST_ACCEL_FS_AVL_6G 6
|
||||
#define ST_ACCEL_FS_AVL_8G 8
|
||||
#define ST_ACCEL_FS_AVL_16G 16
|
||||
#define ST_ACCEL_FS_AVL_100G 100
|
||||
#define ST_ACCEL_FS_AVL_200G 200
|
||||
#define ST_ACCEL_FS_AVL_400G 400
|
||||
|
||||
/* CUSTOM VALUES FOR SENSOR 1 */
|
||||
#define ST_ACCEL_1_WAI_EXP 0x33
|
||||
@ -181,6 +184,33 @@
|
||||
#define ST_ACCEL_5_IG1_EN_MASK 0x08
|
||||
#define ST_ACCEL_5_MULTIREAD_BIT false
|
||||
|
||||
/* CUSTOM VALUES FOR SENSOR 6 */
|
||||
#define ST_ACCEL_6_WAI_EXP 0x32
|
||||
#define ST_ACCEL_6_ODR_ADDR 0x20
|
||||
#define ST_ACCEL_6_ODR_MASK 0x18
|
||||
#define ST_ACCEL_6_ODR_AVL_50HZ_VAL 0x00
|
||||
#define ST_ACCEL_6_ODR_AVL_100HZ_VAL 0x01
|
||||
#define ST_ACCEL_6_ODR_AVL_400HZ_VAL 0x02
|
||||
#define ST_ACCEL_6_ODR_AVL_1000HZ_VAL 0x03
|
||||
#define ST_ACCEL_6_PW_ADDR 0x20
|
||||
#define ST_ACCEL_6_PW_MASK 0x20
|
||||
#define ST_ACCEL_6_FS_ADDR 0x23
|
||||
#define ST_ACCEL_6_FS_MASK 0x30
|
||||
#define ST_ACCEL_6_FS_AVL_100_VAL 0x00
|
||||
#define ST_ACCEL_6_FS_AVL_200_VAL 0x01
|
||||
#define ST_ACCEL_6_FS_AVL_400_VAL 0x03
|
||||
#define ST_ACCEL_6_FS_AVL_100_GAIN IIO_G_TO_M_S_2(49000)
|
||||
#define ST_ACCEL_6_FS_AVL_200_GAIN IIO_G_TO_M_S_2(98000)
|
||||
#define ST_ACCEL_6_FS_AVL_400_GAIN IIO_G_TO_M_S_2(195000)
|
||||
#define ST_ACCEL_6_BDU_ADDR 0x23
|
||||
#define ST_ACCEL_6_BDU_MASK 0x80
|
||||
#define ST_ACCEL_6_DRDY_IRQ_ADDR 0x22
|
||||
#define ST_ACCEL_6_DRDY_IRQ_INT1_MASK 0x02
|
||||
#define ST_ACCEL_6_DRDY_IRQ_INT2_MASK 0x10
|
||||
#define ST_ACCEL_6_IHL_IRQ_ADDR 0x22
|
||||
#define ST_ACCEL_6_IHL_IRQ_MASK 0x80
|
||||
#define ST_ACCEL_6_MULTIREAD_BIT true
|
||||
|
||||
static const struct iio_chan_spec st_accel_8bit_channels[] = {
|
||||
ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
|
||||
BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
|
||||
@ -557,6 +587,68 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
|
||||
.multi_read_bit = ST_ACCEL_5_MULTIREAD_BIT,
|
||||
.bootime = 2, /* guess */
|
||||
},
|
||||
{
|
||||
.wai = ST_ACCEL_6_WAI_EXP,
|
||||
.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
|
||||
.sensors_supported = {
|
||||
[0] = H3LIS331DL_DRIVER_NAME,
|
||||
},
|
||||
.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
|
||||
.odr = {
|
||||
.addr = ST_ACCEL_6_ODR_ADDR,
|
||||
.mask = ST_ACCEL_6_ODR_MASK,
|
||||
.odr_avl = {
|
||||
{ 50, ST_ACCEL_6_ODR_AVL_50HZ_VAL },
|
||||
{ 100, ST_ACCEL_6_ODR_AVL_100HZ_VAL, },
|
||||
{ 400, ST_ACCEL_6_ODR_AVL_400HZ_VAL, },
|
||||
{ 1000, ST_ACCEL_6_ODR_AVL_1000HZ_VAL, },
|
||||
},
|
||||
},
|
||||
.pw = {
|
||||
.addr = ST_ACCEL_6_PW_ADDR,
|
||||
.mask = ST_ACCEL_6_PW_MASK,
|
||||
.value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
|
||||
.value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
|
||||
},
|
||||
.enable_axis = {
|
||||
.addr = ST_SENSORS_DEFAULT_AXIS_ADDR,
|
||||
.mask = ST_SENSORS_DEFAULT_AXIS_MASK,
|
||||
},
|
||||
.fs = {
|
||||
.addr = ST_ACCEL_6_FS_ADDR,
|
||||
.mask = ST_ACCEL_6_FS_MASK,
|
||||
.fs_avl = {
|
||||
[0] = {
|
||||
.num = ST_ACCEL_FS_AVL_100G,
|
||||
.value = ST_ACCEL_6_FS_AVL_100_VAL,
|
||||
.gain = ST_ACCEL_6_FS_AVL_100_GAIN,
|
||||
},
|
||||
[1] = {
|
||||
.num = ST_ACCEL_FS_AVL_200G,
|
||||
.value = ST_ACCEL_6_FS_AVL_200_VAL,
|
||||
.gain = ST_ACCEL_6_FS_AVL_200_GAIN,
|
||||
},
|
||||
[2] = {
|
||||
.num = ST_ACCEL_FS_AVL_400G,
|
||||
.value = ST_ACCEL_6_FS_AVL_400_VAL,
|
||||
.gain = ST_ACCEL_6_FS_AVL_400_GAIN,
|
||||
},
|
||||
},
|
||||
},
|
||||
.bdu = {
|
||||
.addr = ST_ACCEL_6_BDU_ADDR,
|
||||
.mask = ST_ACCEL_6_BDU_MASK,
|
||||
},
|
||||
.drdy_irq = {
|
||||
.addr = ST_ACCEL_6_DRDY_IRQ_ADDR,
|
||||
.mask_int1 = ST_ACCEL_6_DRDY_IRQ_INT1_MASK,
|
||||
.mask_int2 = ST_ACCEL_6_DRDY_IRQ_INT2_MASK,
|
||||
.addr_ihl = ST_ACCEL_6_IHL_IRQ_ADDR,
|
||||
.mask_ihl = ST_ACCEL_6_IHL_IRQ_MASK,
|
||||
},
|
||||
.multi_read_bit = ST_ACCEL_6_MULTIREAD_BIT,
|
||||
.bootime = 2,
|
||||
},
|
||||
};
|
||||
|
||||
static int st_accel_read_raw(struct iio_dev *indio_dev,
|
||||
|
@ -76,6 +76,10 @@ static const struct of_device_id st_accel_of_match[] = {
|
||||
.compatible = "st,lis2dh12-accel",
|
||||
.data = LIS2DH12_ACCEL_DEV_NAME,
|
||||
},
|
||||
{
|
||||
.compatible = "st,h3lis331dl-accel",
|
||||
.data = H3LIS331DL_DRIVER_NAME,
|
||||
},
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, st_accel_of_match);
|
||||
|
Loading…
Reference in New Issue
Block a user