From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796020222; b=oEdccPQ14km4m2tRDIi/ajKNQIh2yYeu2LtfPU5maKCqGE3Qg6SvxwMZnmZZnT8Xnl9V KaWysXOtMdYjy8Pw8bnDu8c/PBeC8oTR5FYfUq8obHf+y+OOH6mcFB1Riojlfg1gY59yM XHESVm8BptkbSG3DvHBVoQYnpsmPq5IHCauFLI+9zBvALd2uaJu39EPFWnbYSDOvrBT8G 5izl4dRm5LTUpG/dRxP1QhPNl2EZ7MxRGeTwuJ2V0mDMzraQI4tIgnft7rbKxTR8gNVoR x9xWHddpxVj6ZWVj1nL6HMMkG3ZJp41BTv9wxsV9kMALjOsAmrRnlLFjiykb1FtrH4g== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796020222; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=CNybR2Qo5ifyOmMuNFovlgI5Y8l8q5T1/ZFl8l+8lqg=; b=1vjW+cwnoEZY6SsKDq7sDvTjC5N69jxcr6DyIt7ylx0Bxm4ujGXQcEL+VfwJG11bohBs 3fZ4iSfnEA/RB41GAST9luo/jR3HQWwdaL7rGGcGVp61+qmJ7oA5ZqavxQ919ejXlhEqL v1MbS6fcYjqzgL4rwbxm8tPskCeuu4TiOkOmX+C+YVGIhaQ3C0lv9dEAKG8R2f8yCCM4J 26QiJcq4Mt6CrTvvwTF+fpe3Qr4MBomEiQgJbk1kdbVFcIdPuyuILXRHSQAJj7dG8oOtx T3Np0X5nfmkCJ/S35q+NtsRtWAai+psyZp/nYtlnUM7vHOmrt1CcsueNKyAPjnprY3g== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=H+LgnPG9; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4201606A33C for ; Mon, 30 Nov 2026 06:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=H+LgnPG9 Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796020221; b=EUqZeoO2PZvC8HYAzA+iZ9ER1Zmuz/JSBgKp5pT9JwWWVGpCxrypZCJgFAAhP7WSEh3i k7q2e61g1BK2NfeS34gneYMZBnNBo+rn2ZBcM9oCM3x8m8YayKHAwo5IuLixlPKZEK6XP 3plaKQsfRsoFYsFn47zwwW2/OFOf8UzE4VZ/SQ1BLXH90r6PX+0nEgH2D4Cie1K8cFXeZ Lf2W6m6zcIhLTNvmb36w8ii1jXfI6VDJl3h9vjr/eVWnkVeCxnw+n2iO3E/rz8Ecrsqco IhvNqrfSISYuguDOx2eW3316TJiYxrA69+JDEXpbXsopnsk73nn8RbvDeoFou+Q+fuw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796020221; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=CNybR2Qo5ifyOmMuNFovlgI5Y8l8q5T1/ZFl8l+8lqg=; b=hRJfBzGJ9lQkvmtCb1TyuTJ4rh383Wvo7bBz3fGpSRSOOBE63OGFPrt4u6h5XArBReXN 7yFbeQkvXmmz4mkVMfTdDbDTb7LcWiV/MBHQLGq1UW5iCOBFGbXHEdTJ7Y0t5R/NbDVuH b4ymwptOSCkPReW4NT4lZ/C7AE7bv6IhP/X4YmaoRM3fYuG1v6p/paAJlY4BWESGDGrQr LyDLZnCh5ksg7VF/NWM2B5I2y4tTXordABtTpRmygWvHCavbOVxHH2P2A44z9T/4TV70O NbOklqcjf0FUstO5xqODUwBhiSp8g5the2cx7WMKwg/idX7sFI2gbkWxHI76uYRkjZQ== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 7E0FE1F0092C; Mon, 30 Nov 2026 06:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796020221; bh=CNybR2Qo5ifyOmMuNFovlgI5Y8l8q5T1/ZFl8l+8lqg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=H+LgnPG9cgK29UHh6eXbG4mAl7IiwEHZwBQ8wDM7oqmGYYlcSpjPxOEorY8X6hA24 ia/otL/TKLDqpyPR8+39oqQAJeQsPIMHEo/WVqZI5zz6TWGdcQIkj//mNyVLEK8dBm ExcjvRbJ7LWL2eq8sy86p9u65aDgvSAMmcn04Aon97pDxnx+VmcqllKUyqVKyTbDKG hHjvhOkGCtM3Rkm6hdTRS7Axyw5k6dGzzpQiT4miOiz5cd0+xYPOzK0rnr9+P/qQR8 ate+eVu0i1/Gv9LkbDq1xPdwFr97ij/t12pe3lB2aeyfxeKbCeW2AqhUvTtHeUPDLC xVp1eL65JQIKQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id E7E854E722; Mon, 30 Nov 2026 06:29:56 +0000 (UTC) From: He Xin via B4 Relay Date: Mon, 30 Nov 2026 14:29:43 +0800 Subject: [PATCH v2 14/18] iio: accel: mma7455_core: support mount matrix X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261130-work-v2-14-9eccecc71702@hexin.host> References: <20261130-work-v2-0-9eccecc71702@hexin.host> In-Reply-To: <20261130-work-v2-0-9eccecc71702@hexin.host> 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=1796020192; l=1977; i=hexin@hexin.host; s=20261130; h=from:subject:message-id; bh=TshP7M6F+REHaPyywSewF+nUyot5HhnIlTDeoatj7zA=; b=t5gmzSddBi5NuO065AtQ3prK2K4RFZm2T/yYtZMUMJ4tzNw71rnUGplyDe/yBkTFxgeSULlfu xe4fEaQ1kdpDcQIOWwpw9Put1pRGe30/VVIxEIJYYvSIXIMCFYBrYkU 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 X-Original-From: He Xin Reply-To: hexin@hexin.host Content-Transfer-Encoding: 7bit From: He Xin The driver ignores the mount matrix described by the firmware (ACPI _DSD "mount-matrix" or the devicetree property), so the orientation reported to userspace is wrong whenever the sensor is not mounted axis-aligned with the display. Read the mount matrix at probe time and expose it through IIO_MOUNT_MATRIX(), as several other accelerometer drivers already do. Signed-off-by: He Xin --- drivers/iio/accel/mma7455_core.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/iio/accel/mma7455_core.c b/drivers/iio/accel/mma7455_core.c index a2b5bdf14d..0d180a6662 100644 --- a/drivers/iio/accel/mma7455_core.c +++ b/drivers/iio/accel/mma7455_core.c @@ -61,6 +61,7 @@ struct mma7455_data { __le16 channels[3]; aligned_s64 ts; } scan; + struct iio_mount_matrix orientation; }; static int mma7455_drdy(struct mma7455_data *mma7455) @@ -209,8 +210,23 @@ static const struct iio_info mma7455_info = { .write_raw = mma7455_write_raw, }; +static const struct iio_mount_matrix * +mma7455_core_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct mma7455_data *mma7455 = iio_priv(indio_dev); + + return &mma7455->orientation; +} + +static const struct iio_chan_spec_ext_info mma7455_core_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, mma7455_core_get_mount_matrix), + { } +}; + #define MMA7455_CHANNEL(axis, idx) { \ .type = IIO_ACCEL, \ + .ext_info = mma7455_core_ext_info,\ .modified = 1, \ .address = MMA7455_REG_##axis##OUTL,\ .channel2 = IIO_MOD_##axis, \ @@ -267,6 +283,11 @@ int mma7455_core_probe(struct device *dev, struct regmap *regmap, dev_set_drvdata(dev, indio_dev); mma7455 = iio_priv(indio_dev); + + ret = iio_read_mount_matrix(dev, &mma7455->orientation); + if (ret) + return ret; + mma7455->regmap = regmap; indio_dev->info = &mma7455_info; -- 2.53.0