* [PATCH] arm64: dts: qcom: msm8916-samsung-serranove: Add magnetometer
[not found] <20220904214935.31032-1-jahau.ref@rocketmail.com>
@ 2022-09-04 21:49 ` Jakob Hauser
2022-09-05 10:25 ` Linus Walleij
2022-09-06 16:38 ` Bjorn Andersson
0 siblings, 2 replies; 3+ messages in thread
From: Jakob Hauser @ 2022-09-04 21:49 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson
Cc: Stephan Gerhold, Linus Walleij, linux-arm-msm, devicetree,
phone-devel, ~postmarketos/upstreaming, Jakob Hauser
Add magnetometer Yamaha YAS537 to the DeviceTree of samsung-serranove.
The YAS537 variant was recently added to the Yamaha YAS magnetometers
driver [1].
In the DeviceTree of samsung-serranove for the Android kernel, there is
unfortunately no information on interrupts or pinctrl [2].
In the Android kernel driver for magnetometer Yamaha YAS537, there is a
device-specific matrix to correct an ellipsoid shape of the measure values
into a sphere shape [3]. This could be converted and applied to a mount-matrix.
However, the current state of the mainline Yamaha YAS537 driver needs
post-process calibration in userspace anyway, as it lacks a formula to center
the measure values around zero. The correction of the ellipsoid into a sphere
can be done in the post-process calibration as well.
A mount-matrix is needed nonetheless. When putting samsung-serranove flat on
a table in portrait orientation heading north, the Yamaha YAS537 magnetometer
axes natively point X+ to north, Y+ to east and Z+ into the ground, which
corresponds to a common way to define the Earth's magnetic field coordinate
system [4]. According to the IIO definition, it should be Y+ to north, X+ to
east and Z+ upwards [5], which corresponds to a common device coordinate system
and eases sensor fusing.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/iio/magnetometer/yamaha-yas530.c?id=65f79b501030678393eae0ae03d60a8151fbef55
[2] https://github.com/msm8916-mainline/android_kernel_qcom_msm8916/blob/GT-I9195I/arch/arm/boot/dts/samsung/msm8916/msm8916-sec-serranovelte-eur-r03.dtsi#L318-L321
[3] https://github.com/msm8916-mainline/android_kernel_qcom_msm8916/blob/GT-I9195I/drivers/iio/magnetometer/yas_mag_drv-yas537.c#L105-L106
[4] https://en.wikipedia.org/wiki/Earth%27s_magnetic_field#Characteristics
[5] https://github.com/torvalds/linux/blob/v5.19/Documentation/devicetree/bindings/iio/mount-matrix.txt#L93-L126
Cc: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
---
arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts b/arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts
index 439e89cf7878..bbd6bb3f4fd7 100644
--- a/arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts
+++ b/arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts
@@ -210,6 +210,15 @@ imu@6b {
pinctrl-names = "default";
pinctrl-0 = <&imu_irq_default>;
};
+
+ magnetometer@2e {
+ compatible = "yamaha,yas537";
+ reg = <0x2e>;
+
+ mount-matrix = "0", "1", "0",
+ "1", "0", "0",
+ "0", "0", "-1";
+ };
};
&blsp_i2c4 {
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] arm64: dts: qcom: msm8916-samsung-serranove: Add magnetometer
2022-09-04 21:49 ` [PATCH] arm64: dts: qcom: msm8916-samsung-serranove: Add magnetometer Jakob Hauser
@ 2022-09-05 10:25 ` Linus Walleij
2022-09-06 16:38 ` Bjorn Andersson
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2022-09-05 10:25 UTC (permalink / raw)
To: Jakob Hauser
Cc: Andy Gross, Bjorn Andersson, Stephan Gerhold, linux-arm-msm,
devicetree, phone-devel, ~postmarketos/upstreaming
On Sun, Sep 4, 2022 at 11:51 PM Jakob Hauser <jahau@rocketmail.com> wrote:
> Add magnetometer Yamaha YAS537 to the DeviceTree of samsung-serranove.
>
> The YAS537 variant was recently added to the Yamaha YAS magnetometers
> driver [1].
>
> In the DeviceTree of samsung-serranove for the Android kernel, there is
> unfortunately no information on interrupts or pinctrl [2].
>
> In the Android kernel driver for magnetometer Yamaha YAS537, there is a
> device-specific matrix to correct an ellipsoid shape of the measure values
> into a sphere shape [3]. This could be converted and applied to a mount-matrix.
> However, the current state of the mainline Yamaha YAS537 driver needs
> post-process calibration in userspace anyway, as it lacks a formula to center
> the measure values around zero. The correction of the ellipsoid into a sphere
> can be done in the post-process calibration as well.
>
> A mount-matrix is needed nonetheless. When putting samsung-serranove flat on
> a table in portrait orientation heading north, the Yamaha YAS537 magnetometer
> axes natively point X+ to north, Y+ to east and Z+ into the ground, which
> corresponds to a common way to define the Earth's magnetic field coordinate
> system [4]. According to the IIO definition, it should be Y+ to north, X+ to
> east and Z+ upwards [5], which corresponds to a common device coordinate system
> and eases sensor fusing.
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/iio/magnetometer/yamaha-yas530.c?id=65f79b501030678393eae0ae03d60a8151fbef55
> [2] https://github.com/msm8916-mainline/android_kernel_qcom_msm8916/blob/GT-I9195I/arch/arm/boot/dts/samsung/msm8916/msm8916-sec-serranovelte-eur-r03.dtsi#L318-L321
> [3] https://github.com/msm8916-mainline/android_kernel_qcom_msm8916/blob/GT-I9195I/drivers/iio/magnetometer/yas_mag_drv-yas537.c#L105-L106
> [4] https://en.wikipedia.org/wiki/Earth%27s_magnetic_field#Characteristics
> [5] https://github.com/torvalds/linux/blob/v5.19/Documentation/devicetree/bindings/iio/mount-matrix.txt#L93-L126
>
> Cc: Stephan Gerhold <stephan@gerhold.net>
> Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] arm64: dts: qcom: msm8916-samsung-serranove: Add magnetometer
2022-09-04 21:49 ` [PATCH] arm64: dts: qcom: msm8916-samsung-serranove: Add magnetometer Jakob Hauser
2022-09-05 10:25 ` Linus Walleij
@ 2022-09-06 16:38 ` Bjorn Andersson
1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2022-09-06 16:38 UTC (permalink / raw)
To: Andy Gross, jahau, Bjorn Andersson
Cc: devicetree, stephan, ~postmarketos/upstreaming, phone-devel,
linux-arm-msm, linus.walleij
On Sun, 4 Sep 2022 23:49:35 +0200, Jakob Hauser wrote:
> Add magnetometer Yamaha YAS537 to the DeviceTree of samsung-serranove.
>
> The YAS537 variant was recently added to the Yamaha YAS magnetometers
> driver [1].
>
> In the DeviceTree of samsung-serranove for the Android kernel, there is
> unfortunately no information on interrupts or pinctrl [2].
>
> [...]
Applied, thanks!
[1/1] arm64: dts: qcom: msm8916-samsung-serranove: Add magnetometer
commit: 3ae82f22ed7a746a8a9e89ea840401c46deddbb3
Best regards,
--
Bjorn Andersson <andersson@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-06 16:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20220904214935.31032-1-jahau.ref@rocketmail.com>
2022-09-04 21:49 ` [PATCH] arm64: dts: qcom: msm8916-samsung-serranove: Add magnetometer Jakob Hauser
2022-09-05 10:25 ` Linus Walleij
2022-09-06 16:38 ` Bjorn Andersson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).