Skip to contentSkip to conversation

arm64: dts: qcom: x1e80100-lenovo-yoga-slim7x: Add lid switch

PATCH Superseded Anthony Ruhier 3 participants 4 messages Dec 18, 2024 – Dec 19, 2024

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: dts: qcom: x1e80100-lenovo-yoga-slim7x: Add lid switch

Add the lid switch for the Lenovo Yoga Slim 7x.

Other x1e80100 laptops use the GPIO pin 92 only, however on the Yoga Slim 7x this pin seems to be bridged with the pin 71. By default, the pin 71 is set as output-high, which blocks any event on pin 92.

This patch sets the pin 71 as output-disable and sets the LID switch on pin 92. This is aligned with how they're configured on Windows:

    GPIO  71 | 0xf147000 | in | func0 | hi | pull up   | 16 mA | 
ctl=0x000001c3 io=0x00000003
    GPIO  92 | 0xf15c000 | in | func0 | lo | no pull   |  2 mA | 

ctl=0x00000000 io=0x00000001

---
 .../dts/qcom/x1e80100-lenovo-yoga-slim7x.dts  | 38 +++++++++++++++++++
 1 file changed, 38 insertions(+)
arch/arm64/boot/dts/qcom/x1e80100-lenovo-yoga-slim7x.dts +38 -0
index ca5a808f2c7d..311202aa9015 100644
@@ -6,6 +6,7 @@
 /dts-v1/;
 
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/gpio-keys.h>
 #include <dt-bindings/regulator/qcom,rpmh-regulator.h>
 
 #include "x1e80100.dtsi"
@@ -19,6 +20,21 @@ aliases {
 		serial0 = &uart21;
 	};
 
+	gpio-keys {
+		compatible = "gpio-keys";
+
+		pinctrl-0 = <&hall_int_n_default>;
+		pinctrl-names = "default";
+
+		switch-lid {
+			gpios = <&tlmm 92 GPIO_ACTIVE_LOW>;
+			linux,input-type = <EV_SW>;
+			linux,code = <SW_LID>;
+			wakeup-source;
+			wakeup-event-action = <EV_ACT_DEASSERTED>;
+		};
+	};
+
 	chosen {
 		stdout-path = "serial0:115200n8";
 	};
@@ -811,6 +827,28 @@ edp_reg_en: edp-reg-en-state {
 		bias-disable;
 	};
 
+	hall_int_n_default: hall-int-n-state {
+		lid-n-pins {
+			pins = "gpio92";
+			function = "gpio";
+			bias-disable;
+		};
+
+		/*
+		 * Pins 71 and 92 seem to be bridged together (pin 71 and 92 show the same
+		 * events). By default, pin 71 is set as output-high, which blocks any
+		 * event on pin 92. Output-disable on pin 71 is necessary to get events on
+		 * pin 92.
+		 * The purpose of pin 71 is not yet known; lid-pull is a supposition.
+		 */
+		lid-pull-n-pins {
+			pins = "gpio71";
+			function = "gpio";
+			bias-pull-up;
+			output-disable;
+		};
+	};
+
 	kybd_default: kybd-default-state {
 		pins = "gpio67";
 		function = "gpio";

--
2.47.1

Tested-by on v1 1/1
#1 lore raw

Nice to see it finally working!

śr., 18 gru 2024 o 20:02 Anthony Ruhier <[email protected]> napisał(a):

Quoted 88 lines

Add the lid switch for the Lenovo Yoga Slim 7x.

Other x1e80100 laptops use the GPIO pin 92 only, however on the Yoga Slim 7x this pin seems to be bridged with the pin 71. By default, the pin 71 is set as output-high, which blocks any event on pin 92.

This patch sets the pin 71 as output-disable and sets the LID switch on pin 92. This is aligned with how they're configured on Windows:

     GPIO  71 | 0xf147000 | in | func0 | hi | pull up   | 16 mA |
ctl=0x000001c3 io=0x00000003
     GPIO  92 | 0xf15c000 | in | func0 | lo | no pull   |  2 mA |

ctl=0x00000000 io=0x00000001

---
  .../dts/qcom/x1e80100-lenovo-yoga-slim7x.dts  | 38 +++++++++++++++++++
  1 file changed, 38 insertions(+)
arch/arm64/boot/dts/qcom/x1e80100-lenovo-yoga-slim7x.dts +25 -0
index ca5a808f2c7d..311202aa9015 100644
@@ -6,6 +6,7 @@
  /dts-v1/;
 
  #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/gpio-keys.h>
  #include <dt-bindings/regulator/qcom,rpmh-regulator.h>
 
  #include "x1e80100.dtsi"
@@ -19,6 +20,21 @@ aliases {
                serial0 = &uart21;
        };
 
+       gpio-keys {
+               compatible = "gpio-keys";
+
+               pinctrl-0 = <&hall_int_n_default>;
+               pinctrl-names = "default";
+
+               switch-lid {
+                       gpios = <&tlmm 92 GPIO_ACTIVE_LOW>;
+                       linux,input-type = <EV_SW>;
+                       linux,code = <SW_LID>;
+                       wakeup-source;
+                       wakeup-event-action = <EV_ACT_DEASSERTED>;
+               };
+       };
+
        chosen {
                stdout-path = "serial0:115200n8";
        };
@@ -811,6 +827,28 @@ edp_reg_en: edp-reg-en-state {
                bias-disable;
        };
 
+       hall_int_n_default: hall-int-n-state {
+               lid-n-pins {
+                       pins = "gpio92";
+                       function = "gpio";
+                       bias-disable;
+               };
+
+               /*
+                * Pins 71 and 92 seem to be bridged together (pin 71 and 92 show the

same

arch/arm64/boot/dts/qcom/x1e80100-lenovo-yoga-slim7x.dts +2 -0
+                * events). By default, pin 71 is set as output-high, which blocks any
+                * event on pin 92. Output-disable on pin 71 is necessary to get

events on

arch/arm64/boot/dts/qcom/x1e80100-lenovo-yoga-slim7x.dts +11 -1
+                * pin 92.
+                * The purpose of pin 71 is not yet known; lid-pull is a supposition.
+                */
+               lid-pull-n-pins {
+                       pins = "gpio71";
+                       function = "gpio";
+                       bias-pull-up;
+                       output-disable;
+               };
+       };
+
        kybd_default: kybd-default-state {
                pins = "gpio67";
                function = "gpio";
--

2.47.1

#2 lore raw

Thank you Maya!
I'm sorry, I realized that the patch format is wrong due to a misconfiguration of my mail client. Tell me if I should send a v2 of this patch fixing it.

Quoted 93 lines · Maya Matuszczyk

Nice to see it finally working!

śr., 18 gru 2024 o 20:02 Anthony Ruhier <[email protected]> napisał(a):

Quoted 88 lines

Add the lid switch for the Lenovo Yoga Slim 7x.

Other x1e80100 laptops use the GPIO pin 92 only, however on the Yoga Slim 7x this pin seems to be bridged with the pin 71. By default, the pin 71 is set as output-high, which blocks any event on pin 92.

This patch sets the pin 71 as output-disable and sets the LID switch on pin 92. This is aligned with how they're configured on Windows:

      GPIO  71 | 0xf147000 | in | func0 | hi | pull up   | 16 mA |
ctl=0x000001c3 io=0x00000003
      GPIO  92 | 0xf15c000 | in | func0 | lo | no pull   |  2 mA |

ctl=0x00000000 io=0x00000001

---
   .../dts/qcom/x1e80100-lenovo-yoga-slim7x.dts  | 38 +++++++++++++++++++
   1 file changed, 38 insertions(+)
arch/arm64/boot/dts/qcom/x1e80100-lenovo-yoga-slim7x.dts +25 -0
index ca5a808f2c7d..311202aa9015 100644
@@ -6,6 +6,7 @@
   /dts-v1/;
 
   #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/gpio-keys.h>
   #include <dt-bindings/regulator/qcom,rpmh-regulator.h>
 
   #include "x1e80100.dtsi"
@@ -19,6 +20,21 @@ aliases {
                 serial0 = &uart21;
         };
 
+       gpio-keys {
+               compatible = "gpio-keys";
+
+               pinctrl-0 = <&hall_int_n_default>;
+               pinctrl-names = "default";
+
+               switch-lid {
+                       gpios = <&tlmm 92 GPIO_ACTIVE_LOW>;
+                       linux,input-type = <EV_SW>;
+                       linux,code = <SW_LID>;
+                       wakeup-source;
+                       wakeup-event-action = <EV_ACT_DEASSERTED>;
+               };
+       };
+
         chosen {
                 stdout-path = "serial0:115200n8";
         };
@@ -811,6 +827,28 @@ edp_reg_en: edp-reg-en-state {
                 bias-disable;
         };
 
+       hall_int_n_default: hall-int-n-state {
+               lid-n-pins {
+                       pins = "gpio92";
+                       function = "gpio";
+                       bias-disable;
+               };
+
+               /*
+                * Pins 71 and 92 seem to be bridged together (pin 71 and 92 show the

same

arch/arm64/boot/dts/qcom/x1e80100-lenovo-yoga-slim7x.dts +2 -0
+                * events). By default, pin 71 is set as output-high, which blocks any
+                * event on pin 92. Output-disable on pin 71 is necessary to get

events on

arch/arm64/boot/dts/qcom/x1e80100-lenovo-yoga-slim7x.dts +11 -1
+                * pin 92.
+                * The purpose of pin 71 is not yet known; lid-pull is a supposition.
+                */
+               lid-pull-n-pins {
+                       pins = "gpio71";
+                       function = "gpio";
+                       bias-pull-up;
+                       output-disable;
+               };
+       };
+
         kybd_default: kybd-default-state {
                 pins = "gpio67";
                 function = "gpio";
--

2.47.1

#3 lore raw
Quoted 2 lines · Anthony Ruhier

Thank you Maya!
I'm sorry, I realized that the patch format is wrong due to a misconfiguration of my mail client. Tell me if I should send a v2 of this patch fixing it.

Git throws an error here when applying, please resend

Konrad