devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Input: synaptics-rmi4 - support capacitive keys
@ 2025-07-07 19:54 André Apitzsch via B4 Relay
  2025-07-07 19:54 ` [PATCH 1/2] dt-bindings: input: syna,rmi4: Document F1A function André Apitzsch via B4 Relay
  2025-07-07 19:54 ` [PATCH 2/2] Input: synaptics-rmi4 - add support for F1A André Apitzsch via B4 Relay
  0 siblings, 2 replies; 4+ messages in thread
From: André Apitzsch via B4 Relay @ 2025-07-07 19:54 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jason A. Donenfeld, Matthias Schiffer, Vincent Huang
  Cc: ~postmarketos/upstreaming, phone-devel, linux-input, devicetree,
	linux-kernel, André Apitzsch

Add support for touch keys found in some Synaptics touch controller
configurations.

Signed-off-by: André Apitzsch <git@apitzsch.eu>
---
André Apitzsch (2):
      dt-bindings: input: syna,rmi4: Document F1A function
      Input: synaptics-rmi4 - add support for F1A

 .../devicetree/bindings/input/syna,rmi4.yaml       |  20 +++
 drivers/input/rmi4/Kconfig                         |   7 +
 drivers/input/rmi4/Makefile                        |   1 +
 drivers/input/rmi4/rmi_bus.c                       |   3 +
 drivers/input/rmi4/rmi_driver.h                    |   1 +
 drivers/input/rmi4/rmi_f1a.c                       | 145 +++++++++++++++++++++
 6 files changed, 177 insertions(+)
---
base-commit: 26ffb3d6f02cd0935fb9fa3db897767beee1cb2a
change-id: 20250707-rmi4_f1a-72fdfcfbe164

Best regards,
-- 
André Apitzsch <git@apitzsch.eu>



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

* [PATCH 1/2] dt-bindings: input: syna,rmi4: Document F1A function
  2025-07-07 19:54 [PATCH 0/2] Input: synaptics-rmi4 - support capacitive keys André Apitzsch via B4 Relay
@ 2025-07-07 19:54 ` André Apitzsch via B4 Relay
  2025-07-08 20:14   ` Rob Herring (Arm)
  2025-07-07 19:54 ` [PATCH 2/2] Input: synaptics-rmi4 - add support for F1A André Apitzsch via B4 Relay
  1 sibling, 1 reply; 4+ messages in thread
From: André Apitzsch via B4 Relay @ 2025-07-07 19:54 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jason A. Donenfeld, Matthias Schiffer, Vincent Huang
  Cc: ~postmarketos/upstreaming, phone-devel, linux-input, devicetree,
	linux-kernel, André Apitzsch

From: André Apitzsch <git@apitzsch.eu>

In some configurations the touch controller can support touch keys.
Document the linux,keycodes property that enables those keys and
specifies the keycodes that should be used to report the key events.

Signed-off-by: André Apitzsch <git@apitzsch.eu>
---
 .../devicetree/bindings/input/syna,rmi4.yaml         | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/syna,rmi4.yaml b/Documentation/devicetree/bindings/input/syna,rmi4.yaml
index b522c8d3ce0db719ff379f2fefbdca79e73d027c..f369385ffaf0227412b908242de84cd7dbeb08f7 100644
--- a/Documentation/devicetree/bindings/input/syna,rmi4.yaml
+++ b/Documentation/devicetree/bindings/input/syna,rmi4.yaml
@@ -89,6 +89,24 @@ properties:
     required:
       - reg
 
+  rmi4-f1a@1a:
+    type: object
+    additionalProperties: false
+    $ref: input.yaml#
+    description:
+      RMI4 Function 1A is for capacitive keys.
+
+    properties:
+      reg:
+        maxItems: 1
+
+      linux,keycodes:
+        minItems: 1
+        maxItems: 4
+
+    required:
+      - reg
+
 patternProperties:
   "^rmi4-f1[12]@1[12]$":
     type: object
@@ -201,6 +219,7 @@ allOf:
 
 examples:
   - |
+    #include <dt-bindings/input/linux-event-codes.h>
     #include <dt-bindings/interrupt-controller/irq.h>
 
     i2c {
@@ -234,6 +253,7 @@ examples:
 
             rmi4-f1a@1a {
                 reg = <0x1a>;
+                linux,keycodes = <KEY_BACK KEY_HOME KEY_MENU>;
             };
         };
     };

-- 
2.50.0



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

* [PATCH 2/2] Input: synaptics-rmi4 - add support for F1A
  2025-07-07 19:54 [PATCH 0/2] Input: synaptics-rmi4 - support capacitive keys André Apitzsch via B4 Relay
  2025-07-07 19:54 ` [PATCH 1/2] dt-bindings: input: syna,rmi4: Document F1A function André Apitzsch via B4 Relay
@ 2025-07-07 19:54 ` André Apitzsch via B4 Relay
  1 sibling, 0 replies; 4+ messages in thread
From: André Apitzsch via B4 Relay @ 2025-07-07 19:54 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jason A. Donenfeld, Matthias Schiffer, Vincent Huang
  Cc: ~postmarketos/upstreaming, phone-devel, linux-input, devicetree,
	linux-kernel, André Apitzsch

From: André Apitzsch <git@apitzsch.eu>

RMI4 F1A implements capacitive keys. Add support for touch keys found in
some Synaptics touch controller configurations.

Signed-off-by: André Apitzsch <git@apitzsch.eu>
---
 drivers/input/rmi4/Kconfig      |   7 ++
 drivers/input/rmi4/Makefile     |   1 +
 drivers/input/rmi4/rmi_bus.c    |   3 +
 drivers/input/rmi4/rmi_driver.h |   1 +
 drivers/input/rmi4/rmi_f1a.c    | 145 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 157 insertions(+)

diff --git a/drivers/input/rmi4/Kconfig b/drivers/input/rmi4/Kconfig
index c0163b983ce698ff241eeb6303d0e29989e0fcb8..c5d18abd28c7c26a9491656608d65fae50e818a8 100644
--- a/drivers/input/rmi4/Kconfig
+++ b/drivers/input/rmi4/Kconfig
@@ -82,6 +82,13 @@ config RMI4_F12
 	  touchpads. For sensors that support relative pointing, F12 also
 	  provides mouse input.
 
+config RMI4_F1A
+	bool "RMI4 Function 1A (0D pointing)"
+	help
+	  Say Y here if you want to add support for RMI4 function 1A.
+
+	  Function 1A provides capacitive keys support for RMI4 devices.
+
 config RMI4_F30
 	bool "RMI4 Function 30 (GPIO LED)"
 	help
diff --git a/drivers/input/rmi4/Makefile b/drivers/input/rmi4/Makefile
index 02f14c84686189b45d6adbbc06e266f64efaa036..70f942196aa2efeeaa7bfd292bcc1b8445761011 100644
--- a/drivers/input/rmi4/Makefile
+++ b/drivers/input/rmi4/Makefile
@@ -8,6 +8,7 @@ rmi_core-$(CONFIG_RMI4_2D_SENSOR) += rmi_2d_sensor.o
 rmi_core-$(CONFIG_RMI4_F03) += rmi_f03.o
 rmi_core-$(CONFIG_RMI4_F11) += rmi_f11.o
 rmi_core-$(CONFIG_RMI4_F12) += rmi_f12.o
+rmi_core-$(CONFIG_RMI4_F1A) += rmi_f1a.o
 rmi_core-$(CONFIG_RMI4_F30) += rmi_f30.o
 rmi_core-$(CONFIG_RMI4_F34) += rmi_f34.o rmi_f34v7.o
 rmi_core-$(CONFIG_RMI4_F3A) += rmi_f3a.o
diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index 3aee0483720533050c60014d843418740cf04a2d..e04fd6e525dcf474d948380d493249251f83a864 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -360,6 +360,9 @@ static struct rmi_function_handler *fn_handlers[] = {
 #ifdef CONFIG_RMI4_F12
 	&rmi_f12_handler,
 #endif
+#ifdef CONFIG_RMI4_F1A
+	&rmi_f1a_handler,
+#endif
 #ifdef CONFIG_RMI4_F30
 	&rmi_f30_handler,
 #endif
diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h
index 3bfe9013043ef3dff46249095a5b3116c8f7d9a6..aefe04008509b4363aa1aaf59d9119d95383e942 100644
--- a/drivers/input/rmi4/rmi_driver.h
+++ b/drivers/input/rmi4/rmi_driver.h
@@ -133,6 +133,7 @@ extern struct rmi_function_handler rmi_f01_handler;
 extern struct rmi_function_handler rmi_f03_handler;
 extern struct rmi_function_handler rmi_f11_handler;
 extern struct rmi_function_handler rmi_f12_handler;
+extern struct rmi_function_handler rmi_f1a_handler;
 extern struct rmi_function_handler rmi_f30_handler;
 extern struct rmi_function_handler rmi_f34_handler;
 extern struct rmi_function_handler rmi_f3a_handler;
diff --git a/drivers/input/rmi4/rmi_f1a.c b/drivers/input/rmi4/rmi_f1a.c
new file mode 100644
index 0000000000000000000000000000000000000000..107f52dd9e1468c2b7c0400bb24f5b0cf2928714
--- /dev/null
+++ b/drivers/input/rmi4/rmi_f1a.c
@@ -0,0 +1,145 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2025 André Apitzsch <git@apitzsch.eu>
+ */
+
+#include <linux/input.h>
+#include <linux/property.h>
+#include "rmi_driver.h"
+
+#define RMI_F1A_BUTTON_BITMASK_SIZE		1
+
+struct f1a_data {
+	u32 *keymap;
+	unsigned int num_keys;
+
+	struct input_dev *input;
+};
+
+static int rmi_f1a_parse_device_properties(struct rmi_function *fn, struct f1a_data *f1a)
+{
+	static const char buttons_property[] = "linux,keycodes";
+	struct device *dev = &fn->dev;
+	u32 *buttonmap;
+	int n_keys;
+	int ret;
+
+	if (!device_property_present(dev, buttons_property))
+		return 0;
+
+	n_keys = device_property_count_u32(dev, buttons_property);
+	if (n_keys <= 0) {
+		ret = n_keys < 0 ? n_keys : -EINVAL;
+		dev_err(dev, "Invalid/malformed '%s' property: %d\n",
+			buttons_property, ret);
+		return ret;
+	}
+
+	buttonmap = devm_kmalloc_array(dev, n_keys, sizeof(*buttonmap),
+				       GFP_KERNEL);
+	if (!buttonmap)
+		return -ENOMEM;
+
+	ret = device_property_read_u32_array(dev, buttons_property, buttonmap,
+					     n_keys);
+	if (ret) {
+		dev_err(dev, "Failed to parse '%s' property: %d\n",
+			buttons_property, ret);
+		return ret;
+	}
+
+	f1a->keymap = buttonmap;
+	f1a->num_keys = n_keys;
+
+	return 0;
+}
+
+static irqreturn_t rmi_f1a_attention(int irq, void *ctx)
+{
+	struct rmi_function *fn = ctx;
+	struct f1a_data *f1a = dev_get_drvdata(&fn->dev);
+	char button_bitmask;
+	int key;
+	int ret;
+
+	ret = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr,
+			     &button_bitmask, RMI_F1A_BUTTON_BITMASK_SIZE);
+	if (ret < 0) {
+		dev_err(&fn->dev, "Failed to read object data. Code: %d.\n",
+			ret);
+		return IRQ_RETVAL(ret);
+	}
+
+	for (key = 0; key < f1a->num_keys; key++)
+		input_report_key(f1a->input, f1a->keymap[key],
+				button_bitmask & BIT(key));
+
+	return IRQ_HANDLED;
+}
+
+static int rmi_f1a_config(struct rmi_function *fn)
+{
+	struct f1a_data *f1a = dev_get_drvdata(&fn->dev);
+	struct rmi_driver *drv = fn->rmi_dev->driver;
+
+	if (f1a->num_keys)
+		drv->set_irq_bits(fn->rmi_dev, fn->irq_mask);
+
+	return 0;
+}
+
+static int rmi_f1a_initialize(struct rmi_function *fn, struct f1a_data *f1a)
+{
+	int ret;
+	int i;
+
+	ret = rmi_f1a_parse_device_properties(fn, f1a);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < f1a->num_keys; i++)
+		input_set_capability(f1a->input, EV_KEY, f1a->keymap[i]);
+
+	f1a->input->keycode = f1a->keymap;
+	f1a->input->keycodemax = f1a->num_keys;
+	f1a->input->keycodesize = sizeof(f1a->keymap[0]);
+
+	return 0;
+}
+
+static int rmi_f1a_probe(struct rmi_function *fn)
+{
+	struct rmi_device *rmi_dev = fn->rmi_dev;
+	struct rmi_driver_data *drv_data = dev_get_drvdata(&rmi_dev->dev);
+	struct f1a_data *f1a;
+	int ret;
+
+	if (!drv_data->input) {
+		dev_info(&fn->dev, "F1A: no input device found, ignoring\n");
+		return -ENXIO;
+	}
+
+	f1a = devm_kzalloc(&fn->dev, sizeof(*f1a), GFP_KERNEL);
+	if (!f1a)
+		return -ENOMEM;
+
+	f1a->input = drv_data->input;
+
+	ret = rmi_f1a_initialize(fn, f1a);
+	if (ret)
+		return ret;
+
+	dev_set_drvdata(&fn->dev, f1a);
+
+	return 0;
+}
+
+struct rmi_function_handler rmi_f1a_handler = {
+	.driver = {
+		.name = "rmi4_f1a",
+	},
+	.func = 0x1a,
+	.probe = rmi_f1a_probe,
+	.config = rmi_f1a_config,
+	.attention = rmi_f1a_attention,
+};

-- 
2.50.0



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

* Re: [PATCH 1/2] dt-bindings: input: syna,rmi4: Document F1A function
  2025-07-07 19:54 ` [PATCH 1/2] dt-bindings: input: syna,rmi4: Document F1A function André Apitzsch via B4 Relay
@ 2025-07-08 20:14   ` Rob Herring (Arm)
  0 siblings, 0 replies; 4+ messages in thread
From: Rob Herring (Arm) @ 2025-07-08 20:14 UTC (permalink / raw)
  To: André Apitzsch
  Cc: linux-input, Dmitry Torokhov, Vincent Huang, phone-devel,
	devicetree, Krzysztof Kozlowski, Jason A. Donenfeld, linux-kernel,
	Conor Dooley, ~postmarketos/upstreaming, Matthias Schiffer


On Mon, 07 Jul 2025 21:54:25 +0200, André Apitzsch wrote:
> In some configurations the touch controller can support touch keys.
> Document the linux,keycodes property that enables those keys and
> specifies the keycodes that should be used to report the key events.
> 
> Signed-off-by: André Apitzsch <git@apitzsch.eu>
> ---
>  .../devicetree/bindings/input/syna,rmi4.yaml         | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 

Reviewed-by: Rob Herring (Arm) <robh@kernel.org>


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

end of thread, other threads:[~2025-07-08 20:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-07 19:54 [PATCH 0/2] Input: synaptics-rmi4 - support capacitive keys André Apitzsch via B4 Relay
2025-07-07 19:54 ` [PATCH 1/2] dt-bindings: input: syna,rmi4: Document F1A function André Apitzsch via B4 Relay
2025-07-08 20:14   ` Rob Herring (Arm)
2025-07-07 19:54 ` [PATCH 2/2] Input: synaptics-rmi4 - add support for F1A André Apitzsch via B4 Relay

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