From patchwork Fri Oct 23 23:22:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 285777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99765C5517A for ; Fri, 23 Oct 2020 23:23:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DF8221D43 for ; Fri, 23 Oct 2020 23:23:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="lSvoOZ0B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758521AbgJWXX1 (ORCPT ); Fri, 23 Oct 2020 19:23:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754377AbgJWXX1 (ORCPT ); Fri, 23 Oct 2020 19:23:27 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DF1EC0613CE for ; Fri, 23 Oct 2020 16:23:26 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id r3so1786278plo.1 for ; Fri, 23 Oct 2020 16:23:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OfVT8h9wTg39Kkdz/cTYNaLpjH3zKVjSrnAnLMVOwP0=; b=lSvoOZ0BrlQ2aaIRwKZoX+KgWKXDVGWOc2TQ+iLwXjyTbcvzz3q2hQ4sBPZQ3+2uPM Uyn4Wa+ret40vchMTDYMZw7LPMi8Jd3+Qvtf5yohR7zQCgwKssECfRopec1uvE9luaZx Cw+xk6X3RgJ9vqDLMPha6RpDTeasaxHj/FkA4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OfVT8h9wTg39Kkdz/cTYNaLpjH3zKVjSrnAnLMVOwP0=; b=slx0CsME3fD2KA59asi+EuIZEkVlltaUpPY6T/pdRMYSxaI+zmwRYdUEAujrQpHO2U 0HCFAFIKeezHOi0gI+UfbXYYWBi1MPmZZV1SP6S39v9hhdlb/O45ooFmYu5DMZx1IBaB rZ8x4i+z1peN5zVsT9Zkd2u8ppjIRb8JAdpJ/DMlYHzs6JDVfLS4cZlCNei6KNrFLzkh hXpTUWrCVb0yydZZPVqcw/WuPGWTpRAtU0SngNBPwxYOuPN9G1P3s0tN/wJuH5euW2MK UvOkF6oaSzuP7Gp1qGLJYaNwRD+I6HYjCzVVqM6B2GhFZiKM6NCnsdbhmnxAgVOHBROi gv8g== X-Gm-Message-State: AOAM530srk3eOkic2hmakSKdEWMQh5iTFjmavK6ZAY+okmcnni5vbrzu 3JoiyzcuD/opsJ+PcU7Lo1J/Rw== X-Google-Smtp-Source: ABdhPJxUQtoeCUCQzbsz0jKCxEwV0OYgkw3J7AFEwHa0RFT0DIhHaQxFc+KB42j7kNQWqOCOQ90AYQ== X-Received: by 2002:a17:90a:66cc:: with SMTP id z12mr5453371pjl.145.1603495405901; Fri, 23 Oct 2020 16:23:25 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id v17sm3789476pjy.40.2020.10.23.16.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 16:23:25 -0700 (PDT) From: Douglas Anderson To: jkosina@suse.cz, benjamin.tissoires@redhat.com, gregkh@linuxfoundation.org Cc: andrea@borgia.bo.it, kai.heng.feng@canonical.com, linux-input@vger.kernel.org, swboyd@chromium.org, hdegoede@redhat.com, Douglas Anderson , Dmitry Torokhov , Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] dt-bindings: HID: i2c-hid: Label this binding as deprecated Date: Fri, 23 Oct 2020 16:22:52 -0700 Message-Id: <20201023162220.v2.1.I45b53fe84e2215946f900f5b28bab1aa9d029ac7@changeid> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org As pointed out by Rob Herring [1], we should have a device-specific compatible string. This means people shouldn't be using the "i2c-over-hid" compatible string anymore, or at least not without a more specific compatible string before it. Specifically: 1. For newly added devices we should just have the device-specific device string (no "hid-over-i2c" fallback) and infer the timings and hid-descr-addr from there. 2. If there's a need for a device tree to be backward compatible, we should list the device-specific compatible string and add the "hid-over-i2c" fallback and the various timings. [1] https://lore.kernel.org/r/20201019211036.GA3595039@bogus Signed-off-by: Douglas Anderson --- Changes in v2: - ("dt-bindings: HID: i2c-hid: Label this binding as deprecated") new in v2. Documentation/devicetree/bindings/input/hid-over-i2c.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/input/hid-over-i2c.txt b/Documentation/devicetree/bindings/input/hid-over-i2c.txt index c76bafaf98d2..733a5f053280 100644 --- a/Documentation/devicetree/bindings/input/hid-over-i2c.txt +++ b/Documentation/devicetree/bindings/input/hid-over-i2c.txt @@ -1,5 +1,8 @@ * HID over I2C Device-Tree bindings +WARNING: this binding is deprecated. Instead of using this, create specific +bindings for each hid-over-i2c device. + HID over I2C provides support for various Human Interface Devices over the I2C bus. These devices can be for example touchpads, keyboards, touch screens or sensors. From patchwork Fri Oct 23 23:22:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 293868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF6ABC55178 for ; Fri, 23 Oct 2020 23:23:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88DAA21D47 for ; Fri, 23 Oct 2020 23:23:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="mp/78y+G" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758582AbgJWXX2 (ORCPT ); Fri, 23 Oct 2020 19:23:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758578AbgJWXX2 (ORCPT ); Fri, 23 Oct 2020 19:23:28 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D240EC0613D5 for ; Fri, 23 Oct 2020 16:23:27 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id r10so2520828pgb.10 for ; Fri, 23 Oct 2020 16:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d8xAtwDVMhNalLtWYZPCO9wz9pojtecxgYkkAm7a2YE=; b=mp/78y+GJ0rc6wdkGEh20lyDMfXAtkv4947P3Lkr8AilrLo9WP0oBIeknsHvQAe0el HEcgpmS7KrMrOHe9XqHuqCHhRnQy2hZnwyDji2aXxGt8lRYiA+RCr4HDTDe3/WMb5AmO wEuDDF+XTo2+MHfz9KDQBACMF+CVBN+1nmVWQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d8xAtwDVMhNalLtWYZPCO9wz9pojtecxgYkkAm7a2YE=; b=CQ0iaTcqMx0OYGdBb3+MqBjyPu16V0mtnFtAey0ew8gn3jUdnoC8y+4AXfwQqxIlMK 3zxbv+8KKuboB5ZjYrdhSsBciIvZ5jvhgm9190T+BPE+X8/jQHbxqHwSwnf3RDxnHWIn a7BrVQU4EYaqQzx33QJJ1X41IKVm4fnzhnF44RklNrejpoS02+WFlzkFEklpsG01vcRx yrVpcKaewjBXHDufjOf01j6HR+7JO4aJ69uVvs++mL81LcpsN7J3MLzy8ndk6DVdierU Wkyjhn6+gwzQHCOsLGzbbw3b2tk8UIolvppnCuusV9nJV9ZNGzBY3zc7vPcsU+xubqaV 3n8A== X-Gm-Message-State: AOAM531Y3sdUDFmBvgGQ1y15SqCz51AFM8Jjk3n4W5jtJ+5H08qr1tVM bDbaEOJWKOYvCLQFv+L+LYw8ew== X-Google-Smtp-Source: ABdhPJx1sO6DuIlMnW+hVd4EBOhapt9SdD8UJIqqO1NSna53HQ08BKrQi3asON0KdwrvPVKG6PMS1w== X-Received: by 2002:a63:c55:: with SMTP id 21mr3663254pgm.392.1603495407402; Fri, 23 Oct 2020 16:23:27 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id v17sm3789476pjy.40.2020.10.23.16.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 16:23:26 -0700 (PDT) From: Douglas Anderson To: jkosina@suse.cz, benjamin.tissoires@redhat.com, gregkh@linuxfoundation.org Cc: andrea@borgia.bo.it, kai.heng.feng@canonical.com, linux-input@vger.kernel.org, swboyd@chromium.org, hdegoede@redhat.com, Douglas Anderson , Dmitry Torokhov , Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] dt-bindings: HID: i2c-hid: Introduce bindings for the Goodix GT7375P Date: Fri, 23 Oct 2020 16:22:53 -0700 Message-Id: <20201023162220.v2.2.Ibb28033c81d87fcc13a6ba28c6ea7ac154d65f93@changeid> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201023162220.v2.1.I45b53fe84e2215946f900f5b28bab1aa9d029ac7@changeid> References: <20201023162220.v2.1.I45b53fe84e2215946f900f5b28bab1aa9d029ac7@changeid> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This adds new bindings for the Goodix GT7375P touchscreen. While this touchscreen works with generic "i2c-over-hid", the current advice is to give it its own compatible string. The cleanest way to do this is to give it its own bindings. Among other things, this has the advantage that we can list the two possible i2c addresses for this device, which gives extra checking. Signed-off-by: Douglas Anderson --- Changes in v2: - ("dt-bindings: HID: i2c-hid: Introduce bindings for the Goodix GT7375P") new in v2. .../bindings/input/goodix,gt7375p.yaml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/goodix,gt7375p.yaml diff --git a/Documentation/devicetree/bindings/input/goodix,gt7375p.yaml b/Documentation/devicetree/bindings/input/goodix,gt7375p.yaml new file mode 100644 index 000000000000..b5008f89e26c --- /dev/null +++ b/Documentation/devicetree/bindings/input/goodix,gt7375p.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/goodix,gt7375p.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Goodix GT7375P touchscreen + +maintainers: + - Benjamin Tissoires + - Douglas Anderson + +description: + Supports the Goodix GT7375P touchscreen. + +properties: + compatible: + items: + - const: goodix,gt7375p + + reg: + enum: + - 0x5d + - 0x14 + + interrupts: + maxItems: 1 + + reset-gpios: + true + + vdd-supply: + description: The 3.3V supply to the touchscreen. + +required: + - compatible + - reg + - interrupts + - reset-gpios + - vdd-supply + +additionalProperties: false + +examples: + - | + #include + #include + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + ap_ts: touchscreen@5d { + compatible = "hid-over-i2c"; + reg = <0x5d>; + + interrupt-parent = <&tlmm>; + interrupts = <9 IRQ_TYPE_LEVEL_LOW>; + + reset-gpios = <&tlmm 8 GPIO_ACTIVE_LOW>; + vdd-supply = <&pp3300_ts>; + }; + }; From patchwork Fri Oct 23 23:22:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 285776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E10F6C55178 for ; Fri, 23 Oct 2020 23:23:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A72A321D43 for ; Fri, 23 Oct 2020 23:23:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="gwjD4X8M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758618AbgJWXXa (ORCPT ); Fri, 23 Oct 2020 19:23:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758556AbgJWXX3 (ORCPT ); Fri, 23 Oct 2020 19:23:29 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAAE6C0613D2 for ; Fri, 23 Oct 2020 16:23:29 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id o1so63131pjt.2 for ; Fri, 23 Oct 2020 16:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LqIgRaytoZbiT4gC6MyyI2BK4NdVuPOlLPLkmdt1eMA=; b=gwjD4X8Mki63BN2D4Xi4bEL3G2Z3WH1tRFHUlg2WkNyo6JRvgInn4mgiTavn1Mq+bA XP/D9Wk9BLwyZY3ht9VVe4X3B5P8OShzgBleJaurJfOIjTqBqQEDg9pfNUQiZtxDNV+C td4dr+eedrB4uhJe5Atxl5vzUcIb39ZWphxNU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LqIgRaytoZbiT4gC6MyyI2BK4NdVuPOlLPLkmdt1eMA=; b=nXFdMR/4k+y7JQjx7pYh1Za7MEvRFBhQZIauUlyaSYHDkzqK6SVJIur0igi+vYIzkX a3GaajBxLwRK6D09pczZYz3F9NZunIZ8m6FWeyStbUdGCOF7qqNKcL8mxHSlOTdiEZ9n ZlH8eQFGcPmEL9mgaX9x5rFJ1A/278qzM/ctabNYvDnAOd7bk57fq2dJREIPMLiR2liT jExoOmvKvE80J5j3TjmsAlHuDiZX4+FCnFXX4SpFcD3HssrVPxJHLaosVN5hm6zaxUwN iiwV5S6Oqep7O3UBOuIEVcuwlu6029cX3LlpxTopsi5elr984JK4ycNLMyaGEP2rrHun hr6w== X-Gm-Message-State: AOAM532t/rOtyT2oud2GVzIP7cHBNGwX5gk/7a+l3E16wg+a8KVIc0Dz ROADtJ59ZBMxW+2VBwo3pktCKg== X-Google-Smtp-Source: ABdhPJzIm383ptlg08roMSJ1XKjvtA0rR3QBqnlBzKw07+Yae7oVDxqyQsKCN/4QzSxp7+TudQT7WA== X-Received: by 2002:a17:90a:7f81:: with SMTP id m1mr5651943pjl.197.1603495409233; Fri, 23 Oct 2020 16:23:29 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id v17sm3789476pjy.40.2020.10.23.16.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 16:23:28 -0700 (PDT) From: Douglas Anderson To: jkosina@suse.cz, benjamin.tissoires@redhat.com, gregkh@linuxfoundation.org Cc: andrea@borgia.bo.it, kai.heng.feng@canonical.com, linux-input@vger.kernel.org, swboyd@chromium.org, hdegoede@redhat.com, Douglas Anderson , Aaron Ma , Daniel Playfair Cal , Jiri Kosina , Pavel Balan , Xiaofei Tan , You-Sheng Yang , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] HID: i2c-hid: Support the Goodix GT7375P touchscreen Date: Fri, 23 Oct 2020 16:22:54 -0700 Message-Id: <20201023162220.v2.3.Ied4ce10d229cd7c69abf13a0361ba0b8d82eb9c4@changeid> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201023162220.v2.1.I45b53fe84e2215946f900f5b28bab1aa9d029ac7@changeid> References: <20201023162220.v2.1.I45b53fe84e2215946f900f5b28bab1aa9d029ac7@changeid> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The Goodix GT7375P touchscreen uses i2c-hid so we can support it with just a few changes to the i2c-hid driver. Specifically this touchscreen needs to control a reset GPIO during its power sequencing. The Goodix timing diagram shows this: +---------------------------------- | AVDD ----+ +------------------------------ | (a) | RESET ---------+ +------------- | (b) | I2C comm OK ---------+ Where (a) is 10 ms and (b) is 120 ms. While we could just add some properties and specify this generically in the device tree, the guidance from the device tree maintainer is that it's better to list the specific model and infer everything from there. Thus that's what this patch implements. Signed-off-by: Douglas Anderson --- Changes in v2: - Use a separate compatible string for this new touchscreen. - Get timings based on the compatible string. drivers/hid/i2c-hid/i2c-hid-core.c | 50 ++++++++++++++++++++++++++- include/linux/platform_data/i2c-hid.h | 5 +++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index 786e3e9af1c9..0b2cd78b05e1 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -71,6 +71,12 @@ do { \ dev_printk(KERN_DEBUG, &(ihid)->client->dev, fmt, ##arg); \ } while (0) +struct i2c_hid_match_data { + u16 hid_descriptor_address; + int post_power_delay_ms; + int post_gpio_reset_delay_ms; +}; + struct i2c_hid_desc { __le16 wHIDDescLength; __le16 bcdVersion; @@ -962,6 +968,21 @@ static inline void i2c_hid_acpi_enable_wakeup(struct device *dev) {} #endif #ifdef CONFIG_OF +static bool i2c_hid_init_from_of_match(struct device *dev, + struct i2c_hid_platform_data *pdata) +{ + const struct i2c_hid_match_data *match_data = device_get_match_data(dev); + + if (!match_data) + return false; + + pdata->hid_descriptor_address = match_data->hid_descriptor_address; + pdata->post_power_delay_ms = match_data->post_power_delay_ms; + pdata->post_gpio_reset_delay_ms = match_data->post_gpio_reset_delay_ms; + + return true; +} + static int i2c_hid_of_probe(struct i2c_client *client, struct i2c_hid_platform_data *pdata) { @@ -969,6 +990,11 @@ static int i2c_hid_of_probe(struct i2c_client *client, u32 val; int ret; + /* Try getting everything based on the compatible string first */ + if (i2c_hid_init_from_of_match(&client->dev, pdata)) + return 0; + + /* Fallback to getting hid-descr-addr from a property */ ret = of_property_read_u32(dev->of_node, "hid-descr-addr", &val); if (ret) { dev_err(&client->dev, "HID register address not provided\n"); @@ -984,8 +1010,15 @@ static int i2c_hid_of_probe(struct i2c_client *client, return 0; } +static const struct i2c_hid_match_data goodix_gt7375p_match_data = { + .hid_descriptor_address = 0x0001, + .post_power_delay_ms = 10, + .post_gpio_reset_delay_ms = 120, +}; + static const struct of_device_id i2c_hid_of_match[] = { - { .compatible = "hid-over-i2c" }, + { .compatible = "goodix,gt7375p", .data = &goodix_gt7375p_match_data }, + { .compatible = "hid-over-i2c" }, /* Deprecated */ {}, }; MODULE_DEVICE_TABLE(of, i2c_hid_of_match); @@ -1053,6 +1086,12 @@ static int i2c_hid_probe(struct i2c_client *client, ihid->pdata.supplies[0].supply = "vdd"; ihid->pdata.supplies[1].supply = "vddl"; + /* Start out with reset asserted */ + ihid->pdata.reset_gpio = + devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(ihid->pdata.reset_gpio)) + return PTR_ERR(ihid->pdata.reset_gpio); + ret = devm_regulator_bulk_get(&client->dev, ARRAY_SIZE(ihid->pdata.supplies), ihid->pdata.supplies); @@ -1067,6 +1106,10 @@ static int i2c_hid_probe(struct i2c_client *client, if (ihid->pdata.post_power_delay_ms) msleep(ihid->pdata.post_power_delay_ms); + gpiod_set_value_cansleep(ihid->pdata.reset_gpio, 0); + if (ihid->pdata.post_gpio_reset_delay_ms) + msleep(ihid->pdata.post_gpio_reset_delay_ms); + i2c_set_clientdata(client, ihid); ihid->client = client; @@ -1163,6 +1206,7 @@ static int i2c_hid_remove(struct i2c_client *client) if (ihid->bufsize) i2c_hid_free_buffers(ihid); + gpiod_set_value_cansleep(ihid->pdata.reset_gpio, 1); regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies), ihid->pdata.supplies); @@ -1228,6 +1272,10 @@ static int i2c_hid_resume(struct device *dev) if (ihid->pdata.post_power_delay_ms) msleep(ihid->pdata.post_power_delay_ms); + + gpiod_set_value_cansleep(ihid->pdata.reset_gpio, 0); + if (ihid->pdata.post_gpio_reset_delay_ms) + msleep(ihid->pdata.post_gpio_reset_delay_ms); } else if (ihid->irq_wake_enabled) { wake_status = disable_irq_wake(client->irq); if (!wake_status) diff --git a/include/linux/platform_data/i2c-hid.h b/include/linux/platform_data/i2c-hid.h index c628bb5e1061..b2150223ffa6 100644 --- a/include/linux/platform_data/i2c-hid.h +++ b/include/linux/platform_data/i2c-hid.h @@ -12,6 +12,7 @@ #ifndef __LINUX_I2C_HID_H #define __LINUX_I2C_HID_H +#include #include #include @@ -20,6 +21,8 @@ * @hid_descriptor_address: i2c register where the HID descriptor is stored. * @supplies: regulators for powering on the device. * @post_power_delay_ms: delay after powering on before device is usable. + * @post_gpio_reset_delay_ms: delay after reset via GPIO. + * @reset_gpio: optional gpio to de-assert after post_power_delay_ms. * * Note that it is the responsibility of the platform driver (or the acpi 5.0 * driver, or the flattened device tree) to setup the irq related to the gpio in @@ -36,6 +39,8 @@ struct i2c_hid_platform_data { u16 hid_descriptor_address; struct regulator_bulk_data supplies[2]; int post_power_delay_ms; + int post_gpio_reset_delay_ms; + struct gpio_desc *reset_gpio; }; #endif /* __LINUX_I2C_HID_H */