Skip to contentSkip to conversation

arm64: dts: qcom: sdm845-oneplus-common: add Hall sensor

PATCH Applied Gergo Koteles 4 participants 4 messages Mar 6, 2023 – Mar 22, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: dts: qcom: sdm845-oneplus-common: add Hall sensor

Enable the Hall effect sensor (flip cover) for OnePlus 6/6T. The GPIO is mapped to SW_LID events as in msm8916, msm8994, msm8998 devices.

---
 .../boot/dts/qcom/sdm845-oneplus-common.dtsi  | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi +25 -0
index 64638ea94db7..b01542d79ae2 100644
@@ -29,6 +29,23 @@ chosen {
 		stdout-path = "serial0:115200n8";
 	};
 
+	gpio-hall-sensor {
+		compatible = "gpio-keys";
+		label = "Hall effect sensor";
+
+		pinctrl-0 = <&hall_sensor_default>;
+		pinctrl-names = "default";
+
+		event-hall-sensor {
+			gpios = <&tlmm 124 GPIO_ACTIVE_LOW>;
+			label = "Hall Effect Sensor";
+			linux,input-type = <EV_SW>;
+			linux,code = <SW_LID>;
+			linux,can-disable;
+			wakeup-source;
+		};
+	};
+
 	gpio-keys {
 		compatible = "gpio-keys";
 		label = "Volume keys";
@@ -753,6 +770,14 @@ &usb_1_hsphy {
 &tlmm {
 	gpio-reserved-ranges = <0 4>, <81 4>;
 
+	hall_sensor_default: hall-sensor-default-state {
+		pins = "gpio124";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-disable;
+		input-enable;
+	};
+
 	tri_state_key_default: tri-state-key-default-state {
 		pins = "gpio40", "gpio42", "gpio26";
 		function = "gpio";
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Gergo Koteles

Enable the Hall effect sensor (flip cover) for OnePlus 6/6T. The GPIO is mapped to SW_LID events as in msm8916, msm8994, msm8998 devices.

---

One fun thing I discovered is that if suspend is broken for whatever reason and you get a magnet close to a device with it mapped to SW_LID, you'll essentially get a hang or a reboot lol

Konrad

Quoted 46 lines
 .../boot/dts/qcom/sdm845-oneplus-common.dtsi  | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi +25 -0
index 64638ea94db7..b01542d79ae2 100644
@@ -29,6 +29,23 @@ chosen {
 		stdout-path = "serial0:115200n8";
 	};
 
+	gpio-hall-sensor {
+		compatible = "gpio-keys";
+		label = "Hall effect sensor";
+
+		pinctrl-0 = <&hall_sensor_default>;
+		pinctrl-names = "default";
+
+		event-hall-sensor {
+			gpios = <&tlmm 124 GPIO_ACTIVE_LOW>;
+			label = "Hall Effect Sensor";
+			linux,input-type = <EV_SW>;
+			linux,code = <SW_LID>;
+			linux,can-disable;
+			wakeup-source;
+		};
+	};
+
 	gpio-keys {
 		compatible = "gpio-keys";
 		label = "Volume keys";
@@ -753,6 +770,14 @@ &usb_1_hsphy {
 &tlmm {
 	gpio-reserved-ranges = <0 4>, <81 4>;
 
+	hall_sensor_default: hall-sensor-default-state {
+		pins = "gpio124";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-disable;
+		input-enable;
+	};
+
 	tri_state_key_default: tri-state-key-default-state {
 		pins = "gpio40", "gpio42", "gpio26";
 		function = "gpio";
Reviewed-by on v1 1/1
#2 lore raw
In reply to Gergo Koteles
Quoted 5 lines · Gergo Koteles

Enable the Hall effect sensor (flip cover) for OnePlus 6/6T. The GPIO is mapped to SW_LID events as in msm8916, msm8994, msm8998 devices.

Quoted 48 lines
---
 .../boot/dts/qcom/sdm845-oneplus-common.dtsi  | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi +25 -1
index 64638ea94db7..b01542d79ae2 100644
@@ -29,6 +29,23 @@ chosen {
 		stdout-path = "serial0:115200n8";
 	};
 
+	gpio-hall-sensor {
+		compatible = "gpio-keys";
+		label = "Hall effect sensor";
+
+		pinctrl-0 = <&hall_sensor_default>;
+		pinctrl-names = "default";
+
+		event-hall-sensor {
+			gpios = <&tlmm 124 GPIO_ACTIVE_LOW>;
+			label = "Hall Effect Sensor";
+			linux,input-type = <EV_SW>;
+			linux,code = <SW_LID>;
+			linux,can-disable;
+			wakeup-source;
+		};
+	};
+
 	gpio-keys {
 		compatible = "gpio-keys";
 		label = "Volume keys";
@@ -753,6 +770,14 @@ &usb_1_hsphy {
 &tlmm {
 	gpio-reserved-ranges = <0 4>, <81 4>;
 
+	hall_sensor_default: hall-sensor-default-state {
+		pins = "gpio124";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-disable;
+		input-enable;
+	};
+
 	tri_state_key_default: tri-state-key-default-state {
 		pins = "gpio40", "gpio42", "gpio26";
 		function = "gpio";
--
Quoted 2 lines

2.39.2

--
Kind Regards,
Caleb

maintainer Applied
#3 lore raw
In reply to Gergo Koteles
Quoted 5 lines · Gergo Koteles

Enable the Hall effect sensor (flip cover) for OnePlus 6/6T. The GPIO is mapped to SW_LID events as in msm8916, msm8994, msm8998 devices.

Applied, thanks!

[1/1] arm64: dts: qcom: sdm845-oneplus-common: add Hall sensor

      commit: 80dc42d9facc9232072855340c2285682c0c3b19

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>