Skip to content

Commit 3f4a559

Browse files
rvlanderjic23
authored andcommitted
iio: accel: st_sensors: add support for LIS2HH12
Add support for STMicroelectronics LISHH12 accelerometer in st_accel framework. https://www.st.com/resource/en/datasheet/lis2hh12.pdf Signed-off-by: Gaëtan André <[email protected]> Reviewed-by: Stephan Gerhold <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 9e3fbad commit 3f4a559

File tree

4 files changed

+85
-1
lines changed

4 files changed

+85
-1
lines changed

drivers/iio/accel/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ config IIO_ST_ACCEL_3AXIS
238238
Say yes here to build support for STMicroelectronics accelerometers:
239239
LSM303DLH, LSM303DLHC, LIS3DH, LSM330D, LSM330DL, LSM330DLC,
240240
LIS331DLH, LSM303DL, LSM303DLM, LSM330, LIS2DH12, H3LIS331DL,
241-
LNG2DM, LIS3DE, LIS2DE12
241+
LNG2DM, LIS3DE, LIS2DE12, LIS2HH12
242242

243243
This driver can also be built as a module. If so, these modules
244244
will be created:

drivers/iio/accel/st_accel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ enum st_accel_type {
3535
LIS2DW12,
3636
LIS3DHH,
3737
LIS2DE12,
38+
LIS2HH12,
3839
ST_ACCEL_MAX,
3940
};
4041

@@ -59,6 +60,7 @@ enum st_accel_type {
5960
#define LIS3DHH_ACCEL_DEV_NAME "lis3dhh"
6061
#define LIS3DE_ACCEL_DEV_NAME "lis3de"
6162
#define LIS2DE12_ACCEL_DEV_NAME "lis2de12"
63+
#define LIS2HH12_ACCEL_DEV_NAME "lis2hh12"
6264

6365
/**
6466
* struct st_sensors_platform_data - default accel platform data

drivers/iio/accel/st_accel_core.c

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,83 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
904904
.multi_read_bit = true,
905905
.bootime = 2,
906906
},
907+
{
908+
.wai = 0x41,
909+
.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
910+
.sensors_supported = {
911+
[0] = LIS2HH12_ACCEL_DEV_NAME,
912+
},
913+
.ch = (struct iio_chan_spec *)st_accel_16bit_channels,
914+
.odr = {
915+
.addr = 0x20,
916+
.mask = 0x70,
917+
.odr_avl = {
918+
{ .hz = 10, .value = 0x01, },
919+
{ .hz = 50, .value = 0x02, },
920+
{ .hz = 100, .value = 0x03, },
921+
{ .hz = 200, .value = 0x04, },
922+
{ .hz = 400, .value = 0x05, },
923+
{ .hz = 800, .value = 0x06, },
924+
},
925+
},
926+
.pw = {
927+
.addr = 0x20,
928+
.mask = 0x70,
929+
.value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
930+
},
931+
.enable_axis = {
932+
.addr = ST_SENSORS_DEFAULT_AXIS_ADDR,
933+
.mask = ST_SENSORS_DEFAULT_AXIS_MASK,
934+
},
935+
.fs = {
936+
.addr = 0x23,
937+
.mask = 0x30,
938+
.fs_avl = {
939+
[0] = {
940+
.num = ST_ACCEL_FS_AVL_2G,
941+
.value = 0x00,
942+
.gain = IIO_G_TO_M_S_2(61),
943+
},
944+
[1] = {
945+
.num = ST_ACCEL_FS_AVL_4G,
946+
.value = 0x02,
947+
.gain = IIO_G_TO_M_S_2(122),
948+
},
949+
[2] = {
950+
.num = ST_ACCEL_FS_AVL_8G,
951+
.value = 0x03,
952+
.gain = IIO_G_TO_M_S_2(244),
953+
},
954+
},
955+
},
956+
.bdu = {
957+
.addr = 0x20,
958+
.mask = 0x08,
959+
},
960+
.drdy_irq = {
961+
.int1 = {
962+
.addr = 0x22,
963+
.mask = 0x01,
964+
},
965+
.int2 = {
966+
.addr = 0x25,
967+
.mask = 0x01,
968+
},
969+
.addr_ihl = 0x24,
970+
.mask_ihl = 0x02,
971+
.stat_drdy = {
972+
.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
973+
.mask = 0x07,
974+
},
975+
},
976+
.sim = {
977+
.addr = 0x23,
978+
.value = BIT(0),
979+
},
980+
.multi_read_bit = true,
981+
.bootime = 2,
982+
},
983+
907984
};
908985

909986
static int st_accel_read_raw(struct iio_dev *indio_dev,

drivers/iio/accel/st_accel_i2c.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ static const struct of_device_id st_accel_of_match[] = {
104104
.compatible = "st,lis2de12",
105105
.data = LIS2DE12_ACCEL_DEV_NAME,
106106
},
107+
{
108+
.compatible = "st,lis2hh12",
109+
.data = LIS2HH12_ACCEL_DEV_NAME,
110+
},
107111
{},
108112
};
109113
MODULE_DEVICE_TABLE(of, st_accel_of_match);
@@ -138,6 +142,7 @@ static const struct i2c_device_id st_accel_id_table[] = {
138142
{ LIS2DW12_ACCEL_DEV_NAME },
139143
{ LIS3DE_ACCEL_DEV_NAME },
140144
{ LIS2DE12_ACCEL_DEV_NAME },
145+
{ LIS2HH12_ACCEL_DEV_NAME },
141146
{},
142147
};
143148
MODULE_DEVICE_TABLE(i2c, st_accel_id_table);

0 commit comments

Comments
 (0)