From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Mario Tesi <mario.tesi@st.com>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6 21/93] iio: st_lsm6dsx: Fixed calibrated timestamp calculation
Date: Wed, 3 Dec 2025 16:29:14 +0100 [thread overview]
Message-ID: <20251203152337.296222759@linuxfoundation.org> (raw)
In-Reply-To: <20251203152336.494201426@linuxfoundation.org>
6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Tesi <martepisa@gmail.com>
[ Upstream commit 8abbf45fcda028c2c05ba38eb14ede9fa9e7341b ]
The calibrated timestamp is calculated from the nominal value using the
formula:
ts_gain[ns] ≈ ts_sensitivity - (ts_trim_coeff * val) / 1000.
The values of ts_sensitivity and ts_trim_coeff are not the same for all
devices, so it is necessary to differentiate them based on the part name.
For the correct values please consult the relevant AN.
Fixes: cb3b6b8e1bc0 ("iio: imu: st_lsm6dsx: add odr calibration feature")
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 18 ++++++++++++++++++
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 19 ++++++++-----------
2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index c19237717e812..0f347684f6fc9 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -190,6 +190,22 @@ struct st_lsm6dsx_fifo_ops {
* @fifo_en: Hw timer FIFO enable register info (addr + mask).
* @decimator: Hw timer FIFO decimator register info (addr + mask).
* @freq_fine: Difference in % of ODR with respect to the typical.
+ * @ts_sensitivity: Nominal timestamp sensitivity.
+ * @ts_trim_coeff: Coefficient for calculating the calibrated timestamp gain.
+ * This coefficient comes into play when linearizing the formula
+ * used to calculate the calibrated timestamp (please see the
+ * relevant formula in the AN for the specific IMU).
+ * For example, in the case of LSM6DSO we have:
+ *
+ * 1 / (1 + x) ~= 1 - x (Taylor’s Series)
+ * ttrim[s] = 1 / (40000 * (1 + 0.0015 * val)) (from AN5192)
+ * ttrim[ns] ~= 25000 - 37.5 * val
+ * ttrim[ns] ~= 25000 - (37500 * val) / 1000
+ *
+ * so, replacing ts_sensitivity = 25000 and
+ * ts_trim_coeff = 37500
+ *
+ * ttrim[ns] ~= ts_sensitivity - (ts_trim_coeff * val) / 1000
*/
struct st_lsm6dsx_hw_ts_settings {
struct st_lsm6dsx_reg timer_en;
@@ -197,6 +213,8 @@ struct st_lsm6dsx_hw_ts_settings {
struct st_lsm6dsx_reg fifo_en;
struct st_lsm6dsx_reg decimator;
u8 freq_fine;
+ u16 ts_sensitivity;
+ u16 ts_trim_coeff;
};
/**
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index b6e6b1df8a618..6e42e0c659e0c 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -77,8 +77,6 @@
#define ST_LSM6DSX_REG_WHOAMI_ADDR 0x0f
-#define ST_LSM6DSX_TS_SENSITIVITY 25000UL /* 25us */
-
static const struct iio_chan_spec st_lsm6dsx_acc_channels[] = {
ST_LSM6DSX_CHANNEL_ACC(IIO_ACCEL, 0x28, IIO_MOD_X, 0),
ST_LSM6DSX_CHANNEL_ACC(IIO_ACCEL, 0x2a, IIO_MOD_Y, 1),
@@ -962,6 +960,8 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
.mask = GENMASK(7, 6),
},
.freq_fine = 0x63,
+ .ts_sensitivity = 25000,
+ .ts_trim_coeff = 37500,
},
.shub_settings = {
.page_mux = {
@@ -1175,6 +1175,8 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
.mask = GENMASK(7, 6),
},
.freq_fine = 0x63,
+ .ts_sensitivity = 25000,
+ .ts_trim_coeff = 37500,
},
.event_settings = {
.enable_reg = {
@@ -1350,6 +1352,8 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
.mask = GENMASK(7, 6),
},
.freq_fine = 0x4f,
+ .ts_sensitivity = 21701,
+ .ts_trim_coeff = 28212,
},
.shub_settings = {
.page_mux = {
@@ -2243,20 +2247,13 @@ static int st_lsm6dsx_init_hw_timer(struct st_lsm6dsx_hw *hw)
}
/* calibrate timestamp sensitivity */
- hw->ts_gain = ST_LSM6DSX_TS_SENSITIVITY;
+ hw->ts_gain = ts_settings->ts_sensitivity;
if (ts_settings->freq_fine) {
err = regmap_read(hw->regmap, ts_settings->freq_fine, &val);
if (err < 0)
return err;
- /*
- * linearize the AN5192 formula:
- * 1 / (1 + x) ~= 1 - x (Taylor’s Series)
- * ttrim[s] = 1 / (40000 * (1 + 0.0015 * val))
- * ttrim[ns] ~= 25000 - 37.5 * val
- * ttrim[ns] ~= 25000 - (37500 * val) / 1000
- */
- hw->ts_gain -= ((s8)val * 37500) / 1000;
+ hw->ts_gain -= ((s8)val * ts_settings->ts_trim_coeff) / 1000;
}
return 0;
--
2.51.0
next prev parent reply other threads:[~2025-12-03 16:58 UTC|newest]
Thread overview: 104+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-03 15:28 [PATCH 6.6 00/93] 6.6.119-rc1 review Greg Kroah-Hartman
2025-12-03 15:28 ` [PATCH 6.6 01/93] can: kvaser_usb: leaf: Fix potential infinite loop in command parsers Greg Kroah-Hartman
2025-12-03 15:28 ` [PATCH 6.6 02/93] can: gs_usb: gs_usb_xmit_callback(): fix handling of failed transmitted URBs Greg Kroah-Hartman
2025-12-03 15:28 ` [PATCH 6.6 03/93] can: gs_usb: gs_usb_receive_bulk_callback(): check actual_length before accessing header Greg Kroah-Hartman
2025-12-03 15:28 ` [PATCH 6.6 04/93] can: gs_usb: gs_usb_receive_bulk_callback(): check actual_length before accessing data Greg Kroah-Hartman
2025-12-03 15:28 ` [PATCH 6.6 05/93] Bluetooth: hci_sock: Prevent race in socket write iter and sock bind Greg Kroah-Hartman
2025-12-03 15:28 ` [PATCH 6.6 06/93] Bluetooth: SMP: Fix not generating mackey and ltk when repairing Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 07/93] net: phy: mxl-gpy: fix bogus error on USXGMII and integrated PHY Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 08/93] platform/x86: intel: punit_ipc: fix memory corruption Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 09/93] net: aquantia: Add missing descriptor cache invalidation on ATL2 Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 10/93] net: lan966x: Fix the initialization of taprio Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 11/93] net/mlx5e: Fix validation logic in rate limiting Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 12/93] net: sxgbe: fix potential NULL dereference in sxgbe_rx() Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 13/93] drm/amdgpu: fix cyan_skillfish2 gpu info fw handling Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 14/93] net: dsa: sja1105: simplify static configuration reload Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 15/93] net: dsa: sja1105: fix SGMII linking at 10M or 100M but not passing traffic Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 16/93] net: atlantic: fix fragment overflow handling in RX path Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 17/93] net: fec: cancel perout_timer when PEROUT is disabled Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 18/93] net: fec: do not update PEROUT if it is enabled Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 19/93] net: fec: do not allow enabling PPS and PEROUT simultaneously Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 20/93] net: fec: do not register PPS event for PEROUT Greg Kroah-Hartman
2025-12-03 15:29 ` Greg Kroah-Hartman [this message]
2025-12-03 15:29 ` [PATCH 6.6 22/93] usb: gadget: renesas_usbf: Handle devm_pm_runtime_enable() errors Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 23/93] mailbox: mailbox-test: Fix debugfs_create_dir error checking Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 24/93] mailbox: pcc: Refactor error handling in irq handler into separate function Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 25/93] mailbox: pcc: dont zero error register Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 26/93] spi: tegra114: remove Kconfig dependency on TEGRA20_APB_DMA Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 27/93] spi: amlogic-spifc-a1: Handle devm_pm_runtime_enable() errors Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 28/93] spi: spi-mem: Allow specifying the byte order in Octal DTR mode Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 29/93] spi: spi-mem: Extend spi-mem operations with a per-operation maximum frequency Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 30/93] spi: spi-mem: Add a new controller capability Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 31/93] spi: nxp-fspi: Support per spi-mem operation frequency switches Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 32/93] spi: nxp-fspi: Propagate fwnode in ACPI case as well Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 33/93] spi: bcm63xx: fix premature CS deassertion on RX-only transactions Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 34/93] Revert "perf/x86: Always store regs->ip in perf_callchain_kernel()" Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 35/93] iio: imu: st_lsm6dsx: fix array size for st_lsm6dsx_settings fields Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 36/93] iio:common:ssp_sensors: Fix an error handling path ssp_probe() Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 37/93] iio: accel: bmc150: Fix irq assumption regression Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 38/93] iio: accel: fix ADXL355 startup race condition Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 39/93] iio: adc: ad7280a: fix ad7280_store_balance_timer() Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 40/93] MIPS: mm: Prevent a TLB shutdown on initial uniquification Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 41/93] MIPS: mm: kmalloc tlb_vpn array to avoid stack overflow Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 42/93] ALSA: usb-audio: Add DSD quirk for LEAK Stereo 230 Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 43/93] ARM: dts: nxp: imx6ul: correct SAI3 interrupt line Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 44/93] atm/fore200e: Fix possible data race in fore200e_open() Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 45/93] can: sja1000: fix max irq loop handling Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 46/93] can: sun4i_can: sun4i_can_interrupt(): " Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 47/93] ceph: fix crash in process_v2_sparse_read() for encrypted directories Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 48/93] dm-verity: fix unreliable memory allocation Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 49/93] drivers/usb/dwc3: fix PCI parent check Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 50/93] smb: client: fix memory leak in cifs_construct_tcon() Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 51/93] thunderbolt: Add support for Intel Wildcat Lake Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 52/93] slimbus: ngd: Fix reference count leak in qcom_slim_ngd_notify_slaves Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 53/93] firmware: stratix10-svc: fix bug in saving controller data Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 54/93] mptcp: clear scheduled subflows on retransmit Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 55/93] serial: amba-pl011: prefer dma_mapping_error() over explicit address checking Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 56/93] most: usb: fix double free on late probe failure Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 57/93] usb: cdns3: Fix double resource release in cdns3_pci_probe Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 58/93] usb: gadget: f_eem: Fix memory leak in eem_unwrap Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 59/93] usb: renesas_usbhs: Fix synchronous external abort on unbind Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 60/93] usb: storage: Fix memory leak in USB bulk transport Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 61/93] USB: storage: Remove subclass and protocol overrides from Novatek quirk Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 62/93] usb: storage: sddr55: Reject out-of-bound new_pba Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 63/93] usb: uas: fix urb unmapping issue when the uas device is remove during ongoing data transfer Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 64/93] usb: dwc3: pci: add support for the Intel Nova Lake -S Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 65/93] usb: dwc3: pci: Sort out the Intel device IDs Greg Kroah-Hartman
2025-12-03 15:29 ` [PATCH 6.6 66/93] usb: dwc3: Fix race condition between concurrent dwc3_remove_requests() call paths Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 67/93] xhci: dbgtty: Fix data corruption when transmitting data form DbC to host Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 68/93] xhci: dbgtty: fix device unregister Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 69/93] USB: serial: ftdi_sio: add support for u-blox EVK-M101 Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 70/93] USB: serial: option: add support for Rolling RW101R-GL Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 71/93] drm: sti: fix device leaks at component probe Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 72/93] drm/amd/display: Check NULL before accessing Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 73/93] net: dsa: microchip: common: Fix checks on irq_find_mapping() Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 74/93] net: dsa: microchip: ptp: " Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 75/93] libceph: fix potential use-after-free in have_mon_and_osd_map() Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 76/93] libceph: prevent potential out-of-bounds writes in handle_auth_session_key() Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 77/93] libceph: replace BUG_ON with bounds check for map->max_osd Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 78/93] bonding: return detailed error when loading native XDP fails Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 79/93] bonding: check xdp prog when set bond mode Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 80/93] nfsd: Replace clamp_t in nfsd4_get_drc_mem() Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 81/93] usb: udc: Add trace event for usb_gadget_set_state Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 82/93] usb: gadget: udc: fix use-after-free in usb_gadget_state_work Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 83/93] usb: typec: ucsi: psy: Set max current to zero when disconnected Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 84/93] can: rcar_canfd: Fix CAN-FD mode as default Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 85/93] iio: adc: rtq6056: Correct the sign bit index Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 86/93] net: macb: fix unregister_netdev call order in macb_remove() Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 87/93] staging: rtl8712: Remove driver using deprecated API wext Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 88/93] selftests: mptcp: join: properly kill background tasks Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 89/93] mptcp: fix duplicate reset on fastclose Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 90/93] ksmbd: fix use-after-free in session logoff Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 91/93] net: dsa: microchip: Fix symetry in ksz_ptp_msg_irq_{setup/free}() Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 92/93] net: dsa: microchip: Free previously initialized ports on init failures Greg Kroah-Hartman
2025-12-03 15:30 ` [PATCH 6.6 93/93] HID: core: Harden s32ton() against conversion to 0 bits Greg Kroah-Hartman
2025-12-03 18:29 ` [PATCH 6.6 00/93] 6.6.119-rc1 review Florian Fainelli
2025-12-03 23:12 ` Hardik Garg
2025-12-03 23:49 ` Shuah Khan
2025-12-04 6:47 ` Peter Schneider
2025-12-04 10:00 ` Jon Hunter
2025-12-04 10:39 ` Ron Economos
2025-12-04 11:35 ` Mark Brown
2025-12-04 17:55 ` Naresh Kamboju
2025-12-05 9:09 ` Miguel Ojeda
2025-12-05 11:00 ` Brett A C Sheffield
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251203152337.296222759@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=lorenzo@kernel.org \
--cc=mario.tesi@st.com \
--cc=patches@lists.linux.dev \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).