Skip to content

Commit b8f15d1

Browse files
legkom3jic23
authored andcommitted
iio: accel: iis328dq: fix gain values
The sensors IIS328DQ and H3LIS331DL share one configuration but H3LIS331DL has different gain parameters, configs therefore need to be split up. The gain parameters for the IIS328DQ are 0.98, 1.95 and 3.91, depending on the selected measurement range. See sensor manuals, chapter 2.1 "mechanical characteristics", parameter "Sensitivity". Datasheet: https://www.st.com/resource/en/datasheet/iis328dq.pdf Datasheet: https://www.st.com/resource/en/datasheet/h3lis331dl.pdf Fixes: 46e3370 ("iio: accel: add support for IIS328DQ variant") Reviewed-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com> Signed-off-by: Markus Koeniger <markus.koeniger@liebherr.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 9910159 commit b8f15d1

1 file changed

Lines changed: 71 additions & 1 deletion

File tree

drivers/iio/accel/st_accel_core.c

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,6 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
517517
.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
518518
.sensors_supported = {
519519
[0] = H3LIS331DL_ACCEL_DEV_NAME,
520-
[1] = IIS328DQ_ACCEL_DEV_NAME,
521520
},
522521
.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
523522
.odr = {
@@ -584,6 +583,77 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
584583
.multi_read_bit = true,
585584
.bootime = 2,
586585
},
586+
{
587+
.wai = 0x32,
588+
.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
589+
.sensors_supported = {
590+
[0] = IIS328DQ_ACCEL_DEV_NAME,
591+
},
592+
.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
593+
.odr = {
594+
.addr = 0x20,
595+
.mask = 0x18,
596+
.odr_avl = {
597+
{ .hz = 50, .value = 0x00, },
598+
{ .hz = 100, .value = 0x01, },
599+
{ .hz = 400, .value = 0x02, },
600+
{ .hz = 1000, .value = 0x03, },
601+
},
602+
},
603+
.pw = {
604+
.addr = 0x20,
605+
.mask = 0x20,
606+
.value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
607+
.value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
608+
},
609+
.enable_axis = {
610+
.addr = ST_SENSORS_DEFAULT_AXIS_ADDR,
611+
.mask = ST_SENSORS_DEFAULT_AXIS_MASK,
612+
},
613+
.fs = {
614+
.addr = 0x23,
615+
.mask = 0x30,
616+
.fs_avl = {
617+
[0] = {
618+
.num = ST_ACCEL_FS_AVL_100G,
619+
.value = 0x00,
620+
.gain = IIO_G_TO_M_S_2(980),
621+
},
622+
[1] = {
623+
.num = ST_ACCEL_FS_AVL_200G,
624+
.value = 0x01,
625+
.gain = IIO_G_TO_M_S_2(1950),
626+
},
627+
[2] = {
628+
.num = ST_ACCEL_FS_AVL_400G,
629+
.value = 0x03,
630+
.gain = IIO_G_TO_M_S_2(3910),
631+
},
632+
},
633+
},
634+
.bdu = {
635+
.addr = 0x23,
636+
.mask = 0x80,
637+
},
638+
.drdy_irq = {
639+
.int1 = {
640+
.addr = 0x22,
641+
.mask = 0x02,
642+
},
643+
.int2 = {
644+
.addr = 0x22,
645+
.mask = 0x10,
646+
},
647+
.addr_ihl = 0x22,
648+
.mask_ihl = 0x80,
649+
},
650+
.sim = {
651+
.addr = 0x23,
652+
.value = BIT(0),
653+
},
654+
.multi_read_bit = true,
655+
.bootime = 2,
656+
},
587657
{
588658
/* No WAI register present */
589659
.sensors_supported = {

0 commit comments

Comments
 (0)