From patchwork Mon Dec 11 12:14:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamel Bouhara X-Patchwork-Id: 176644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6999349vqy; Mon, 11 Dec 2023 04:15:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFY3jt/rTflWSx6pZzh+/OX7V/1Yrxsr6H6yjyiyJWgHEcKnxej9KgcV4jiMJ4CQpwk7VaD X-Received: by 2002:a17:90a:c298:b0:286:6cc1:3f28 with SMTP id f24-20020a17090ac29800b002866cc13f28mr2975896pjt.95.1702296954189; Mon, 11 Dec 2023 04:15:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702296954; cv=none; d=google.com; s=arc-20160816; b=ZyQtioKWdt2yWq3qycKNKQSXfXB+BqE4NHSd6HazAcFZBpFnuIrQXsNNPjIoBlvEJD 0VKKfJwad944FlGXH+yYVo7TecL1Yhxln7qpZ3fdC13r9n/4TBETPKoGpOfZOXHVUXBR zQjClUWi505OgnxC/N2jtxLVgJ+GH9Yf66OyPEYCLprdQudPrMewNI//0IlHsnn0/Gjv hQ8Pk5JJr7QgExHyyiGAENjyEAx2cyk/1yZYr3QSSPe/69PRGdSLpnACwhclkBfHWn2v wP+ORzVG999xQ3OkiiL1myJHMFRjzOcb+IG1lR7ukb3pkjAQA7Qdouf+rTnK7TFLV+DR B/cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PyU0MrPkAquO0yDvZ3LG19USjtRAx9Zi0FGDGYHw/pQ=; fh=wL1G2MS26CWSBXBtVk27IAuidjjeLxyntSWijhW8Z0Q=; b=r4w3fXv232PSL/hRMR7UbWoh0oJ5RUNhShS1Nezc4/8JGuv0AVYxPtJd3KyE0DWAug PWXQVXVW0kmIahN61Rx0SRR09vZoq9vnmvur9MrTt1WlqOdzdv79vpqXuJRPCE2xhOSK 8ziw2lXcSjbvoZGIbEDsmTaMgyAOtbmng8rViWwDMvuN89jLQvGemkJUF1DkxNVAlLK0 OqeE8Yn2nLpQqgZViPsH07frSlt9GtZbAvtL6DHZK61n/tCFtaKm/pUeyzxPQ8GokS4O PNb+2HvMydfQm/4wwAUmBFy5me5q+ZWLVwlhossjhycip4/sT0XY7c0RuoNwJduWmHAe sgHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="XNJ4ic/3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id mv6-20020a17090b198600b0028683c7ed04si5934360pjb.157.2023.12.11.04.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 04:15:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="XNJ4ic/3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id EFE52807782E; Mon, 11 Dec 2023 04:15:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229768AbjLKMOi (ORCPT + 99 others); Mon, 11 Dec 2023 07:14:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234790AbjLKMOh (ORCPT ); Mon, 11 Dec 2023 07:14:37 -0500 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAAA8D5; Mon, 11 Dec 2023 04:14:42 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 51D461BF204; Mon, 11 Dec 2023 12:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702296881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PyU0MrPkAquO0yDvZ3LG19USjtRAx9Zi0FGDGYHw/pQ=; b=XNJ4ic/305M6+X+lKQnyuEWHW9sv0O3tlNi1Fl2mff859EFMspqQe1X8fJmcrcTIvsuFPd 1OFj6e9wErqMZuUBHRAA8Lwj17meEPSlkJE80aHnhS1j+ivxdgiZetReOxviqNFFra0VyZ 0f96UiHbLVxM53dVaQSIR/9YCpzJmhzUlN8Wpy6udLvGz8JsFWoONtK7TNYEenMP6xRdu2 04pCZd/m7mwJU6lfsBLewF1r5D9sNIs+xeKRIW3/hKPUoTmWwzVpZ2oNiq7aphNhe8F7W9 0CKcIn+enSCMga8N1jjbtbS5ldgPNx1iy7x2bM49PH0lOOVHKxlEoS11OzU5Ww== From: Kamel Bouhara To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Marco Felsch , Jeff LaBundy Cc: catalin.popescu@leica-geosystems.com, mark.satterthwaite@touchnetix.com, bartp@baasheep.co.uk, hannah.rossiter@touchnetix.com, Thomas Petazzoni , Gregory Clement , bsp-development.geo@leica-geosystems.com, Kamel Bouhara , Krzysztof Kozlowski Subject: [PATCH v5 1/3] dt-bindings: vendor-prefixes: Add TouchNetix AS Date: Mon, 11 Dec 2023 13:14:27 +0100 Message-ID: <20231211121430.1689139-2-kamel.bouhara@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231211121430.1689139-1-kamel.bouhara@bootlin.com> References: <20231211121430.1689139-1-kamel.bouhara@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: kamel.bouhara@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 11 Dec 2023 04:15:27 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784987730892740511 X-GMAIL-MSGID: 1784987730892740511 Add vendor prefix for TouchNetix AS (https://www.touchnetix.com/products/). Signed-off-by: Kamel Bouhara Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index 573578db9509..78581001a79c 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -1400,6 +1400,8 @@ patternProperties: description: Toradex AG "^toshiba,.*": description: Toshiba Corporation + "^touchnetix,.*": + description: TouchNetix AS "^toumaz,.*": description: Toumaz "^tpk,.*": From patchwork Mon Dec 11 12:14:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamel Bouhara X-Patchwork-Id: 176643 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6998873vqy; Mon, 11 Dec 2023 04:15:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbdYZEoyGJTvXoYwtvV9bOG5ITZG642QhpEjTjk0Dv05kGMQvaxtJyS6xW7BHgtu29rKHG X-Received: by 2002:a17:90a:ce03:b0:286:e34a:d163 with SMTP id f3-20020a17090ace0300b00286e34ad163mr1632543pju.3.1702296907446; Mon, 11 Dec 2023 04:15:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702296907; cv=none; d=google.com; s=arc-20160816; b=hXvqTn21m+7vFKJ1a9cGIsY4mr0cX5wih1g9qMIXcG57wYEjpmB3k3nxhOAEYOTpAZ 6hVLTjGUGVuklsGginVqrYPQoEKw/oD67hkU9dqoMj0Cmxp+dqaQthSHcu1Kir3nG80c VD7ShKtcyGkTC4OWpN4n1oEL9RIxj/doPmRC6YcpofVLDSS+rY5PneO7FlseZHkHNM3X G6bgfPZLaVrrwR8FYpo3BVkSriVg89AHUOCdJfcEihDw7mCVD84D5c1vCVG3Z0miVnOJ dSjlhebVCIBbYTjCd69WU47sWFjCQhHehqTRKE0nIz7n6kCpbCEfQTNrqICFUWbh/TaS 7wGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Eg87ZovtTfscZWbYAJIdbHo+yXOg2XwLG3HN8O/pMsg=; fh=EgA3ynOL0MYidVPneEorVrq8MDk7rnKA329crS/81pE=; b=Fw132PYl/2H4ObwFySAHtdwNei79hwzfIm+J73OyCYHIesEqCFiiv7ZB9qIIvn0Fla hNKCdN3kD9jTyl31GKGfXIBaOfLnfr596XN+Q7GOfh3Q/0RQVxGI1TYspWmec7A3Jsxa NTiaRUozAMxpKgeZYHLZ/Pencove1fmy5D6gYZUOsxWOchz62811/FsRAYrYYZJabJp9 0gNx7vs/r/amnhTeFZ0R/ok5P02jD9jVGWlbJzqAGzPgoptpSJ6yMnx5BVS8dBKxEpT8 aeCqz8QsYHE8M2mag38fFCgviQO2bPKrPeew0jWcrcKx/+6ye8rCvV0AWaa7YG+neytj FYAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=QH6gccPC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o8-20020a17090aac0800b0028648abac04si6008447pjq.58.2023.12.11.04.15.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 04:15:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=QH6gccPC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8CB2B808D239; Mon, 11 Dec 2023 04:14:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234453AbjLKMOp (ORCPT + 99 others); Mon, 11 Dec 2023 07:14:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234803AbjLKMOi (ORCPT ); Mon, 11 Dec 2023 07:14:38 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58ABADC; Mon, 11 Dec 2023 04:14:43 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 795DD1C000A; Mon, 11 Dec 2023 12:14:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702296882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Eg87ZovtTfscZWbYAJIdbHo+yXOg2XwLG3HN8O/pMsg=; b=QH6gccPCVALh6eD2FyEtc0C4RVC37GtrEsTRk8a6j6rGH5DXwN/K/MchaZW0XGMjeS0PEK z7NWkjpCKIjM7g7/2qBTUzDN86vdFLHhJE/89nx5n7uU2U8hcAgWLPupdbCpdWPzIXrcT9 5CiVDc5WFQqevtFhwv23E+qnfFxoSFkbL10GEtWaMX5yJdyK9joUEiTUpZV2Pz+RlI48AO Z5rbWBFA7+QM5JKjjKHgSsHdovYI3gMx+39g43BKf+TBRJwtXDvr77XVMix4EV7/Y6kXXY XoaYMqjIDVuG9iHlaRVyxNh8fBMUBbmtewZRQkVRP3TLr0he4PfRYA8GLWFFwA== From: Kamel Bouhara To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Marco Felsch , Jeff LaBundy Cc: catalin.popescu@leica-geosystems.com, mark.satterthwaite@touchnetix.com, bartp@baasheep.co.uk, hannah.rossiter@touchnetix.com, Thomas Petazzoni , Gregory Clement , bsp-development.geo@leica-geosystems.com, Kamel Bouhara Subject: [PATCH v5 2/3] dt-bindings: input: Add TouchNetix axiom touchscreen Date: Mon, 11 Dec 2023 13:14:28 +0100 Message-ID: <20231211121430.1689139-3-kamel.bouhara@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231211121430.1689139-1-kamel.bouhara@bootlin.com> References: <20231211121430.1689139-1-kamel.bouhara@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: kamel.bouhara@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 11 Dec 2023 04:14:58 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784987681939648766 X-GMAIL-MSGID: 1784987681939648766 Add the TouchNetix axiom I2C touchscreen device tree bindings documentation. Signed-off-by: Kamel Bouhara --- .../input/touchscreen/touchnetix,ax54a.yaml | 64 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchnetix,ax54a.yaml diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchnetix,ax54a.yaml b/Documentation/devicetree/bindings/input/touchscreen/touchnetix,ax54a.yaml new file mode 100644 index 000000000000..cbdf48fc538b --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/touchnetix,ax54a.yaml @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/touchnetix,ax54a.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TouchNetix Axiom series touchscreen controller + +maintainers: + - Kamel Bouhara + +allOf: + - $ref: /schemas/input/touchscreen/touchscreen.yaml# + - $ref: /schemas/input/input.yaml# + +properties: + compatible: + const: touchnetix,ax54a + + reg: + const: 0x66 + + interrupts: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + vdda-supply: + description: Analog power supply regulator on VDDA pin + + vddi-supply: + description: I/O power supply regulator on VDDI pin + + poll-interval: true + +required: + - compatible + - reg + - vdda-supply + - vddi-supply + +additionalProperties: false + +examples: + - | + #include + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + touchscreen@66 { + compatible = "touchnetix,ax54a"; + reg = <0x66>; + interrupt-parent = <&gpio2>; + interrupts = <2 IRQ_TYPE_EDGE_FALLING>; + reset-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>; + vdda-supply = <&vdda_reg>; + vddi-supply = <&vddi_reg>; + poll-interval = <20>; + }; + }; +... diff --git a/MAINTAINERS b/MAINTAINERS index 7608b714653f..4752d8436dbb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21431,6 +21431,12 @@ S: Maintained F: Documentation/ABI/testing/sysfs-class-firmware-attributes F: drivers/platform/x86/think-lmi.? +TOUCHNETIX AXIOM I2C TOUCHSCREEN DRIVER +M: Kamel Bouhara +L: linux-input@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/input/touchscreen/touchnetix,ax54a.yaml + THUNDERBOLT DMA TRAFFIC TEST DRIVER M: Isaac Hazan L: linux-usb@vger.kernel.org From patchwork Mon Dec 11 12:14:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamel Bouhara X-Patchwork-Id: 176645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6999383vqy; Mon, 11 Dec 2023 04:15:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYAYmQvVRNUu9l7yiTYe1X8So1ysef/ivUgvA0oHa8W9HvCYlDNFcHPohhPz3UlJkyu56b X-Received: by 2002:a05:6a00:194d:b0:6ce:4927:2811 with SMTP id s13-20020a056a00194d00b006ce49272811mr5136561pfk.22.1702296956125; Mon, 11 Dec 2023 04:15:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702296956; cv=none; d=google.com; s=arc-20160816; b=t2IJTwZ0gUBAq5Kv3ETupekvkkF96vjFImJ1lx71KvHB/+VHNMMZjGPGlDG1p6Vm7t 4eZtZj1ehlTSaVQW/tAUTWvCQ0cHgyFZK+qPuuTn2OaEadiKvt45bxQDwQl7T8Gho2lF vLNL4y6tZPijJDhxMmIwPLO9dWmv+xOjs6BMNQ4GEl2tiS+B5BG+V/6Eg/XxtZDlrBHW LunRSIOxnY0EDKVpIgCy7krCpl3W1y7gjST5RI0Rs4tB7mWG7BG6lcy43kQo5vjyiS9h a7UexMzcU5rn9qUnoVdIqqEOzG0bDRwAoMm6z0am01oZGBXBRnm/ku5MIl+CiviAQxNa WBzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3NHd7/TIBMO6ajuA6MciK2iY40x565JzIM9NwkMsObI=; fh=EgA3ynOL0MYidVPneEorVrq8MDk7rnKA329crS/81pE=; b=KohHOuXlxnAHkBigIJrhRK1bnrmXRtgcOFzrJ25pX0E15+Cg7uPYd2OkgIW1HwMCne k5vtjUap0utLKZlvwLoqunbT+/WH3TNGog7leThr6JEbrEzFZ3WZeBAJgNLhc8T/nPbD VoyZQh6f/ISdTmDXcIVTINbmzaOSo1C0kqACn+KjpqMUuVICJD9DXGrof9Kmf4te4wTh N+NxRpKX2y66gI3GZ/KeEBUaQPVE/YHaq5j3qSQH7X+F0pPk+M+4oawFD7VQKw3AuhZ1 0G1DOYsPzmkbzN0yPhTBurpaJCp+X0iYJjj9hFFlkPuqbi65fSZERJC4bXt3AJ7kcqdB NNzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=QDzI6xnj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id g10-20020a056a00078a00b006cc0219fc85si5930939pfu.252.2023.12.11.04.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 04:15:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=QDzI6xnj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A50C68095814; Mon, 11 Dec 2023 04:15:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343495AbjLKMOt (ORCPT + 99 others); Mon, 11 Dec 2023 07:14:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234843AbjLKMOo (ORCPT ); Mon, 11 Dec 2023 07:14:44 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63C7FD6; Mon, 11 Dec 2023 04:14:44 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 8B4CE240007; Mon, 11 Dec 2023 12:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702296883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3NHd7/TIBMO6ajuA6MciK2iY40x565JzIM9NwkMsObI=; b=QDzI6xnjbheJAlkgXnowBHXmIw1SpTKMVau6uJ9VoP+8FCNpWX0jmXoOJxXBWynXGqFBJ8 V2s5Zt++vnEMvyfi6vzHUudCr1QxCqEDtQdlDOvFhAuI0TInM+yHP1JfmKq0eGqBQkK3Zz +NWBYftIB7LwGectEeTCK6pVwWUMR1fKjcgBb6T9C5SWtTVMAh2gyMbozSTS3q9ISC59Ls 5adKL+OkJjBy1BWqqTbN1qkxqQIkfIiB6b4LKhSayv9Vqrgop6+qs9uU7qEQsg1S17TFNo ao460YggYOTx+D+4Cu+/PNYmcoUG/U6GY4/sSTWmjepmwPKgQJsNZbwT0eKb8g== From: Kamel Bouhara To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Marco Felsch , Jeff LaBundy Cc: catalin.popescu@leica-geosystems.com, mark.satterthwaite@touchnetix.com, bartp@baasheep.co.uk, hannah.rossiter@touchnetix.com, Thomas Petazzoni , Gregory Clement , bsp-development.geo@leica-geosystems.com, Kamel Bouhara Subject: [PATCH v5 3/3] Input: Add TouchNetix axiom i2c touchscreen driver Date: Mon, 11 Dec 2023 13:14:29 +0100 Message-ID: <20231211121430.1689139-4-kamel.bouhara@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231211121430.1689139-1-kamel.bouhara@bootlin.com> References: <20231211121430.1689139-1-kamel.bouhara@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: kamel.bouhara@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 11 Dec 2023 04:15:39 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784987732953973723 X-GMAIL-MSGID: 1784987732953973723 Add a new driver for the TouchNetix's axiom family of touchscreen controllers. This driver only supports i2c and can be later adapted for SPI and USB support. Signed-off-by: Kamel Bouhara --- MAINTAINERS | 1 + drivers/input/touchscreen/Kconfig | 12 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/touchnetix_axiom.c | 667 +++++++++++++++++++ 4 files changed, 681 insertions(+) create mode 100644 drivers/input/touchscreen/touchnetix_axiom.c diff --git a/MAINTAINERS b/MAINTAINERS index 4752d8436dbb..337ddac6c74b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21436,6 +21436,7 @@ M: Kamel Bouhara L: linux-input@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/input/touchscreen/touchnetix,ax54a.yaml +F: drivers/input/touchscreen/touchnetix_axiom.c THUNDERBOLT DMA TRAFFIC TEST DRIVER M: Isaac Hazan diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index e3e2324547b9..f36bee8d8696 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -803,6 +803,18 @@ config TOUCHSCREEN_MIGOR To compile this driver as a module, choose M here: the module will be called migor_ts. +config TOUCHSCREEN_TOUCHNETIX_AXIOM + tristate "TouchNetix AXIOM based touchscreen controllers" + depends on I2C + help + Say Y here if you have a axiom touchscreen connected to + your system. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called axiom. + config TOUCHSCREEN_TOUCHRIGHT tristate "Touchright serial touchscreen" select SERIO diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 62bd24f3ac8e..8e32a2df5e18 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -88,6 +88,7 @@ obj-$(CONFIG_TOUCHSCREEN_SUR40) += sur40.o obj-$(CONFIG_TOUCHSCREEN_SURFACE3_SPI) += surface3_spi.o obj-$(CONFIG_TOUCHSCREEN_TI_AM335X_TSC) += ti_am335x_tsc.o obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o +obj-$(CONFIG_TOUCHSCREEN_TOUCHNETIX_AXIOM) += touchnetix_axiom.o obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o obj-$(CONFIG_TOUCHSCREEN_TS4800) += ts4800-ts.o diff --git a/drivers/input/touchscreen/touchnetix_axiom.c b/drivers/input/touchscreen/touchnetix_axiom.c new file mode 100644 index 000000000000..4ade2d1adba0 --- /dev/null +++ b/drivers/input/touchscreen/touchnetix_axiom.c @@ -0,0 +1,667 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * TouchNetix axiom Touchscreen Driver + * + * Copyright (C) 2020-2023 TouchNetix Ltd. + * + * Author(s): Bart Prescott + * Pedro Torruella + * Mark Satterthwaite + * Hannah Rossiter + * Kamel Bouhara + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define AXIOM_PROX_LEVEL -128 +/* + * Register group u31 has 2 pages for usage table entries. + */ +#define AXIOM_U31_MAX_USAGES ((2 * AXIOM_COMMS_PAGE_SIZE) / AXIOM_U31_BYTES_PER_USAGE) +#define AXIOM_U31_BYTES_PER_USAGE 6 +#define AXIOM_U31_PAGE0_LENGTH 0x0C +#define AXIOM_U31_BOOTMODE_MASK BIT(7) +#define AXIOM_U31_DEVID_MASK GENMASK(14, 0) + +#define AXIOM_CMD_HEADER_READ_MASK BIT(15) +#define AXIOM_U41_MAX_TARGETS 10 + +#define AXIOM_U46_AUX_CHANNELS 4 +#define AXIOM_U46_AUX_MASK GENMASK(11, 0) + +#define AXIOM_COMMS_MAX_USAGE_PAGES 3 +#define AXIOM_COMMS_PAGE_SIZE 256 +#define AXIOM_COMMS_REPORT_LEN_MASK GENMASK(6, 0) + +#define AXIOM_REPORT_USAGE_ID 0x34 +#define AXIOM_DEVINFO_USAGE_ID 0x31 +#define AXIOM_USAGE_2HB_REPORT_ID 0x01 +#define AXIOM_USAGE_2AUX_REPORT_ID 0x46 +#define AXIOM_USAGE_2DCTS_REPORT_ID 0x41 + +#define AXIOM_PAGE_OFFSET_MASK GENMASK(6, 0) + +struct axiom_devinfo { + u16 device_id; + u8 fw_minor; + u8 fw_major; + u8 fw_info_extra; + u8 tcp_revision; + u8 bootloader_fw_minor; + u8 bootloader_fw_major; + u16 jedec_id; + u8 num_usages; +} __packed; + +/* + * Describes parameters of a specific usage, essentially a single element of + * the "Usage Table" + */ +struct axiom_usage_entry { + u8 id; + u8 is_report; + u8 start_page; + u8 num_pages; +}; + +/* + * Represents state of a touch or target when detected prior a touch (eg. + * hover or proximity events). + */ +enum axiom_target_state { + AXIOM_TARGET_STATE_NOT_PRESENT = 0, + AXIOM_TARGET_STATE_PROX = 1, + AXIOM_TARGET_STATE_HOVER = 2, + AXIOM_TARGET_STATE_TOUCHING = 3, +}; + +struct axiom_u41_target { + enum axiom_target_state state; + u16 x; + u16 y; + s8 z; + bool insert; + bool touch; +}; + +struct axiom_target_report { + u8 index; + u8 present; + u16 x; + u16 y; + s8 z; +}; + +struct axiom_cmd_header { + __le16 target_address; + __le16 length; +} __packed; + +struct axiom_data { + struct axiom_devinfo devinfo; + struct device *dev; + struct gpio_desc *reset_gpio; + struct i2c_client *client; + struct input_dev *input_dev; + u32 max_report_len; + char rx_buf[AXIOM_COMMS_MAX_USAGE_PAGES * AXIOM_COMMS_PAGE_SIZE]; + struct axiom_u41_target targets[AXIOM_U41_MAX_TARGETS]; + struct axiom_usage_entry usage_table[AXIOM_U31_MAX_USAGES]; + bool usage_table_populated; + struct regulator *vdda; + struct regulator *vddi; +}; + +/* + * axiom devices are typically configured to report + * touches at a rate of 100Hz (10ms). For systems + * that require polling for reports. + * When reports are polled, it will be expected to + * occasionally observe the overflow bit being set + * in the reports. This indicates that reports are not + * being read fast enough. + */ +#define POLL_INTERVAL_DEFAULT_MS 10 + +/* Translate usage/page/offset triplet into physical address. */ +static u16 axiom_usage_to_target_address(struct axiom_data *ts, char usage, char page, + char offset) +{ + u32 i; + + /* At the moment the convention is that u31 is always at physical address 0x0 */ + if (!ts->usage_table_populated) { + if (usage == AXIOM_DEVINFO_USAGE_ID) + return ((page << 8) + offset); + else + return 0xffff; + } + + for (i = 0; i < ts->devinfo.num_usages; i++) { + if (ts->usage_table[i].id != usage) + continue; + + if (page >= ts->usage_table[i].num_pages) { + dev_err(ts->dev, "Invalid usage table! usage: %u, page: %u, offset: %u\n", + usage, page, offset); + return 0xffff; + } + break; + } + + return ((ts->usage_table[i].start_page + page) << 8) + offset; +} + +static int axiom_i2c_read(struct i2c_client *client, u8 usage, u8 page, u8 *buf, u16 len) +{ + struct axiom_data *ts = i2c_get_clientdata(client); + struct axiom_cmd_header cmd_header; + struct i2c_msg msg[2]; + int error; + + cmd_header.target_address = cpu_to_le16(axiom_usage_to_target_address(ts, usage, page, 0)); + cmd_header.length = cpu_to_le16(len | AXIOM_CMD_HEADER_READ_MASK); + + msg[0].addr = client->addr; + msg[0].flags = 0; + msg[0].len = sizeof(cmd_header); + msg[0].buf = (u8 *)&cmd_header; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].len = len; + msg[1].buf = (char *)buf; + + error = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)); + if (error != ARRAY_SIZE(msg)) { + dev_err(&client->dev, + "Failed reading usage %#x page %#x, error=%d\n", + usage, page, error); + return -EIO; + } + + usleep_range(250, 300); + + return 0; +} + +/* + * One of the main purposes for reading the usage table is to identify + * which usages reside at which target address. + * When performing subsequent reads or writes to AXIOM, the target address + * is used to specify which usage is being accessed. + * Consider the following discovery code which will build up the usage table. + */ +static u32 axiom_populate_usage_table(struct axiom_data *ts) +{ + struct axiom_usage_entry *usage_table; + u32 max_report_len = 0; + char *rx_data = ts->rx_buf; + u32 usage_id; + int error; + + usage_table = ts->usage_table; + + /* Read the second page of usage u31 to get the usage table */ + error = axiom_i2c_read(ts->client, AXIOM_DEVINFO_USAGE_ID, 1, rx_data, + (AXIOM_U31_BYTES_PER_USAGE * ts->devinfo.num_usages)); + if (error) + return error; + + for (usage_id = 0; usage_id < ts->devinfo.num_usages; usage_id++) { + u16 offset = (usage_id * AXIOM_U31_BYTES_PER_USAGE); + u8 id = rx_data[offset + 0]; + u8 start_page = rx_data[offset + 1]; + u8 num_pages = rx_data[offset + 2]; + u32 max_offset = ((rx_data[offset + 3] & AXIOM_PAGE_OFFSET_MASK) + 1) * 2; + + if (!num_pages) + usage_table[usage_id].is_report = true; + + /* Store the entry into the usage table */ + usage_table[usage_id].id = id; + usage_table[usage_id].start_page = start_page; + usage_table[usage_id].num_pages = num_pages; + + dev_dbg(ts->dev, "Usage u%02x Info: %*ph\n", id, + AXIOM_U31_BYTES_PER_USAGE, &rx_data[offset]); + + /* Identify the max report length the module will receive */ + if (usage_table[usage_id].is_report && max_offset > max_report_len) + max_report_len = max_offset; + } + + ts->usage_table_populated = true; + + return max_report_len; +} + +static int axiom_discover(struct axiom_data *ts) +{ + int error; + + /* + * Fetch the first page of usage u31 to get the + * device information and the number of usages + */ + error = axiom_i2c_read(ts->client, AXIOM_DEVINFO_USAGE_ID, 0, (char *)&ts->devinfo, + AXIOM_U31_PAGE0_LENGTH); + if (error) + return error; + + dev_dbg(ts->dev, " Boot Mode : %s\n", + FIELD_GET(AXIOM_U31_BOOTMODE_MASK, ts->devinfo.device_id) ? "BLP" : "TCP"); + dev_dbg(ts->dev, " Device ID : %04lx\n", + FIELD_GET(AXIOM_U31_DEVID_MASK, ts->devinfo.device_id)); + dev_dbg(ts->dev, " Firmware Rev : %02x.%02x\n", ts->devinfo.fw_major, + ts->devinfo.fw_minor); + dev_dbg(ts->dev, " Bootloader Rev : %02x.%02x\n", ts->devinfo.bootloader_fw_major, + ts->devinfo.bootloader_fw_minor); + dev_dbg(ts->dev, " FW Extra Info : %04x\n", ts->devinfo.fw_info_extra); + dev_dbg(ts->dev, " Silicon : %04x\n", ts->devinfo.jedec_id); + dev_dbg(ts->dev, " Number usages : %04x\n", ts->devinfo.num_usages); + + ts->max_report_len = axiom_populate_usage_table(ts); + if (!ts->max_report_len || !ts->devinfo.num_usages) + return -EINVAL; + + dev_dbg(ts->dev, "Max Report Length: %u\n", ts->max_report_len); + + return 0; +} + +/* + * Support function to axiom_process_u41_report. + * Generates input-subsystem events for every target. + * After calling this function the caller shall issue + * a Sync to the input sub-system. + */ +static bool axiom_process_u41_report_target(struct axiom_data *ts, + struct axiom_target_report *target) +{ + struct input_dev *input_dev = ts->input_dev; + struct axiom_u41_target *target_prev_state; + enum axiom_target_state current_state; + bool update = false; + int slot; + + /* Verify the target index */ + if (target->index >= AXIOM_U41_MAX_TARGETS) { + dev_dbg(ts->dev, "Invalid target index! %u\n", target->index); + return false; + } + + target_prev_state = &ts->targets[target->index]; + + current_state = AXIOM_TARGET_STATE_NOT_PRESENT; + + if (target->present) { + if (target->z >= 0) + current_state = AXIOM_TARGET_STATE_TOUCHING; + else if (target->z > AXIOM_PROX_LEVEL && target->z < 0) + current_state = AXIOM_TARGET_STATE_HOVER; + else if (target->z == AXIOM_PROX_LEVEL) + current_state = AXIOM_TARGET_STATE_PROX; + } + + if (target_prev_state->state == current_state && + target_prev_state->x == target->x && + target_prev_state->y == target->y && + target_prev_state->z == target->z) { + return false; + } + + slot = target->index; + + dev_dbg(ts->dev, "U41 Target T%u, slot:%u present:%u, x:%u, y:%u, z:%d\n", + target->index, slot, target->present, + target->x, target->y, target->z); + + switch (current_state) { + case AXIOM_TARGET_STATE_NOT_PRESENT: + case AXIOM_TARGET_STATE_PROX: + if (!target_prev_state->insert) + break; + update = true; + target_prev_state->insert = false; + input_mt_slot(input_dev, slot); + + if (!slot) + input_report_key(input_dev, BTN_TOUCH, 0); + + input_mt_report_slot_inactive(input_dev); + /* + * make sure the previous coordinates are + * all off screen when the finger comes back + */ + target->x = 65535; + target->y = 65535; + target->z = AXIOM_PROX_LEVEL; + break; + case AXIOM_TARGET_STATE_HOVER: + case AXIOM_TARGET_STATE_TOUCHING: + target_prev_state->insert = true; + update = true; + input_mt_slot(input_dev, slot); + input_report_abs(input_dev, ABS_MT_TRACKING_ID, slot); + input_report_abs(input_dev, ABS_MT_POSITION_X, target->x); + input_report_abs(input_dev, ABS_X, target->x); + input_report_abs(input_dev, ABS_MT_POSITION_Y, target->y); + input_report_abs(input_dev, ABS_Y, target->y); + + if (current_state == AXIOM_TARGET_STATE_TOUCHING) { + input_report_abs(input_dev, ABS_MT_DISTANCE, 0); + input_report_abs(input_dev, ABS_DISTANCE, 0); + input_report_abs(input_dev, ABS_MT_PRESSURE, target->z); + input_report_abs(input_dev, ABS_PRESSURE, target->z); + } else { + input_report_abs(input_dev, ABS_MT_DISTANCE, -target->z); + input_report_abs(input_dev, ABS_DISTANCE, -target->z); + input_report_abs(input_dev, ABS_MT_PRESSURE, 0); + input_report_abs(input_dev, ABS_PRESSURE, 0); + } + + if (!slot) + input_report_key(input_dev, BTN_TOUCH, (current_state == + AXIOM_TARGET_STATE_TOUCHING)); + break; + default: + break; + } + + target_prev_state->state = current_state; + target_prev_state->x = target->x; + target_prev_state->y = target->y; + target_prev_state->z = target->z; + + return update; +} + +/* + * U41 is the output report of the 2D CTS and contains the status of targets + * (including contacts and pre-contacts) along with their X,Y,Z values. + * When a target has been removed (no longer detected), + * the corresponding X,Y,Z values will be zeroed. + */ +static bool axiom_process_u41_report(struct axiom_data *ts, char *rx_buf) +{ + struct axiom_target_report target; + bool update_done = false; + u16 target_status; + u32 i; + + target_status = ((rx_buf[1]) | (rx_buf[2] << 8)); + + for (i = 0; i < AXIOM_U41_MAX_TARGETS; i++) { + char target_step = i * 4; + + target.index = i; + target.present = ((target_status & (1 << i)) != 0) ? 1 : 0; + target.x = (rx_buf[(target_step + 3)] | (rx_buf[target_step + 4] << 8)); + target.y = (rx_buf[(target_step + 5)] | (rx_buf[target_step + 6] << 8)); + target.z = (s8)(rx_buf[i + 43]); + update_done |= axiom_process_u41_report_target(ts, &target); + } + + return update_done; +} + +/* + * U46 report contains a low level measurement data generated by the CDS + * algorithms from the AUX channels. This information is useful when tuning + * multi-press to assess mechanical consistency in the unit's construction. + */ +static void axiom_process_u46_report(struct axiom_data *ts, char *rx_buf) +{ + struct input_dev *input_dev = ts->input_dev; + u32 event_value; + u16 aux_value; + u32 i = 0; + + for (i = 0; i < AXIOM_U46_AUX_CHANNELS; i++) { + char target_step = i * 2; + + aux_value = ((rx_buf[target_step + 2] << 8) | (rx_buf[target_step + 1])) + & AXIOM_U46_AUX_MASK; + event_value = (i << 16) | (aux_value); + input_event(input_dev, EV_MSC, MSC_RAW, event_value); + } +} + +/* + * Validates the crc and demultiplexes the axiom reports to the appropriate + * report handler + */ +static int axiom_handle_events(struct axiom_data *ts) +{ + struct input_dev *input_dev = ts->input_dev; + char *report_data = ts->rx_buf; + struct device *dev = ts->dev; + u16 crc_report; + u16 crc_calc; + int error; + char len; + + error = axiom_i2c_read(ts->client, AXIOM_REPORT_USAGE_ID, 0, report_data, + ts->max_report_len); + if (error) + return error; + + len = (report_data[0] & AXIOM_COMMS_REPORT_LEN_MASK) << 1; + if (!len) { + dev_err(dev, "Zero length report discarded.\n"); + return -ENODATA; + } + + /* Validate the report CRC */ + crc_report = (report_data[len - 1] << 8) | (report_data[len - 2]); + /* Length is in 16 bit words and remove the size of the CRC16 itself */ + crc_calc = crc16(0, report_data, (len - 2)); + + if (crc_calc != crc_report) { + dev_err(dev, + "CRC mismatch! Expected: %#x, Calculated CRC: %#x.\n", + crc_report, crc_calc); + return -EINVAL; + } + + switch (report_data[1]) { + case AXIOM_USAGE_2DCTS_REPORT_ID: + if (axiom_process_u41_report(ts, &report_data[1])) { + input_mt_sync_frame(input_dev); + input_sync(input_dev); + } + break; + + case AXIOM_USAGE_2AUX_REPORT_ID: + /* This is an aux report (force) */ + axiom_process_u46_report(ts, &report_data[1]); + input_mt_sync(input_dev); + input_sync(input_dev); + break; + + case AXIOM_USAGE_2HB_REPORT_ID: + /* This is a heartbeat report */ + break; + default: + return -EINVAL; + } + + return 0; +} + +static void axiom_i2c_poll(struct input_dev *input_dev) +{ + struct axiom_data *ts = input_get_drvdata(input_dev); + + axiom_handle_events(ts); +} + +static irqreturn_t axiom_irq(int irq, void *dev_id) +{ + struct axiom_data *ts = dev_id; + + axiom_handle_events(ts); + + return IRQ_HANDLED; +} + +static void axiom_reset(struct gpio_desc *reset_gpio) +{ + gpiod_set_value_cansleep(reset_gpio, 1); + usleep_range(1000, 2000); + gpiod_set_value_cansleep(reset_gpio, 0); + msleep(110); +} + +static int axiom_i2c_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct input_dev *input_dev; + struct axiom_data *ts; + u32 startup_delay_ms; + u32 poll_interval; + int target; + int error; + + ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); + if (!ts) + return -ENOMEM; + + ts->client = client; + i2c_set_clientdata(client, ts); + ts->dev = dev; + + ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(ts->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(ts->reset_gpio), "failed to get reset GPIO\n"); + + if (ts->reset_gpio) + axiom_reset(ts->reset_gpio); + + ts->vddi = devm_regulator_get_optional(dev, "VDDI"); + if (!IS_ERR(ts->vddi)) { + error = regulator_enable(ts->vddi); + if (error) + return dev_err_probe(&client->dev, error, + "Failed to enable VDDI regulator\n"); + } + + ts->vdda = devm_regulator_get_optional(dev, "VDDA"); + if (!IS_ERR(ts->vdda)) { + error = regulator_enable(ts->vdda); + if (error) { + dev_err(dev, "Failed to get VDDA regulator\n"); + regulator_disable(ts->vddi); + return error; + } + if (!device_property_read_u32(dev, "startup-time-ms", &startup_delay_ms)) + msleep(startup_delay_ms); + } + + error = axiom_discover(ts); + if (error) + return dev_err_probe(dev, error, "Failed touchscreen discover\n"); + + input_dev = devm_input_allocate_device(ts->dev); + if (!input_dev) + return -ENOMEM; + + input_dev->name = "TouchNetix axiom Touchscreen"; + input_dev->phys = "input/axiom_ts"; + + /* Single Touch */ + input_set_abs_params(input_dev, ABS_X, 0, 65535, 0, 0); + input_set_abs_params(input_dev, ABS_Y, 0, 65535, 0, 0); + + /* Multi Touch */ + /* Min, Max, Fuzz (expected noise in px, try 4?) and Flat */ + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, 65535, 0, 0); + /* Min, Max, Fuzz (expected noise in px, try 4?) and Flat */ + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, 65535, 0, 0); + input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE, 0, MT_TOOL_MAX, 0, 0); + input_set_abs_params(input_dev, ABS_MT_DISTANCE, 0, 127, 0, 0); + input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, 127, 0, 0); + + input_set_capability(input_dev, EV_KEY, BTN_TOUCH); + + /* Registers the axiom device as a touchscreen instead of a mouse pointer */ + error = input_mt_init_slots(input_dev, AXIOM_U41_MAX_TARGETS, INPUT_MT_DIRECT); + if (error) + return error; + + /* Enables the raw data for up to 4 force channels to be sent to the input subsystem */ + set_bit(EV_REL, input_dev->evbit); + set_bit(EV_MSC, input_dev->evbit); + /* Declare that we support "RAW" Miscellaneous events */ + set_bit(MSC_RAW, input_dev->mscbit); + + ts->input_dev = input_dev; + input_set_drvdata(ts->input_dev, ts); + + /* Ensure that all reports are initialised to not be present. */ + for (target = 0; target < AXIOM_U41_MAX_TARGETS; target++) + ts->targets[target].state = AXIOM_TARGET_STATE_NOT_PRESENT; + + error = input_register_device(input_dev); + if (error) + return dev_err_probe(ts->dev, error, + "Could not register with Input Sub-system.\n"); + + error = devm_request_threaded_irq(dev, client->irq, NULL, + axiom_irq, IRQF_ONESHOT, dev_name(dev), ts); + if (error < 0) { + dev_warn(dev, "Request irq failed, falling back to polling mode"); + + error = input_setup_polling(input_dev, axiom_i2c_poll); + if (error) + return dev_err_probe(ts->dev, error, "Unable to set up polling mode\n"); + + if (!device_property_read_u32(ts->dev, "poll-interval", &poll_interval)) + input_set_poll_interval(input_dev, poll_interval); + else + input_set_poll_interval(input_dev, POLL_INTERVAL_DEFAULT_MS); + } + + return 0; +} + +static const struct i2c_device_id axiom_i2c_id_table[] = { + { "ax54a" }, + {}, +}; +MODULE_DEVICE_TABLE(i2c, axiom_i2c_id_table); + +static const struct of_device_id axiom_i2c_of_match[] = { + { .compatible = "touchnetix,ax54a", }, + { } +}; +MODULE_DEVICE_TABLE(of, axiom_i2c_of_match); + +static struct i2c_driver axiom_i2c_driver = { + .driver = { + .name = "axiom", + .of_match_table = axiom_i2c_of_match, + }, + .id_table = axiom_i2c_id_table, + .probe = axiom_i2c_probe, +}; +module_i2c_driver(axiom_i2c_driver); +MODULE_AUTHOR("Bart Prescott "); +MODULE_AUTHOR("Pedro Torruella "); +MODULE_AUTHOR("Mark Satterthwaite "); +MODULE_AUTHOR("Hannah Rossiter "); +MODULE_AUTHOR("Kamel Bouhara "); +MODULE_DESCRIPTION("TouchNetix axiom touchscreen I2C bus driver"); +MODULE_LICENSE("GPL");