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=1796020223; b=qSLro+OLBE8linVnhNr5yodG7LiNEFQkrH3n0gPZLmTfLQp2YhBVyiKaI2UBHramvqMn NTjKDjxcSDJioLCJYIQAoWuiPN/Xs+mfSk/9ue7qzuGJ8BQSPjb8MxYW6UwN9+bBAFh5f dCvCibSx8OyKIotXlQpDphi/YQtcxS136VRBlQ+sBwGmQ+Yc+5XA/FlHEksLFohA115IM Cq/oFU6pNJlJSVTQZMKZI1/6W0ihhYsvfKnliQ22BfJH9HJVG4r4wtZnLCdoI8GVwQhfT Mo5An8ILljJgDd9nroDvaZpEpVeEWH7mRtsMjSfmdxPcyJDevVzT9dHykq7ltvLKP6Q== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796020223; 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=X2IswQsSfllyZnLeQMkjNK3+csqhyXHhydVjZ9nOhIw=; b=RNmWIS9fS7CXIh8dts0JyO9nY0+UqGAwNVfpA27LwWadlWVnAGT2UiIQKllojPl765Vv E709XirAwyD2hn4I2GPCLfWvR/mQvcpgv1G3x1lx7oOcaOg5OkRcjIQc3M4LHJySqguvN yjnipWqmvelCSiM3FFHTIuayjG57V2F8j/eCjy/noQ1wUY++FJ5DkNREpqoyfbBIbqabE DE09x4ZT5cr7RH42IsaT2b+6d+F0Xr5vB1LUP7+gKynWVZmjuiV+2i2lyhDN+sd7+Q20+ iJ366Qs9iR7wppBmZ5A3L1Pj6xCHW7sHXTlp7MyQ9iUBX8n+RsvahSBF03mG4FT3kiQ== 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=jl0FKt2o; 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 AE1E3606A6B0 for ; Mon, 30 Nov 2026 06:30:23 +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=jl0FKt2o 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=1796020223; b=21M9gn46gdCEjweIq95N1eJLPkPntk3WDHqxPHZj74IOWXHQMsFfqztBJwMK6164bdmG nw6XQVlha7meR+sAsiqO7aBhc6iAdOOBFOJ6l+UwlWgfys0jTHUpMRFFaCxnCgV2/qRUL nc85N4NmqzzJcbxyvwPewGaqH19M7UpvHkMSn1R/m1H3984RQG88HhvaRk8t2q+u8a78p lqAXRe+rXwvxsdpcFp9txlFmbmdMFOzBQjAaF89atyOuKL5JG6EvkqVVR/YS9dPtIGMvn 2CMg/CbrS4fEcTuoRf1x8RYOwmWdmzfm5MM9aajzTtaYVA9GIEi/1wBQF7nsImrpkpQ== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796020223; 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=X2IswQsSfllyZnLeQMkjNK3+csqhyXHhydVjZ9nOhIw=; b=M9HdSU3d20c5LMWZRrBzd6rP/krGiddng8rozdp4GCf6/omNmAbVp7cvm4J1jg0FKqf8 MKBopdZndbC/Yzymp3CBGhIee3+j8JkzEI4zVYefcPq+VTMqazL3vDBSa++9yu7Vo/xaJ JmfRgWnP1I7/cJXlmMM1FySQ5NDf2wAGC+3h0+EKpkJPFFMFxUAI7yAuALmjBlZSQEeX3 2AzTiyI66NKq7OjzNWrzO3KskGuLBRp2tTH3C9IksEpHeL2PiSeVOOBDjvK/iWvJzGiJj Rj2LbPYpK85siH3Ef/ho9aQZF5BR26MLOBAgBs+TAIQgx99hQZYnPdbN6qB0EfXfvTQ== 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 7FB021F0089F; Mon, 30 Nov 2026 06:30:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796020223; bh=X2IswQsSfllyZnLeQMkjNK3+csqhyXHhydVjZ9nOhIw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=jl0FKt2oyeFI2pjlvovCoHsQMFO4RBX3X+47fKut2kyU14TVEtAi+Ziz9b2HktptG MqQLnlVNdWsKV5PbXspDpunaZ1ay/DGIcHQ+C2NxEMRTffSNzFCoQGwTkX4Y1utEy8 LAIEDen4GwMmolYhOyz0uKpkAFzpH1uVSwfos1uvEAEHgHJ2Oe9x9gAhozchp/d7go 0y3xg9IxZh306klSCABv6iBGgE3CyfNYggOn74w8ZhmmP8rsex3Ko+LjUBb/A9M8T+ WsvU1xxW/7rlg86QcVY6H9SWR95iaFqK4TcuijtNlhXXT+WGyaaYd8CpiFv5WksWbH hnJLxtgPEJQ7Q== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 3EB994E72A; Mon, 30 Nov 2026 06:29:57 +0000 (UTC) From: He Xin via B4 Relay Date: Mon, 30 Nov 2026 14:29:45 +0800 Subject: [PATCH v2 16/18] iio: accel: mxc6255: 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-16-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=1931; i=hexin@hexin.host; s=20261130; h=from:subject:message-id; bh=F4pdCYwRPfjocr90sJdrb8kATgJffPzUoUibcpyiiwI=; b=OdD4/JhH00wjkIbS6Japta/d3hs6f0veIcviaJroHybYzv0XtROEjtbykpA+hhG4GlNs/lBU9 9x7J2wnWgrPCA6U+bFWgs/rM9Nm8MesP1oZRcqn6aSoOB3mfVZv11Tc 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/mxc6255.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/iio/accel/mxc6255.c b/drivers/iio/accel/mxc6255.c index a9f41cf27a..7a53cdff50 100644 --- a/drivers/iio/accel/mxc6255.c +++ b/drivers/iio/accel/mxc6255.c @@ -42,6 +42,7 @@ enum mxc6255_axis { struct mxc6255_data { struct i2c_client *client; struct regmap *regmap; + struct iio_mount_matrix orientation; }; static int mxc6255_read_raw(struct iio_dev *indio_dev, @@ -76,8 +77,23 @@ static const struct iio_info mxc6255_info = { .read_raw = mxc6255_read_raw, }; +static const struct iio_mount_matrix * +mxc6255_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct mxc6255_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + +static const struct iio_chan_spec_ext_info mxc6255_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, mxc6255_get_mount_matrix), + { } +}; + #define MXC6255_CHANNEL(_axis, reg) { \ .type = IIO_ACCEL, \ + .ext_info = mxc6255_ext_info, \ .modified = 1, \ .channel2 = IIO_MOD_##_axis, \ .address = reg, \ @@ -130,6 +146,11 @@ static int mxc6255_probe(struct i2c_client *client) } data = iio_priv(indio_dev); + + ret = iio_read_mount_matrix(&client->dev, &data->orientation); + if (ret) + return ret; + i2c_set_clientdata(client, indio_dev); data->client = client; data->regmap = regmap; -- 2.53.0