From patchwork Tue Oct 1 14:29:36 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: 11168925 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 4D1221709 for ; Tue, 1 Oct 2019 14:29:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F8CB2086A for ; Tue, 1 Oct 2019 14:29:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ysoft.com header.i=@ysoft.com header.b="cAuoUUt/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388954AbfJAO35 (ORCPT ); Tue, 1 Oct 2019 10:29:57 -0400 Received: from uho.ysoft.cz ([81.19.3.130]:56398 "EHLO uho.ysoft.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388922AbfJAO3z (ORCPT ); Tue, 1 Oct 2019 10:29:55 -0400 Received: from iota-build.ysoft.local (unknown [10.1.5.151]) by uho.ysoft.cz (Postfix) with ESMTP id 286E6A06E5; Tue, 1 Oct 2019 16:29:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ysoft.com; s=20160406-ysoft-com; t=1569940193; bh=T5y8rYo1ChPRnQan76zQKfnGw0/ifzLo7zhRzVnYC5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cAuoUUt/W4Fb5y07V6+Mywf47w2NHRYYpM4EgjijT0sPrF7Ov1VuSkaEGkw66ek09 +i7MtbM6exlihGkpAr6s2JxQrDe1oEiCgpxZf7AG23LAfMNLgiT4JrdxuC0Cf0XaE+ b/NRrtUNnsQHMkdCez62nTGP0UbuB5jXfNBwZcdk= 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 v2 1/5] dt-bindings: input: Add common input binding in json-schema Date: Tue, 1 Oct 2019 16:29:36 +0200 Message-Id: <1569940180-11417-2-git-send-email-michal.vokac@ysoft.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1569940180-11417-1-git-send-email-michal.vokac@ysoft.com> References: <1569940180-11417-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. Signed-off-by: Michal Vokáč --- Changes since v1: - New patch in the series. Rob, you suggested to extract the common properties from fsl,mpr121-touchkey.yaml into this file. In the meantime I realized that the linux,keycodes property is already documented in keys.txt. What do you suggest to do? Some possible options: - Just remove the linux,keycodes propery from keys.txt. - Merge this input.yaml with all content of keys.txt. How to name the result? - Something else? Documentation/devicetree/bindings/input/input.yaml | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/input.yaml diff --git a/Documentation/devicetree/bindings/input/input.yaml b/Documentation/devicetree/bindings/input/input.yaml new file mode 100644 index 000000000000..494e7d031ea3 --- /dev/null +++ b/Documentation/devicetree/bindings/input/input.yaml @@ -0,0 +1,25 @@ +# 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: + linux,keycodes: + description: + Specifies an array of numeric keycode values to be used for reporting + button presses. The array can contain up to 12 entries. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - items: + minimum: 0 + maximum: 0xff + + autorepeat: + description: Enable autorepeat when key is pressed and held down. + type: boolean From patchwork Tue Oct 1 14:29:37 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: 11168917 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 458D71709 for ; Tue, 1 Oct 2019 14:29:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2437421906 for ; Tue, 1 Oct 2019 14:29:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ysoft.com header.i=@ysoft.com header.b="DkIs+YUN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388931AbfJAO3z (ORCPT ); Tue, 1 Oct 2019 10:29:55 -0400 Received: from uho.ysoft.cz ([81.19.3.130]:56410 "EHLO uho.ysoft.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387581AbfJAO3z (ORCPT ); Tue, 1 Oct 2019 10:29:55 -0400 Received: from iota-build.ysoft.local (unknown [10.1.5.151]) by uho.ysoft.cz (Postfix) with ESMTP id 4FB9FA2404; Tue, 1 Oct 2019 16:29:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ysoft.com; s=20160406-ysoft-com; t=1569940193; bh=VN7qskQAVyh3tRWO2kLLTeHCGTrYt/Z/8M7iu5AsLpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DkIs+YUNhpQI6puCAucuP8xjYM3K41pd0jUQPrNmre6O5jP+V4DVnkD4yMRopIJMS 5CKptkHV/+h5T7mOuxuhXWan2r6T7jDNXFkEMhz40dnxRTJZla9DvEazF4zEaXTtwT NBCZyEoNN42VDkceC/KxvkkbL9gXQW8YsXMgIzDg= 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 v2 2/5] dt-bindings: input: Convert mpr121 binding to json-schema Date: Tue, 1 Oct 2019 16:29:37 +0200 Message-Id: <1569940180-11417-3-git-send-email-michal.vokac@ysoft.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1569940180-11417-1-git-send-email-michal.vokac@ysoft.com> References: <1569940180-11417-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áč --- 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. Rob, 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. What could be wrong? 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,keycodes' 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/processed-schema.yaml' failed 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 Tue Oct 1 14:29:38 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: 11168921 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 4D7A11709 for ; Tue, 1 Oct 2019 14:29:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 222CF21855 for ; Tue, 1 Oct 2019 14:29:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ysoft.com header.i=@ysoft.com header.b="Peuh7/He" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388925AbfJAO34 (ORCPT ); Tue, 1 Oct 2019 10:29:56 -0400 Received: from uho.ysoft.cz ([81.19.3.130]:56418 "EHLO uho.ysoft.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727018AbfJAO3z (ORCPT ); Tue, 1 Oct 2019 10:29:55 -0400 Received: from iota-build.ysoft.local (unknown [10.1.5.151]) by uho.ysoft.cz (Postfix) with ESMTP id 788E6A078B; Tue, 1 Oct 2019 16:29:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ysoft.com; s=20160406-ysoft-com; t=1569940193; bh=xBMl9U1gJeO+OggxuC6OMHUmFd5fnSDNMzUpQFCCr7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Peuh7/HexD4GCEsDyedNEY/DnA2fgAvBq3bhfMC1y08DffwtmMM/1ssHpicdMCi7y zZOUygJQDOCr+2HTLRZ83Sd9HNE1j7nYPuQczmz+c0eImQVUQv1wDnVjdAbqOS4kRc g4VLpnTrvQv1CmgNkO+Aif77DbxPNxaip14AggwE= 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 v2 3/5] dt-bindings: input: Add poll-interval property Date: Tue, 1 Oct 2019 16:29:38 +0200 Message-Id: <1569940180-11417-4-git-send-email-michal.vokac@ysoft.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1569940180-11417-1-git-send-email-michal.vokac@ysoft.com> References: <1569940180-11417-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áč --- 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 494e7d031ea3..cc5f9e8a3c01 100644 --- a/Documentation/devicetree/bindings/input/input.yaml +++ b/Documentation/devicetree/bindings/input/input.yaml @@ -23,3 +23,7 @@ properties: autorepeat: description: Enable autorepeat when key is pressed and held down. type: boolean + + poll-interval: + description: Poll interval time in milliseconds. + $ref: /schemas/types.yaml#/definitions/uint32 From patchwork Tue Oct 1 14:29:39 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: 11168919 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 A5AA91920 for ; Tue, 1 Oct 2019 14:29:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8333521D81 for ; Tue, 1 Oct 2019 14:29:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ysoft.com header.i=@ysoft.com header.b="F9oMFiHz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387581AbfJAO3z (ORCPT ); Tue, 1 Oct 2019 10:29:55 -0400 Received: from uho.ysoft.cz ([81.19.3.130]:56426 "EHLO uho.ysoft.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388925AbfJAO3z (ORCPT ); Tue, 1 Oct 2019 10:29:55 -0400 Received: from iota-build.ysoft.local (unknown [10.1.5.151]) by uho.ysoft.cz (Postfix) with ESMTP id A9C2CA2405; Tue, 1 Oct 2019 16:29:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ysoft.com; s=20160406-ysoft-com; t=1569940193; bh=ZfFAl5slIX6BZUhMX14bAZoNHkJmdi7i65/tACs7alY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F9oMFiHz1s9imdLragvWtkGbokmKirB+pac3YRJA2TfW4SCLWc8j4Dk7MTgw/pkIg sqL315c2SxSepvd0Z9Tnc4nQq/Y4BRxbA12RZIx+lLqQpnLKRpQbG3IE+qftkHC9S5 4IHovUfTFeVbeCovcKBjPahwEr9YnBj/zACZqK7M= 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 v2 4/5] Input: mpr121: Add polling mode Date: Tue, 1 Oct 2019 16:29:39 +0200 Message-Id: <1569940180-11417-5-git-send-email-michal.vokac@ysoft.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1569940180-11417-1-git-send-email-michal.vokac@ysoft.com> References: <1569940180-11417-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 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 Tue Oct 1 14:29:40 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: 11168923 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 A36541747 for ; Tue, 1 Oct 2019 14:29:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7187E21855 for ; Tue, 1 Oct 2019 14:29:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ysoft.com header.i=@ysoft.com header.b="SPYTYToX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727018AbfJAO34 (ORCPT ); Tue, 1 Oct 2019 10:29:56 -0400 Received: from uho.ysoft.cz ([81.19.3.130]:56434 "EHLO uho.ysoft.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388919AbfJAO34 (ORCPT ); Tue, 1 Oct 2019 10:29:56 -0400 Received: from iota-build.ysoft.local (unknown [10.1.5.151]) by uho.ysoft.cz (Postfix) with ESMTP id CFFAAA2406; Tue, 1 Oct 2019 16:29:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ysoft.com; s=20160406-ysoft-com; t=1569940193; bh=JEQ0Zhzqtv0m8dZrNqigOmsZVclmMwiqAsUiORb5z80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SPYTYToXVD+7nB1XgQ81/afNBGtxeFTS6wP+vDCzaMlh2n+7Br8zJbBLKhq8bjQEH Nn2oIkkpg/5zZBThfzgMes9ac5uHWsfoJZUPbpXAib8rGOF5Cy5fspTP0/9wZt07Vz xstAdhgugdFeitsFcPz7GhW7RCUzwvL7dL3M5cQY= 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 v2 5/5] ARM: dts: imx6dl-yapp4: Enable the MPR121 touchkey controller on Hydra Date: Tue, 1 Oct 2019 16:29:40 +0200 Message-Id: <1569940180-11417-6-git-send-email-michal.vokac@ysoft.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1569940180-11417-1-git-send-email-michal.vokac@ysoft.com> References: <1569940180-11417-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 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"; };