linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: dts: qcom: msm8960: expressatt: Add coreriver,tc360-touchkey
@ 2025-12-05 10:16 Rudraksha Gupta via B4 Relay
  2025-12-06  2:18 ` Dmitry Baryshkov
  2025-12-08 16:35 ` Konrad Dybcio
  0 siblings, 2 replies; 7+ messages in thread
From: Rudraksha Gupta via B4 Relay @ 2025-12-05 10:16 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: linux-arm-msm, devicetree, linux-kernel, Rudraksha Gupta

From: Rudraksha Gupta <guptarud@gmail.com>

Add the tc360 touchkey. It's unknown if this is the actual model of the
touchkey, as downstream doesn't mention a variant, but this works.

Link:
https://github.com/LineageOS/android_kernel_samsung_d2/blob/stable/cm-12.0-YNG4N/drivers/input/keyboard/cypress_touchkey_236/Makefile#L5

Signed-off-by: Rudraksha Gupta <guptarud@gmail.com>
---
Add the tc360 touchkey. It's unknown if this is the actual model of the
touchkey, as downstream doesn't mention a variant, but this works.

Link:
https://github.com/LineageOS/android_kernel_samsung_d2/blob/stable/cm-12.0-YNG4N/drivers/input/keyboard/cypress_touchkey_236/Makefile#L5

Test:
=============
- LEDs:
samsung-expressatt:/sys/class/leds/tm2-touchkey$ echo heartbeat > trigger
// Flashes LEDs :)

- Touching buttons:
samsung-expressatt:/sys/class/leds/tm2-touchkey$ evtest
No device specified, trying to scan all of /dev/input/event*
Not running as root, no devices may be available.
Available devices:
/dev/input/event0:      pmic8xxx_pwrkey
/dev/input/event1:      gpio-keys
/dev/input/event2:      tm2-touchkey
/dev/input/event3:      Atmel maXTouch Touchscreen
Select the device event number [0-3]: 2
Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "tm2-touchkey"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 139 (KEY_MENU)
    Event code 158 (KEY_BACK)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 1761059686.899755, type 4 (EV_MSC), code 4 (MSC_SCAN), value 00
Event: time 1761059686.899755, type 1 (EV_KEY), code 139 (KEY_MENU), value 1
Event: time 1761059686.899755, -------------- SYN_REPORT ------------
Event: time 1761059687.113489, type 4 (EV_MSC), code 4 (MSC_SCAN), value 00
Event: time 1761059687.113489, type 1 (EV_KEY), code 139 (KEY_MENU), value 0
Event: time 1761059687.113489, -------------- SYN_REPORT ------------
Event: time 1761059688.764757, type 4 (EV_MSC), code 4 (MSC_SCAN), value 01
Event: time 1761059688.764757, type 1 (EV_KEY), code 158 (KEY_BACK), value 1
Event: time 1761059688.764757, -------------- SYN_REPORT ------------
Event: time 1761059688.817516, type 4 (EV_MSC), code 4 (MSC_SCAN), value 01
Event: time 1761059688.817516, type 1 (EV_KEY), code 158 (KEY_BACK), value 0
Event: time 1761059688.817516, -------------- SYN_REPORT ------------
---
 .../dts/qcom/qcom-msm8960-samsung-expressatt.dts   | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/arch/arm/boot/dts/qcom/qcom-msm8960-samsung-expressatt.dts b/arch/arm/boot/dts/qcom/qcom-msm8960-samsung-expressatt.dts
index 5a39abd6f3ce..c4b98af6955d 100644
--- a/arch/arm/boot/dts/qcom/qcom-msm8960-samsung-expressatt.dts
+++ b/arch/arm/boot/dts/qcom/qcom-msm8960-samsung-expressatt.dts
@@ -52,6 +52,41 @@ key-volume-down {
 			linux,code = <KEY_VOLUMEDOWN>;
 		};
 	};
+
+	touchkey_enable: touchkey-enable {
+		compatible = "regulator-fixed";
+		regulator-name = "touchkey_enable";
+		gpio = <&tlmm 51 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+		regulator-boot-on;
+	};
+
+	i2c-gpio-touchkey {
+		compatible = "i2c-gpio";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		sda-gpios = <&tlmm 71 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
+		scl-gpios = <&tlmm 72 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&touchkey_i2c_pins>;
+		status = "okay";
+		i2c-gpio,delay-us = <2>;
+
+		touchkey@20 {
+			compatible = "coreriver,tc360-touchkey";
+			reg = <0x20>;
+
+			interrupts-extended = <&tlmm 52 IRQ_TYPE_EDGE_FALLING>;
+			pinctrl-names = "default";
+			pinctrl-0 = <&touchkey_irq_pin>;
+
+			vddio-supply = <&touchkey_enable>;
+			vdd-supply = <&pm8921_l29>;
+			vcc-supply = <&pm8921_l29>;
+
+			linux,keycodes = <KEY_MENU KEY_BACK>;
+		};
+	};
 };
 
 &gsbi2 {
@@ -198,6 +233,20 @@ firmware-pins {
 			bias-disable;
 		};
 	};
+
+	touchkey_i2c_pins: touchkey-i2c-state {
+		pins = "gpio71", "gpio72";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-disable;
+	};
+
+	touchkey_irq_pin: touchkey-irq-state {
+		pins = "gpio52";
+		function = "gpio";
+		drive-strength = <2>;
+		bias-disable;
+	};
 };
 
 &pm8921 {
@@ -420,6 +469,12 @@ pm8921_l25: l25 {
 			bias-pull-down;
 		};
 
+		pm8921_l29: l29 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <3300000>;
+			bias-pull-down;
+		};
+
 		/* Low Voltage Switch */
 		pm8921_lvs1: lvs1 {
 			bias-pull-down;

---
base-commit: 0ccd3ddf45c93ab06c9b1a9d266dcab1e52bf3d2
change-id: 20251205-expressatt-touchkey-1747c503a2f3
prerequisite-change-id: 20251119-expressatt_nfc_accel_magn_light-f78e02897186:v4
prerequisite-patch-id: 6fdd0efa5eda512b442b885df80774d1a7037df7
prerequisite-patch-id: 12d296f83ccb1bdfb8d06a72e476bf51ae5f4e6c
prerequisite-patch-id: a970acf2080143f41ae0935dd2c57bb71f5bf338
prerequisite-patch-id: fd25fef58503c5e5cf742e79b124948c7f6b98d9
prerequisite-patch-id: 966ae746687ebf8eb29c6185a8909b047e70dbb1
prerequisite-patch-id: 68603a680b24921759425fc289e61fc4435e5ccd

Best regards,
-- 
Rudraksha Gupta <guptarud@gmail.com>



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] ARM: dts: qcom: msm8960: expressatt: Add coreriver,tc360-touchkey
  2025-12-05 10:16 [PATCH] ARM: dts: qcom: msm8960: expressatt: Add coreriver,tc360-touchkey Rudraksha Gupta via B4 Relay
@ 2025-12-06  2:18 ` Dmitry Baryshkov
  2025-12-06  3:54   ` Rudraksha Gupta
  2025-12-08 16:35 ` Konrad Dybcio
  1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Baryshkov @ 2025-12-06  2:18 UTC (permalink / raw)
  To: guptarud
  Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-arm-msm, devicetree, linux-kernel

On Fri, Dec 05, 2025 at 02:16:45AM -0800, Rudraksha Gupta via B4 Relay wrote:
> From: Rudraksha Gupta <guptarud@gmail.com>
> 
> Add the tc360 touchkey. It's unknown if this is the actual model of the
> touchkey, as downstream doesn't mention a variant, but this works.
> 
> Link:
> https://github.com/LineageOS/android_kernel_samsung_d2/blob/stable/cm-12.0-YNG4N/drivers/input/keyboard/cypress_touchkey_236/Makefile#L5
> 
> Signed-off-by: Rudraksha Gupta <guptarud@gmail.com>
> ---
> Add the tc360 touchkey. It's unknown if this is the actual model of the
> touchkey, as downstream doesn't mention a variant, but this works.
> 
> Link:
> https://github.com/LineageOS/android_kernel_samsung_d2/blob/stable/cm-12.0-YNG4N/drivers/input/keyboard/cypress_touchkey_236/Makefile#L5
> 
> Test:
> =============
> - LEDs:
> samsung-expressatt:/sys/class/leds/tm2-touchkey$ echo heartbeat > trigger
> // Flashes LEDs :)
> 
> - Touching buttons:
> samsung-expressatt:/sys/class/leds/tm2-touchkey$ evtest
> No device specified, trying to scan all of /dev/input/event*
> Not running as root, no devices may be available.
> Available devices:
> /dev/input/event0:      pmic8xxx_pwrkey
> /dev/input/event1:      gpio-keys
> /dev/input/event2:      tm2-touchkey
> /dev/input/event3:      Atmel maXTouch Touchscreen
> Select the device event number [0-3]: 2
> Input driver version is 1.0.1
> Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
> Input device name: "tm2-touchkey"
> Supported events:
>   Event type 0 (EV_SYN)
>   Event type 1 (EV_KEY)
>     Event code 139 (KEY_MENU)
>     Event code 158 (KEY_BACK)
>   Event type 4 (EV_MSC)
>     Event code 4 (MSC_SCAN)
> Properties:
> Testing ... (interrupt to exit)
> Event: time 1761059686.899755, type 4 (EV_MSC), code 4 (MSC_SCAN), value 00
> Event: time 1761059686.899755, type 1 (EV_KEY), code 139 (KEY_MENU), value 1
> Event: time 1761059686.899755, -------------- SYN_REPORT ------------
> Event: time 1761059687.113489, type 4 (EV_MSC), code 4 (MSC_SCAN), value 00
> Event: time 1761059687.113489, type 1 (EV_KEY), code 139 (KEY_MENU), value 0
> Event: time 1761059687.113489, -------------- SYN_REPORT ------------
> Event: time 1761059688.764757, type 4 (EV_MSC), code 4 (MSC_SCAN), value 01
> Event: time 1761059688.764757, type 1 (EV_KEY), code 158 (KEY_BACK), value 1
> Event: time 1761059688.764757, -------------- SYN_REPORT ------------
> Event: time 1761059688.817516, type 4 (EV_MSC), code 4 (MSC_SCAN), value 01
> Event: time 1761059688.817516, type 1 (EV_KEY), code 158 (KEY_BACK), value 0
> Event: time 1761059688.817516, -------------- SYN_REPORT ------------
> ---
>  .../dts/qcom/qcom-msm8960-samsung-expressatt.dts   | 55 ++++++++++++++++++++++
>  1 file changed, 55 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/qcom/qcom-msm8960-samsung-expressatt.dts b/arch/arm/boot/dts/qcom/qcom-msm8960-samsung-expressatt.dts
> index 5a39abd6f3ce..c4b98af6955d 100644
> --- a/arch/arm/boot/dts/qcom/qcom-msm8960-samsung-expressatt.dts
> +++ b/arch/arm/boot/dts/qcom/qcom-msm8960-samsung-expressatt.dts
> @@ -52,6 +52,41 @@ key-volume-down {
>  			linux,code = <KEY_VOLUMEDOWN>;
>  		};
>  	};
> +
> +	touchkey_enable: touchkey-enable {
> +		compatible = "regulator-fixed";
> +		regulator-name = "touchkey_enable";
> +		gpio = <&tlmm 51 GPIO_ACTIVE_HIGH>;
> +		enable-active-high;
> +		regulator-boot-on;
> +	};
> +
> +	i2c-gpio-touchkey {
> +		compatible = "i2c-gpio";
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +		sda-gpios = <&tlmm 71 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
> +		scl-gpios = <&tlmm 72 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;

I don't have docs at hand, but it looks like these pins belong to
GSBI10. Have you tried using it directly?

> +		pinctrl-names = "default";
> +		pinctrl-0 = <&touchkey_i2c_pins>;
> +		status = "okay";
> +		i2c-gpio,delay-us = <2>;
> +
> +		touchkey@20 {
> +			compatible = "coreriver,tc360-touchkey";
> +			reg = <0x20>;
> +
> +			interrupts-extended = <&tlmm 52 IRQ_TYPE_EDGE_FALLING>;
> +			pinctrl-names = "default";
> +			pinctrl-0 = <&touchkey_irq_pin>;
> +
> +			vddio-supply = <&touchkey_enable>;
> +			vdd-supply = <&pm8921_l29>;
> +			vcc-supply = <&pm8921_l29>;
> +
> +			linux,keycodes = <KEY_MENU KEY_BACK>;
> +		};
> +	};
>  };
>  
>  &gsbi2 {
> @@ -198,6 +233,20 @@ firmware-pins {
>  			bias-disable;
>  		};
>  	};
> +
> +	touchkey_i2c_pins: touchkey-i2c-state {
> +		pins = "gpio71", "gpio72";
> +		function = "gpio";
> +		drive-strength = <2>;
> +		bias-disable;
> +	};
> +
> +	touchkey_irq_pin: touchkey-irq-state {
> +		pins = "gpio52";
> +		function = "gpio";
> +		drive-strength = <2>;
> +		bias-disable;
> +	};
>  };
>  
>  &pm8921 {
> @@ -420,6 +469,12 @@ pm8921_l25: l25 {
>  			bias-pull-down;
>  		};
>  
> +		pm8921_l29: l29 {
> +			regulator-min-microvolt = <1800000>;
> +			regulator-max-microvolt = <3300000>;
> +			bias-pull-down;
> +		};
> +
>  		/* Low Voltage Switch */
>  		pm8921_lvs1: lvs1 {
>  			bias-pull-down;
> 
> ---
> base-commit: 0ccd3ddf45c93ab06c9b1a9d266dcab1e52bf3d2
> change-id: 20251205-expressatt-touchkey-1747c503a2f3
> prerequisite-change-id: 20251119-expressatt_nfc_accel_magn_light-f78e02897186:v4
> prerequisite-patch-id: 6fdd0efa5eda512b442b885df80774d1a7037df7
> prerequisite-patch-id: 12d296f83ccb1bdfb8d06a72e476bf51ae5f4e6c
> prerequisite-patch-id: a970acf2080143f41ae0935dd2c57bb71f5bf338
> prerequisite-patch-id: fd25fef58503c5e5cf742e79b124948c7f6b98d9
> prerequisite-patch-id: 966ae746687ebf8eb29c6185a8909b047e70dbb1
> prerequisite-patch-id: 68603a680b24921759425fc289e61fc4435e5ccd
> 
> Best regards,
> -- 
> Rudraksha Gupta <guptarud@gmail.com>
> 
> 

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ARM: dts: qcom: msm8960: expressatt: Add coreriver,tc360-touchkey
  2025-12-06  2:18 ` Dmitry Baryshkov
@ 2025-12-06  3:54   ` Rudraksha Gupta
  2025-12-06  4:01     ` Dmitry Baryshkov
  0 siblings, 1 reply; 7+ messages in thread
From: Rudraksha Gupta @ 2025-12-06  3:54 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-arm-msm, devicetree, linux-kernel

>> +		sda-gpios = <&tlmm 71 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
>> +		scl-gpios = <&tlmm 72 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
> I don't have docs at hand, but it looks like these pins belong to
> GSBI10. Have you tried using it directly?

This is the log when I use GSBI10:

samsung-expressatt:~$ dmesg | grep tm2
[   79.555802] input: tm2-touchkey as 
/devices/platform/soc/1a200000.gsbi/1a280000.i2c/i2c-4/4-0020/input/input3
[  110.242881] leds tm2-touchkey: Setting an LED's brightness failed (-110)
[  167.074920] tm2-touchkey 4-0020: failed to read i2c data: -110
[  182.435009] tm2-touchkey 4-0020: failed to read i2c data: -110

I could be doing something wrong, so here are the changes I made on top 
of this diff

diff --git a/arch/arm/boot/dts/qcom/qcom-msm8960-samsung-expressatt.dts 
b/arch/arm/boot/dts/qcom/qcom-msm8960-samsung-expressatt.dts
index c4b98af6955d..fde5f739a314 100644
--- a/arch/arm/boot/dts/qcom/qcom-msm8960-samsung-expressatt.dts
+++ b/arch/arm/boot/dts/qcom/qcom-msm8960-samsung-expressatt.dts
@@ -60,33 +60,6 @@ touchkey_enable: touchkey-enable {
          enable-active-high;
          regulator-boot-on;
      };
-
-    i2c-gpio-touchkey {
-        compatible = "i2c-gpio";
-        #address-cells = <1>;
-        #size-cells = <0>;
-        sda-gpios = <&tlmm 71 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
-        scl-gpios = <&tlmm 72 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
-        pinctrl-names = "default";
-        pinctrl-0 = <&touchkey_i2c_pins>;
-        status = "okay";
-        i2c-gpio,delay-us = <2>;
-
-        touchkey@20 {
-            compatible = "coreriver,tc360-touchkey";
-            reg = <0x20>;
-
-            interrupts-extended = <&tlmm 52 IRQ_TYPE_EDGE_FALLING>;
-            pinctrl-names = "default";
-            pinctrl-0 = <&touchkey_irq_pin>;
-
-            vddio-supply = <&touchkey_enable>;
-            vdd-supply = <&pm8921_l29>;
-            vcc-supply = <&pm8921_l29>;
-
-            linux,keycodes = <KEY_MENU KEY_BACK>;
-        };
-    };
  };

  &gsbi2 {
@@ -572,3 +545,28 @@ magnetometer@2e {
          /* TODO: Figure out Mount Matrix */
      };
  };
+
+&gsbi10 {
+    qcom,mode = <GSBI_PROT_I2C>;
+
+    status = "okay";
+};
+
+&gsbi10_i2c {
+    status = "okay";
+
+    touchkey@20 {
+        compatible = "coreriver,tc360-touchkey";
+        reg = <0x20>;
+
+        interrupts-extended = <&tlmm 52 IRQ_TYPE_EDGE_FALLING>;
+        pinctrl-names = "default";
+        pinctrl-0 = <&touchkey_irq_pin>;
+
+        vddio-supply = <&touchkey_enable>;
+        vdd-supply = <&pm8921_l29>;
+        vcc-supply = <&pm8921_l29>;
+
+        linux,keycodes = <KEY_MENU KEY_BACK>;
+    };
+};
diff --git a/arch/arm/boot/dts/qcom/qcom-msm8960.dtsi 
b/arch/arm/boot/dts/qcom/qcom-msm8960.dtsi
index fd28401cebb5..c598fb324e7d 100644
--- a/arch/arm/boot/dts/qcom/qcom-msm8960.dtsi
+++ b/arch/arm/boot/dts/qcom/qcom-msm8960.dtsi
@@ -223,7 +223,7 @@ i2c8-pins {

              i2c10_default_state: i2c10-default-state {
                  i2c10-pins {
-                    pins = "gpio73", "gpio74";
+                    pins = "gpio71", "gpio72";
                      function = "gsbi10";
                      drive-strength = <8>;
                      bias-disable;
@@ -232,7 +232,7 @@ i2c10-pins {

              i2c10_sleep_state: i2c10-sleep-state {
                  i2c10-pins {
-                    pins = "gpio73", "gpio74";
+                    pins = "gpio71", "gpio72";
                      function = "gpio";
                      drive-strength = <2>;
                      bias-bus-hold;
diff --git a/arch/arm/configs/qcom_defconfig 
b/arch/arm/configs/qcom_defconfig
index 29a1dea500f0..49baa91937ca 100644
--- a/arch/arm/configs/qcom_defconfig
+++ b/arch/arm/configs/qcom_defconfig
@@ -321,3 +321,4 @@ CONFIG_MAGIC_SYSRQ=y
  CONFIG_DEBUG_FS=y
  # CONFIG_SLUB_DEBUG is not set
  # CONFIG_SCHED_DEBUG is not set
+CONFIG_KEYBOARD_TM2_TOUCHKEY=m
\ No newline at end of file


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] ARM: dts: qcom: msm8960: expressatt: Add coreriver,tc360-touchkey
  2025-12-06  3:54   ` Rudraksha Gupta
@ 2025-12-06  4:01     ` Dmitry Baryshkov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Baryshkov @ 2025-12-06  4:01 UTC (permalink / raw)
  To: Rudraksha Gupta
  Cc: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-arm-msm, devicetree, linux-kernel

On Fri, Dec 05, 2025 at 07:54:55PM -0800, Rudraksha Gupta wrote:
> > > +		sda-gpios = <&tlmm 71 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
> > > +		scl-gpios = <&tlmm 72 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
> > I don't have docs at hand, but it looks like these pins belong to
> > GSBI10. Have you tried using it directly?
> 
> This is the log when I use GSBI10:
> 
> samsung-expressatt:~$ dmesg | grep tm2
> [   79.555802] input: tm2-touchkey as
> /devices/platform/soc/1a200000.gsbi/1a280000.i2c/i2c-4/4-0020/input/input3
> [  110.242881] leds tm2-touchkey: Setting an LED's brightness failed (-110)
> [  167.074920] tm2-touchkey 4-0020: failed to read i2c data: -110
> [  182.435009] tm2-touchkey 4-0020: failed to read i2c data: -110
> 
> I could be doing something wrong, so here are the changes I made on top of
> this diff

I see, GSBI 10 uses pins 72 / 73 for I2C. Then this your patch is indeed
correct.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ARM: dts: qcom: msm8960: expressatt: Add coreriver,tc360-touchkey
  2025-12-05 10:16 [PATCH] ARM: dts: qcom: msm8960: expressatt: Add coreriver,tc360-touchkey Rudraksha Gupta via B4 Relay
  2025-12-06  2:18 ` Dmitry Baryshkov
@ 2025-12-08 16:35 ` Konrad Dybcio
  2025-12-09  7:10   ` Rudraksha Gupta
  1 sibling, 1 reply; 7+ messages in thread
From: Konrad Dybcio @ 2025-12-08 16:35 UTC (permalink / raw)
  To: guptarud, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-arm-msm, devicetree, linux-kernel

On 12/5/25 11:16 AM, Rudraksha Gupta via B4 Relay wrote:
> From: Rudraksha Gupta <guptarud@gmail.com>
> 
> Add the tc360 touchkey. It's unknown if this is the actual model of the
> touchkey, as downstream doesn't mention a variant, but this works.
> 
> Link:
> https://github.com/LineageOS/android_kernel_samsung_d2/blob/stable/cm-12.0-YNG4N/drivers/input/keyboard/cypress_touchkey_236/Makefile#L5
> 
> Signed-off-by: Rudraksha Gupta <guptarud@gmail.com>
> ---
> Add the tc360 touchkey. It's unknown if this is the actual model of the
> touchkey, as downstream doesn't mention a variant, but this works.
> 
> Link:
> https://github.com/LineageOS/android_kernel_samsung_d2/blob/stable/cm-12.0-YNG4N/drivers/input/keyboard/cypress_touchkey_236/Makefile#L5

This driver mentions a register called CYPRESS_MODULE_VER - maybe
it could help confirm the model?

Konrad

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ARM: dts: qcom: msm8960: expressatt: Add coreriver,tc360-touchkey
  2025-12-08 16:35 ` Konrad Dybcio
@ 2025-12-09  7:10   ` Rudraksha Gupta
  2025-12-16 12:59     ` Konrad Dybcio
  0 siblings, 1 reply; 7+ messages in thread
From: Rudraksha Gupta @ 2025-12-09  7:10 UTC (permalink / raw)
  To: Konrad Dybcio, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-arm-msm, devicetree, linux-kernel, beomho.seo, jcsing.lee

>> Add the tc360 touchkey. It's unknown if this is the actual model of the
>> touchkey, as downstream doesn't mention a variant, but this works.
>>
>> Link:
>> https://github.com/LineageOS/android_kernel_samsung_d2/blob/stable/cm-12.0-YNG4N/drivers/input/keyboard/cypress_touchkey_236/Makefile#L5
> This driver mentions a register called CYPRESS_MODULE_VER - maybe
> it could help confirm the model?
>
> Konrad


Here are the changes that Claude made to the tm2-touchkey driver, which 
seems to do what you asked and matches downstream (I have never written 
a driver before, so please free to provide corrections if necessary):


diff --git a/drivers/input/keyboard/tm2-touchkey.c 
b/drivers/input/keyboard/tm2-touchkey.c
index 55d699d9037d..d1f435dc6b05 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -33,6 +33,9 @@
  #define TM2_TOUCHKEY_LED_VOLTAGE_MIN    2500000
  #define TM2_TOUCHKEY_LED_VOLTAGE_MAX    3300000

+#define CYPRESS_FW_VER            0x01
+#define CYPRESS_MODULE_VER        0x02
+
  struct touchkey_variant {
      u8 keycode_reg;
      u8 base_reg;
@@ -180,6 +183,53 @@ static irqreturn_t tm2_touchkey_irq_handler(int 
irq, void *devid)
      return IRQ_HANDLED;
  }

+static ssize_t module_version_show(struct device *dev,
+                    struct device_attribute *attr, char *buf)
+{
+    struct i2c_client *client = to_i2c_client(dev);
+    struct tm2_touchkey_data *touchkey = i2c_get_clientdata(client);
+    int module_ver;
+
+    if (touchkey->variant->no_reg) {
+        /* Aries variant doesn't support register reads */
+        return sysfs_emit(buf, "unknown\n");
+    }
+
+    module_ver = i2c_smbus_read_byte_data(touchkey->client, 
CYPRESS_MODULE_VER);
+    if (module_ver < 0)
+        return module_ver;
+
+    return sysfs_emit(buf, "0x%02x\n", module_ver);
+}
+static DEVICE_ATTR_RO(module_version);
+
+static ssize_t fw_version_show(struct device *dev,
+                   struct device_attribute *attr, char *buf)
+{
+    struct i2c_client *client = to_i2c_client(dev);
+    struct tm2_touchkey_data *touchkey = i2c_get_clientdata(client);
+    int fw_ver;
+
+    if (touchkey->variant->no_reg) {
+        /* Aries variant doesn't support register reads */
+        return sysfs_emit(buf, "unknown\n");
+    }
+
+    fw_ver = i2c_smbus_read_byte_data(touchkey->client, CYPRESS_FW_VER);
+    if (fw_ver < 0)
+        return fw_ver;
+
+    return sysfs_emit(buf, "0x%02x\n", fw_ver);
+}
+static DEVICE_ATTR_RO(fw_version);
+
+static struct attribute *tm2_touchkey_attrs[] = {
+    &dev_attr_module_version.attr,
+    &dev_attr_fw_version.attr,
+    NULL
+};
+ATTRIBUTE_GROUPS(tm2_touchkey);
+
  static int tm2_touchkey_probe(struct i2c_client *client)
  {
      struct device_node *np = client->dev.of_node;
@@ -354,6 +404,7 @@ static struct i2c_driver tm2_touchkey_driver = {
          .name = TM2_TOUCHKEY_DEV_NAME,
          .pm = pm_sleep_ptr(&tm2_touchkey_pm_ops),
          .of_match_table = tm2_touchkey_of_match,
+        .dev_groups = tm2_touchkey_groups,
      },
      .probe = tm2_touchkey_probe,
      .id_table = tm2_touchkey_id_table,

When run on mainline, this is what was outputted:

samsung-expressatt:~$ cat /sys/bus/i2c/devices/0-0020/module_version
0x06
samsung-expressatt:~$ cat /sys/bus/i2c/devices/0-0020/fw_version
0x09


fw_version matches downstream ClockworkMod Recovery dmesg:

~ # dmesg | grep "FW Ver"
<3>[    2.201312] cypress_touchkey 16-0020: Touchkey FW Version: 0x09
<3>[    2.206317] cypress_touchkey 16-0020: Touchkey FW Version: 0x09, 
system_rev: 8


Unfortunately, I'm not to sure what the other variant versions are, so I 
will CC the driver's maintainers:

MODULE_AUTHOR("Beomho Seo <beomho.seo@samsung.com>");
MODULE_AUTHOR("Jaechul Lee <jcsing.lee@samsung.com>");


It also seems like I forgot to mention that this patch was assisted with 
Claude and cleaned up by me. Will update the patch's description if I 
need to send a v2.


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] ARM: dts: qcom: msm8960: expressatt: Add coreriver,tc360-touchkey
  2025-12-09  7:10   ` Rudraksha Gupta
@ 2025-12-16 12:59     ` Konrad Dybcio
  0 siblings, 0 replies; 7+ messages in thread
From: Konrad Dybcio @ 2025-12-16 12:59 UTC (permalink / raw)
  To: Rudraksha Gupta, Bjorn Andersson, Konrad Dybcio, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-arm-msm, devicetree, linux-kernel, beomho.seo, jcsing.lee

On 12/9/25 8:10 AM, Rudraksha Gupta wrote:
>>> Add the tc360 touchkey. It's unknown if this is the actual model of the
>>> touchkey, as downstream doesn't mention a variant, but this works.
>>>
>>> Link:
>>> https://github.com/LineageOS/android_kernel_samsung_d2/blob/stable/cm-12.0-YNG4N/drivers/input/keyboard/cypress_touchkey_236/Makefile#L5
>> This driver mentions a register called CYPRESS_MODULE_VER - maybe
>> it could help confirm the model?
>>
>> Konrad

[...]

> When run on mainline, this is what was outputted:
> 
> samsung-expressatt:~$ cat /sys/bus/i2c/devices/0-0020/module_version
> 0x06
> samsung-expressatt:~$ cat /sys/bus/i2c/devices/0-0020/fw_version
> 0x09
> 
> 
> fw_version matches downstream ClockworkMod Recovery dmesg:
> 
> ~ # dmesg | grep "FW Ver"
> <3>[    2.201312] cypress_touchkey 16-0020: Touchkey FW Version: 0x09
> <3>[    2.206317] cypress_touchkey 16-0020: Touchkey FW Version: 0x09, system_rev: 8
> 
> 
> Unfortunately, I'm not to sure what the other variant versions are, so I will CC the driver's maintainers:
> 
> MODULE_AUTHOR("Beomho Seo <beomho.seo@samsung.com>");
> MODULE_AUTHOR("Jaechul Lee <jcsing.lee@samsung.com>");

Sounds like the best idea, I have no clue either

Konrad

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-12-16 12:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-05 10:16 [PATCH] ARM: dts: qcom: msm8960: expressatt: Add coreriver,tc360-touchkey Rudraksha Gupta via B4 Relay
2025-12-06  2:18 ` Dmitry Baryshkov
2025-12-06  3:54   ` Rudraksha Gupta
2025-12-06  4:01     ` Dmitry Baryshkov
2025-12-08 16:35 ` Konrad Dybcio
2025-12-09  7:10   ` Rudraksha Gupta
2025-12-16 12:59     ` Konrad Dybcio

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).