Skip to contentSkip to conversation

iio: imu: st_lsm6dsx: Add ISM330DHCX 4000 dps gyro scale

RFC PATCH New mohammedryn 1 participant 1 message Nov 29

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 iio: imu: st_lsm6dsx: Add ISM330DHCX 4000 dps gyro scale

The ISM330DHCX supports a 4000 dps gyroscope full scale with a sensitivity of 140 mdps/LSB. The shared st_lsm6dsx scale table tops out at 2000 dps, so users cannot select the additional range through IIO.

Select a dedicated scale table for the ISM330DHCX gyroscope. Include FS_4000 in the full-scale mask so that selecting any of the existing scales clears it. Leave the output data rate bits outside the mask.

Check the OIS control mode before enabling FS_4000. ST AN5398 documents that CTRL1_OIS.OIS_EN_SPI2 reads zero when CTRL7_G selects primary interface control. In that mode check CTRL7_G.OIS_ON. In auxiliary control mode check OIS_EN_SPI2. Return -EBUSY when OIS is enabled.

---
Is checking the OIS state when selecting 4000 dps sufficient for this driver, or should the range be restricted further on boards where a separate auxiliary SPI controller can enable OIS later?

Tested on a Raspberry Pi 5 with a SmartElex ISM330DHCX breakout on I2C bus 1 at 0x6b. The driver change was backported to the running Ubuntu 6.8.0-1056-raspi kernel for this test. With OIS disabled, sysfs accepted all five scales. Switching 2000 -> 4000 -> 2000 dps wrote CTRL2_G values 0x0c -> 0x01 -> 0x0c. The I2C trace showed reads of both OIS control registers before the 4000 dps write, and direct reads returned raw samples from all three gyro axes at 4000 dps.

The core, I2C and SPI objects built with W=1. A host harness with simulated registers checked OIS rejection in both control modes, I/O errors, the four existing scales and preservation of the output data rate bits. OIS-on behavior and angular accuracy at high speed were not measured on hardware.

AI assistance was used to trace the scale path, draft the driver change and changelog, and build the host regression harness.

 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  4 +-
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 67 ++++++++++++++++++--
 2 files changed, 63 insertions(+), 8 deletions(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +3 -1
index 767aadfe7..1df14b20a 100644
@@ -154,7 +154,7 @@ struct st_lsm6dsx_fs {
 	u8 val;
 };
 
-#define ST_LSM6DSX_FS_LIST_SIZE		4
+#define ST_LSM6DSX_FS_LIST_SIZE		5
 struct st_lsm6dsx_fs_table_entry {
 	struct st_lsm6dsx_reg reg;
 
@@ -413,6 +413,7 @@ enum st_lsm6dsx_fifo_mode {
  * @name: Sensor name.
  * @id: Sensor identifier.
  * @hw: Pointer to instance of struct st_lsm6dsx_hw.
+ * @fs_table: Full-scale settings for the primary accelerometer or gyroscope.
  * @gain: Configured sensor sensitivity.
  * @odr: Output data rate of the sensor [mHz].
  * hwfifo_odr_mHz: Batch data rate for hardware FIFO [mHz]
@@ -427,6 +428,7 @@ struct st_lsm6dsx_sensor {
 	char name[32];
 	enum st_lsm6dsx_sensor_id id;
 	struct st_lsm6dsx_hw *hw;
+	const struct st_lsm6dsx_fs_table_entry *fs_table;
 
 	u32 gain;
 	u32 odr;
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +60 -7

117 lines not on this page · raw message

base-commit: 7083dbb93943f4a468d35bbdb4f1d523a3069f2b

Signature · 1 line
2.34.1