From: He Xin Subject: [PATCH v3 00/18] iio: accel: add mount matrix support to 18 accelerometer drivers Date: Fri, 04 Dec 2026 19:12:51 +0800 Message-Id: <20261204-work-v3-0-c7b74b9bc63f@hexin.host> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/12MQQrCMBBFr1Jm7UiSSkpdeQ/poqajGYREJiVWS u7etEvhb97n8VZIJEwJrs0KQpkTx1ChPTXg/BhehDxVBqOM1bpV+I3yxvGhpt6Ss/pCUNWP0JO XI3MfKntOc5TfUc1mf/8C2aDCnpyr63SnzM3TwuHsY5phKKVslS7PEZkAAAA= X-Change-ID: 20261130-work-ab0d96ec614e To: linux-iio@vger.kernel.org, Michael Hennerich , Puranjay Mohan , Marcelo Schmitt , Antoniu Miclaus , Ramona Gradinariu , Petre Rodan Cc: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , linux@analog.com, He Xin X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796382823; l=5693; i=hexin@hexin.host; s=20261130; h=from:subject:message-id; bh=wH7vVBTE5mc2majr8tudZS/EgV9kSj4BAMUCni4gVxA=; b=AlXi1w2ZwPYlrysDmfljnCXsOLWwxnXqYxPiqyXG96A/2KXdUcd+YxCZ5UBa+M5aK0ReZZ9Uh A9fgWYWy6JDA2dJEYYFZNOSUaR7o54EZyf2rq0KIKJXVipZLT2vpAMZ X-Developer-Key: i=hexin@hexin.host; a=ed25519; pk=XShmjlZrsbSLtSY1GT4Ptl+4KQ/QVjE9VGdvbN87rFk= X-Endpoint-Received: by B4 Relay for hexin@hexin.host/20261130 with auth_id=1691 List-Id: B4 Relay Submissions These drivers ignore the mount matrix described by the firmware, so userspace gets raw sensor axes on any board whose sensor is not mounted axis-aligned with the display. A udev/hwdb override does not cover it either: it keys off the sensor modalias and DMI, which do not tell such boards apart. Each patch follows the pattern of the drivers that already support this: try the ACPI ROTM method first, fall back to the "mount-matrix" property (devicetree, or _DSD on ACPI platforms), and keep the result in the driver's private data so it can be exposed through IIO_MOUNT_MATRIX(). The patches remain independent of each other. The ACPI tables on the platform this was tested on are part of the board firmware rather than a local SSDT overlay, and that firmware provides "mount-matrix" through _DSD today. Adding the ROTM method to it later does not require touching these drivers again. Andy suggested on the mxc6255 patch that the matrix belongs in the IIO core rather than in every driver. I kept the per-driver shape because that is what kxcjk-1013, bmc150-accel, mxc4005, bmi323 and st_lsm6dsx already do; moving parsing and storage into the core, together with those five, is a separate change and I can send it as a follow-up. One behaviour change: a board whose firmware describes the property with the wrong number of entries now fails to probe with -EINVAL instead of being ignored, which is what the drivers that already support the property do. A board that provides neither ROTM nor the property keeps the identity matrix. Not converted here, because the change would not have the same shape: adis16201, adis16209 and sca3000 list their channels as array literals, adxl313_core and fxls8962af-core keep the probe in the bus wrappers, and mma9551/mma9553 differ in both. hid-sensor-accel-3d, ssp_accel_sensor and cros_ec_accel_legacy take the orientation from the HID/SSP/EC side rather than from a firmware property. Changes in v3: - read the matrix through iio_read_acpi_mount_matrix("ROTM") first and fall back to the "mount-matrix" property, as kxcjk-1013, bmc150-accel, mxc4005, bmi323 and st_lsm6dsx already do - drop the Reviewed-by carried in v2: the probe path changed, so the series needs another look Changes in v2: - move stk8ba50 to patch 1 - place the mount matrix before the __aligned(IIO_DMA_MINALIGN) members in adxl345, adxl355, adxl367, adxl380, bma220, bmi088 and sca3300, so the DMA buffers keep their own cacheline - add the missing blank line after the mount matrix read in probe - add the @orientation kernel-doc entry for msa311 and sca3300 - shorten the stk8ba50 test note to the behaviour observed on the device - v1 lost its threading because the sending MTA rewrote Message-IDs while leaving References untouched; v2 is posted as a new series Build tested with allmodconfig: drivers/iio/accel, 71 objects, no warnings; checkpatch.pl is silent in default and in --strict mode. Only stk8ba50 was tested on hardware; the other 17 are compile tested. Link: https://lore.kernel.org/linux-iio/5F08289E852625FC+20261127030810.3150676-1-hexin@hexin.host/ Link: https://lore.kernel.org/r/20261130-work-v2-0-9eccecc71702@hexin.host Signed-off-by: He Xin --- He Xin (18): iio: accel: stk8ba50: support mount matrix iio: accel: adxl345_core: support mount matrix iio: accel: adxl355_core: support mount matrix iio: accel: adxl367: support mount matrix iio: accel: adxl372: support mount matrix iio: accel: adxl380: support mount matrix iio: accel: bma220_core: support mount matrix iio: accel: bmi088-accel-core: support mount matrix iio: accel: da280: support mount matrix iio: accel: da311: support mount matrix iio: accel: dmard06: support mount matrix iio: accel: dmard09: support mount matrix iio: accel: dmard10: support mount matrix iio: accel: mma7455_core: support mount matrix iio: accel: msa311: support mount matrix iio: accel: mxc6255: support mount matrix iio: accel: sca3300: support mount matrix iio: accel: stk8312: support mount matrix drivers/iio/accel/adxl345_core.c | 23 +++++++++++++++++++++++ drivers/iio/accel/adxl355_core.c | 23 +++++++++++++++++++++++ drivers/iio/accel/adxl367.c | 23 +++++++++++++++++++++++ drivers/iio/accel/adxl372.c | 27 +++++++++++++++++++++++++++ drivers/iio/accel/adxl380.c | 22 ++++++++++++++++++++++ drivers/iio/accel/bma220_core.c | 27 +++++++++++++++++++++++++++ drivers/iio/accel/bmi088-accel-core.c | 23 +++++++++++++++++++++++ drivers/iio/accel/da280.c | 27 +++++++++++++++++++++++++++ drivers/iio/accel/da311.c | 27 +++++++++++++++++++++++++++ drivers/iio/accel/dmard06.c | 27 +++++++++++++++++++++++++++ drivers/iio/accel/dmard09.c | 23 +++++++++++++++++++++++ drivers/iio/accel/dmard10.c | 27 +++++++++++++++++++++++++++ drivers/iio/accel/mma7455_core.c | 23 +++++++++++++++++++++++ drivers/iio/accel/msa311.c | 24 ++++++++++++++++++++++++ drivers/iio/accel/mxc6255.c | 23 +++++++++++++++++++++++ drivers/iio/accel/sca3300.c | 28 ++++++++++++++++++++++++++++ drivers/iio/accel/stk8312.c | 27 +++++++++++++++++++++++++++ drivers/iio/accel/stk8ba50.c | 23 +++++++++++++++++++++++ 18 files changed, 447 insertions(+) --- base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 change-id: 20261130-work-ab0d96ec614e Best regards, -- He Xin