All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: accel: iis328dq: fix gain values
@ 2025-12-22 14:50 ` Markus Koeniger via B4 Relay
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Koeniger @ 2025-12-22 14:50 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: linux-iio, linux-kernel, Dimitri Fedrau, Dimitri Fedrau,
	Markus Koeniger

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":
IIS328DQ https://www.st.com/resource/en/datasheet/iis328dq.pdf
H3LIS331DL https://www.st.com/resource/en/datasheet/h3lis331dl.pdf

Fixes: 46e33707fe95 ("iio: accel: add support for IIS328DQ variant")
Reviewed-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
Signed-off-by: Markus Koeniger <markus.koeniger@liebherr.com>
---
Fix gain value of IIS328DQ accelerometer. The typical gain parameters for 
the IIS328DQ are 0.98, 1.95 and 3.91, depending on the selected 
measurement range. The configuration for IIS328DQ and H3LIS331DL needs 
to be split up as H3LIS331DL has different gains of 49, 98 and 195. 
---
 drivers/iio/accel/st_accel_core.c | 72 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 99cb661fabb2..afd97216d8ae 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -517,7 +517,6 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 		.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
 		.sensors_supported = {
 			[0] = H3LIS331DL_ACCEL_DEV_NAME,
-			[1] = IIS328DQ_ACCEL_DEV_NAME,
 		},
 		.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
 		.odr = {
@@ -584,6 +583,77 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 		.multi_read_bit = true,
 		.bootime = 2,
 	},
+	{
+		.wai = 0x32,
+		.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
+		.sensors_supported = {
+			[0] = IIS328DQ_ACCEL_DEV_NAME,
+		},
+		.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
+		.odr = {
+			.addr = 0x20,
+			.mask = 0x18,
+			.odr_avl = {
+				{ .hz = 50, .value = 0x00, },
+				{ .hz = 100, .value = 0x01, },
+				{ .hz = 400, .value = 0x02, },
+				{ .hz = 1000, .value = 0x03, },
+			},
+		},
+		.pw = {
+			.addr = 0x20,
+			.mask = 0x20,
+			.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 = 0x23,
+			.mask = 0x30,
+			.fs_avl = {
+				[0] = {
+					.num = ST_ACCEL_FS_AVL_100G,
+					.value = 0x00,
+					.gain = IIO_G_TO_M_S_2(980),
+				},
+				[1] = {
+					.num = ST_ACCEL_FS_AVL_200G,
+					.value = 0x01,
+					.gain = IIO_G_TO_M_S_2(1950),
+				},
+				[2] = {
+					.num = ST_ACCEL_FS_AVL_400G,
+					.value = 0x03,
+					.gain = IIO_G_TO_M_S_2(3910),
+				},
+			},
+		},
+		.bdu = {
+			.addr = 0x23,
+			.mask = 0x80,
+		},
+		.drdy_irq = {
+			.int1 = {
+				.addr = 0x22,
+				.mask = 0x02,
+			},
+			.int2 = {
+				.addr = 0x22,
+				.mask = 0x10,
+			},
+			.addr_ihl = 0x22,
+			.mask_ihl = 0x80,
+		},
+		.sim = {
+			.addr = 0x23,
+			.value = BIT(0),
+		},
+		.multi_read_bit = true,
+		.bootime = 2,
+	},
 	{
 		/* No WAI register present */
 		.sensors_supported = {

---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20251222-iio-accel-iis328dq-fix-gains-c281f9961b22

Best regards,
-- 
Markus Koeniger <markus.koeniger@liebherr.com>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] iio: accel: iis328dq: fix gain values
@ 2025-12-22 14:50 ` Markus Koeniger via B4 Relay
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Koeniger via B4 Relay @ 2025-12-22 14:50 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: linux-iio, linux-kernel, Dimitri Fedrau, Dimitri Fedrau,
	Markus Koeniger

From: Markus Koeniger <markus.koeniger@liebherr.com>

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":
IIS328DQ https://www.st.com/resource/en/datasheet/iis328dq.pdf
H3LIS331DL https://www.st.com/resource/en/datasheet/h3lis331dl.pdf

Fixes: 46e33707fe95 ("iio: accel: add support for IIS328DQ variant")
Reviewed-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
Signed-off-by: Markus Koeniger <markus.koeniger@liebherr.com>
---
Fix gain value of IIS328DQ accelerometer. The typical gain parameters for 
the IIS328DQ are 0.98, 1.95 and 3.91, depending on the selected 
measurement range. The configuration for IIS328DQ and H3LIS331DL needs 
to be split up as H3LIS331DL has different gains of 49, 98 and 195. 
---
 drivers/iio/accel/st_accel_core.c | 72 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 99cb661fabb2..afd97216d8ae 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -517,7 +517,6 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 		.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
 		.sensors_supported = {
 			[0] = H3LIS331DL_ACCEL_DEV_NAME,
-			[1] = IIS328DQ_ACCEL_DEV_NAME,
 		},
 		.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
 		.odr = {
@@ -584,6 +583,77 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 		.multi_read_bit = true,
 		.bootime = 2,
 	},
+	{
+		.wai = 0x32,
+		.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
+		.sensors_supported = {
+			[0] = IIS328DQ_ACCEL_DEV_NAME,
+		},
+		.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
+		.odr = {
+			.addr = 0x20,
+			.mask = 0x18,
+			.odr_avl = {
+				{ .hz = 50, .value = 0x00, },
+				{ .hz = 100, .value = 0x01, },
+				{ .hz = 400, .value = 0x02, },
+				{ .hz = 1000, .value = 0x03, },
+			},
+		},
+		.pw = {
+			.addr = 0x20,
+			.mask = 0x20,
+			.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 = 0x23,
+			.mask = 0x30,
+			.fs_avl = {
+				[0] = {
+					.num = ST_ACCEL_FS_AVL_100G,
+					.value = 0x00,
+					.gain = IIO_G_TO_M_S_2(980),
+				},
+				[1] = {
+					.num = ST_ACCEL_FS_AVL_200G,
+					.value = 0x01,
+					.gain = IIO_G_TO_M_S_2(1950),
+				},
+				[2] = {
+					.num = ST_ACCEL_FS_AVL_400G,
+					.value = 0x03,
+					.gain = IIO_G_TO_M_S_2(3910),
+				},
+			},
+		},
+		.bdu = {
+			.addr = 0x23,
+			.mask = 0x80,
+		},
+		.drdy_irq = {
+			.int1 = {
+				.addr = 0x22,
+				.mask = 0x02,
+			},
+			.int2 = {
+				.addr = 0x22,
+				.mask = 0x10,
+			},
+			.addr_ihl = 0x22,
+			.mask_ihl = 0x80,
+		},
+		.sim = {
+			.addr = 0x23,
+			.value = BIT(0),
+		},
+		.multi_read_bit = true,
+		.bootime = 2,
+	},
 	{
 		/* No WAI register present */
 		.sensors_supported = {

---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20251222-iio-accel-iis328dq-fix-gains-c281f9961b22

Best regards,
-- 
Markus Koeniger <markus.koeniger@liebherr.com>



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: accel: iis328dq: fix gain values
  2025-12-22 14:50 ` Markus Koeniger via B4 Relay
  (?)
@ 2025-12-27 15:26 ` Andy Shevchenko
  -1 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2025-12-27 15:26 UTC (permalink / raw)
  To: markus.koeniger
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	linux-iio, linux-kernel, Dimitri Fedrau, Dimitri Fedrau

On Mon, Dec 22, 2025 at 03:50:04PM +0100, Markus Koeniger via B4 Relay wrote:
> From: Markus Koeniger <markus.koeniger@liebherr.com>
> 
> 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":
> IIS328DQ https://www.st.com/resource/en/datasheet/iis328dq.pdf
> H3LIS331DL https://www.st.com/resource/en/datasheet/h3lis331dl.pdf

You can make them as Datasheet tags:

  ...
  See sensor manuals, chapter 2.1 "mechanical characteristics",
  parameter "Sensitivity" in the datasheet.

  Datasheet: https://www.st.com/resource/en/datasheet/iis328dq.pdf
  Datasheet: https://www.st.com/resource/en/datasheet/h3lis331dl.pdf
  Fixes: ...
  ...

> Fixes: 46e33707fe95 ("iio: accel: add support for IIS328DQ variant")
> Reviewed-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> Signed-off-by: Markus Koeniger <markus.koeniger@liebherr.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-27 15:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-22 14:50 [PATCH] iio: accel: iis328dq: fix gain values Markus Koeniger
2025-12-22 14:50 ` Markus Koeniger via B4 Relay
2025-12-27 15:26 ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.