From nobody Tue Apr 7 12:22:05 2026 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76D6238F931; Wed, 25 Feb 2026 15:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.120.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772034865; cv=none; b=hS4VvBzmM0foC5cBciYU2+++a0tLnYJFKoo3uriPnl4X8w4BZLocwz760NqlW+L7MGnr+GfhC5WBpZ/DW1wmTufCcYsHrBzHbPWj1bEqZRjL455gwqgn9gweg6j8n1FRjF+1VWaWWHFHaPnjAmHXMxFKI1r/qmW2jO5B9IQ5EOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772034865; c=relaxed/simple; bh=xwieGuFpW5SNyjYgVjLUefXyKWf3Y5DCc1CeIBqFKLo=; h=From:To:Cc:Date:Message-ID:In-Reply-To:References:MIME-Version: Subject; b=pWTCC52GL/jYFSKOo5THWqcIYDjLcLbLgw1LojC6ERTfV23KiWRCckYrgcp+e72QH5iShe7hLxP4quLEGDyrp3JeDUkZP0KyxnoHwE/jDbc/SJIGkuSo8Qnb4kW+kR2fSManEeUkoDLe/POcLMTQV12V7Xz4XQtQuXVjJNUZ+eA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com; spf=pass smtp.mailfrom=hugovil.com; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b=iOswTt2q; arc=none smtp.client-ip=162.243.120.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="iOswTt2q" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Cc:To :From:subject:date:message-id:reply-to; bh=faZvFWUwi+UVcnr0qhwBPMqLzuXN/R2EuHLgNgE03ZM=; b=iOswTt2qCd6EYVkX/pC+ZJ+iZY uklpL5zkz+rK4OGrrArqhWj8a38G1nu2Lg5vm7ksvj3NRYGqArl8gzkF05depzuH7I68SHtIi8RpT jLZ0/2iNZWDv9BR8LkfG3vwApds22n9SA9dm06yQggZamSWOgCbVz/0u8g4UT6od5kTM=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:47746 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1vvHDJ-0005uT-OB; Wed, 25 Feb 2026 10:54:14 -0500 From: Hugo Villeneuve To: robin@protonic.nl, andy@kernel.org, geert@linux-m68k.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com, hvilleneuve@dimonoff.com, mkorpershoek@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, lee@kernel.org, alexander.sverdlin@gmail.com, marek.vasut@gmail.com, akurz@blala.de Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, hugo@hugovil.com Date: Wed, 25 Feb 2026 10:53:58 -0500 Message-ID: <20260225155409.612478-2-hugo@hugovil.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260225155409.612478-1-hugo@hugovil.com> References: <20260225155409.612478-1-hugo@hugovil.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Subject: [PATCH v3 1/4] dt-bindings: input: add debounce-delay-ms common property X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Content-Type: text/plain; charset="utf-8" From: Hugo Villeneuve A few bindings are already defining a debounce-delay-ms property, so add it to the input binding to reduce redundant redefines. Signed-off-by: Hugo Villeneuve --- .../devicetree/bindings/auxdisplay/holtek,ht16k33.yaml | 5 ++--- .../devicetree/bindings/input/cirrus,ep9307-keypad.yaml | 7 +++---- .../devicetree/bindings/input/gpio-matrix-keypad.yaml | 5 ++--- Documentation/devicetree/bindings/input/input.yaml | 8 ++++++++ .../devicetree/bindings/input/mediatek,mt6779-keypad.yaml | 1 + Documentation/devicetree/bindings/mfd/fsl,mc13xxx.yaml | 2 -- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.ya= ml b/Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml index b90eec2077b4..c46a2471f8b1 100644 --- a/Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml +++ b/Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml @@ -10,6 +10,7 @@ maintainers: - Robin van der Gracht =20 allOf: + - $ref: /schemas/input/input.yaml# - $ref: /schemas/input/matrix-keymap.yaml# =20 properties: @@ -33,9 +34,7 @@ properties: interrupts: maxItems: 1 =20 - debounce-delay-ms: - maxItems: 1 - description: Debouncing interval time in milliseconds + debounce-delay-ms: true =20 linux,keymap: true =20 diff --git a/Documentation/devicetree/bindings/input/cirrus,ep9307-keypad.y= aml b/Documentation/devicetree/bindings/input/cirrus,ep9307-keypad.yaml index a0d2460c55ab..25b8b29c87d7 100644 --- a/Documentation/devicetree/bindings/input/cirrus,ep9307-keypad.yaml +++ b/Documentation/devicetree/bindings/input/cirrus,ep9307-keypad.yaml @@ -10,6 +10,7 @@ maintainers: - Alexander Sverdlin =20 allOf: + - $ref: input.yaml# - $ref: /schemas/input/matrix-keymap.yaml# =20 description: @@ -37,10 +38,8 @@ properties: clocks: maxItems: 1 =20 - debounce-delay-ms: - description: | - Time in microseconds that key must be pressed or - released for state change interrupt to trigger. + # Time for state change interrupt to trigger + debounce-delay-ms: true =20 cirrus,prescale: description: row/column counter pre-scaler load value diff --git a/Documentation/devicetree/bindings/input/gpio-matrix-keypad.yam= l b/Documentation/devicetree/bindings/input/gpio-matrix-keypad.yaml index ebfff9e42a36..69df24a5ae70 100644 --- a/Documentation/devicetree/bindings/input/gpio-matrix-keypad.yaml +++ b/Documentation/devicetree/bindings/input/gpio-matrix-keypad.yaml @@ -18,6 +18,7 @@ description: report the event using GPIO interrupts to the cpu. =20 allOf: + - $ref: input.yaml# - $ref: /schemas/input/matrix-keymap.yaml# =20 properties: @@ -46,9 +47,7 @@ properties: Force GPIO polarity to active low. In the absence of this property GPIOs are treated as active high. =20 - debounce-delay-ms: - description: Debounce interval in milliseconds. - default: 0 + debounce-delay-ms: true =20 col-scan-delay-us: description: diff --git a/Documentation/devicetree/bindings/input/input.yaml b/Documenta= tion/devicetree/bindings/input/input.yaml index 94f7942189e8..502e0b7eb500 100644 --- a/Documentation/devicetree/bindings/input/input.yaml +++ b/Documentation/devicetree/bindings/input/input.yaml @@ -14,6 +14,14 @@ properties: description: Enable autorepeat when key is pressed and held down. type: boolean =20 + debounce-delay-ms: + description: + Debounce delay in milliseconds. This is the time during which the key + press or release signal must remain stable before it is considered v= alid. + minimum: 0 + maximum: 999 + default: 0 + linux,keycodes: description: Specifies an array of numeric keycode values to be used for reporting diff --git a/Documentation/devicetree/bindings/input/mediatek,mt6779-keypad= .yaml b/Documentation/devicetree/bindings/input/mediatek,mt6779-keypad.yaml index e365413732e7..914dd3283df3 100644 --- a/Documentation/devicetree/bindings/input/mediatek,mt6779-keypad.yaml +++ b/Documentation/devicetree/bindings/input/mediatek,mt6779-keypad.yaml @@ -10,6 +10,7 @@ maintainers: - Mattijs Korpershoek =20 allOf: + - $ref: input.yaml# - $ref: /schemas/input/matrix-keymap.yaml# =20 description: | diff --git a/Documentation/devicetree/bindings/mfd/fsl,mc13xxx.yaml b/Docum= entation/devicetree/bindings/mfd/fsl,mc13xxx.yaml index d2886f2686a8..542ba5114424 100644 --- a/Documentation/devicetree/bindings/mfd/fsl,mc13xxx.yaml +++ b/Documentation/devicetree/bindings/mfd/fsl,mc13xxx.yaml @@ -76,8 +76,6 @@ properties: debounce-delay-ms: enum: [0, 30, 150, 750] default: 30 - description: - Sets the debouncing delay in milliseconds. =20 active-low: description: Set active when pin is pulled low. --=20 2.47.3 From nobody Tue Apr 7 12:22:05 2026 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76CD72236F7; Wed, 25 Feb 2026 15:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.120.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772034866; cv=none; b=AU8PSXaJ2scdG6syYxmYkGlF8WszXkZL/4G0BYcXXhH39LArFZTHoztV7U0Lws/amuK/2ebxVWJURN4MlwCKDisXUObvkQeDBpMmN1Y4dQOnvhagmJ9VyRnQ6+dUUW5MWe1d2Vp55KzUch9f7IL8j9PUIYiKFysStrEaordn+r8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772034866; c=relaxed/simple; bh=rSz6IXhh2QscmjUlh9jv5Yx4lx9IplfcfVw4rrzsgYQ=; h=From:To:Cc:Date:Message-ID:In-Reply-To:References:MIME-Version: Subject; b=F5axlSu0rj7LP/jaFI/OG6NsPxJNdvDRLOK3VqqSeGoVGAjdXZPL17luALUdn0iF12zYWS0ZKHBuO/edpZHWT5n5fd8YLp14uWHAFJauJ6psMHHudRSQLBcpupaTnkf2QADjiB5KLyK7BZR/wMcQwQDtkOTDR1w5+tyUUJ5VzAo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com; spf=pass smtp.mailfrom=hugovil.com; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b=qbVbDMbq; arc=none smtp.client-ip=162.243.120.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="qbVbDMbq" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Cc:To :From:subject:date:message-id:reply-to; bh=XX4ai7/kA1JrfXNrpCNkIDlOwikwomvibsgv25K1pKk=; b=qbVbDMbq62dN6kBqo/s705o8sx MZVlDbsGuEoTefCcVIgHXONFOu3LqIOFWHL46zDjckzqVeoYAaHLTnfwZR+iXEf8zwEv1RHL+y/IU 7aSB40UbxE+u5IwPBPtbw5b2zmmpJ2aAX7ZSbNdx6LBEJwveQ0cbjX8EZnZWvFV6Bsm4=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:47746 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1vvHDL-0005uT-9J; Wed, 25 Feb 2026 10:54:15 -0500 From: Hugo Villeneuve To: robin@protonic.nl, andy@kernel.org, geert@linux-m68k.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com, hvilleneuve@dimonoff.com, mkorpershoek@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, lee@kernel.org, alexander.sverdlin@gmail.com, marek.vasut@gmail.com, akurz@blala.de Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, hugo@hugovil.com Date: Wed, 25 Feb 2026 10:53:59 -0500 Message-ID: <20260225155409.612478-3-hugo@hugovil.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260225155409.612478-1-hugo@hugovil.com> References: <20260225155409.612478-1-hugo@hugovil.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Subject: [PATCH v3 2/4] dt-bindings: input: add settling-time-us common property X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Content-Type: text/plain; charset="utf-8" From: Hugo Villeneuve Add common property that can be reused by other bindings. Signed-off-by: Hugo Villeneuve --- Note: a similar property is used by gpio-matrix-keypad.yaml: col-scan-delay-us --- Documentation/devicetree/bindings/input/input.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/input/input.yaml b/Documenta= tion/devicetree/bindings/input/input.yaml index 502e0b7eb500..14652d324e2c 100644 --- a/Documentation/devicetree/bindings/input/input.yaml +++ b/Documentation/devicetree/bindings/input/input.yaml @@ -66,6 +66,14 @@ properties: reset automatically. Device with key pressed reset feature can speci= fy this property. =20 + settling-time-us: + description: + Delay, in microseconds, when activating an output line/col/row GPIO + before we can reliably read other input GPIOs that maybe affected by= this + output. This can be the case for an output with a RC circuit that af= fects + ramp-up/down times. + default: 0 + dependencies: linux,input-type: [ "linux,code" ] =20 --=20 2.47.3 From nobody Tue Apr 7 12:22:05 2026 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD3153D6474; Wed, 25 Feb 2026 15:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.120.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772034865; cv=none; b=Y0hrbuCDfMJSRyFP0eyMMEvW8KhOEf9rgzm+hU47kZCdCrmYrZLufPngpAmbYJO66meVQciqrn8i40mkqEo24npkj/aDXHSvBbFjeUWNN94g/I0LPm+DY4mJpfZb7ALPm1Dv+hxNdowSWFh6Rt+OflgXm0U6g+loLVw0J3pqIys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772034865; c=relaxed/simple; bh=jyzTkXjHgnTVbLdqDlCMLTuOJpSQ30echftUdHOYWU8=; h=From:To:Cc:Date:Message-ID:In-Reply-To:References:MIME-Version: Subject; b=b2wW8X1BkNxJemqkDA2iMOwC92ncBPrkOGdGXuUzo1AxX5a08puy8ganCag1hksP3C/RBDgXN+GOCNjvwKcMQxfSl9wkxQQs3f2i/LtEFiSxsQrrr/VtSgqnWR5WIhJKY4jBaQ1fNDptr4wxiyaqQRGQW7T730mktfUwTuDJVuU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com; spf=pass smtp.mailfrom=hugovil.com; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b=rsQqJHwZ; arc=none smtp.client-ip=162.243.120.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="rsQqJHwZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Cc:To :From:subject:date:message-id:reply-to; bh=K0P0g16xTJdhYm8l3vI0AbR3OUqzHDBE6PhK3jSMQGU=; b=rsQqJHwZaMP5H5rjbQqDX0aJEH CrKT+SkMKHEXDVfMlwtNuZBDMjp6mtOSI8g0XVYvTH6v+lJPMF83+gyOS/c5T9xVRRZV75I4qPxRs 2XsQ1gBJEoQoBHFkhckW7V+W2zp7vbjFN0a3IniMGMdsyiBE6JB/JiIJIfvaWqj5lTvg=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:47746 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1vvHDM-0005uT-JY; Wed, 25 Feb 2026 10:54:17 -0500 From: Hugo Villeneuve To: robin@protonic.nl, andy@kernel.org, geert@linux-m68k.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com, hvilleneuve@dimonoff.com, mkorpershoek@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, lee@kernel.org, alexander.sverdlin@gmail.com, marek.vasut@gmail.com, akurz@blala.de Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, hugo@hugovil.com Date: Wed, 25 Feb 2026 10:54:00 -0500 Message-ID: <20260225155409.612478-4-hugo@hugovil.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260225155409.612478-1-hugo@hugovil.com> References: <20260225155409.612478-1-hugo@hugovil.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Subject: [PATCH v3 3/4] dt-bindings: input: add GPIO charlieplex keypad X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Content-Type: text/plain; charset="utf-8" From: Hugo Villeneuve Add DT bindings for GPIO charlieplex keypad. Signed-off-by: Hugo Villeneuve --- .../input/gpio-charlieplex-keypad.yaml | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/gpio-charlieple= x-keypad.yaml diff --git a/Documentation/devicetree/bindings/input/gpio-charlieplex-keypa= d.yaml b/Documentation/devicetree/bindings/input/gpio-charlieplex-keypad.ya= ml new file mode 100644 index 000000000000..d3eeddc8e533 --- /dev/null +++ b/Documentation/devicetree/bindings/input/gpio-charlieplex-keypad.yaml @@ -0,0 +1,106 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- + +$id: http://devicetree.org/schemas/input/gpio-charlieplex-keypad.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: GPIO charlieplex keypad + +maintainers: + - Hugo Villeneuve + +description: | + The charlieplex keypad supports N^2)-N different key combinations (where= N is + the number of lines). Key presses and releases are detected by configuri= ng + only one line as output at a time, and reading other line states. This p= rocess + is repeated for each line. Diodes are required to ensure current flows i= n only + one direction between any pair of pins. + This mechanism doesn't allow to detect simultaneous key presses. + + Wiring example for 3 lines keyboard with 6 switches and 3 diodes: + + L0 --+---------------------+----------------------+ + | | | + L1 -------+-----------+---------------------+ | + | | | | | | + L2 -------------+----------------+-----+ | | + | | | | | | | | | + | | | | | | | | | + | S1 \ S2 \ | S3 \ S4 \ | S5 \ S6 \ + | | | | | | | | | + | +--+--+ | +--+--+ | +--+--+ + | | | | | | + | D1 v | D2 v | D3 v + | - (k) | - (k) | - (k) + | | | | | | + +-------+ +-------+ +-------+ + + L: GPIO line + S: switch + D: diode (k indicates cathode) + +allOf: + - $ref: input.yaml# + - $ref: /schemas/input/matrix-keymap.yaml# + +properties: + compatible: + const: gpio-charlieplex-keypad + + autorepeat: true + + debounce-delay-ms: + default: 5 + + line-gpios: + description: + List of GPIOs used as lines. The gpio specifier for this property + depends on the gpio controller to which these lines are connected. + + linux,keymap: true + + poll-interval: true + + settling-time-us: true + + wakeup-source: true + +required: + - compatible + - line-gpios + - linux,keymap + - poll-interval + +additionalProperties: false + +examples: + - | + #include + #include + + charlieplex-keypad { + compatible =3D "gpio-charlieplex-keypad"; + debounce-delay-ms =3D <20>; + poll-interval =3D <5>; + settling-time-us =3D <2>; + + line-gpios =3D <&gpio2 25 GPIO_ACTIVE_HIGH + &gpio2 26 GPIO_ACTIVE_HIGH + &gpio2 27 GPIO_ACTIVE_HIGH>; + + /* MATRIX_KEY(output, input, key-code) */ + linux,keymap =3D < + /* + * According to wiring diagram above, if L1 is configured as + * output and HIGH, and we detect a HIGH level on input L0, + * then it means S1 is pressed: MATRIX_KEY(L1, L0, KEY...) + */ + MATRIX_KEY(1, 0, KEY_F1) /* S1 */ + MATRIX_KEY(2, 0, KEY_F2) /* S2 */ + MATRIX_KEY(0, 1, KEY_F3) /* S3 */ + MATRIX_KEY(2, 1, KEY_F4) /* S4 */ + MATRIX_KEY(1, 2, KEY_F5) /* S5 */ + MATRIX_KEY(0, 2, KEY_F6) /* S6 */ + >; + }; --=20 2.47.3 From nobody Tue Apr 7 12:22:05 2026 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CB8B3D6698; Wed, 25 Feb 2026 15:54:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.120.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772034867; cv=none; b=O979Tgx2DKuwNxwvufxT3IcUwVAO4jVGr2mdAhVa7AsnMVn+3KWJ0e5NnxkvHPvAZVmP8nGCk5MaP/Q/6/tlzlbjr36Iaf+Rq/0Qd85iJDDSAgH6yQFn8WpCOPyj47gpEddR5NzxHRRvcTlPX542mw0LCnjgN35TowVTQHxknaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772034867; c=relaxed/simple; bh=UlxhWottnAskULrwuLN5gikMitjQzAFvK3xbKAutqIw=; h=From:To:Cc:Date:Message-ID:In-Reply-To:References:MIME-Version: Subject; b=Xz2SvOnZaVaax9I0+lvE9a34w4wbsEH16Qr3RIesI6+MprwfobntoQOAihT3gBtpk+WDiilFHBGxW6u15tGCO/BAtIREwLrvQd13iBT3dz/GmTOJPf4T6TIYEsMBsQBhWAAa2YBrH2cIfS1Q0QVu/+Oreia2DkeCLzr7mfc3S6k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com; spf=pass smtp.mailfrom=hugovil.com; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b=cmX8fe2+; arc=none smtp.client-ip=162.243.120.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="cmX8fe2+" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Cc:To :From:subject:date:message-id:reply-to; bh=qGaoYtle+bX/4SmeNH8BhwDQZAURuEQKPgOmITzcCQo=; b=cmX8fe2+ZHEqUnIxat86+aAQpH O/hCpSbjj5A2rIg+5Xq2u5VG/aM/cHuS2WQrRewefcsrFq6sUKAOvs40Gi2OqY0TzJUyt6eXwDqCi r+NIg0cjYu5ya00l5u4kg+lOVf7SThfLYQ2u6spo3TOTX1JQJ/1foPAELYyVYnFokDsM=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:47746 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1vvHDO-0005uT-TS; Wed, 25 Feb 2026 10:54:20 -0500 From: Hugo Villeneuve To: robin@protonic.nl, andy@kernel.org, geert@linux-m68k.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com, hvilleneuve@dimonoff.com, mkorpershoek@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, lee@kernel.org, alexander.sverdlin@gmail.com, marek.vasut@gmail.com, akurz@blala.de Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, hugo@hugovil.com Date: Wed, 25 Feb 2026 10:54:01 -0500 Message-ID: <20260225155409.612478-5-hugo@hugovil.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260225155409.612478-1-hugo@hugovil.com> References: <20260225155409.612478-1-hugo@hugovil.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * 1.7 URIBL_BLACK Contains an URL listed in the URIBL blacklist * [URIs: perches.com] * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Subject: [PATCH v3 4/4] Input: charlieplex_keypad: add GPIO charlieplex keypad X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Content-Type: text/plain; charset="utf-8" From: Hugo Villeneuve Add support for GPIO-based charlieplex keypad, allowing to control N^2-N keys using N GPIO lines. Reuse matrix keypad keymap to simplify, even if there is no concept of rows and columns in this type of keyboard. Signed-off-by: Hugo Villeneuve --- MAINTAINERS | 7 + drivers/input/keyboard/Kconfig | 14 ++ drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/charlieplex_keypad.c | 213 ++++++++++++++++++++ 4 files changed, 235 insertions(+) create mode 100644 drivers/input/keyboard/charlieplex_keypad.c diff --git a/MAINTAINERS b/MAINTAINERS index 9ed6d11a7746..0b2d71f32b40 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5765,6 +5765,13 @@ S: Maintained F: Documentation/hwmon/powerz.rst F: drivers/hwmon/powerz.c =20 +CHARLIEPLEX KEYPAD DRIVER +M: Hugo Villeneuve +S: Supported +W: http://www.mosaic-industries.com/embedded-systems/microcontroller-proje= cts/electronic-circuits/matrix-keypad-scan-decode +F: Documentation/devicetree/bindings/input/gpio-charlieplex-keypad.yaml +F: drivers/input/keyboard/charlieplex_keypad.c + CHECKPATCH M: Andy Whitcroft M: Joe Perches diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 2ff4fef322c2..ae54b4b7e2d8 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -289,6 +289,20 @@ config KEYBOARD_MATRIX To compile this driver as a module, choose M here: the module will be called matrix_keypad. =20 +config KEYBOARD_CHARLIEPLEX + tristate "GPIO driven chearlieplex keypad support" + depends on GPIOLIB || COMPILE_TEST + select INPUT_MATRIXKMAP + help + Enable support for GPIO driven charlieplex keypad. A charlieplex + keypad allows to use fewer GPIO lines to interface to key switches. + For example, an N lines charlieplex keypad can be used to interface + to N^2-N different key switches. However, this type of keypad + cannot detect more than one key press at a time. + + To compile this driver as a module, choose M here: the + module will be called charlieplex_keypad. + config KEYBOARD_HIL_OLD tristate "HP HIL keyboard support (simple driver)" depends on GSC || HP300 diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makef= ile index 2d906e14f3e2..40b5cf5d374d 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile @@ -40,6 +40,7 @@ obj-$(CONFIG_KEYBOARD_LOCOMO) +=3D locomokbd.o obj-$(CONFIG_KEYBOARD_LPC32XX) +=3D lpc32xx-keys.o obj-$(CONFIG_KEYBOARD_MAPLE) +=3D maple_keyb.o obj-$(CONFIG_KEYBOARD_MATRIX) +=3D matrix_keypad.o +obj-$(CONFIG_KEYBOARD_CHARLIEPLEX) +=3D charlieplex_keypad.o obj-$(CONFIG_KEYBOARD_MAX7359) +=3D max7359_keypad.o obj-$(CONFIG_KEYBOARD_MAX7360) +=3D max7360-keypad.o obj-$(CONFIG_KEYBOARD_MPR121) +=3D mpr121_touchkey.o diff --git a/drivers/input/keyboard/charlieplex_keypad.c b/drivers/input/ke= yboard/charlieplex_keypad.c new file mode 100644 index 000000000000..fae0aeb1d167 --- /dev/null +++ b/drivers/input/keyboard/charlieplex_keypad.c @@ -0,0 +1,213 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * GPIO driven charlieplex keypad driver + * + * Copyright (c) 2025 Hugo Villeneuve + * + * Based on matrix_keyboard.c + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct charlieplex_keypad { + struct input_dev *input_dev; + struct gpio_descs *line_gpios; + unsigned int nlines; + unsigned int settling_time_us; + unsigned int debounce_threshold; + unsigned int debounce_count; + int debounce_code; + int current_code; +}; + +static void charlieplex_keypad_report_key(struct input_dev *input) +{ + struct charlieplex_keypad *keypad =3D input_get_drvdata(input); + const unsigned short *keycodes =3D input->keycode; + + if (keypad->current_code > 0) { + input_event(input, EV_MSC, MSC_SCAN, keypad->current_code); + input_report_key(input, keycodes[keypad->current_code], 0); + } + + if (keypad->debounce_code) { + input_event(input, EV_MSC, MSC_SCAN, keypad->debounce_code); + input_report_key(input, keycodes[keypad->debounce_code], 1); + } + + input_sync(input); + keypad->current_code =3D keypad->debounce_code; +} + +static void charlieplex_keypad_check_switch_change(struct input_dev *input, + int code) +{ + struct charlieplex_keypad *keypad =3D input_get_drvdata(input); + + if (code !=3D keypad->debounce_code) { + keypad->debounce_count =3D 0; + keypad->debounce_code =3D code; + } else if (keypad->debounce_count < keypad->debounce_threshold) { + keypad->debounce_count++; + + if (keypad->debounce_count >=3D keypad->debounce_threshold && + keypad->debounce_code !=3D keypad->current_code) + charlieplex_keypad_report_key(input); + } +} + +static void charlieplex_keypad_poll(struct input_dev *input) +{ + struct charlieplex_keypad *keypad =3D input_get_drvdata(input); + int oline; + int code; + + for (code =3D 0, oline =3D 0; oline < keypad->nlines; oline++) { + DECLARE_BITMAP(values, MATRIX_MAX_ROWS); + int iline; + int rc; + + /* Activate only one line as output at a time. */ + gpiod_direction_output(keypad->line_gpios->desc[oline], 1); + + if (keypad->settling_time_us) + fsleep(keypad->settling_time_us); + + /* Read input on all other lines. */ + rc =3D gpiod_get_array_value_cansleep(keypad->line_gpios->ndescs, + keypad->line_gpios->desc, + keypad->line_gpios->info, values); + if (rc) + return; + + for (iline =3D 0; iline < keypad->nlines; iline++) { + if (iline =3D=3D oline) + continue; /* Do not read active output line. */ + + /* Check if GPIO is asserted. */ + if (test_bit(iline, values)) { + code =3D MATRIX_SCAN_CODE(oline, iline, + get_count_order(keypad->nlines)); + /* + * Exit loop immediately since we cannot detect + * more than one key press at a time. + */ + break; + } + } + + gpiod_direction_input(keypad->line_gpios->desc[oline]); + + if (code) + break; + } + + charlieplex_keypad_check_switch_change(input, code); +} + +static int charlieplex_keypad_init_gpio(struct platform_device *pdev, + struct charlieplex_keypad *keypad) +{ + int i; + + keypad->line_gpios =3D devm_gpiod_get_array(&pdev->dev, "line", GPIOD_IN); + if (IS_ERR(keypad->line_gpios)) + return PTR_ERR(keypad->line_gpios); + + keypad->nlines =3D keypad->line_gpios->ndescs; + + if (keypad->nlines > MATRIX_MAX_ROWS) + return -EINVAL; + + for (i =3D 0; i < keypad->nlines; i++) + gpiod_set_consumer_name(keypad->line_gpios->desc[i], "charlieplex_kbd_li= ne"); + + return 0; +} + +static int charlieplex_keypad_probe(struct platform_device *pdev) +{ + struct charlieplex_keypad *keypad; + unsigned int debounce_interval_ms; + unsigned int poll_interval_ms; + struct input_dev *input_dev; + int err; + + keypad =3D devm_kzalloc(&pdev->dev, sizeof(*keypad), GFP_KERNEL); + if (!keypad) + return -ENOMEM; + + input_dev =3D devm_input_allocate_device(&pdev->dev); + if (!input_dev) + return -ENOMEM; + + keypad->input_dev =3D input_dev; + + device_property_read_u32(&pdev->dev, "poll-interval", &poll_interval_ms); + device_property_read_u32(&pdev->dev, "debounce-delay-ms", &debounce_inter= val_ms); + device_property_read_u32(&pdev->dev, "settling-time-us", &keypad->settlin= g_time_us); + + keypad->current_code =3D -1; + keypad->debounce_code =3D -1; + keypad->debounce_threshold =3D DIV_ROUND_UP(debounce_interval_ms, poll_in= terval_ms); + + err =3D charlieplex_keypad_init_gpio(pdev, keypad); + if (err) + return err; + + input_dev->name =3D pdev->name; + input_dev->id.bustype =3D BUS_HOST; + + err =3D matrix_keypad_build_keymap(NULL, NULL, keypad->nlines, + keypad->nlines, NULL, input_dev); + if (err) + dev_err_probe(&pdev->dev, -ENOMEM, "failed to build keymap\n"); + + if (device_property_read_bool(&pdev->dev, "autorepeat")) + __set_bit(EV_REP, input_dev->evbit); + + input_set_capability(input_dev, EV_MSC, MSC_SCAN); + + err =3D input_setup_polling(input_dev, charlieplex_keypad_poll); + if (err) + dev_err_probe(&pdev->dev, err, "unable to set up polling\n"); + + input_set_poll_interval(input_dev, poll_interval_ms); + + input_set_drvdata(input_dev, keypad); + + err =3D input_register_device(keypad->input_dev); + if (err) + return err; + + platform_set_drvdata(pdev, keypad); + + return 0; +} + +static const struct of_device_id charlieplex_keypad_dt_match[] =3D { + { .compatible =3D "gpio-charlieplex-keypad" }, + { } +}; +MODULE_DEVICE_TABLE(of, charlieplex_keypad_dt_match); + +static struct platform_driver charlieplex_keypad_driver =3D { + .probe =3D charlieplex_keypad_probe, + .driver =3D { + .name =3D "charlieplex-keypad", + .of_match_table =3D of_match_ptr(charlieplex_keypad_dt_match), + }, +}; +module_platform_driver(charlieplex_keypad_driver); + +MODULE_AUTHOR("Hugo Villeneuve "); +MODULE_DESCRIPTION("GPIO driven charlieplex keypad driver"); +MODULE_LICENSE("GPL"); --=20 2.47.3