From patchwork Thu Jan 6 07:28:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Travkin X-Patchwork-Id: 12705177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AA90C433EF for ; Thu, 6 Jan 2022 07:29:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235641AbiAFH3F (ORCPT ); Thu, 6 Jan 2022 02:29:05 -0500 Received: from box.trvn.ru ([194.87.146.52]:38493 "EHLO box.trvn.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235610AbiAFH3E (ORCPT ); Thu, 6 Jan 2022 02:29:04 -0500 Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id 2B49642064; Thu, 6 Jan 2022 12:29:01 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1641454141; bh=YGq3tK4Qa1gT0lBwrqqbtBTes6WWGLWzf8xd1+IjiT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T5e2E5FoiHzX2Sr198cDknRr8t2aKUCHJvlwt2mT2ZClqgXjVRqte4zpIJMGrgnH1 vv/VnFJ2fdLYPbBHL8N3afCbZSgfZqSIou3k6ia9kybz3qWuwu3/XoTnsfWzFql3Bm s7SKSVfD1+IMfPtVmQ0+yfahRD2m4VsCCIEOM+6eaw1P3ChfBs7oqXkAzRNa6kb3mL pMcjXd55Ug1CiVaO/VeBu6EDTrQvU9LBibU5kHo4PcUTk1X0ZQt8adA/gvjvYwui/e yFSQdkGCZP0oK5iYhaLeeqRajWW54C7BDBggHyWFCD/ecDpw+eOc9vzByFTQClT2uq Y/q12tAf5REXg== From: Nikita Travkin To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, Michael.Srba@seznam.cz, linus.walleij@linaro.org, broonie@kernel.org, luca@z3ntu.xyz, linux-input@vger.kernel.org, devicetree@vger.kernel.org, phone-devel@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Nikita Travkin Subject: [PATCH v3 1/6] input: zinitix: Make sure the IRQ is allocated before it gets enabled Date: Thu, 6 Jan 2022 12:28:35 +0500 Message-Id: <20220106072840.36851-2-nikita@trvn.ru> In-Reply-To: <20220106072840.36851-1-nikita@trvn.ru> References: <20220106072840.36851-1-nikita@trvn.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Since irq request is the last thing in the driver probe, it happens later than the input device registration. This means that there is a small time window where if the open method is called the driver will attempt to enable not yet available irq. Fix that by moving the irq request before the input device registration. Reviewed-by: Linus Walleij Fixes: 26822652c85e ("Input: add zinitix touchscreen driver") Signed-off-by: Nikita Travkin --- drivers/input/touchscreen/zinitix.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c index b8d901099378..1e70b8d2a8d7 100644 --- a/drivers/input/touchscreen/zinitix.c +++ b/drivers/input/touchscreen/zinitix.c @@ -488,6 +488,15 @@ static int zinitix_ts_probe(struct i2c_client *client) return error; } + error = devm_request_threaded_irq(&client->dev, client->irq, + NULL, zinitix_ts_irq_handler, + IRQF_ONESHOT | IRQF_NO_AUTOEN, + client->name, bt541); + if (error) { + dev_err(&client->dev, "Failed to request IRQ: %d\n", error); + return error; + } + error = zinitix_init_input_dev(bt541); if (error) { dev_err(&client->dev, @@ -513,15 +522,6 @@ static int zinitix_ts_probe(struct i2c_client *client) return -EINVAL; } - error = devm_request_threaded_irq(&client->dev, client->irq, - NULL, zinitix_ts_irq_handler, - IRQF_ONESHOT | IRQF_NO_AUTOEN, - client->name, bt541); - if (error) { - dev_err(&client->dev, "Failed to request IRQ: %d\n", error); - return error; - } - return 0; } From patchwork Thu Jan 6 07:28:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Travkin X-Patchwork-Id: 12705178 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C880C433F5 for ; Thu, 6 Jan 2022 07:29:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235662AbiAFH3F (ORCPT ); Thu, 6 Jan 2022 02:29:05 -0500 Received: from box.trvn.ru ([194.87.146.52]:49453 "EHLO box.trvn.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235612AbiAFH3E (ORCPT ); Thu, 6 Jan 2022 02:29:04 -0500 Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id E5E364285E; Thu, 6 Jan 2022 12:29:01 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1641454142; bh=Onf6EQi/egtn2QPY2nKoZCNdgHfMJXA66JIUj5ords0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AkUWmWHEnjPs+MNm9J4DR6e6lqc8OPGmpjdr7133QK/39gn7PVXQwJPxwl5Y1fqjo lrKTU7t3KDg+z3aVX2N1wsx8ZmXc4LAvBbGK2mBBLrnaBPUefbtIFeDGjp0L608LsI dOuPIpcRFq2byYG1bh9phofa1+LxGIg766sn+Op70cRV2ix510GagqXweNYfBKHX2T ysNloMGcKiz2ISXmmzF3558wWDvPOfl7/F+Ppji1V/xbvv2RToSsVUEaTUvAU8GNGH HNCAK1daxEV5XG44TW1OVXFCM2jGYG7hBGFAfV1t3SBfo1cTpVnjVUOXxM1fsT7MgC S9DJ8n5QicI4g== From: Nikita Travkin To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, Michael.Srba@seznam.cz, linus.walleij@linaro.org, broonie@kernel.org, luca@z3ntu.xyz, linux-input@vger.kernel.org, devicetree@vger.kernel.org, phone-devel@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Rob Herring , Nikita Travkin Subject: [PATCH v3 2/6] dt-bindings: input/ts/zinitix: Convert to YAML, fix and extend Date: Thu, 6 Jan 2022 12:28:36 +0500 Message-Id: <20220106072840.36851-3-nikita@trvn.ru> In-Reply-To: <20220106072840.36851-1-nikita@trvn.ru> References: <20220106072840.36851-1-nikita@trvn.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Linus Walleij This converts the Zinitix BT4xx and BT5xx touchscreen bindings to YAML, fix them up a bit and extends them. We list all the existing BT4xx and BT5xx components with compatible strings. These are all similar, use the same bindings and work in similar ways. We rename the supplies from the erroneous vdd/vddo to the actual supply names vcca/vdd as specified on the actual component. It is long established that supplies shall be named after the supply pin names of a component. The confusion probably stems from that in a certain product the rails to the component were named vdd/vddo. Drop some notes on how OS implementations should avoid confusion by first looking for vddo, and if that exists assume the legacy binding pair and otherwise use vcca/vdd. Add reset-gpios as sometimes manufacturers pulls a GPIO line to the reset line on the chip. Add optional touchscreen-fuzz-x and touchscreen-fuzz-y properties. Cc: Mark Brown Cc: Michael Srba Cc: phone-devel@vger.kernel.org Cc: devicetree@vger.kernel.org Reviewed-by: Rob Herring Signed-off-by: Linus Walleij [Fixed dt_schema_check] Signed-off-by: Nikita Travkin --- This patch was previously submitted here: https://lore.kernel.org/linux-input/20210625113435.2539282-1-linus.walleij@linaro.org/ Changes since the original patch: - Use enum for compatible list instead of oneOf + const --- .../input/touchscreen/zinitix,bt400.yaml | 115 ++++++++++++++++++ .../bindings/input/touchscreen/zinitix.txt | 40 ------ 2 files changed, 115 insertions(+), 40 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/zinitix.txt diff --git a/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml b/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml new file mode 100644 index 000000000000..b4e5ba7c0b49 --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml @@ -0,0 +1,115 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/zinitix,bt400.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Zinitix BT4xx and BT5xx series touchscreen controller bindings + +description: The Zinitix BT4xx and BT5xx series of touchscreen controllers + are Korea-produced touchscreens with embedded microcontrollers. The + BT4xx series was produced 2010-2013 and the BT5xx series 2013-2014. + +maintainers: + - Michael Srba + - Linus Walleij + +allOf: + - $ref: touchscreen.yaml# + +properties: + $nodename: + pattern: "^touchscreen(@.*)?$" + + compatible: + enum: + - zinitix,bt402 + - zinitix,bt403 + - zinitix,bt404 + - zinitix,bt412 + - zinitix,bt413 + - zinitix,bt431 + - zinitix,bt432 + - zinitix,bt531 + - zinitix,bt532 + - zinitix,bt538 + - zinitix,bt541 + - zinitix,bt548 + - zinitix,bt554 + - zinitix,at100 + + reg: + description: I2C address on the I2C bus + + clock-frequency: + description: I2C client clock frequency, defined for host when using + the device on the I2C bus + minimum: 0 + maximum: 400000 + + interrupts: + description: Interrupt to host + maxItems: 1 + + vcca-supply: + description: Analog power supply regulator on the VCCA pin + + vdd-supply: + description: Digital power supply regulator on the VDD pin. + In older device trees this can be the accidental name for the analog + supply on the VCCA pin, and in that case the deprecated vddo-supply is + used for the digital power supply. + + vddo-supply: + description: Deprecated name for the digital power supply, use vdd-supply + as this reflects the real name of the pin. If this supply is present, + the vdd-supply represents VCCA instead of VDD. Implementers should first + check for this property, and if it is present assume that the vdd-supply + represents the analog supply. + deprecated: true + + reset-gpios: + description: Reset line for the touchscreen, should be tagged + as GPIO_ACTIVE_LOW + + zinitix,mode: + description: Mode of reporting touch points. Some modes may not work + with a particular ts firmware for unknown reasons. Available modes are + 1 and 2. Mode 2 is the default and preferred. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2] + + touchscreen-size-x: true + touchscreen-size-y: true + touchscreen-fuzz-x: true + touchscreen-fuzz-y: true + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + - touchscreen-size-x + - touchscreen-size-y + +examples: + - | + #include + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + touchscreen@20 { + compatible = "zinitix,bt541"; + reg = <0x20>; + interrupt-parent = <&gpio>; + interrupts = <13 IRQ_TYPE_EDGE_FALLING>; + vcca-supply = <®_vcca_tsp>; + vdd-supply = <®_vdd_tsp>; + touchscreen-size-x = <540>; + touchscreen-size-y = <960>; + zinitix,mode = <2>; + }; + }; diff --git a/Documentation/devicetree/bindings/input/touchscreen/zinitix.txt b/Documentation/devicetree/bindings/input/touchscreen/zinitix.txt deleted file mode 100644 index 446efb9f5f55..000000000000 --- a/Documentation/devicetree/bindings/input/touchscreen/zinitix.txt +++ /dev/null @@ -1,40 +0,0 @@ -Device tree bindings for Zinitx BT541 touchscreen controller - -Required properties: - - - compatible : Should be "zinitix,bt541" - - reg : I2C address of the chip. Should be 0x20 - - interrupts : Interrupt to which the chip is connected - -Optional properties: - - - vdd-supply : Analog power supply regulator on VCCA pin - - vddo-supply : Digital power supply regulator on VDD pin - - zinitix,mode : Mode of reporting touch points. Some modes may not work - with a particular ts firmware for unknown reasons. Available - modes are 1 and 2. Mode 2 is the default and preferred. - -The touchscreen-* properties are documented in touchscreen.txt in this -directory. - -Example: - - i2c@00000000 { - /* ... */ - - bt541@20 { - compatible = "zinitix,bt541"; - reg = <0x20>; - interrupt-parent = <&msmgpio>; - interrupts = <13 IRQ_TYPE_EDGE_FALLING>; - pinctrl-names = "default"; - pinctrl-0 = <&tsp_default>; - vdd-supply = <®_vdd_tsp>; - vddo-supply = <&pm8916_l6>; - touchscreen-size-x = <540>; - touchscreen-size-y = <960>; - zinitix,mode = <2>; - }; - - /* ... */ - }; From patchwork Thu Jan 6 07:28:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Travkin X-Patchwork-Id: 12705179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E9B5C4332F for ; Thu, 6 Jan 2022 07:29:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235710AbiAFH3P (ORCPT ); Thu, 6 Jan 2022 02:29:15 -0500 Received: from box.trvn.ru ([194.87.146.52]:42175 "EHLO box.trvn.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235746AbiAFH3O (ORCPT ); Thu, 6 Jan 2022 02:29:14 -0500 Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id BB09C4A104; Thu, 6 Jan 2022 12:29:02 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1641454143; bh=DjJJ7gWun3Q4+s3Ds07ABkL7/Fme7iFeHa0zyKq7N4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vXz2PFTbckdcauw4kcD8+ZQJn+oRKmbWG0AoF3PrM3H2c96SIRW+LZ3y6AG15Zr5/ VMxtUmZfLCyyzFeHORX3Ju7narbSqEnA5SIE2VBHAnFRw+xM3xsZsm50gMXxekGTnu 19NePWMBi3zIVENpR+GoirAOZUxFQl94CNRIXda8rcN3xuprwvImnjo5dAEpDgKCwL q/4uk0KENzBSFDrYqry3vzuVMOfQiH2V0Aq7NTOHduuAJmxS3nUh7GrcEtWYBYbgFV 8i90esYO9KOv7fkCW4j+WEey14iC0NCHx0mPGxAOqhOUoo21+KfHqxeZmieDwhJALf IoxgMt/HFpPVg== From: Nikita Travkin To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, Michael.Srba@seznam.cz, linus.walleij@linaro.org, broonie@kernel.org, luca@z3ntu.xyz, linux-input@vger.kernel.org, devicetree@vger.kernel.org, phone-devel@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Nikita Travkin Subject: [PATCH v3 3/6] Input: zinitix - Handle proper supply names Date: Thu, 6 Jan 2022 12:28:37 +0500 Message-Id: <20220106072840.36851-4-nikita@trvn.ru> In-Reply-To: <20220106072840.36851-1-nikita@trvn.ru> References: <20220106072840.36851-1-nikita@trvn.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Linus Walleij The supply names of the Zinitix touchscreen were a bit confused, the new bindings rectifies this. To deal with old and new devicetrees, first check if we have "vddo" and in case that exists assume the old supply names. Else go and look for the new ones. We cannot just get the regulators since we would get an OK and a dummy regulator: we need to check explicitly for the old supply name. Use struct device *dev as a local variable instead of the I2C client since the device is what we are actually obtaining the resources from. Cc: Mark Brown Cc: Michael Srba Cc: phone-devel@vger.kernel.org Cc: devicetree@vger.kernel.org Signed-off-by: Linus Walleij [Slightly changed the legacy regulator detection] Signed-off-by: Nikita Travkin --- This patch was previously submitted here: https://lore.kernel.org/linux-input/20210625113435.2539282-2-linus.walleij@linaro.org/ Changes since the original patch: - Address the review comments by Dmitry: Drop explicit OF check and use of_find_property() Changes in v2: - Reword the legacy regulator comment to drop "... and warn" as no warning is done. (I think adding a warning is not very useful here) --- drivers/input/touchscreen/zinitix.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c index 1e70b8d2a8d7..e84e4c3b1b3a 100644 --- a/drivers/input/touchscreen/zinitix.c +++ b/drivers/input/touchscreen/zinitix.c @@ -252,16 +252,27 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541) static int zinitix_init_regulators(struct bt541_ts_data *bt541) { - struct i2c_client *client = bt541->client; + struct device *dev = &bt541->client->dev; int error; - bt541->supplies[0].supply = "vdd"; - bt541->supplies[1].supply = "vddo"; - error = devm_regulator_bulk_get(&client->dev, + /* + * Some older device trees have erroneous names for the regulators, + * so check if "vddo" is present and in that case use these names. + * Else use the proper supply names on the component. + */ + if (of_find_property(dev->of_node, "vddo-supply", NULL)) { + bt541->supplies[0].supply = "vdd"; + bt541->supplies[1].supply = "vddo"; + } else { + /* Else use the proper supply names */ + bt541->supplies[0].supply = "vcca"; + bt541->supplies[1].supply = "vdd"; + } + error = devm_regulator_bulk_get(dev, ARRAY_SIZE(bt541->supplies), bt541->supplies); if (error < 0) { - dev_err(&client->dev, "Failed to get regulators: %d\n", error); + dev_err(dev, "Failed to get regulators: %d\n", error); return error; } From patchwork Thu Jan 6 07:28:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Travkin X-Patchwork-Id: 12705180 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73262C433FE for ; Thu, 6 Jan 2022 07:29:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235706AbiAFH3o (ORCPT ); Thu, 6 Jan 2022 02:29:44 -0500 Received: from box.trvn.ru ([194.87.146.52]:54145 "EHLO box.trvn.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235746AbiAFH3k (ORCPT ); Thu, 6 Jan 2022 02:29:40 -0500 Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id 664184A109; Thu, 6 Jan 2022 12:29:07 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1641454147; bh=7qZ33c7U2ffXr+klqsI55vzDEMsVG+TTv1mDnFLdpF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qskUSr4qks9ZWq+TaEFvMs0ojFVfL/ybptyevOazcelP6LDzr4I3/1Oo4ze1zhzDx livPOZ/Ssx4Rak0fvxmo42NGpQBLPO6o+728081m+/fzT9iY5nqW+6NQ71ZdvAKJSn bJckYlO+obVKCgHVoBWzb2BujZCiZ80DwttCGOghI0cyY50CrU5uiWBzz+3lb3YIfK YTMBobest9y/KSzzsoMzrJdl1cZJWgdBjJxLTfTaPA9CG3Zez3cX5kY5YxjhXukdfF nwh/jLFtGe6zmkOIKacjVI0O8nCNeUwa7obPeOMSUtZ8U/IomOEZKTRQbY7z9cpSZJ myh2p3NIsUEnQ== From: Nikita Travkin To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, Michael.Srba@seznam.cz, linus.walleij@linaro.org, broonie@kernel.org, luca@z3ntu.xyz, linux-input@vger.kernel.org, devicetree@vger.kernel.org, phone-devel@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Nikita Travkin Subject: [PATCH v3 4/6] input: zinitix: Add compatible for bt532 Date: Thu, 6 Jan 2022 12:28:38 +0500 Message-Id: <20220106072840.36851-5-nikita@trvn.ru> In-Reply-To: <20220106072840.36851-1-nikita@trvn.ru> References: <20220106072840.36851-1-nikita@trvn.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Zinitix BT532 is another touch controller that seem to implement the same interface as an already supported BT541. Add it to the driver. Reviewed-by: Linus Walleij Signed-off-by: Nikita Travkin --- drivers/input/touchscreen/zinitix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c index e84e4c3b1b3a..7c82c4f5fa6b 100644 --- a/drivers/input/touchscreen/zinitix.c +++ b/drivers/input/touchscreen/zinitix.c @@ -571,6 +571,7 @@ static SIMPLE_DEV_PM_OPS(zinitix_pm_ops, zinitix_suspend, zinitix_resume); #ifdef CONFIG_OF static const struct of_device_id zinitix_of_match[] = { + { .compatible = "zinitix,bt532" }, { .compatible = "zinitix,bt541" }, { } }; From patchwork Thu Jan 6 07:28:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Travkin X-Patchwork-Id: 12705181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7645CC433F5 for ; Thu, 6 Jan 2022 07:29:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235794AbiAFH3p (ORCPT ); Thu, 6 Jan 2022 02:29:45 -0500 Received: from box.trvn.ru ([194.87.146.52]:48347 "EHLO box.trvn.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235610AbiAFH3k (ORCPT ); Thu, 6 Jan 2022 02:29:40 -0500 Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id 949AC4A10A; Thu, 6 Jan 2022 12:29:11 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1641454152; bh=0iuDf5aFUiE3JU9JwKkEu11b1MvWifmGotGBDvsIXfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ThqJuqmMR/kJrLqvTr6zhOTBVyEZg1XLOUaOK3V6mc09CGsqI5LGXecPwh/oJrPCR YHq3s+JuOlHbVNJ/bzrf8ejfboOL+uC9e4V2+T7mspbbBbKtVG0VI6scSYskVdbURD CZzk/dR07EClbVf/lyDyADsnS6ZC5y6CbmztfxL7BbieqkGRiqUyOnG6jUMK0tnIh5 sTZC7IrZL40GG5AxYhybgHcoYuXgKtYICXHImK0Q1sr+rqdhyHZCGcnQdX/Y3btZYT gMH4uKxXVaRLW33YJEOG7mLJgj3QpfMDRXnmmBykrXMXGAkuI5FnrhGWjWAat8ev3O 1CDytkOU+L9vw== From: Nikita Travkin To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, Michael.Srba@seznam.cz, linus.walleij@linaro.org, broonie@kernel.org, luca@z3ntu.xyz, linux-input@vger.kernel.org, devicetree@vger.kernel.org, phone-devel@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Nikita Travkin Subject: [PATCH v3 5/6] dt-bindings: input: zinitix: Document touch-keys support Date: Thu, 6 Jan 2022 12:28:39 +0500 Message-Id: <20220106072840.36851-6-nikita@trvn.ru> In-Reply-To: <20220106072840.36851-1-nikita@trvn.ru> References: <20220106072840.36851-1-nikita@trvn.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org In some configurations the touch controller can support the 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: Nikita Travkin Reviewed-by: Rob Herring --- Changes in v2: - Include input.yaml schema at the top level instead of at the property. (Seems like I still can't think of the schema as device and not implementation-specific thing...) - Reword the description to be more informative. --- .../bindings/input/touchscreen/zinitix,bt400.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml b/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml index b4e5ba7c0b49..67ed853289b2 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/zinitix,bt400.yaml @@ -16,6 +16,7 @@ maintainers: allOf: - $ref: touchscreen.yaml# + - $ref: ../input.yaml# properties: $nodename: @@ -79,6 +80,15 @@ properties: $ref: /schemas/types.yaml#/definitions/uint32 enum: [1, 2] + linux,keycodes: + description: | + This property specifies an array of keycodes assigned to the + touch-keys that can be present in some touchscreen configurations. + If the touch-keys are enabled, controller firmware will assign some + touch sense lines to those keys. + minItems: 1 + maxItems: 8 + touchscreen-size-x: true touchscreen-size-y: true touchscreen-fuzz-x: true From patchwork Thu Jan 6 07:28:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Travkin X-Patchwork-Id: 12705182 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C5C6C4332F for ; Thu, 6 Jan 2022 07:29:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235746AbiAFH3q (ORCPT ); Thu, 6 Jan 2022 02:29:46 -0500 Received: from box.trvn.ru ([194.87.146.52]:50873 "EHLO box.trvn.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235753AbiAFH3l (ORCPT ); Thu, 6 Jan 2022 02:29:41 -0500 Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id 25B8B4A10B; Thu, 6 Jan 2022 12:29:20 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1641454161; bh=WzQHGrt6ILqtpbDtnsFPvG2/kLMOm+SPiFjbaBaeIQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wb82V16Ux8ae16s6kITjRx1IECHp0aI5522h9fUHdypqMtSmkvK9DisN88QjvQxpT A0MaYccgAwTn0Zn6jCtYqy+Ob6KA/jErygFPtjaarIMa8oLrCeYSpugMhQVR6Zr1s/ zJi4EzfJPhlkhaC6ubB/0dm4qeBLrKbANx1s0FeCD7C025m6gYfxUGJhUDfPaWIrec Wbxf11BNQMCTbOugMpgpkg0yMquNQQrM2aaTC6VCjLgWg+eSJ4TQbg+1ZTyZtuZwU9 BJ9TIxKJ2JrZwMu74OrVfUK4dWxZHUUoeI2yUN2cxIMcQvBczVentRutBz1MdEMsSW 2gKIHj66lmEDQ== From: Nikita Travkin To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, Michael.Srba@seznam.cz, linus.walleij@linaro.org, broonie@kernel.org, luca@z3ntu.xyz, linux-input@vger.kernel.org, devicetree@vger.kernel.org, phone-devel@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Nikita Travkin Subject: [PATCH v3 6/6] input: zinitix: Add touchkey support Date: Thu, 6 Jan 2022 12:28:40 +0500 Message-Id: <20220106072840.36851-7-nikita@trvn.ru> In-Reply-To: <20220106072840.36851-1-nikita@trvn.ru> References: <20220106072840.36851-1-nikita@trvn.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Zinitix touch controllers can use some of the sense lines for virtual keys (like those found on many phones). Add support for those keys. Reviewed-by: Linus Walleij Signed-off-by: Nikita Travkin --- Changes in v2: - Add missing le16_to_cpu() Changes in v3: - Add yet another missing le16_to_cpu() --- drivers/input/touchscreen/zinitix.c | 61 +++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c index 7c82c4f5fa6b..d076dc756980 100644 --- a/drivers/input/touchscreen/zinitix.c +++ b/drivers/input/touchscreen/zinitix.c @@ -119,6 +119,7 @@ #define DEFAULT_TOUCH_POINT_MODE 2 #define MAX_SUPPORTED_FINGER_NUM 5 +#define MAX_SUPPORTED_BUTTON_NUM 8 #define CHIP_ON_DELAY 15 // ms #define FIRMWARE_ON_DELAY 40 // ms @@ -146,6 +147,8 @@ struct bt541_ts_data { struct touchscreen_properties prop; struct regulator_bulk_data supplies[2]; u32 zinitix_mode; + u32 keycodes[MAX_SUPPORTED_BUTTON_NUM]; + int num_keycodes; }; static int zinitix_read_data(struct i2c_client *client, @@ -195,6 +198,7 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541) struct i2c_client *client = bt541->client; int i; int error; + u16 int_flags = 0; error = zinitix_write_cmd(client, BT541_SWRESET_CMD); if (error) { @@ -225,6 +229,11 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541) if (error) return error; + error = zinitix_write_u16(client, BT541_BUTTON_SUPPORTED_NUM, + bt541->num_keycodes); + if (error) + return error; + error = zinitix_write_u16(client, BT541_INITIAL_TOUCH_MODE, bt541->zinitix_mode); if (error) @@ -235,9 +244,12 @@ static int zinitix_init_touch(struct bt541_ts_data *bt541) if (error) return error; - error = zinitix_write_u16(client, BT541_INT_ENABLE_FLAG, - BIT_PT_CNT_CHANGE | BIT_DOWN | BIT_MOVE | - BIT_UP); + int_flags = BIT_PT_CNT_CHANGE | BIT_DOWN | BIT_MOVE | BIT_UP; + + if (bt541->num_keycodes) + int_flags |= BIT_ICON_EVENT; + + error = zinitix_write_u16(client, BT541_INT_ENABLE_FLAG, int_flags); if (error) return error; @@ -329,6 +341,15 @@ static void zinitix_report_finger(struct bt541_ts_data *bt541, int slot, input_report_abs(bt541->input_dev, ABS_MT_TOUCH_MAJOR, p->width); } +static void zinitix_report_keys(struct bt541_ts_data *bt541, u16 icon_events) +{ + int i; + + for (i = 0; i < bt541->num_keycodes; i++) + input_report_key(bt541->input_dev, + bt541->keycodes[i], !!(icon_events & BIT(i))); +} + static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler) { struct bt541_ts_data *bt541 = bt541_handler; @@ -336,6 +357,7 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler) struct touch_event touch_event; int error; int i; + __le16 icon_events = 0; memset(&touch_event, 0, sizeof(struct touch_event)); @@ -346,6 +368,17 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler) goto out; } + if (le16_to_cpu(touch_event.status) & BIT_ICON_EVENT) { + error = zinitix_read_data(bt541->client, BT541_ICON_STATUS_REG, + &icon_events, sizeof(icon_events)); + if (error) { + dev_err(&client->dev, "Failed to read icon events\n"); + goto out; + } + + zinitix_report_keys(bt541, le16_to_cpu(icon_events)); + } + for (i = 0; i < MAX_SUPPORTED_FINGER_NUM; i++) if (touch_event.point_coord[i].sub_status & SUB_BIT_EXIST) zinitix_report_finger(bt541, i, @@ -427,6 +460,7 @@ static int zinitix_init_input_dev(struct bt541_ts_data *bt541) { struct input_dev *input_dev; int error; + int i; input_dev = devm_input_allocate_device(&bt541->client->dev); if (!input_dev) { @@ -444,6 +478,14 @@ static int zinitix_init_input_dev(struct bt541_ts_data *bt541) input_dev->open = zinitix_input_open; input_dev->close = zinitix_input_close; + if (bt541->num_keycodes) { + input_dev->keycode = bt541->keycodes; + input_dev->keycodemax = bt541->num_keycodes; + input_dev->keycodesize = sizeof(bt541->keycodes[0]); + for (i = 0; i < bt541->num_keycodes; i++) + input_set_capability(input_dev, EV_KEY, bt541->keycodes[i]); + } + input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X); input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y); input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); @@ -508,6 +550,19 @@ static int zinitix_ts_probe(struct i2c_client *client) return error; } + bt541->num_keycodes = of_property_read_variable_u32_array( + client->dev.of_node, "linux,keycodes", + bt541->keycodes, 0, + ARRAY_SIZE(bt541->keycodes)); + if (bt541->num_keycodes == -EINVAL) { + bt541->num_keycodes = 0; + } else if (bt541->num_keycodes < 0) { + dev_err(&client->dev, + "Unable to parse \"linux,keycodes\" property: %d\n", + bt541->num_keycodes); + return bt541->num_keycodes; + } + error = zinitix_init_input_dev(bt541); if (error) { dev_err(&client->dev,