[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5b6ijumsm6bgqymsfc25frqzjlpiryq7iupuk2pokcb6d4bz56@yqrz6j3oj5ga>
Date: Sun, 21 Sep 2025 15:10:49 +0200
From: Ondřej Jirman <megi@....cz>
To: guptarud@...il.com
Cc: Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Heiko Stuebner <heiko@...ech.de>, devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/5] arm64: dts: rk3399-pinephone-pro: Add
accelerometer sensor support
Hi,
On Sun, Sep 21, 2025 at 01:04:20AM -0700, Rudraksha Gupta via B4 Relay wrote:
> From: Ondrej Jirman <megi@....cz>
>
> Pinephone Pro uses mpu6500.
>
> Signed-off-by: Ondrej Jirman <megi@....cz>
> Signed-off-by: Rudraksha Gupta <guptarud@...il.com>
> ---
> arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts b/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
> index 65ee0b805034a4357a766d4f1f9efa2d4a843d77..21ff12ac5f6e52041f485c9f2702f5a15ee831f9 100644
> --- a/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
> +++ b/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
> @@ -544,7 +544,13 @@ mpu6500@68 {
> reg = <0x68>;
> interrupt-parent = <&gpio1>;
> interrupts = <RK_PC6 IRQ_TYPE_LEVEL_LOW>;
> + vdd-supply = <&vcc_1v8>;
> vddio-supply = <&vcc_1v8>;
> +
> + mount-matrix =
> + "1", "0", "0",
> + "0", "-1", "0",
> + "0", "0", "1";
I'm not sure where you got this patch, but it's not from me (I know for sure
I never did any mount-matrix testing/DT patches) and should not have my
Signed-of-by.
I have this in my tree https://codeberg.org/megi/linux/commit/d7cd2eab931e32fa94408a96d73b4e6c0616107a
Which is:
Signed-of-by: Leonardo G. Trombetta <lgtrombetta@....com>
And has different values on top of that and much more explanation. :)
mount-matrix =
"0", "1", "0",
"-1", "0", "0",
"0", "0", "1";
So I guess you'd need to provide a bit more information about how you
tested/verified these values, or where you've got them from.
See: https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/iio/mount-matrix.txt#L93
Looking at where the magnetometer is mounted, it's mounted on the bottom side of
the PCB (U29 chip):
https://xff.cz/dl/tmp/a0a36024d1ce9b15.png
https://xff.cz/dl/tmp/8f9dce63f3a7f3f4.png
Which means it would face from the PCB in the direction of the display and up
towards the user who is looking at the display, due to the way PCB is mounted.
>From the datasheet: https://xff.cz/dl/tmp/6b163fbe4335e58e.png the relationship
of the chip orientation to measured XYZ values.
Putting it together https://xff.cz/dl/tmp/a17eec1488ea7705.png
- Z increases downwards away from user looking at the phone display
- Y increases to the left
- X increases to the bottom of the display (towards USB-C connector)
DT bindings state:
- Magnetometers (compasses) have their world frame of reference relative to the
geomagnetic field. The system orientation vis-a-vis the world is defined with
respect to the local earth geomagnetic reference frame where (y) is in the
ground plane and positive towards magnetic North, (x) is in the ground plane,
perpendicular to the North axis and positive towards the East and (z) is
perpendicular to the ground plane and positive upwards.
^^^ North: y > 0
(---------)
! !
! !
! !
! ! >
! ! > North: x > 0
! 1 2 3 ! >
! 4 5 6 !
! 7 8 9 !
! * 0 # !
(---------)
Mount matrix in your patch just flips Y axis and leaves the rest as is, so that
doesn't seem to match what bindings ask for at all.
Just based on the PCB component placement and datasheets we should have:
(small letters = DT bindings, big letters output from magnetometer)
x = -Y
y = -X
z = -Z
So that gives:
mount-matrix =
"0", "-1", "0",
"-1", "0", "0",
"0", "0", "-1";
I did a quick test (rotating the phone on the table with display
facing up):
- Y is highest when right edge of the phone faces north:
in_magn_x_raw: -3074
in_magn_y_raw: -690
in_magn_z_raw: -1622
and lowest when pointing south
in_magn_x_raw: -3569
in_magn_y_raw: -2052
in_magn_z_raw: -1824
(X is roughly the same)
so that matches x = Y
- X is highest when top edge of the phone faces north:
in_magn_x_raw: -3990
in_magn_y_raw: -1287
in_magn_z_raw: -1677
and lowest when facing south
in_magn_x_raw: -2553
in_magn_y_raw: -1314
in_magn_z_raw: -1624
(Y is roughly the same)
y = X
- Z is lower when display faces up
in_magn_x_raw: -4083
in_magn_y_raw: -1179
in_magn_z_raw: -2436
and higher with display facing down
in_magn_x_raw: -3999
in_magn_y_raw: -1584
in_magn_z_raw: 393
z = -Z
So based on that mount-matrix should be:
mount-matrix =
"0", "1", "0",
"1", "0", "0",
"0", "0", "-1";
Go figure. :-D
Best regards,
o.
> };
> };
>
>
> --
> 2.51.0
>
>
Powered by blists - more mailing lists