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=1796020216; b=m76/T+ICwIvnCktBa3xF0vuw+q/cYbdE+rg583To6fDkyZsE42NKJosTqyoB94hjPw5I rK9eLGNqQ9ngrCB4lC5Q4NH4I0PDGLY9ih+vQt/2JOCjRHflKh3NCFo/UF3fpAzJZNcV+ j/ZCvdWFddub+3ZPzeTCfU0Ze/y8edf8TmdaD901bl1c0tuetV3q7bY6tkqhQeZC/3l5g PkOmzMkdiiVjVgbzSIehr/bUCETWP6NeCJT7c9+hZ9pbqzGgDigOa0Vgug/gjUexPi2Wp n70C8SmpGEWCUX+X7vD39QzjtkLCbCFGyOOFYDKFVGiILgt7B+apCCMqYOq5Jh9CPXw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796020216; 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=0hzFp2J7rDodHDCEJVNFl08IT4MOmnJOALagGbSPC1Y=; b=cVN5RgErAEHMjkWTgWe9HVqwjq7vo72aDZK5HMMcimKjgYCDlBgy8TIhwqeoxvldBd7T YOq0HWRO7lRdqk/etQSpDhzqlEU8VzaEYV5sA/3NEaL7Z2woItl0zEEIpQdXLHulQ9JdY 31/J9VCMlHviJMTUEZyaH9+j4koDCtGIUAEWuOhvXm5Prcfb5+0UWLh3spNytZFzYcuyU l2R4qvdzojaoXjT7nobyFIUwz9m82wzmQDBspuSt2Nc/w8q4hpXXTOlQvprJTgJZgMxsS Ut2RYkzz2Y7W1sjwDsTZ35W7SIiUoC9ky2HNDeyWNw3zpWoNmOEGy9dOW6jchdz99/A== 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=UuXhSI9F; 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 7261D606A69D for ; Mon, 30 Nov 2026 06:30:16 +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=UuXhSI9F 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=1796020216; b=dLij94RxoiTppblPowDjo8Zhq/kV2Hc1OdYcqBq1+yeTTjVWuQsNX4CtMGZWDb8pN2qH s7uwgoxIgtgydVduGBOCsn/67R9icwBewpV85DR0hBqVR7+HQ+Zt3TZwqaXna2iNEPzxQ GCe3LRT981auTq+6UHP414xCaHxrMFRUnYICrXzBpHRwh2PkrsAMMI4/t9HpvpPSumKnw KmbHAs0NOqA534VNMvfIlPIZdeI/jZtrduVV8iNvMEfabgaNzVVO3at6PaAfAs8DNq+69 izRT520ZkIeYgX+E//O93MaEASNAqVxadSQXLy88SaqOJZLqmFCH1b11UUIwv3tkQqg== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796020216; 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=0hzFp2J7rDodHDCEJVNFl08IT4MOmnJOALagGbSPC1Y=; b=Zsl0cCyjNpFoqKpEhPn3bRFg1lpK+jMK3h25M4WrnnulY50mZCnqvZVe9Y9oHlbujHh2 dHAaG7Hg9TkbJpv6bJgh99YiuRxKqp/IeC1W1dR8I2xdkrrp0zAHrqiFstWiMKIGwafV+ LcFZvAoyVaWLjc6tS/aKSaCtb0uTm784OrXTXxVf++wxn5GMC9O+do07J23ODu+UZGAo0 k1reZTpGnCsDY/D/qpH1/rggHDXwpq0Nr5LEE76yCoGshw1GVVMuOVWxbCFxBVJgWX0yM ubEAAhmvFvMo6vyyt/wP8jjI96zP8Wrte35RIXYKBtfu5JrNo/LOilBHZBXTi5QcvLg== 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 A16421F0092A; Mon, 30 Nov 2026 06:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796020216; bh=0hzFp2J7rDodHDCEJVNFl08IT4MOmnJOALagGbSPC1Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=UuXhSI9FAVmB4jDvXfQ0PUqj4o5LVLG4DR2q45nUEbBwQJoIdk7mK6leQZ6AW4YZp t9TUg9lAQwqHHg9Z9SzsqhpuSeUrEsN8t9mWliV+5VZGs28OV4ai0G5q2cPZ+Za3ZI 1GMVwGswsj+tGU9htAq2aUIzb7nN1xoToWniewrNSRVIOP6h8JsnGFqwpv4zC9dg6L pAtcVan75EkNNxT9oiKrt6WZJemwvmdTpMXuDdmbUNp8Qbcr4LGEpS0AXFCS6xHFil iAGlHiwIf7NwxghVj35zQsRtxojB+JxeGfwUaKFucColjIXUhFUz0xam/Ps3fCQ3Ya QnMyNN+LFCxGg== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 02BBE4E70A; Mon, 30 Nov 2026 06:29:56 +0000 (UTC) From: He Xin via B4 Relay Date: Mon, 30 Nov 2026 14:29:37 +0800 Subject: [PATCH v2 08/18] iio: accel: bmi088-accel-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-8-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=2076; i=hexin@hexin.host; s=20261130; h=from:subject:message-id; bh=kxditqW3lM71nggfQdJzlrVB5Jkhe5wtB5xj0hUvreA=; b=EFp48swp5hZLgBiMrcReAUqw7sSoEPlpTpwzchiTwzlCCZVbMcKQxVA71xOEf70jSDh16ifA+ UjlzGiGdMJ9ADbx1WWVbbG8tLMBntAhYvuAcbbGgxaggBfdRH7YHzJj 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/bmi088-accel-core.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c index c7da90af0d..dea150b33c 100644 --- a/drivers/iio/accel/bmi088-accel-core.c +++ b/drivers/iio/accel/bmi088-accel-core.c @@ -125,6 +125,7 @@ struct bmi088_accel_chip_info { struct bmi088_accel_data { struct regmap *regmap; const struct bmi088_accel_chip_info *chip_info; + struct iio_mount_matrix orientation; u8 buffer[2] __aligned(IIO_DMA_MINALIGN); /* shared DMA safe buffer */ }; @@ -433,8 +434,23 @@ static int bmi088_accel_write_raw(struct iio_dev *indio_dev, } } +static const struct iio_mount_matrix * +bmi088_accel_core_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct bmi088_accel_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + +static const struct iio_chan_spec_ext_info bmi088_accel_core_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, bmi088_accel_core_get_mount_matrix), + { } +}; + #define BMI088_ACCEL_CHANNEL(_axis) { \ .type = IIO_ACCEL, \ + .ext_info = bmi088_accel_core_ext_info,\ .modified = 1, \ .channel2 = IIO_MOD_##_axis, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ @@ -555,6 +571,11 @@ int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap, return -ENOMEM; data = iio_priv(indio_dev); + + ret = iio_read_mount_matrix(dev, &data->orientation); + if (ret) + return ret; + dev_set_drvdata(dev, indio_dev); data->regmap = regmap; -- 2.53.0