From patchwork Thu Oct 3 06:12:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGFsIFZva8OhxI0=?= X-Patchwork-Id: 11172171 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E53CD1902 for ; Thu, 3 Oct 2019 06:13:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C43A9222C3 for ; Thu, 3 Oct 2019 06:13:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ysoft.com header.i=@ysoft.com header.b="Qnyz60Vu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727259AbfJCGND (ORCPT ); Thu, 3 Oct 2019 02:13:03 -0400 Received: from uho.ysoft.cz ([81.19.3.130]:44162 "EHLO uho.ysoft.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbfJCGND (ORCPT ); Thu, 3 Oct 2019 02:13:03 -0400 Received: from iota-build.ysoft.local (unknown [10.1.5.151]) by uho.ysoft.cz (Postfix) with ESMTP id DE39BA095B; Thu, 3 Oct 2019 08:13:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ysoft.com; s=20160406-ysoft-com; t=1570083180; bh=Sy55JxpoNfmQQuRDsoHKv3oT39z9AK+6c1CfdAzxXGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qnyz60Vu9VwZiPMwwj/WiDRprNd7qgpiuD8Yo2Tbrt3b5CsxGoLBWutOLIj9rVX8j v2Hdxf2KH3lB1Y9P4+MHxTVMuvrcqNTdx6VOJmP36W7+S8zMMVTONbqN09Rai6rp2i 5kX72p9/bZGdvLbxqXqg9hWohGIoWiS/ySMpWjK8= From: =?utf-8?b?TWljaGFsIFZva8OhxI0=?= To: Dmitry Torokhov , Rob Herring Cc: Shawn Guo , Fabio Estevam , linux-input@vger.kernel.org, devicetree@vger.kernel.org, =?utf-8?b?TWljaGFs?= =?utf-8?b?IFZva8OhxI0=?= Subject: [PATCH v3 1/5] dt-bindings: input: Add common input binding in json-schema Date: Thu, 3 Oct 2019 08:12:52 +0200 Message-Id: <1570083176-8231-2-git-send-email-michal.vokac@ysoft.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1570083176-8231-1-git-send-email-michal.vokac@ysoft.com> References: <1570083176-8231-1-git-send-email-michal.vokac@ysoft.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Create schema for the common input properties and merge all properties from the Documentation/devicetree/bindings/input/keys.txt binding into this common schema. Signed-off-by: Michal Vokáč Reviewed-by: Rob Herring --- Changes since v2: - Merge content of keys.txt binding inti this schema. Changes since v1: - New patch in the series. Documentation/devicetree/bindings/input/input.yaml | 32 ++++++++++++++++++++++ Documentation/devicetree/bindings/input/keys.txt | 8 ------ .../devicetree/bindings/input/mtk-pmic-keys.txt | 4 +-- .../devicetree/bindings/input/st,stpmic1-onkey.txt | 2 +- 4 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/input.yaml delete mode 100644 Documentation/devicetree/bindings/input/keys.txt diff --git a/Documentation/devicetree/bindings/input/input.yaml b/Documentation/devicetree/bindings/input/input.yaml new file mode 100644 index 000000000000..ca8fe84a2e62 --- /dev/null +++ b/Documentation/devicetree/bindings/input/input.yaml @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/input.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Common input schema binding + +maintainers: + - Dmitry Torokhov + +properties: + autorepeat: + description: Enable autorepeat when key is pressed and held down. + type: boolean + + linux,keycodes: + description: + Specifies an array of numeric keycode values to be used for reporting + button presses. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - items: + minimum: 0 + maximum: 0xff + + power-off-time-sec: + description: + Duration in seconds which the key should be kept pressed for device to + power off automatically. Device with key pressed shutdown feature can + specify this property. + $ref: /schemas/types.yaml#/definitions/uint32 diff --git a/Documentation/devicetree/bindings/input/keys.txt b/Documentation/devicetree/bindings/input/keys.txt deleted file mode 100644 index f5a5ddde53f1..000000000000 --- a/Documentation/devicetree/bindings/input/keys.txt +++ /dev/null @@ -1,8 +0,0 @@ -General Keys Properties: - -Optional properties for Keys: -- power-off-time-sec: Duration in seconds which the key should be kept - pressed for device to power off automatically. Device with key pressed - shutdown feature can specify this property. -- linux,keycodes: Specifies the numeric keycode values to be used for - reporting key presses. diff --git a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt index 2888d07c2ef0..535d92885372 100644 --- a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt +++ b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt @@ -10,13 +10,13 @@ Documentation/devicetree/bindings/mfd/mt6397.txt Required properties: - compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys" -- linux,keycodes: See Documentation/devicetree/bindings/input/keys.txt +- linux,keycodes: See Documentation/devicetree/bindings/input/input.yaml Optional Properties: - wakeup-source: See Documentation/devicetree/bindings/power/wakeup-source.txt - mediatek,long-press-mode: Long press key shutdown setting, 1 for pwrkey only, 2 for pwrkey/homekey together, others for disabled. -- power-off-time-sec: See Documentation/devicetree/bindings/input/keys.txt +- power-off-time-sec: See Documentation/devicetree/bindings/input/input.yaml Example: diff --git a/Documentation/devicetree/bindings/input/st,stpmic1-onkey.txt b/Documentation/devicetree/bindings/input/st,stpmic1-onkey.txt index 4494613ae7ad..eb8e83736c02 100644 --- a/Documentation/devicetree/bindings/input/st,stpmic1-onkey.txt +++ b/Documentation/devicetree/bindings/input/st,stpmic1-onkey.txt @@ -15,7 +15,7 @@ Optional properties: - st,onkey-pu-inactive: onkey pull up is not active - power-off-time-sec: Duration in seconds which the key should be kept pressed for device to power off automatically (from 1 to 16 seconds). - see See Documentation/devicetree/bindings/input/keys.txt + see See Documentation/devicetree/bindings/input/input.yaml Example: From patchwork Thu Oct 3 06:12:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGFsIFZva8OhxI0=?= X-Patchwork-Id: 11172167 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C5811902 for ; Thu, 3 Oct 2019 06:13:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16D58222CE for ; Thu, 3 Oct 2019 06:13:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ysoft.com header.i=@ysoft.com header.b="Vlq3MXY9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728047AbfJCGND (ORCPT ); Thu, 3 Oct 2019 02:13:03 -0400 Received: from uho.ysoft.cz ([81.19.3.130]:44170 "EHLO uho.ysoft.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727382AbfJCGND (ORCPT ); Thu, 3 Oct 2019 02:13:03 -0400 Received: from iota-build.ysoft.local (unknown [10.1.5.151]) by uho.ysoft.cz (Postfix) with ESMTP id 1427DA0962; Thu, 3 Oct 2019 08:13:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ysoft.com; s=20160406-ysoft-com; t=1570083181; bh=wke8h2wbrfQNZ42H8T4keUHJBoM895dO4SfW7Gsx5cs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vlq3MXY94LPhnRgAvVyr9K4iVpJXW1YJQ56inc7cTe5OOSuFSicFKDKho+ijX9byp nZtPIdNhB4ANQ1G/tzy4AlbO3OUX2r+aNDYdkKaGoPhSbaQhfdXuE8lN6G+9YmUvVy cBIiYmQyIDU49Ij5UN/vXPdC+jC6M9vhpkrwbSws= From: =?utf-8?b?TWljaGFsIFZva8OhxI0=?= To: Dmitry Torokhov , Rob Herring Cc: Shawn Guo , Fabio Estevam , linux-input@vger.kernel.org, devicetree@vger.kernel.org, =?utf-8?b?TWljaGFs?= =?utf-8?b?IFZva8OhxI0=?= Subject: [PATCH v3 2/5] dt-bindings: input: Convert mpr121 binding to json-schema Date: Thu, 3 Oct 2019 08:12:53 +0200 Message-Id: <1570083176-8231-3-git-send-email-michal.vokac@ysoft.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1570083176-8231-1-git-send-email-michal.vokac@ysoft.com> References: <1570083176-8231-1-git-send-email-michal.vokac@ysoft.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Convert the mpr121 binding to DT schema format using json-schema. Signed-off-by: Michal Vokáč Reviewed-by: Rob Herring --- Changes since v2: - None Changes since v1: - Extract the common input properties into the input.yaml schema. - Fix the wakeup-source description. - Fix the example to pass validation. Put the mpr121 device sub-node into a i2c {} node. The linux,keycodes property is not valid as it is. If I put the minItems and maxItems into the common schema, it is valid and the min/max length check works fine. Rob, could you advice how to fix this please? The error is not very specific.. $ make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/input/fsl,mpr121-touchkey.yaml SCHEMA Documentation/devicetree/bindings/processed-schema.yaml /home/vokac/development/sources/linux-fslc/Documentation/devicetree/bindings/input/fsl,mpr121-touchkey.yaml: ignoring, error in schema 'linux,ke warning: no schema found in file: /home/vokac/development/sources/linux-fslc/Documentation/devicetree/bindings/input/fsl,mpr121-touchkey.yaml /home/vokac/development/sources/linux-fslc/Documentation/devicetree/bindings/Makefile:33: recipe for target 'Documentation/devicetree/bindings/p make[3]: *** [Documentation/devicetree/bindings/processed-schema.yaml] Error 255 /home/vokac/development/sources/linux-fslc/Makefile:1264: recipe for target 'dt_binding_check' failed .../bindings/input/fsl,mpr121-touchkey.yaml | 66 ++++++++++++++++++++++ .../devicetree/bindings/input/mpr121-touchkey.txt | 30 ---------- 2 files changed, 66 insertions(+), 30 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/fsl,mpr121-touchkey.yaml delete mode 100644 Documentation/devicetree/bindings/input/mpr121-touchkey.txt diff --git a/Documentation/devicetree/bindings/input/fsl,mpr121-touchkey.yaml b/Documentation/devicetree/bindings/input/fsl,mpr121-touchkey.yaml new file mode 100644 index 000000000000..c6fbcdf78556 --- /dev/null +++ b/Documentation/devicetree/bindings/input/fsl,mpr121-touchkey.yaml @@ -0,0 +1,66 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/fsl,mpr121-touchkey.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Freescale MPR121 capacitive touch sensor controller + +maintainers: + - Dmitry Torokhov + +description: | + The MPR121 supports up to 12 completely independent electrodes/capacitance + sensing inputs in which 8 are multifunctional for LED driving and GPIO. + https://www.nxp.com/docs/en/data-sheet/MPR121.pdf + +allOf: + - $ref: input.yaml# + +properties: + compatible: + const: fsl,mpr121-touchkey + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vdd-supply: + maxItems: 1 + + linux,keycodes: + minItems: 1 + maxItems: 12 + + wakeup-source: + description: Use any event on keypad as wakeup event. + type: boolean + +required: + - compatible + - reg + - interrupts + - vdd-supply + - linux,keycodes + +examples: + - | + #include "dt-bindings/input/input.h" + i2c { + #address-cells = <1>; + #size-cells = <0>; + + mpr121@5a { + compatible = "fsl,mpr121-touchkey"; + reg = <0x5a>; + interrupt-parent = <&gpio1>; + interrupts = <28 2>; + autorepeat; + vdd-supply = <&ldo4_reg>; + linux,keycodes = , , , , + , , , , + , , , ; + }; + }; diff --git a/Documentation/devicetree/bindings/input/mpr121-touchkey.txt b/Documentation/devicetree/bindings/input/mpr121-touchkey.txt deleted file mode 100644 index b7c61ee5841b..000000000000 --- a/Documentation/devicetree/bindings/input/mpr121-touchkey.txt +++ /dev/null @@ -1,30 +0,0 @@ -* Freescale MPR121 Controllor - -Required Properties: -- compatible: Should be "fsl,mpr121-touchkey" -- reg: The I2C slave address of the device. -- interrupts: The interrupt number to the cpu. -- vdd-supply: Phandle to the Vdd power supply. -- linux,keycodes: Specifies an array of numeric keycode values to - be used for reporting button presses. The array can - contain up to 12 entries. - -Optional Properties: -- wakeup-source: Use any event on keypad as wakeup event. -- autorepeat: Enable autorepeat feature. - -Example: - -#include "dt-bindings/input/input.h" - - touchkey: mpr121@5a { - compatible = "fsl,mpr121-touchkey"; - reg = <0x5a>; - interrupt-parent = <&gpio1>; - interrupts = <28 2>; - autorepeat; - vdd-supply = <&ldo4_reg>; - linux,keycodes = , , , , - , , , - , , , ; - }; From patchwork Thu Oct 3 06:12:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGFsIFZva8OhxI0=?= X-Patchwork-Id: 11172169 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB1C3139A for ; Thu, 3 Oct 2019 06:13:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 98B1D222CE for ; Thu, 3 Oct 2019 06:13:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ysoft.com header.i=@ysoft.com header.b="VXlKrOCX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725874AbfJCGND (ORCPT ); Thu, 3 Oct 2019 02:13:03 -0400 Received: from uho.ysoft.cz ([81.19.3.130]:44178 "EHLO uho.ysoft.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727587AbfJCGND (ORCPT ); Thu, 3 Oct 2019 02:13:03 -0400 Received: from iota-build.ysoft.local (unknown [10.1.5.151]) by uho.ysoft.cz (Postfix) with ESMTP id 3BE37A0973; Thu, 3 Oct 2019 08:13:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ysoft.com; s=20160406-ysoft-com; t=1570083181; bh=oIkokaJCWSqaC/MedpRmpwQpGjqjHo/ZVzfOZeqsW7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VXlKrOCX494qkZhWWBl8z/EKmVHGAZPXGKrEcaMkcFMBDAUqlelwpBBPMCSazjWs5 ay7kf0rGeWqbSRFR8qtURyvozFED66cP7HqJW5KMCwXK4SzCPX6Az0pSSpIFPQbv7Q 7ZR862+7j/EvhXN1OeaofSGP7h3TxTxOSdAcLsyE= From: =?utf-8?b?TWljaGFsIFZva8OhxI0=?= To: Dmitry Torokhov , Rob Herring Cc: Shawn Guo , Fabio Estevam , linux-input@vger.kernel.org, devicetree@vger.kernel.org, =?utf-8?b?TWljaGFs?= =?utf-8?b?IFZva8OhxI0=?= Subject: [PATCH v3 3/5] dt-bindings: input: Add poll-interval property Date: Thu, 3 Oct 2019 08:12:54 +0200 Message-Id: <1570083176-8231-4-git-send-email-michal.vokac@ysoft.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1570083176-8231-1-git-send-email-michal.vokac@ysoft.com> References: <1570083176-8231-1-git-send-email-michal.vokac@ysoft.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add an option to periodicaly poll the device to get state of the inputs as the interrupt line may not be used on some platforms. Signed-off-by: Michal Vokáč Reviewed-by: Rob Herring --- Changes since v2: - None Changes since v1: - Use poll-interval instead of linux,poll-interval. - Place the poll-interval binding into the common schema. - Properly describe that either interrupts or poll-interval property is required. - Fix the example to pass validation. .../bindings/input/fsl,mpr121-touchkey.yaml | 25 +++++++++++++++++++++- Documentation/devicetree/bindings/input/input.yaml | 4 ++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/input/fsl,mpr121-touchkey.yaml b/Documentation/devicetree/bindings/input/fsl,mpr121-touchkey.yaml index c6fbcdf78556..035b2fee4491 100644 --- a/Documentation/devicetree/bindings/input/fsl,mpr121-touchkey.yaml +++ b/Documentation/devicetree/bindings/input/fsl,mpr121-touchkey.yaml @@ -17,6 +17,10 @@ description: | allOf: - $ref: input.yaml# +oneOf: + - required: [ interrupts ] + - required: [ poll-interval ] + properties: compatible: const: fsl,mpr121-touchkey @@ -41,12 +45,12 @@ properties: required: - compatible - reg - - interrupts - vdd-supply - linux,keycodes examples: - | + // Example with interrupts #include "dt-bindings/input/input.h" i2c { #address-cells = <1>; @@ -64,3 +68,22 @@ examples: , , , ; }; }; + + - | + // Example with polling + #include "dt-bindings/input/input.h" + i2c { + #address-cells = <1>; + #size-cells = <0>; + + mpr121@5a { + compatible = "fsl,mpr121-touchkey"; + reg = <0x5a>; + poll-interval = <20>; + autorepeat; + vdd-supply = <&ldo4_reg>; + linux,keycodes = , , , , + , , , , + , , , ; + }; + }; diff --git a/Documentation/devicetree/bindings/input/input.yaml b/Documentation/devicetree/bindings/input/input.yaml index ca8fe84a2e62..6d519046b3af 100644 --- a/Documentation/devicetree/bindings/input/input.yaml +++ b/Documentation/devicetree/bindings/input/input.yaml @@ -24,6 +24,10 @@ properties: minimum: 0 maximum: 0xff + poll-interval: + description: Poll interval time in milliseconds. + $ref: /schemas/types.yaml#/definitions/uint32 + power-off-time-sec: description: Duration in seconds which the key should be kept pressed for device to From patchwork Thu Oct 3 06:12:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGFsIFZva8OhxI0=?= X-Patchwork-Id: 11172173 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 263C9195A for ; Thu, 3 Oct 2019 06:13:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EEC22222C3 for ; Thu, 3 Oct 2019 06:13:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ysoft.com header.i=@ysoft.com header.b="gXhGxtVa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728061AbfJCGND (ORCPT ); Thu, 3 Oct 2019 02:13:03 -0400 Received: from uho.ysoft.cz ([81.19.3.130]:44186 "EHLO uho.ysoft.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727259AbfJCGND (ORCPT ); Thu, 3 Oct 2019 02:13:03 -0400 Received: from iota-build.ysoft.local (unknown [10.1.5.151]) by uho.ysoft.cz (Postfix) with ESMTP id 716A8A0977; Thu, 3 Oct 2019 08:13:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ysoft.com; s=20160406-ysoft-com; t=1570083181; bh=sDhAcmy0v+OgVf0jXfuCTQcjSqcE9lp3+uJN92xToZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gXhGxtVaL9IVFMS+evKfshej9cFhsVjhzODMxrTa4Pqalbw5kQvnTRN3Cp2hwG+qY 7fu+tdNQLibLv3ps3v1m06LwP8IrnW0Tr/YaWEbueEJNEWVk70GwSHDLM+VtzP0BQT jn7L8B8hiPveETnvj1su6rvhHjhTxI0YjzIpsmsU= From: =?utf-8?b?TWljaGFsIFZva8OhxI0=?= To: Dmitry Torokhov , Rob Herring Cc: Shawn Guo , Fabio Estevam , linux-input@vger.kernel.org, devicetree@vger.kernel.org, =?utf-8?b?TWljaGFs?= =?utf-8?b?IFZva8OhxI0=?= Subject: [PATCH v3 4/5] Input: mpr121: Add polling mode Date: Thu, 3 Oct 2019 08:12:55 +0200 Message-Id: <1570083176-8231-5-git-send-email-michal.vokac@ysoft.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1570083176-8231-1-git-send-email-michal.vokac@ysoft.com> References: <1570083176-8231-1-git-send-email-michal.vokac@ysoft.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org In case the interrupt line is not available, polling can be used to read out the state of the keys. Period of the polling needs to be configured by the poll-interval DT property. Signed-off-by: Michal Vokáč --- Changes since v2: - None Changes since v1: - Use poll-interval property name instead of linux,poll-interval. drivers/input/keyboard/mpr121_touchkey.c | 69 +++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/drivers/input/keyboard/mpr121_touchkey.c b/drivers/input/keyboard/mpr121_touchkey.c index ee80de44ce3f..40d6e5087cde 100644 --- a/drivers/input/keyboard/mpr121_touchkey.c +++ b/drivers/input/keyboard/mpr121_touchkey.c @@ -54,6 +54,9 @@ /* MPR121 has 12 keys */ #define MPR121_MAX_KEY_COUNT 12 +#define MPR121_MIN_POLL_INTERVAL 10 +#define MPR121_MAX_POLL_INTERVAL 200 + struct mpr121_touchkey { struct i2c_client *client; struct input_dev *input_dev; @@ -115,11 +118,11 @@ static struct regulator *mpr121_vdd_supply_init(struct device *dev) return vdd_supply; } -static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id) +static void mpr_touchkey_report(struct input_dev *dev) { - struct mpr121_touchkey *mpr121 = dev_id; - struct i2c_client *client = mpr121->client; + struct mpr121_touchkey *mpr121 = input_get_drvdata(dev); struct input_dev *input = mpr121->input_dev; + struct i2c_client *client = mpr121->client; unsigned long bit_changed; unsigned int key_num; int reg; @@ -127,14 +130,14 @@ static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id) reg = i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_1_ADDR); if (reg < 0) { dev_err(&client->dev, "i2c read error [%d]\n", reg); - goto out; + return; } reg <<= 8; reg |= i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_0_ADDR); if (reg < 0) { dev_err(&client->dev, "i2c read error [%d]\n", reg); - goto out; + return; } reg &= TOUCH_STATUS_MASK; @@ -155,8 +158,14 @@ static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id) } input_sync(input); +} + +static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id) +{ + struct mpr121_touchkey *mpr121 = dev_id; + + mpr_touchkey_report(mpr121->input_dev); -out: return IRQ_HANDLED; } @@ -229,14 +238,10 @@ static int mpr_touchkey_probe(struct i2c_client *client, int vdd_uv; struct mpr121_touchkey *mpr121; struct input_dev *input_dev; + u32 poll_interval = 0; int error; int i; - if (!client->irq) { - dev_err(dev, "irq number should not be zero\n"); - return -EINVAL; - } - vdd_supply = mpr121_vdd_supply_init(dev); if (IS_ERR(vdd_supply)) return PTR_ERR(vdd_supply); @@ -274,6 +279,7 @@ static int mpr_touchkey_probe(struct i2c_client *client, if (device_property_read_bool(dev, "autorepeat")) __set_bit(EV_REP, input_dev->evbit); input_set_capability(input_dev, EV_MSC, MSC_SCAN); + input_set_drvdata(input_dev, mpr121); input_dev->keycode = mpr121->keycodes; input_dev->keycodesize = sizeof(mpr121->keycodes[0]); @@ -288,13 +294,40 @@ static int mpr_touchkey_probe(struct i2c_client *client, return error; } - error = devm_request_threaded_irq(dev, client->irq, NULL, - mpr_touchkey_interrupt, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - dev->driver->name, mpr121); - if (error) { - dev_err(dev, "Failed to register interrupt\n"); - return error; + device_property_read_u32(dev, "poll-interval", &poll_interval); + + if (client->irq) { + error = devm_request_threaded_irq(dev, client->irq, NULL, + mpr_touchkey_interrupt, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + dev->driver->name, mpr121); + if (error) { + dev_err(dev, "Failed to register interrupt\n"); + return error; + } + } else if (poll_interval) { + if (poll_interval < MPR121_MIN_POLL_INTERVAL) + return -EINVAL; + + if (poll_interval > MPR121_MAX_POLL_INTERVAL) + return -EINVAL; + + error = input_setup_polling(input_dev, mpr_touchkey_report); + if (error) { + dev_err(dev, "Failed to setup polling\n"); + return error; + } + + input_set_poll_interval(input_dev, poll_interval); + input_set_min_poll_interval(input_dev, + MPR121_MIN_POLL_INTERVAL); + input_set_max_poll_interval(input_dev, + MPR121_MAX_POLL_INTERVAL); + } else { + dev_err(dev, + "invalid IRQ number and polling not configured\n"); + return -EINVAL; } error = input_register_device(input_dev); From patchwork Thu Oct 3 06:12:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGFsIFZva8OhxI0=?= X-Patchwork-Id: 11172175 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CAE031709 for ; Thu, 3 Oct 2019 06:13:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E0FC218DE for ; Thu, 3 Oct 2019 06:13:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ysoft.com header.i=@ysoft.com header.b="jzXNuTst" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728117AbfJCGNF (ORCPT ); Thu, 3 Oct 2019 02:13:05 -0400 Received: from uho.ysoft.cz ([81.19.3.130]:44198 "EHLO uho.ysoft.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728049AbfJCGNE (ORCPT ); Thu, 3 Oct 2019 02:13:04 -0400 Received: from iota-build.ysoft.local (unknown [10.1.5.151]) by uho.ysoft.cz (Postfix) with ESMTP id 984FBA097E; Thu, 3 Oct 2019 08:13:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ysoft.com; s=20160406-ysoft-com; t=1570083181; bh=xdnbhlP5VZbX9psldGdVTegnvgtlaS1Fp9fUYQIGahc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jzXNuTstAvIRcwxw0uaMz8WP5eiNlVYqcxVHcXy6k2MuFix+Owq2QWpSAN4aZHoTZ OsDVix5LvcztbDzQS720x6g7Xtc1wTTvUTgeeM8wFpvxwlF1IWwAwiUMsh15uUv4+m RetB633fnFBW7m/qIfY4BBwCT/FiW/fP1kqwHtrQ= From: =?utf-8?b?TWljaGFsIFZva8OhxI0=?= To: Dmitry Torokhov , Rob Herring Cc: Shawn Guo , Fabio Estevam , linux-input@vger.kernel.org, devicetree@vger.kernel.org, =?utf-8?b?TWljaGFs?= =?utf-8?b?IFZva8OhxI0=?= Subject: [PATCH v3 5/5] ARM: dts: imx6dl-yapp4: Enable the MPR121 touchkey controller on Hydra Date: Thu, 3 Oct 2019 08:12:56 +0200 Message-Id: <1570083176-8231-6-git-send-email-michal.vokac@ysoft.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1570083176-8231-1-git-send-email-michal.vokac@ysoft.com> References: <1570083176-8231-1-git-send-email-michal.vokac@ysoft.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add the touch keyboard present on Hydra board. The controller is connected only using I2C lines. The interrupt line is not available hence we use the polling mode. Signed-off-by: Michal Vokáč --- Changes since v2: - None Changes since v1: - Use poll-interval property name instead of linux,poll-interval. arch/arm/boot/dts/imx6dl-yapp4-common.dtsi | 13 +++++++++++++ arch/arm/boot/dts/imx6dl-yapp4-hydra.dts | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/arch/arm/boot/dts/imx6dl-yapp4-common.dtsi b/arch/arm/boot/dts/imx6dl-yapp4-common.dtsi index e8d800fec637..6507bfc0141a 100644 --- a/arch/arm/boot/dts/imx6dl-yapp4-common.dtsi +++ b/arch/arm/boot/dts/imx6dl-yapp4-common.dtsi @@ -4,6 +4,7 @@ #include #include +#include #include / { @@ -330,6 +331,18 @@ vcc-supply = <&sw2_reg>; status = "disabled"; }; + + touchkeys: keys@5a { + compatible = "fsl,mpr121-touchkey"; + reg = <0x5a>; + vdd-supply = <&sw2_reg>; + autorepeat; + linux,keycodes = , , , , , + , , , , + , , ; + poll-interval = <50>; + status = "disabled"; + }; }; &iomuxc { diff --git a/arch/arm/boot/dts/imx6dl-yapp4-hydra.dts b/arch/arm/boot/dts/imx6dl-yapp4-hydra.dts index f97927064750..84c275bfdd38 100644 --- a/arch/arm/boot/dts/imx6dl-yapp4-hydra.dts +++ b/arch/arm/boot/dts/imx6dl-yapp4-hydra.dts @@ -45,6 +45,10 @@ status = "okay"; }; +&touchkeys { + status = "okay"; +}; + &usdhc3 { status = "okay"; };