From patchwork Tue Jul 25 20:34:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 125801 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp2103vqo; Tue, 25 Jul 2023 13:45:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlFqhzSv2eScnIgD46faBCIgncyGDK+69axj0sfXUGtYSEpvBuprorEKvxsLMRKlMos+/SlX X-Received: by 2002:a17:907:7625:b0:99b:4d3c:d7e4 with SMTP id jy5-20020a170907762500b0099b4d3cd7e4mr13407892ejc.63.1690317906767; Tue, 25 Jul 2023 13:45:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690317906; cv=none; d=google.com; s=arc-20160816; b=uAWO1vp/Vuh/zYs22CIle2bjCmAlTKUqCMfzE1vgmmGliVFvqvFAkrCSfCBc2bTI2Z p7Y4vWlPJqwAGxsexIdEmc8cW/v94KVf/QmeqmapZjGZpYfLgPwK3wN4hSNUue6dCdXn kRAYFVmiKFhg0pSf9POtGQce3PER3GzO23GBqG/D7JTD8T0EUWM096dpVsT+bRss0msu OSDf00VgjR6cNWXFvg3WeP0P+TeJirO7p4leMhZzjy6JFJQjGzZ/IWwi1KK4BKzj3ZdK /Bj092y5ka1QueJIQGwlVHTQSrHObR0+xOJraQziWYvoAhCMoGD3mlBh1jmEKOVs5WIY 5sDg== 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=Vug0/nTFX8HO+SAnOamtMcLZ6ZH608dzw2nZDsl1wy8=; fh=SR6gopKkpsJzcK81N+yIM2UKbfIRHNVfhaSPeEPS/8g=; b=ermnR5vR6/7R68HqEHFldWxRAGPp0f/YX75QmEgVSfIZdUEX+HiAY6BBoeJmXMblii 3U8FGUOBstIVml9yAvsonV5Zq3cDvMGqpZ35tSSoLSOwFOKGyTzmO0Q/mpXNExDQL23A thDLUMCan8uqe+pOT69gNVcs1XfK3PqGEiA9X0e2yUjuvrumZMvQnJLgOzSc9kRvfdLk O5RPi2RJKgkbBq4qWpDGTFeES1c3g6I/FKlL+tuyivhQhPrru5SDIzaHnoJvn0zIvfFg vsmyVxD7k4MqZOpBO9R0jWNcuxFZwvYGEF+cUJMGpF0GqlAZXvLU6ogZ7k+e+b7g4us1 JS+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lbVLtx4h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lg4-20020a170906f88400b0098f564f636fsi8213490ejb.1000.2023.07.25.13.44.43; Tue, 25 Jul 2023 13:45:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lbVLtx4h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230498AbjGYUhB (ORCPT + 99 others); Tue, 25 Jul 2023 16:37:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230494AbjGYUg7 (ORCPT ); Tue, 25 Jul 2023 16:36:59 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCD1D19A7 for ; Tue, 25 Jul 2023 13:36:57 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1bbc87ded50so3154145ad.1 for ; Tue, 25 Jul 2023 13:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690317417; x=1690922217; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vug0/nTFX8HO+SAnOamtMcLZ6ZH608dzw2nZDsl1wy8=; b=lbVLtx4hawMq5I080q+oToFTxyc6v6bosk165MRmbugZnfuhF31ItqVkRUAkZjutOw WIaLBwyPHkjC4XIR1DDCQtEx+c7Xxocb3RDBVJqDHyPqL4cNT2L7k/0maaU2NBk1kqWo SdNFbskTdR6zphWqI4pbKO0FGlCP2SxMpLr0U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690317417; x=1690922217; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vug0/nTFX8HO+SAnOamtMcLZ6ZH608dzw2nZDsl1wy8=; b=DNw6253z6SQmvT8oLz8n77QPt6ed6lYfSdwSHamNz4VXAT6EeRCHOZiAwPtpazpjzc LeU4gvq+GDMKPVeNyi8jy8kWave0ImJB/BOYYZ25VbwZBAUepDql80yoglzPWYxSZLsI YYiShpXAodv/pNa30aB0/TDQ8QbCe/gwitEHwdnjnNtF0/9OvPipc1QCH7W0yHk7kktA Yhtp/b3IEAcVNO3Lc1NWUq3qRi0fgGpPlLDt31YJd2WXi8cyXUPFOQc3VahNDyJ5ZtY6 eVZHW7W8JAk10gkeguYLJKVTJqHiBohUiYnBdkBQ/ewmsEu3SkPzqERIb6cPWriuttFO FGrQ== X-Gm-Message-State: ABy/qLYYdkiXYAwdJ66eXxxQiRtoZD5tgdyuofn1vlCWqEgraMKgiAu3 l425JN4U8V4Ewyrdhh2N+LzYEg== X-Received: by 2002:a17:90a:542:b0:267:f9ab:15bb with SMTP id h2-20020a17090a054200b00267f9ab15bbmr240485pjf.14.1690317417199; Tue, 25 Jul 2023 13:36:57 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:c363:4681:f5b8:301]) by smtp.gmail.com with ESMTPSA id bg1-20020a17090b0d8100b002676e961261sm1396951pjb.1.2023.07.25.13.36.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 13:36:56 -0700 (PDT) From: Douglas Anderson To: Jiri Kosina , Benjamin Tissoires , Bjorn Andersson , Konrad Dybcio , Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: cros-qcom-dts-watchers@chromium.org, Chris Morgan , linux-input@vger.kernel.org, hsinyi@google.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Torokhov , devicetree@vger.kernel.org, Daniel Vetter , yangcong5@huaqin.corp-partner.google.com, Douglas Anderson , Krzysztof Kozlowski Subject: [PATCH v3 01/10] dt-bindings: HID: i2c-hid: Add "panel" property to i2c-hid backed touchscreens Date: Tue, 25 Jul 2023 13:34:36 -0700 Message-ID: <20230725133443.v3.1.Id68e30343bb1e11470582a9078b086176cfec46b@changeid> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230725203545.2260506-1-dianders@chromium.org> References: <20230725203545.2260506-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772426789539503489 X-GMAIL-MSGID: 1772426789539503489 As talked about in the patch ("drm/panel: Add a way for other devices to follow panel state"), touchscreens that are connected to panels are generally expected to be power sequenced together with the panel they're attached to. Today, nothing provides information allowing you to find out that a touchscreen is connected to a panel. Let's add a phandle for this. The proerty is added to the generic touchscreen bindings and then enabled in the bindings for the i2c-hid backed devices. This can and should be added for other touchscreens in the future, but for now let's start small. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Douglas Anderson --- (no changes since v2) Changes in v2: - Move the description to the generic touchscreen.yaml. - Update the desc to make it clearer it's only for integrated devices. Documentation/devicetree/bindings/input/elan,ekth6915.yaml | 5 +++++ .../devicetree/bindings/input/goodix,gt7375p.yaml | 5 +++++ Documentation/devicetree/bindings/input/hid-over-i2c.yaml | 2 ++ .../devicetree/bindings/input/touchscreen/touchscreen.yaml | 7 +++++++ 4 files changed, 19 insertions(+) diff --git a/Documentation/devicetree/bindings/input/elan,ekth6915.yaml b/Documentation/devicetree/bindings/input/elan,ekth6915.yaml index 05e6f2df604c..3e2d216c6432 100644 --- a/Documentation/devicetree/bindings/input/elan,ekth6915.yaml +++ b/Documentation/devicetree/bindings/input/elan,ekth6915.yaml @@ -13,6 +13,9 @@ description: Supports the Elan eKTH6915 touchscreen controller. This touchscreen controller uses the i2c-hid protocol with a reset GPIO. +allOf: + - $ref: /schemas/input/touchscreen/touchscreen.yaml# + properties: compatible: items: @@ -24,6 +27,8 @@ properties: interrupts: maxItems: 1 + panel: true + reset-gpios: description: Reset GPIO; not all touchscreens using eKTH6915 hook this up. diff --git a/Documentation/devicetree/bindings/input/goodix,gt7375p.yaml b/Documentation/devicetree/bindings/input/goodix,gt7375p.yaml index 1edad1da1196..358cb8275bf1 100644 --- a/Documentation/devicetree/bindings/input/goodix,gt7375p.yaml +++ b/Documentation/devicetree/bindings/input/goodix,gt7375p.yaml @@ -14,6 +14,9 @@ description: This touchscreen uses the i2c-hid protocol but has some non-standard power sequencing required. +allOf: + - $ref: /schemas/input/touchscreen/touchscreen.yaml# + properties: compatible: oneOf: @@ -30,6 +33,8 @@ properties: interrupts: maxItems: 1 + panel: true + reset-gpios: true diff --git a/Documentation/devicetree/bindings/input/hid-over-i2c.yaml b/Documentation/devicetree/bindings/input/hid-over-i2c.yaml index 7156b08f7645..138caad96a29 100644 --- a/Documentation/devicetree/bindings/input/hid-over-i2c.yaml +++ b/Documentation/devicetree/bindings/input/hid-over-i2c.yaml @@ -44,6 +44,8 @@ properties: description: HID descriptor address $ref: /schemas/types.yaml#/definitions/uint32 + panel: true + post-power-on-delay-ms: description: Time required by the device after enabling its regulators or powering it on, before it is ready for communication. diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml index 895592da9626..431c13335c40 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml @@ -10,6 +10,13 @@ maintainers: - Dmitry Torokhov properties: + panel: + description: If this touchscreen is integrally connected to a panel, this + is a reference to that panel. The presence of this reference indicates + that the touchscreen should be power sequenced together with the panel + and that they may share power and/or reset signals. + $ref: /schemas/types.yaml#/definitions/phandle + touchscreen-min-x: description: minimum x coordinate reported $ref: /schemas/types.yaml#/definitions/uint32 From patchwork Tue Jul 25 20:34:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 125804 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp4204vqo; Tue, 25 Jul 2023 13:51:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlEQJ0aK24+Qr0OPQR3EVUG30Ovp4JePgQXiWyEXUDjkZ58HdEbixPIY2uyx41aoYXuYthat X-Received: by 2002:a17:906:64c8:b0:993:f081:2c5a with SMTP id p8-20020a17090664c800b00993f0812c5amr3200ejn.5.1690318288836; Tue, 25 Jul 2023 13:51:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690318288; cv=none; d=google.com; s=arc-20160816; b=aucKogFdF349JV7TjhnYVXmeXzTDCZA8a/OICjxJdOM38+ijzwcpqL8cAWYZ2goMnp 2SMzEoaNWkIcCP1hi14EmgQRGbKNXiJuzJa09rTCHgwV29S5hEhz/1ljJjzqTUKnDDXc EkHQYlNSgci6yRGZJb/akXxg00lsPAXXw/s2pCQk1BvZH7AqLKPcKnusWhCpc9CB7ADp akg8ccTRoEmtyzhi2KAS8j5Penx1ebpbm6/lq6+RP//Gtvd7dyr8S31bzR85x2tPWGry pXxAcw7Neno86WSubScNk8xlTRQdiC5x6qNq4Y5Lrj24McWPCnyOcOpNKJwLEAWhP/je /trg== 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=iP077J8EmgyqkeILX2Yz7pVClwWU9gA5lNNcugVIOYM=; fh=l9Sxp0WjWxoPPBlRLV6ri41IHQAwx7j1EblxKJXOsZc=; b=ywZPB3xgPWD6AX5k+8POlyYhYqlY2kzaIMGrhSJG3PpaE9e9bKWRTBfFcOqBegfzYf 0tU98U5WgrDijaWzCMEuYy6JT6MDrC34yMwOwpzHGSSt40Eh94ADoE0ACRFAVT49iYtC zmKiOFVCFe8a4aG4AYrJBcN2tkGUjZdQRAs91TsoyPybYZoFHA3ULKgHfZptD4ccHKlX eM6pQlXWgqwG2cYvUY1lKgGmi5CAcd3fq7emLYM1cT2/2047R+XN4LT8dr2IlUdWzNCO kpECd4Tvr2o5doZJ/vdP7cy4JAoHQXOMz9TGvHHd5WY9/kWaO+lBWmIAxkqZfosjDpq4 nGig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GZtIAhgp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p21-20020a1709060dd500b0098d2f716c75si8011733eji.597.2023.07.25.13.51.04; Tue, 25 Jul 2023 13:51:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GZtIAhgp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231159AbjGYUhI (ORCPT + 99 others); Tue, 25 Jul 2023 16:37:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230500AbjGYUhB (ORCPT ); Tue, 25 Jul 2023 16:37:01 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F85610F7 for ; Tue, 25 Jul 2023 13:37:00 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-563c7aabf38so187187a12.0 for ; Tue, 25 Jul 2023 13:37:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690317419; x=1690922219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iP077J8EmgyqkeILX2Yz7pVClwWU9gA5lNNcugVIOYM=; b=GZtIAhgpfRM6/PPCpYhDawEQ6STVkqSIEtcARCGIslDV0E2Oz5EubU2sXZt7Y5WysZ nKHRRDgxz+IHkbiAD+r0tr3hYj9QMJNtPXWKWcYKUibKzK1RlYALHKuldQpyQ+rjq2tC vqm+0xJeEEXyQUwsjDBcku/nb5WAuu2nfu6Mw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690317419; x=1690922219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iP077J8EmgyqkeILX2Yz7pVClwWU9gA5lNNcugVIOYM=; b=X+d4cBZzlhzn651uzeqiyzzLa98K/pQU9V8OyfTmOZ8tgGgTAzBWNMw67ag2y4W5zP 2niJ+f71uATipKMG8sEJHHcVTc0DO2i1QyaviioznIkQM06Pb7Lr03Kh9DRZqKpwc5+Y 1z72WChGM7aZj7x1aWjCSjkmCK9OPB81xh2Th4TtRqU25kcNUDguMykIEhqscOqA4z4q 6fnth3mk6kdSewV6dJwyw8YNR+8BpqKG2NHAIWpcVcKYHcNpHz4PZyNsj3G8ASdoGGU/ 2R2k4ndoXjcYgupR2mfAKdTAdJ1Pd2zqNaMUruHEkg0Zo6Ert8ae0NvT+2yh29rU5rcB bsbA== X-Gm-Message-State: ABy/qLYmr4ot0Q9CtgClUlzDLsjBznbSYpCo6xCl+OWC07NePVwREjTX 66jpCMXaGBvPYp9U6B0nIAnFpQ== X-Received: by 2002:a17:90a:4a8e:b0:268:e3d:1251 with SMTP id f14-20020a17090a4a8e00b002680e3d1251mr269480pjh.20.1690317419541; Tue, 25 Jul 2023 13:36:59 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:c363:4681:f5b8:301]) by smtp.gmail.com with ESMTPSA id bg1-20020a17090b0d8100b002676e961261sm1396951pjb.1.2023.07.25.13.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 13:36:58 -0700 (PDT) From: Douglas Anderson To: Jiri Kosina , Benjamin Tissoires , Bjorn Andersson , Konrad Dybcio , Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: cros-qcom-dts-watchers@chromium.org, Chris Morgan , linux-input@vger.kernel.org, hsinyi@google.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Torokhov , devicetree@vger.kernel.org, Daniel Vetter , yangcong5@huaqin.corp-partner.google.com, Douglas Anderson Subject: [PATCH v3 02/10] drm/panel: Check for already prepared/enabled in drm_panel Date: Tue, 25 Jul 2023 13:34:37 -0700 Message-ID: <20230725133443.v3.2.I59b417d4c29151cc2eff053369ec4822b606f375@changeid> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230725203545.2260506-1-dianders@chromium.org> References: <20230725203545.2260506-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772427189794567059 X-GMAIL-MSGID: 1772427189794567059 In a whole pile of panel drivers, we have code to make the prepare/unprepare/enable/disable callbacks behave as no-ops if they've already been called. It's silly to have this code duplicated everywhere. Add it to the core instead so that we can eventually delete it from all the drivers. Note: to get some idea of the duplicated code, try: git grep 'if.*>prepared' -- drivers/gpu/drm/panel git grep 'if.*>enabled' -- drivers/gpu/drm/panel NOTE: arguably, the right thing to do here is actually to skip this patch and simply remove all the extra checks from the individual drivers. Perhaps the checks were needed at some point in time in the past but maybe they no longer are? Certainly as we continue transitioning over to "panel_bridge" then we expect there to be much less variety in how these calls are made. When we're called as part of the bridge chain, things should be pretty simple. In fact, there was some discussion in the past about these checks [1], including a discussion about whether the checks were needed and whether the calls ought to be refcounted. At the time, I decided not to mess with it because it felt too risky. Looking closer at it now, I'm fairly certain that nothing in the existing codebase is expecting these calls to be refcounted. The only real question is whether someone is already doing something to ensure prepare()/unprepare() match and enabled()/disable() match. I would say that, even if there is something else ensuring that things match, there's enough complexity that adding an extra bool and an extra double-check here is a good idea. Let's add a drm_warn() to let people know that it's considered a minor error to take advantage of drm_panel's double-checking but we'll still make things work fine. [1] https://lore.kernel.org/r/20210416153909.v4.27.I502f2a92ddd36c3d28d014dd75e170c2d405a0a5@changeid Acked-by: Neil Armstrong Signed-off-by: Douglas Anderson --- This has Neil's Ack and I could commit it to drm-misc-next, but for now I'm holding off to see where this series ends up. If the series ends up looking good we'll have to coordinate landing the various bits between the drm and the hid trees and the second drm patch in my series depends on this one. If my series implodes I'll land this one on its own. In any case, once this lands somewhere I'll take an AI to cleanup the panels. (no changes since v1) drivers/gpu/drm/drm_panel.c | 49 ++++++++++++++++++++++++++++++++----- include/drm/drm_panel.h | 14 +++++++++++ 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index f634371c717a..4e1c4e42575b 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -105,11 +105,22 @@ EXPORT_SYMBOL(drm_panel_remove); */ int drm_panel_prepare(struct drm_panel *panel) { + int ret; + if (!panel) return -EINVAL; - if (panel->funcs && panel->funcs->prepare) - return panel->funcs->prepare(panel); + if (panel->prepared) { + dev_warn(panel->dev, "Skipping prepare of already prepared panel\n"); + return 0; + } + + if (panel->funcs && panel->funcs->prepare) { + ret = panel->funcs->prepare(panel); + if (ret < 0) + return ret; + } + panel->prepared = true; return 0; } @@ -128,11 +139,22 @@ EXPORT_SYMBOL(drm_panel_prepare); */ int drm_panel_unprepare(struct drm_panel *panel) { + int ret; + if (!panel) return -EINVAL; - if (panel->funcs && panel->funcs->unprepare) - return panel->funcs->unprepare(panel); + if (!panel->prepared) { + dev_warn(panel->dev, "Skipping unprepare of already unprepared panel\n"); + return 0; + } + + if (panel->funcs && panel->funcs->unprepare) { + ret = panel->funcs->unprepare(panel); + if (ret < 0) + return ret; + } + panel->prepared = false; return 0; } @@ -155,11 +177,17 @@ int drm_panel_enable(struct drm_panel *panel) if (!panel) return -EINVAL; + if (panel->enabled) { + dev_warn(panel->dev, "Skipping enable of already enabled panel\n"); + return 0; + } + if (panel->funcs && panel->funcs->enable) { ret = panel->funcs->enable(panel); if (ret < 0) return ret; } + panel->enabled = true; ret = backlight_enable(panel->backlight); if (ret < 0) @@ -187,13 +215,22 @@ int drm_panel_disable(struct drm_panel *panel) if (!panel) return -EINVAL; + if (!panel->enabled) { + dev_warn(panel->dev, "Skipping disable of already disabled panel\n"); + return 0; + } + ret = backlight_disable(panel->backlight); if (ret < 0) DRM_DEV_INFO(panel->dev, "failed to disable backlight: %d\n", ret); - if (panel->funcs && panel->funcs->disable) - return panel->funcs->disable(panel); + if (panel->funcs && panel->funcs->disable) { + ret = panel->funcs->disable(panel); + if (ret < 0) + return ret; + } + panel->enabled = false; return 0; } diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 432fab2347eb..c6cf75909389 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -198,6 +198,20 @@ struct drm_panel { * the panel is powered up. */ bool prepare_prev_first; + + /** + * @prepared: + * + * If true then the panel has been prepared. + */ + bool prepared; + + /** + * @enabled: + * + * If true then the panel has been enabled. + */ + bool enabled; }; void drm_panel_init(struct drm_panel *panel, struct device *dev, From patchwork Tue Jul 25 20:34:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 125805 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp12548vqo; Tue, 25 Jul 2023 14:10:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlFOKe17Q4Pl+tu5dhVAh+d1PAjWowdHgIyZ3LYsYdfG6+AL9/RAM6WJuT017G7J8YgQqXAA X-Received: by 2002:a05:6a21:4985:b0:10f:52e2:49ec with SMTP id ax5-20020a056a21498500b0010f52e249ecmr164342pzc.53.1690319405790; Tue, 25 Jul 2023 14:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690319405; cv=none; d=google.com; s=arc-20160816; b=WxUpFdxyw3OnZqkh/3LnvNilXW1WMNMkjdb1Hmc+Lm/FuOzuWALN+PhV6RD6uSmtuX EIuz9oxXs01bX/mCqdRJ79HR3qvSyjT4MR0gzWGsGmWkD6WG5JROvLhckKgWJ2OzANsA v2fgGEfN0J3YRRNifOkAl6I01x3v8jo4DorqIXS1A5/SqrjyVmVofzT6HNZr+9VzfWWL hOG17Q8Pb4RWSOniyGphg/epaE1bcKurpJCDqLvWTsu7H4TigrwpMG/wk7h85yieQEvc ty9bGqH4UW2HE+Pxa3m8W2Uv0u+0rfldZUOGXxCXhRoXqeucSfiONHVmn2o8GFy8I1ki Azxw== 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=df8uPWWKgNUJNGqmzE4JLwOSLgI3EOexaoTRxYQ2qW0=; fh=l9Sxp0WjWxoPPBlRLV6ri41IHQAwx7j1EblxKJXOsZc=; b=n+WuBa1G0vt1Qek49V7BCDGGwimuYwNGTE/p3UREx4PBF55fl8HGcUKmAfWj/LHG1Z i7YrhUi8x/ply6yNVdmNw2EwRFT08+OMJxw0cAlgZUM1PtF91zghJ3o8OgO5kaHt0jJp T2rj2Lg6lj8QJw2d54MrEE9V0NdWWgYZC5ouSrWiT5FqzqOo7EQotd6yqnUUDvoRD8C0 XkVrK6qkGy8NApQaTllCAGLa3XlS2Kw2dLLycekJdj16L3R567mdRy1vcGfKmuRC88PH cG/Nl6ccQmwswIQ6eRqWlPKLvGtGFqvag9w/ura6rc25AsnsxVq6sMhqfpVueIXGQCYe lmsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=euQ1y1eL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bs123-20020a632881000000b0055337ca9ce9si11811079pgb.248.2023.07.25.14.09.29; Tue, 25 Jul 2023 14:10:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=euQ1y1eL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231157AbjGYUhM (ORCPT + 99 others); Tue, 25 Jul 2023 16:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231216AbjGYUhH (ORCPT ); Tue, 25 Jul 2023 16:37:07 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF11B1FDA for ; Tue, 25 Jul 2023 13:37:02 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-563d3e4f73cso480524a12.3 for ; Tue, 25 Jul 2023 13:37:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690317422; x=1690922222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=df8uPWWKgNUJNGqmzE4JLwOSLgI3EOexaoTRxYQ2qW0=; b=euQ1y1eLLNbwUWa7hQ4JpJoVBvc7HkJwBCYVUNIdu0ZtCaRRUsWWjo8I3ugR7b7s2J NXU/kDcTyLZqp57G70Q9vDfqVZ7mSCBQCjbgayS2CXGcavEGibZjpxrX9J5vVHZe3z0e DmTbIoTmq5RWLSwBEpu9qYhe6eUQJvu0V4J6w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690317422; x=1690922222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=df8uPWWKgNUJNGqmzE4JLwOSLgI3EOexaoTRxYQ2qW0=; b=atLsOc9ng407UgCWVjybO833Y8CJf2lR/rK+pwdvlyaqVIq1Tm1s/KYYUfVWsy/++m D9/SyXKEp99DGie5ecwoIk9R3QVudtcFhOR+AHdVl43qYW0Ed9gtPgODDsCSVMB0wFz2 eu0HiNnggnYsywesOqL2jzVy6aYcIeSD+C97vD359FlU+9a/QgH1ibC1yiiIOUwpKYmu eZfKf4sNhXOXOAvcbxgv9fzaBBSrK8nYLHksALJEdiEEPM3rFxLv83N4NYdCE/PqB8Gs t8MeomZGEovOTwcrtKGZq4NA9afm+5bPHKJUvfTgSa0ZWik8+ZF5Qj06rhExeE8pKPDv V2bA== X-Gm-Message-State: ABy/qLYP9O7KUUTOmi39uudmzj9Nk9jwfQZ5E3jICB2aQum9DmD6DZcj +a06YgO2elOncSFkKWIq5RDu2w== X-Received: by 2002:a17:90a:f191:b0:268:a26:d9ee with SMTP id bv17-20020a17090af19100b002680a26d9eemr196450pjb.46.1690317421952; Tue, 25 Jul 2023 13:37:01 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:c363:4681:f5b8:301]) by smtp.gmail.com with ESMTPSA id bg1-20020a17090b0d8100b002676e961261sm1396951pjb.1.2023.07.25.13.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 13:37:01 -0700 (PDT) From: Douglas Anderson To: Jiri Kosina , Benjamin Tissoires , Bjorn Andersson , Konrad Dybcio , Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: cros-qcom-dts-watchers@chromium.org, Chris Morgan , linux-input@vger.kernel.org, hsinyi@google.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Torokhov , devicetree@vger.kernel.org, Daniel Vetter , yangcong5@huaqin.corp-partner.google.com, Douglas Anderson Subject: [PATCH v3 03/10] drm/panel: Add a way for other devices to follow panel state Date: Tue, 25 Jul 2023 13:34:38 -0700 Message-ID: <20230725133443.v3.3.Icd5f96342d2242051c754364f4bee13ef2b986d4@changeid> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230725203545.2260506-1-dianders@chromium.org> References: <20230725203545.2260506-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772428361086269397 X-GMAIL-MSGID: 1772428361086269397 These days, it's fairly common to see panels that have touchscreens attached to them. The panel and the touchscreen can somewhat be thought of as totally separate devices and, historically, this is how Linux has treated them. However, treating them as separate isn't necessarily the best way to model the two devices, it was just that there was no better way. Specifically, there is little practical reason to have the touchscreen powered on when the panel is turned off, but if we model the devices separately we have no way to keep the two devices' power states in sync with each other. The issue described above makes it sound as if the problem here is just about efficiency. We're wasting power keeping the touchscreen powered up when the screen is off. While that's true, the problem can go deeper. Specifically, hardware designers see that there's no reason to have the touchscreen on while the screen is off and then build hardware assuming that software would never turn the touchscreen on while the screen is off. In the very simplest case of hardware designs like this, the touchscreen and the panel share some power rails. In most cases, this turns out not to be terrible and is, again, just a little less efficient. Specifically if we tell Linux that the touchscreen and the panel are using the same rails then Linux will keep the rails on when _either_ device is turned on. That ends to work OK-ish, but now if you turn the panel off not only will the touchscreen remain powered, but the power rails for the panel itself won't be switched off, burning extra power. The above two inefficiencies are _extra_ minor when you consider the fact that laptops rarely spend much time with the screen off. The main use case would be when an external screen (and presumably a power supply) is attached. Unfortunately, it gets worse from here. On sc7180-trogdor-homestar, for instance, the display's TCON (timing controller) sometimes crashes if you don't power cycle it whenever you stop and restart the video stream (like during a modeset). The touchscreen keeping the power rails on causes real problems. One proposal in the homestar timeframe was to move the touchscreen to an always-on rail, dedicating the main power rail to the panel. That caused _different_ problems as talked about in commit 557e05fa9fdd ("HID: i2c-hid: goodix: Stop tying the reset line to the regulator"). The end result of all of this was to add an extra regulator to the board, increasing cost. Recently, Cong Yang posted a patch [1] where things are even worse. The panel and touch controller on that system seem even more intimately tied together and really can't be thought of separately. To address this issue, let's start allowing devices to register themselves as "panel followers". These devices will get called after a panel has been powered on and before a panel is powered off. This makes the panel the primary device in charge of the power state, which matches how userspace uses it. The panel follower API should be fairly straightforward to use. The current code assumes that panel followers are using device tree and have a "panel" property pointing to the panel to follow. More flexibility and non-DT implementations could be added as needed. Right now, panel followers can follow the prepare/unprepare functions. There could be arguments made that, instead, they should follow enable/disable. I've chosen prepare/unprepare for now since those functions are guaranteed to power up/power down the panel and it seems better to start the process earlier. A bit of explaining about why this is a roll-your-own API instead of using something more standard: 1. In standard APIs in Linux, parent devices are automatically powered on when a child needs power. Applying that here, it would mean that we'd force the panel on any time someone was listening to the touchscreen. That, unfortunately, would have broken homestar's need (if we hadn't changed the hardware, as per above) where the panel absolutely needs to be able to power cycle itself. While one could argue that homestar is broken hardware and we shouldn't have the API do backflips for it, _officially_ the eDP timing guidelines agree with homestar's needs and the panel power sequencing diagrams show power going off. It's nice to be able to support this. 2. We could, conceibably, try to add a new flag to device_link causing the parent to be in charge of power. Then we could at least use normal pm_runtime APIs. This sounds great, except that we run into problems with initial probe. As talked about in the later patch ("HID: i2c-hid: Support being a panel follower") the initial power on of a panel follower might need to do things (like add sub-devices) that aren't allowed in a runtime_resume function. The above complexities explain why this API isn't using common functions. That being said, this patch is very small and self-contained, so if someone was later able to adapt it to using more common APIs while solving the above issues then that could happen in the future. [1] https://lore.kernel.org/r/20230519032316.3464732-1-yangcong5@huaqin.corp-partner.google.com Signed-off-by: Douglas Anderson --- Changes in v3: - Add is_panel_follower() as a convenience for clients. Changes in v2: - Add even more text to the commit message. - A few comment cleanups. drivers/gpu/drm/drm_panel.c | 173 +++++++++++++++++++++++++++++++++++- include/drm/drm_panel.h | 80 +++++++++++++++++ 2 files changed, 249 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 4e1c4e42575b..e814020bbcd3 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -58,6 +58,8 @@ void drm_panel_init(struct drm_panel *panel, struct device *dev, const struct drm_panel_funcs *funcs, int connector_type) { INIT_LIST_HEAD(&panel->list); + INIT_LIST_HEAD(&panel->followers); + mutex_init(&panel->follower_lock); panel->dev = dev; panel->funcs = funcs; panel->connector_type = connector_type; @@ -105,6 +107,7 @@ EXPORT_SYMBOL(drm_panel_remove); */ int drm_panel_prepare(struct drm_panel *panel) { + struct drm_panel_follower *follower; int ret; if (!panel) @@ -115,14 +118,27 @@ int drm_panel_prepare(struct drm_panel *panel) return 0; } + mutex_lock(&panel->follower_lock); + if (panel->funcs && panel->funcs->prepare) { ret = panel->funcs->prepare(panel); if (ret < 0) - return ret; + goto exit; } panel->prepared = true; - return 0; + list_for_each_entry(follower, &panel->followers, list) { + ret = follower->funcs->panel_prepared(follower); + if (ret < 0) + dev_info(panel->dev, "%ps failed: %d\n", + follower->funcs->panel_prepared, ret); + } + + ret = 0; +exit: + mutex_unlock(&panel->follower_lock); + + return ret; } EXPORT_SYMBOL(drm_panel_prepare); @@ -139,6 +155,7 @@ EXPORT_SYMBOL(drm_panel_prepare); */ int drm_panel_unprepare(struct drm_panel *panel) { + struct drm_panel_follower *follower; int ret; if (!panel) @@ -149,14 +166,27 @@ int drm_panel_unprepare(struct drm_panel *panel) return 0; } + mutex_lock(&panel->follower_lock); + + list_for_each_entry(follower, &panel->followers, list) { + ret = follower->funcs->panel_unpreparing(follower); + if (ret < 0) + dev_info(panel->dev, "%ps failed: %d\n", + follower->funcs->panel_unpreparing, ret); + } + if (panel->funcs && panel->funcs->unprepare) { ret = panel->funcs->unprepare(panel); if (ret < 0) - return ret; + goto exit; } panel->prepared = false; - return 0; + ret = 0; +exit: + mutex_unlock(&panel->follower_lock); + + return ret; } EXPORT_SYMBOL(drm_panel_unprepare); @@ -342,6 +372,141 @@ int of_drm_get_panel_orientation(const struct device_node *np, EXPORT_SYMBOL(of_drm_get_panel_orientation); #endif +/** + * drm_is_panel_follower() - Check if the device is a panel follower + * @dev: The 'struct device' to check + * + * This checks to see if a device needs to be power sequenced together with + * a panel using the panel follower API. + * At the moment panels can only be followed on device tree enabled systems. + * The "panel" property of the follower points to the panel to be followed. + * + * Return: true if we should be power sequenced with a panel; false otherwise. + */ +bool drm_is_panel_follower(struct device *dev) +{ + /* + * The "panel" property is actually a phandle, but for simplicity we + * don't bother trying to parse it here. We just need to know if the + * property is there. + */ + return of_property_read_bool(dev->of_node, "panel"); +} +EXPORT_SYMBOL(drm_is_panel_follower); + +/** + * drm_panel_add_follower() - Register something to follow panel state. + * @follower_dev: The 'struct device' for the follower. + * @follower: The panel follower descriptor for the follower. + * + * A panel follower is called right after preparing the panel and right before + * unpreparing the panel. It's primary intention is to power on an associated + * touchscreen, though it could be used for any similar devices. Multiple + * devices are allowed the follow the same panel. + * + * If a follower is added to a panel that's already been turned on, the + * follower's prepare callback is called right away. + * + * At the moment panels can only be followed on device tree enabled systems. + * The "panel" property of the follower points to the panel to be followed. + * + * Return: 0 or an error code. Note that -ENODEV means that we detected that + * follower_dev is not actually following a panel. The caller may + * choose to ignore this return value if following a panel is optional. + */ +int drm_panel_add_follower(struct device *follower_dev, + struct drm_panel_follower *follower) +{ + struct device_node *panel_np; + struct drm_panel *panel; + int ret; + + panel_np = of_parse_phandle(follower_dev->of_node, "panel", 0); + if (!panel_np) + return -ENODEV; + + panel = of_drm_find_panel(panel_np); + of_node_put(panel_np); + if (IS_ERR(panel)) + return PTR_ERR(panel); + + get_device(panel->dev); + follower->panel = panel; + + mutex_lock(&panel->follower_lock); + + list_add_tail(&follower->list, &panel->followers); + if (panel->prepared) { + ret = follower->funcs->panel_prepared(follower); + if (ret < 0) + dev_info(panel->dev, "%ps failed: %d\n", + follower->funcs->panel_prepared, ret); + } + + mutex_unlock(&panel->follower_lock); + + return 0; +} +EXPORT_SYMBOL(drm_panel_add_follower); + +/** + * drm_panel_remove_follower() - Reverse drm_panel_add_follower(). + * @follower: The panel follower descriptor for the follower. + * + * Undo drm_panel_add_follower(). This includes calling the follower's + * unprepare function if we're removed from a panel that's currently prepared. + * + * Return: 0 or an error code. + */ +void drm_panel_remove_follower(struct drm_panel_follower *follower) +{ + struct drm_panel *panel = follower->panel; + int ret; + + mutex_lock(&panel->follower_lock); + + if (panel->prepared) { + ret = follower->funcs->panel_unpreparing(follower); + if (ret < 0) + dev_info(panel->dev, "%ps failed: %d\n", + follower->funcs->panel_unpreparing, ret); + } + list_del_init(&follower->list); + + mutex_unlock(&panel->follower_lock); + + put_device(panel->dev); +} +EXPORT_SYMBOL(drm_panel_remove_follower); + +static void drm_panel_remove_follower_void(void *follower) +{ + drm_panel_remove_follower(follower); +} + +/** + * devm_drm_panel_add_follower() - devm version of drm_panel_add_follower() + * @follower_dev: The 'struct device' for the follower. + * @follower: The panel follower descriptor for the follower. + * + * Handles calling drm_panel_remove_follower() using devm on the follower_dev. + * + * Return: 0 or an error code. + */ +int devm_drm_panel_add_follower(struct device *follower_dev, + struct drm_panel_follower *follower) +{ + int ret; + + ret = drm_panel_add_follower(follower_dev, follower); + if (ret) + return ret; + + return devm_add_action_or_reset(follower_dev, + drm_panel_remove_follower_void, follower); +} +EXPORT_SYMBOL(devm_drm_panel_add_follower); + #if IS_REACHABLE(CONFIG_BACKLIGHT_CLASS_DEVICE) /** * drm_panel_of_backlight - use backlight device node for backlight diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index c6cf75909389..5ac67eeb0860 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -27,12 +27,14 @@ #include #include #include +#include struct backlight_device; struct dentry; struct device_node; struct drm_connector; struct drm_device; +struct drm_panel_follower; struct drm_panel; struct display_timing; @@ -144,6 +146,45 @@ struct drm_panel_funcs { void (*debugfs_init)(struct drm_panel *panel, struct dentry *root); }; +struct drm_panel_follower_funcs { + /** + * @panel_prepared: + * + * Called after the panel has been powered on. + */ + int (*panel_prepared)(struct drm_panel_follower *follower); + + /** + * @panel_unpreparing: + * + * Called before the panel is powered off. + */ + int (*panel_unpreparing)(struct drm_panel_follower *follower); +}; + +struct drm_panel_follower { + /** + * @funcs: + * + * Dependent device callbacks; should be initted by the caller. + */ + const struct drm_panel_follower_funcs *funcs; + + /** + * @list + * + * Used for linking into panel's list; set by drm_panel_add_follower(). + */ + struct list_head list; + + /** + * @panel + * + * The panel we're dependent on; set by drm_panel_add_follower(). + */ + struct drm_panel *panel; +}; + /** * struct drm_panel - DRM panel object */ @@ -189,6 +230,20 @@ struct drm_panel { */ struct list_head list; + /** + * @followers: + * + * A list of struct drm_panel_follower dependent on this panel. + */ + struct list_head followers; + + /** + * @followers_lock: + * + * Lock for followers list. + */ + struct mutex follower_lock; + /** * @prepare_prev_first: * @@ -246,6 +301,31 @@ static inline int of_drm_get_panel_orientation(const struct device_node *np, } #endif +#if defined(CONFIG_DRM_PANEL) +bool drm_is_panel_follower(struct device *dev); +int drm_panel_add_follower(struct device *follower_dev, + struct drm_panel_follower *follower); +void drm_panel_remove_follower(struct drm_panel_follower *follower); +int devm_drm_panel_add_follower(struct device *follower_dev, + struct drm_panel_follower *follower); +#else +static inline bool drm_is_panel_follower(struct device *dev) +{ + return false; +} +static inline int drm_panel_add_follower(struct device *follower_dev, + struct drm_panel_follower *follower) +{ + return -ENODEV; +} +static inline void drm_panel_remove_follower(struct drm_panel_follower *follower) { } +static inline int devm_drm_panel_add_follower(struct device *follower_dev, + struct drm_panel_follower *follower) +{ + return -ENODEV; +} +#endif + #if IS_ENABLED(CONFIG_DRM_PANEL) && (IS_BUILTIN(CONFIG_BACKLIGHT_CLASS_DEVICE) || \ (IS_MODULE(CONFIG_DRM) && IS_MODULE(CONFIG_BACKLIGHT_CLASS_DEVICE))) int drm_panel_of_backlight(struct drm_panel *panel); From patchwork Tue Jul 25 20:34:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 125810 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp16117vqo; Tue, 25 Jul 2023 14:18:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlFlOBj0hv8EnhZbfepr58P/yU77QslxYKMfAXaAJNW8r2WdHUmSGb3jxWZ0SFRe2OiZG4uO X-Received: by 2002:a05:6a00:1ad3:b0:66d:514c:cb33 with SMTP id f19-20020a056a001ad300b0066d514ccb33mr316665pfv.6.1690319899052; Tue, 25 Jul 2023 14:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690319899; cv=none; d=google.com; s=arc-20160816; b=DGJCRlf+Vk7AkG3AAx10BD7weQfY4+hLRFtYQ9uRHNdA4OLLyGAoJLfW8HlK3qBnDr b+9WG5OYhGmclq3jPxwNwYoY8ocNz/07969sPME+l1j6qJ5OZ9TYh5Laejhv0OYK2Xg8 6WxrudCa7s88kmnwk5gSh9N14n86nxvbU5uYikslXmBrlCAc6BEalMZcyej9tY4O+S5M wfrZxyiahedLVsQmNkUhjn8pkMNGHRXG3ciB47Z3GcabI4fdbTXmaS6IuaeozUWbsRae I/qKA9I4DDRu3dUdCHQqqqZ5u6e5He9dkhCPabuvmTl/F0YWI9rttMMNkrGjgDmilOgw 8K6A== 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=EhdEP47Q6zcMA0F+PcMkdWz/9ABzj35GTZZYW72E4F8=; fh=o7dLtACNl+Nw/xU4h1UwCts2zldYlioddaEk9AfYnGo=; b=SmcV9/UBoXp8dtaY1HvezrWCq4b/309XcY8LoWv3hWDL8voXTQorLcfRHw+eO0/Meu eXhMGJ1qADgIx3WgwQJWR0ebUAKF5WLK9RRmugqf+WooRDqzYQZSSzMHl8Ga55Tpuq02 6tJTUL+XayIFoLV0Sl9PaVwF0/f2LvXNqSwd5Ndghn/h37mlBwe3JlWPGqX1TLSoVeKc N3aSAUMCUh4JzXQgJUi+gVd2GtBKSKUHch8XtvyyHgccignbXZsplyUzGPBWdYf8KdWb Ln3FPqWm8gQkKEFHUDuJdhXoF8DO279RlwjL+BvWPGDKguvRk3H2Qfthgn3WQuWW06Hh 0GYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FK9uzQr2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cu12-20020a056a00448c00b006786b7f4cc4si11500658pfb.240.2023.07.25.14.18.05; Tue, 25 Jul 2023 14:18:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FK9uzQr2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231317AbjGYUhR (ORCPT + 99 others); Tue, 25 Jul 2023 16:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231253AbjGYUhI (ORCPT ); Tue, 25 Jul 2023 16:37:08 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39AB6212C for ; Tue, 25 Jul 2023 13:37:05 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-267f870e6ffso1659854a91.0 for ; Tue, 25 Jul 2023 13:37:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690317424; x=1690922224; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EhdEP47Q6zcMA0F+PcMkdWz/9ABzj35GTZZYW72E4F8=; b=FK9uzQr2XJHv+OfyWZgjtunriUloqdtwx+ivv6sQ2PO2zuBkv8MqfPI9lg7syKN0Lc jKh6qXFqfVPH+Q6qa2kQ3Ihe8Ymc8CsB/6MVMGNgfmzaEbLiMCXZ6tlj4sYCiIfzo2r1 6Fdvc5Qyo+4UaTFF7lBNW7PLpmXbQKhBDUpMg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690317424; x=1690922224; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EhdEP47Q6zcMA0F+PcMkdWz/9ABzj35GTZZYW72E4F8=; b=NOKGoqpPtE4G9eMypodh0fnlAxqzkT/ZPv7BUsiHRpPCwlvmKYGsaPBTWQR0v5V3N2 6PDRJPgRqIojAza0pghfGipPAi+4pT8/yiKG8XnSkkfwCn3jElICm6vxVJZY0WRZWkzA krMLlrv8oaW7s2a2lfwDdjYVhLCAw8rZRUb+xHmHwMYhjVqTuGotsOr34d+tWUbudrOy uBZ/eFLjUNj7/SM3vzYNpv8vAvby5hb/h8ta28ToTfQBCKdtDT+HhTcrH+aIJkYu8DgH HIyp9Xd6oERTKbBUbo+SzhuuTrxv00SDc3/uwEsOY4Gpohn1oEEZQijzPnmIBAg32e0J 3xMQ== X-Gm-Message-State: ABy/qLZ4BeGtnisxWL7U2htsC8tweB8M/Kv30dWzs2alLgRn0+nRGZUe ZX+C2klYWokvK2ARGj1f4yDM0g== X-Received: by 2002:a17:90b:4b89:b0:268:2d6:74d6 with SMTP id lr9-20020a17090b4b8900b0026802d674d6mr235219pjb.16.1690317424748; Tue, 25 Jul 2023 13:37:04 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:c363:4681:f5b8:301]) by smtp.gmail.com with ESMTPSA id bg1-20020a17090b0d8100b002676e961261sm1396951pjb.1.2023.07.25.13.37.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 13:37:03 -0700 (PDT) From: Douglas Anderson To: Jiri Kosina , Benjamin Tissoires , Bjorn Andersson , Konrad Dybcio , Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: cros-qcom-dts-watchers@chromium.org, Chris Morgan , linux-input@vger.kernel.org, hsinyi@google.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Torokhov , devicetree@vger.kernel.org, Daniel Vetter , yangcong5@huaqin.corp-partner.google.com, Douglas Anderson , Rob Herring Subject: [PATCH v3 04/10] of: property: fw_devlink: Add a devlink for panel followers Date: Tue, 25 Jul 2023 13:34:39 -0700 Message-ID: <20230725133443.v3.4.Ibf8e1342b5b7906279db2365aca45e6253857bb3@changeid> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230725203545.2260506-1-dianders@chromium.org> References: <20230725203545.2260506-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772428878415304942 X-GMAIL-MSGID: 1772428878415304942 Inform fw_devlink of the fact that a panel follower (like a touchscreen) is effectively a consumer of the panel from the purposes of fw_devlink. NOTE: this patch isn't required for correctness but instead optimizes probe order / helps avoid deferrals. Acked-by: Rob Herring Signed-off-by: Douglas Anderson --- Since this is so small, I'd presume it's OK for it to go through a DRM tree with the proper Ack. That being said, this patch is just an optimization and thus it could land completely separately from the rest and they could all meet up in mainline. (no changes since v2) Changes in v2: - ("Add a devlink for panel followers") new for v2. drivers/of/property.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/of/property.c b/drivers/of/property.c index ddc75cd50825..cf8dacf3e3b8 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1266,6 +1266,7 @@ DEFINE_SIMPLE_PROP(pwms, "pwms", "#pwm-cells") DEFINE_SIMPLE_PROP(resets, "resets", "#reset-cells") DEFINE_SIMPLE_PROP(leds, "leds", NULL) DEFINE_SIMPLE_PROP(backlight, "backlight", NULL) +DEFINE_SIMPLE_PROP(panel, "panel", NULL) DEFINE_SUFFIX_PROP(regulators, "-supply", NULL) DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells") @@ -1354,6 +1355,7 @@ static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_resets, }, { .parse_prop = parse_leds, }, { .parse_prop = parse_backlight, }, + { .parse_prop = parse_panel, }, { .parse_prop = parse_gpio_compat, }, { .parse_prop = parse_interrupts, }, { .parse_prop = parse_regulators, }, From patchwork Tue Jul 25 20:34:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 125803 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp4105vqo; Tue, 25 Jul 2023 13:51:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlGiqX/gi1nk/O4t+7jOAIZ78bg9u1Hm68tZaUKR0+0mWYct3zjB/Q9Z/f4INGTk1OTiTP5+ X-Received: by 2002:adf:eccc:0:b0:313:dee2:e052 with SMTP id s12-20020adfeccc000000b00313dee2e052mr11335179wro.26.1690318267251; Tue, 25 Jul 2023 13:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690318267; cv=none; d=google.com; s=arc-20160816; b=DKQxP+XBKHIE3/hSVFpgrIQkIZ1Jaf77Ez24ikqvytAwmvwNAju/KVNewrVil15mCt yqnmqFl3u6lfYlR8/1VdRIbmfBKxyo/Jqep0nqwAhPcMt6Fv26Hb0VTnDpLHTrxrg/Vc xYuovmACL4oTXqZm8uOF0OuOHG5S9NqgoKIQf3Qj9oH+B5Tlqk7lJIABLqWc4Bh4ZUQU U5i4ShKy2BuaSZVMj6PUAKfbZpSGlwftCRJvLiAYP+0XK5n9C90CfPvUOOC3+uucw40c uIsqheLP2IMgN17pd7c85O4mA3kFvtnn5fBLan9UWCOwjbdhqq58rVtteGXGDdvQtv0H QiTw== 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=Tppdylk0o3RU6iRFgC5acPR+he8rkEb+eKspBj7RST0=; fh=l9Sxp0WjWxoPPBlRLV6ri41IHQAwx7j1EblxKJXOsZc=; b=l+rm7QJMLNlpR5qdLEq78+L6ngY7A+82hIWMbebGGFjRJcZaeVZMxQ6fiQMAB1eSdO mTDgggqs03LWVP1oSMHTZ/+O7/DLnQ+nRGEl0f5NAygiSts53qGRCH8PFEtRmYNYNJtS sGYFRXMRTdiUFyBlcKTr9opBn1PIPE5j8z51MNaAfVxfI7Iiy/GdjIikbDq3Sd/q3fiP clsQ2K9Ahl3sQfiS8n5vJXryDgnfxJBtidzEJuVoJf80NW80PdAFNDLZSW3N68TVz501 KXHl4l1ru5qERra2Wp0nxitlTWMqrBwKzkyhwlkJV+IJj7wB2kjApc+0BDOR2Wx/ENYp Z4lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CDswuo0P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1-20020a05640214c100b005221b934ceasi5211442edx.225.2023.07.25.13.50.42; Tue, 25 Jul 2023 13:51:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CDswuo0P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231342AbjGYUhW (ORCPT + 99 others); Tue, 25 Jul 2023 16:37:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231230AbjGYUhK (ORCPT ); Tue, 25 Jul 2023 16:37:10 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC6801988 for ; Tue, 25 Jul 2023 13:37:07 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-55b1238a013so4216754a12.3 for ; Tue, 25 Jul 2023 13:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690317427; x=1690922227; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Tppdylk0o3RU6iRFgC5acPR+he8rkEb+eKspBj7RST0=; b=CDswuo0Ppz/RMLI26l0suYt7iqnZQQL9jsIa7tvwwvzx5N2EWZMkh61eSE4a3jgY1L RyUarTsCyibpS4rymF0dFRninecA2fWPvhT+ttJQqlJQC9wf43OfkU90OE14LY4hojeK VSljfpYLBp6w/EA/YeVmI046LSOuunRgKG6OA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690317427; x=1690922227; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tppdylk0o3RU6iRFgC5acPR+he8rkEb+eKspBj7RST0=; b=hS78ZcFMHs5FGBiqRqCAhk/yg+PWst1isxMMYXuj7BoOOUCZTVcSpfh0FNrWFHtw4W 82vzwyfpCy76JuaVwVseDc0LAK03tRDbV//WOiOM+vPwty8njLoMXb3ssdCGXYnG1pI7 N8DVThB8ZIaMUWk2cFXQT2aN3xSfXLfldtG2iS9wIbH5WvMR95JTVvqIs+BsdIAaVeQ0 XMbqKQAvYQWJ9Wcg4v33CjtYpD9IL9xZqBjDBXGSNWEpo6tEP7LoEMmE8gbi+3q6zpe2 c7BV3nrlFW4JFH02Iifgdl9eR7jwuAUvc92K1B52nWRWW5u7qu9q6Q6mSKO0aPLMWb7U xs+g== X-Gm-Message-State: ABy/qLZU2X4Gi1Ag/Nb5yGDvgxXcHCu7zFTXXwjlCkiJQEO/acHBvbix xATqGDYefTtrgKYl+IfP8Serdg== X-Received: by 2002:a17:90a:d58f:b0:267:f9da:4611 with SMTP id v15-20020a17090ad58f00b00267f9da4611mr266815pju.14.1690317427135; Tue, 25 Jul 2023 13:37:07 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:c363:4681:f5b8:301]) by smtp.gmail.com with ESMTPSA id bg1-20020a17090b0d8100b002676e961261sm1396951pjb.1.2023.07.25.13.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 13:37:06 -0700 (PDT) From: Douglas Anderson To: Jiri Kosina , Benjamin Tissoires , Bjorn Andersson , Konrad Dybcio , Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: cros-qcom-dts-watchers@chromium.org, Chris Morgan , linux-input@vger.kernel.org, hsinyi@google.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Torokhov , devicetree@vger.kernel.org, Daniel Vetter , yangcong5@huaqin.corp-partner.google.com, Douglas Anderson Subject: [PATCH v3 05/10] HID: i2c-hid: Switch to SYSTEM_SLEEP_PM_OPS() Date: Tue, 25 Jul 2023 13:34:40 -0700 Message-ID: <20230725133443.v3.5.Ib2a2865bd3c0b068432259dfc7d76cebcbb512be@changeid> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230725203545.2260506-1-dianders@chromium.org> References: <20230725203545.2260506-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772427167291291260 X-GMAIL-MSGID: 1772427167291291260 The SYSTEM_SLEEP_PM_OPS() allows us to get rid of '#ifdef CONFIG_PM_SLEEP', as talked about in commit 1a3c7bb08826 ("PM: core: Add new *_PM_OPS macros, deprecate old ones"). This change is expected to have no functional effect. Signed-off-by: Douglas Anderson --- (no changes since v1) drivers/hid/i2c-hid/i2c-hid-core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index efbba0465eef..19d985c20a5c 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -1085,7 +1085,6 @@ void i2c_hid_core_shutdown(struct i2c_client *client) } EXPORT_SYMBOL_GPL(i2c_hid_core_shutdown); -#ifdef CONFIG_PM_SLEEP static int i2c_hid_core_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -1138,10 +1137,9 @@ static int i2c_hid_core_resume(struct device *dev) return hid_driver_reset_resume(hid); } -#endif const struct dev_pm_ops i2c_hid_core_pm = { - SET_SYSTEM_SLEEP_PM_OPS(i2c_hid_core_suspend, i2c_hid_core_resume) + SYSTEM_SLEEP_PM_OPS(i2c_hid_core_suspend, i2c_hid_core_resume) }; EXPORT_SYMBOL_GPL(i2c_hid_core_pm); From patchwork Tue Jul 25 20:34:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 125811 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp16700vqo; Tue, 25 Jul 2023 14:19:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlEBb6NxlFYc8j1pIDGJVLN8NmXyNnqnPMoN2nzQmHy5l5d+ZwIp/GXgN1aGk+sgMtrXodd6 X-Received: by 2002:a17:90b:33cd:b0:262:ca69:bf9a with SMTP id lk13-20020a17090b33cd00b00262ca69bf9amr316108pjb.21.1690319983706; Tue, 25 Jul 2023 14:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690319983; cv=none; d=google.com; s=arc-20160816; b=hYgN7MsXCvG59xm4FW4Mp546gCQ3ERHQwGdR4mnmme95Qtbapou9GcEsth7Go4cZwd hk1IpPE9BxbJUgqqKSWG64uFbSHBtVOAVr16R2QhgNWt6VdMLPvs5RuV9qvH3Jwf80Ot j6ZEdrFFaQOAbKDx3gPYY3C2YtfQFB7ed8JaB4xJt8SSNnU3ZJAQJBvyx4OPcXIFZa3e cWPdwvlZmi/rCKCeqpzaWS/hOf6rq5waBp9Po/1t9TZv1BU+ECButhSeSL/GrTY+2L6Q LRZQyvT47rChF4yFvZ31dKDFlkMU8PraRFsaGVUvHRV55gMcvzSrkpCh5Tw1MeURPcNt iDPg== 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=TpzMl+hQ1ZFKADkTA6+giANmnh0KSfYRxfLW5dMWSJw=; fh=l9Sxp0WjWxoPPBlRLV6ri41IHQAwx7j1EblxKJXOsZc=; b=sX+g++qFuHDaUOPkQWkBFRAZUtGUG0DHcRrzePXnNbm57b1Ur5Rl2BnPVihRSJqfls XeiXkux60dSHOw7ytlyJIlM474/3dT/tNtCuyVKpKVKt777dIFAzdI6DKjHcgxbWdOCj aP6mvS4ZvcuOvrp68g1KhKushr83wccxGHyHtpe4m/kcO/UVG+6aUvPEjIZF4uEMLbx8 cs6g2NmZgWBn76vYV7bm0IFbFaHL9pyuFEdNQ08SYzJsnQCtH+FEfCWnNzlFF7Ov4VWk DLMsckpn0JDoI33whPJ2pWC5SPiGhg3/pyEmby5KhpMsaEFxTTUYPoLFW49uwp5t5wAu I7Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nRURIRJw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lp16-20020a17090b4a9000b0026341fc8ae2si46892pjb.122.2023.07.25.14.19.30; Tue, 25 Jul 2023 14:19:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nRURIRJw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231280AbjGYUhc (ORCPT + 99 others); Tue, 25 Jul 2023 16:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230500AbjGYUhV (ORCPT ); Tue, 25 Jul 2023 16:37:21 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94108268B for ; Tue, 25 Jul 2023 13:37:10 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-26813478800so1586332a91.1 for ; Tue, 25 Jul 2023 13:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690317429; x=1690922229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TpzMl+hQ1ZFKADkTA6+giANmnh0KSfYRxfLW5dMWSJw=; b=nRURIRJwmt7wFoCuQYM1uZzf9MGtZsG5Bho2gKdWg+wAlJuwE5Vh9eeZWFn86FqOhD PaGpjOy3OaPwjjOseSuaywGZBg/VmDc10evbQ4F3D+enyMTScqxyrVNVyJwfZD2iNVRX /M7VjtZ+GAq3ABUFSrGtvW8BB92y4ibITyKnw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690317429; x=1690922229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TpzMl+hQ1ZFKADkTA6+giANmnh0KSfYRxfLW5dMWSJw=; b=JIATm9XrAxcjh/ZQYqEUzpkMg23N9aYC2JHn06hvzEdfy9o2079DtxyQc/iBAAuDJc OYFvXNV6Vsl6jF/KOL+PR4xpOS0ylnOsSCYAazpWmVfTm6E5H38/SnJLZJSacAldaU0D hMadKjgHL/Xal0phemhC6S8ysGhbTYGHDeRND2+SxpTQ35pooAEWm1FY4ibk2ACrQxqH JL3Z0IGrjGMQT0OcKieW+vhyuNfwnnGElk9oj4fYyg5C3AmvYFh3kFzFsCweW28l2YDC rQpSFhQrEOKaULanSkOuzbe9qysQgcS/R/L5WFqQcwSBBIe2Kz5yKNxXqCXdzBchPd2C sZ3Q== X-Gm-Message-State: ABy/qLbJ0hY2qP5V8wJVQa8TZcwPJzVGwFEyi4sEMrFwABmpqdhMI1Ow JEsaocUxoS63nex24bHD5igwsQ== X-Received: by 2002:a17:90a:f988:b0:268:273e:b75d with SMTP id cq8-20020a17090af98800b00268273eb75dmr242482pjb.20.1690317429623; Tue, 25 Jul 2023 13:37:09 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:c363:4681:f5b8:301]) by smtp.gmail.com with ESMTPSA id bg1-20020a17090b0d8100b002676e961261sm1396951pjb.1.2023.07.25.13.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 13:37:08 -0700 (PDT) From: Douglas Anderson To: Jiri Kosina , Benjamin Tissoires , Bjorn Andersson , Konrad Dybcio , Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: cros-qcom-dts-watchers@chromium.org, Chris Morgan , linux-input@vger.kernel.org, hsinyi@google.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Torokhov , devicetree@vger.kernel.org, Daniel Vetter , yangcong5@huaqin.corp-partner.google.com, Douglas Anderson Subject: [PATCH v3 06/10] HID: i2c-hid: Rearrange probe() to power things up later Date: Tue, 25 Jul 2023 13:34:41 -0700 Message-ID: <20230725133443.v3.6.Ifcc9b0a44895d164788966f9b9511fe094ca8cf9@changeid> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230725203545.2260506-1-dianders@chromium.org> References: <20230725203545.2260506-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772428967339195947 X-GMAIL-MSGID: 1772428967339195947 In a future patch, we want to change i2c-hid not to necessarily power up the touchscreen during probe. In preparation for that, rearrange the probe function so that we put as much stuff _before_ powering up the device as possible. This change is expected to have no functional effect. Signed-off-by: Douglas Anderson --- (no changes since v2) Changes in v2: - i2c_hid_core_initial_power_up() is now static. drivers/hid/i2c-hid/i2c-hid-core.c | 124 ++++++++++++++++++----------- 1 file changed, 77 insertions(+), 47 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index 19d985c20a5c..d29e6421ecba 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -855,7 +855,8 @@ static int i2c_hid_init_irq(struct i2c_client *client) irqflags = IRQF_TRIGGER_LOW; ret = request_threaded_irq(client->irq, NULL, i2c_hid_irq, - irqflags | IRQF_ONESHOT, client->name, ihid); + irqflags | IRQF_ONESHOT | IRQF_NO_AUTOEN, + client->name, ihid); if (ret < 0) { dev_warn(&client->dev, "Could not register for %s interrupt, irq = %d," @@ -940,6 +941,72 @@ static void i2c_hid_core_shutdown_tail(struct i2c_hid *ihid) ihid->ops->shutdown_tail(ihid->ops); } +/** + * i2c_hid_core_initial_power_up() - First time power up of the i2c-hid device. + * @ihid: The ihid object created during probe. + * + * This function is called at probe time. + * + * The initial power on is where we do some basic validation that the device + * exists, where we fetch the HID descriptor, and where we create the actual + * HID devices. + * + * Return: 0 or error code. + */ +static int i2c_hid_core_initial_power_up(struct i2c_hid *ihid) +{ + struct i2c_client *client = ihid->client; + struct hid_device *hid = ihid->hid; + int ret; + + ret = i2c_hid_core_power_up(ihid); + if (ret) + return ret; + + /* Make sure there is something at this address */ + ret = i2c_smbus_read_byte(client); + if (ret < 0) { + i2c_hid_dbg(ihid, "nothing at this address: %d\n", ret); + ret = -ENXIO; + goto err; + } + + ret = i2c_hid_fetch_hid_descriptor(ihid); + if (ret < 0) { + dev_err(&client->dev, + "Failed to fetch the HID Descriptor\n"); + goto err; + } + + enable_irq(client->irq); + + hid->version = le16_to_cpu(ihid->hdesc.bcdVersion); + hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID); + hid->product = le16_to_cpu(ihid->hdesc.wProductID); + + hid->initial_quirks |= i2c_hid_get_dmi_quirks(hid->vendor, + hid->product); + + snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", + client->name, (u16)hid->vendor, (u16)hid->product); + strscpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys)); + + ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product); + + ret = hid_add_device(hid); + if (ret) { + if (ret != -ENODEV) + hid_err(client, "can't add hid device: %d\n", ret); + goto err; + } + + return 0; + +err: + i2c_hid_core_power_down(ihid); + return ret; +} + int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, u16 hid_descriptor_address, u32 quirks) { @@ -966,16 +1033,10 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, if (!ihid) return -ENOMEM; - ihid->ops = ops; - - ret = i2c_hid_core_power_up(ihid); - if (ret) - return ret; - i2c_set_clientdata(client, ihid); + ihid->ops = ops; ihid->client = client; - ihid->wHIDDescRegister = cpu_to_le16(hid_descriptor_address); init_waitqueue_head(&ihid->wait); @@ -986,28 +1047,12 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, * real computation later. */ ret = i2c_hid_alloc_buffers(ihid, HID_MIN_BUFFER_SIZE); if (ret < 0) - goto err_powered; - + return ret; device_enable_async_suspend(&client->dev); - /* Make sure there is something at this address */ - ret = i2c_smbus_read_byte(client); - if (ret < 0) { - i2c_hid_dbg(ihid, "nothing at this address: %d\n", ret); - ret = -ENXIO; - goto err_powered; - } - - ret = i2c_hid_fetch_hid_descriptor(ihid); - if (ret < 0) { - dev_err(&client->dev, - "Failed to fetch the HID Descriptor\n"); - goto err_powered; - } - ret = i2c_hid_init_irq(client); if (ret < 0) - goto err_powered; + goto err_buffers_allocated; hid = hid_allocate_device(); if (IS_ERR(hid)) { @@ -1021,26 +1066,11 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, hid->ll_driver = &i2c_hid_ll_driver; hid->dev.parent = &client->dev; hid->bus = BUS_I2C; - hid->version = le16_to_cpu(ihid->hdesc.bcdVersion); - hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID); - hid->product = le16_to_cpu(ihid->hdesc.wProductID); - hid->initial_quirks = quirks; - hid->initial_quirks |= i2c_hid_get_dmi_quirks(hid->vendor, - hid->product); - - snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", - client->name, (u16)hid->vendor, (u16)hid->product); - strscpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys)); - - ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product); - ret = hid_add_device(hid); - if (ret) { - if (ret != -ENODEV) - hid_err(client, "can't add hid device: %d\n", ret); + ret = i2c_hid_core_initial_power_up(ihid); + if (ret) goto err_mem_free; - } return 0; @@ -1050,9 +1080,9 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, err_irq: free_irq(client->irq, ihid); -err_powered: - i2c_hid_core_power_down(ihid); +err_buffers_allocated: i2c_hid_free_buffers(ihid); + return ret; } EXPORT_SYMBOL_GPL(i2c_hid_core_probe); @@ -1062,6 +1092,8 @@ void i2c_hid_core_remove(struct i2c_client *client) struct i2c_hid *ihid = i2c_get_clientdata(client); struct hid_device *hid; + i2c_hid_core_power_down(ihid); + hid = ihid->hid; hid_destroy_device(hid); @@ -1069,8 +1101,6 @@ void i2c_hid_core_remove(struct i2c_client *client) if (ihid->bufsize) i2c_hid_free_buffers(ihid); - - i2c_hid_core_power_down(ihid); } EXPORT_SYMBOL_GPL(i2c_hid_core_remove); From patchwork Tue Jul 25 20:34:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 125807 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp14185vqo; Tue, 25 Jul 2023 14:13:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlHK0EgAutYGaom2qAMyzJ7844cmoBF/EBEXiySmiVru+EluMALiMtbgvNNYceQNM0wekNF1 X-Received: by 2002:a05:6358:7252:b0:133:a55:7e26 with SMTP id i18-20020a056358725200b001330a557e26mr10475399rwa.7.1690319620447; Tue, 25 Jul 2023 14:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690319620; cv=none; d=google.com; s=arc-20160816; b=dDfqyG8iBhT6ZDkyVBKpIDXq7MKd4b2iW1YGg5ZQFJnUCnO7JiLIGj94G4RH67Pl3N Nt7jnQ3WRlK4F+zYwDyRCA99YXMEFrt98GNbLXF1YmX5QVP652GfYgAXHn0fR8Qvc4hU bJ72a7UeDBU+RjFJmlvKGzf1usjRK3C1Gvk0DEr1+74G/OHbvFhigJWzLktRW3USp6s5 3CuQ2k8gjzHSEaNg8aPrsv50cIRzxoaUZyGPi33N32TZ7rJA0FdketOL28I181nDuX18 uBMH5mF5C53vGBBBnKUmze/4FwLm5A8kT2CBjgD1tLhb6zdiQWR5x3apcBvuUOamdpXi KciQ== 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=1yusd29cgfRRFtrYmhPQHQbup7csmZzeM7LlzCXEQcE=; fh=l9Sxp0WjWxoPPBlRLV6ri41IHQAwx7j1EblxKJXOsZc=; b=i10EX5Juj9y0jEKo0euqYBE2lIP/19r/09iG6yp/30TEit02w1a4KReoaNEJgA05cx HqeWd2q3dv/QyK9FWJ25bDeLEBOE22f4eEZHr0rRFO4Xn+1G8caT6GHOYTYOkHNGnyGr HngX/zjH6uNVxFaQAxqLkLYRjRR3zLLo/o/MIwNOPoCV5dQna4Ohy3KF2f0OOtW2uQ4Q i0k9tTU+cDZQFMANRCVWxVC2QhS3KDqYkj9zW9eftWMyJ1WhBzh0tAU4IicpoF9yzbJk Qw4OrTmKyrnyW50M1T7rnaAHlw/Z5aeoJDo8Kzb4pa5Jsfih6zF6RembIkcIp7CKoxKA KvJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TF14OHDO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x69-20020a638648000000b005576229306esi11721503pgd.545.2023.07.25.14.13.27; Tue, 25 Jul 2023 14:13:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TF14OHDO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231409AbjGYUhg (ORCPT + 99 others); Tue, 25 Jul 2023 16:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231195AbjGYUh2 (ORCPT ); Tue, 25 Jul 2023 16:37:28 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C33A82137 for ; Tue, 25 Jul 2023 13:37:12 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-563de62f861so226780a12.1 for ; Tue, 25 Jul 2023 13:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690317432; x=1690922232; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1yusd29cgfRRFtrYmhPQHQbup7csmZzeM7LlzCXEQcE=; b=TF14OHDO1wEjzH6Xy7aXPUbcQtUqGBeFXB4QhCj0y8AeGf+DAuLjvIRgwcCw/tcFDp PS1T0Vy3YdqVEEDbb8VRCgf9KjM600BNH/YfOSQZMVX06aWbCZw8YcVSd9wNHvfcj+Bb DNINWWLr8uxpcu8fLvAzMqCooDlayovz5lL1k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690317432; x=1690922232; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1yusd29cgfRRFtrYmhPQHQbup7csmZzeM7LlzCXEQcE=; b=cOFRMw19vabBf75myfZoRyiLC6Xn3ODAvW8yyfWu7EFJaeVQOgIMtBT783y/LWPSWL g/bFtnpJ582dAQ9VRsfm50+GnMA0jmVF+o9nU0KGPHlt6FreoYBKTkVgVM26xrHP/CdY ip6i6pgEfdPN8KphSU4qHIlbqQGD3WTWkfiNXspBUzrhPr7Xj4K82kUS0ejlQD1SG30q oYtfF7cv9At8ShUxG7aacmf9LNzNNMJ/a8Tv9nQOAnEqi9rmMP2rT1UjSqjhKlLF0FM4 yP5OuaCGQS6xTHwUumj0DuObZVeWIG6WJvDCBKkdczhNUN5R/DTyMvIvEVoP0aF6j1Kk fF6w== X-Gm-Message-State: ABy/qLY0WCVh5j8TmDsM56I+f767oyB+0LeP99B7PI9o1ftheEt35mje iG83q7I0bbxQkxjTHnZ+LkY8aw== X-Received: by 2002:a17:90a:a08a:b0:267:f7eb:f12e with SMTP id r10-20020a17090aa08a00b00267f7ebf12emr241772pjp.39.1690317431969; Tue, 25 Jul 2023 13:37:11 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:c363:4681:f5b8:301]) by smtp.gmail.com with ESMTPSA id bg1-20020a17090b0d8100b002676e961261sm1396951pjb.1.2023.07.25.13.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 13:37:11 -0700 (PDT) From: Douglas Anderson To: Jiri Kosina , Benjamin Tissoires , Bjorn Andersson , Konrad Dybcio , Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: cros-qcom-dts-watchers@chromium.org, Chris Morgan , linux-input@vger.kernel.org, hsinyi@google.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Torokhov , devicetree@vger.kernel.org, Daniel Vetter , yangcong5@huaqin.corp-partner.google.com, Douglas Anderson Subject: [PATCH v3 07/10] HID: i2c-hid: Make suspend and resume into helper functions Date: Tue, 25 Jul 2023 13:34:42 -0700 Message-ID: <20230725133443.v3.7.I5c9894789b8b02f029bf266ae9b4f43c7907a173@changeid> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230725203545.2260506-1-dianders@chromium.org> References: <20230725203545.2260506-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772428586062789584 X-GMAIL-MSGID: 1772428586062789584 In a future patch we'd like to be able to call the current i2c-hid suspend and resume functions from times other than system suspend. Move the functions higher up in the file and have them take a "struct i2c_hid" to make this simpler. We'll then add tiny wrappers of the functions for use with system suspend. This change is expected to have no functional effect. Signed-off-by: Douglas Anderson --- (no changes since v1) drivers/hid/i2c-hid/i2c-hid-core.c | 98 +++++++++++++++++------------- 1 file changed, 56 insertions(+), 42 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index d29e6421ecba..fa8a1ca43d7f 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -941,6 +941,57 @@ static void i2c_hid_core_shutdown_tail(struct i2c_hid *ihid) ihid->ops->shutdown_tail(ihid->ops); } +static int i2c_hid_core_suspend(struct i2c_hid *ihid) +{ + struct i2c_client *client = ihid->client; + struct hid_device *hid = ihid->hid; + int ret; + + ret = hid_driver_suspend(hid, PMSG_SUSPEND); + if (ret < 0) + return ret; + + /* Save some power */ + i2c_hid_set_power(ihid, I2C_HID_PWR_SLEEP); + + disable_irq(client->irq); + + if (!device_may_wakeup(&client->dev)) + i2c_hid_core_power_down(ihid); + + return 0; +} + +static int i2c_hid_core_resume(struct i2c_hid *ihid) +{ + struct i2c_client *client = ihid->client; + struct hid_device *hid = ihid->hid; + int ret; + + if (!device_may_wakeup(&client->dev)) + i2c_hid_core_power_up(ihid); + + enable_irq(client->irq); + + /* Instead of resetting device, simply powers the device on. This + * solves "incomplete reports" on Raydium devices 2386:3118 and + * 2386:4B33 and fixes various SIS touchscreens no longer sending + * data after a suspend/resume. + * + * However some ALPS touchpads generate IRQ storm without reset, so + * let's still reset them here. + */ + if (ihid->quirks & I2C_HID_QUIRK_RESET_ON_RESUME) + ret = i2c_hid_hwreset(ihid); + else + ret = i2c_hid_set_power(ihid, I2C_HID_PWR_ON); + + if (ret) + return ret; + + return hid_driver_reset_resume(hid); +} + /** * i2c_hid_core_initial_power_up() - First time power up of the i2c-hid device. * @ihid: The ihid object created during probe. @@ -1115,61 +1166,24 @@ void i2c_hid_core_shutdown(struct i2c_client *client) } EXPORT_SYMBOL_GPL(i2c_hid_core_shutdown); -static int i2c_hid_core_suspend(struct device *dev) +static int i2c_hid_core_pm_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct i2c_hid *ihid = i2c_get_clientdata(client); - struct hid_device *hid = ihid->hid; - int ret; - - ret = hid_driver_suspend(hid, PMSG_SUSPEND); - if (ret < 0) - return ret; - /* Save some power */ - i2c_hid_set_power(ihid, I2C_HID_PWR_SLEEP); - - disable_irq(client->irq); - - if (!device_may_wakeup(&client->dev)) - i2c_hid_core_power_down(ihid); - - return 0; + return i2c_hid_core_suspend(ihid); } -static int i2c_hid_core_resume(struct device *dev) +static int i2c_hid_core_pm_resume(struct device *dev) { - int ret; struct i2c_client *client = to_i2c_client(dev); struct i2c_hid *ihid = i2c_get_clientdata(client); - struct hid_device *hid = ihid->hid; - if (!device_may_wakeup(&client->dev)) - i2c_hid_core_power_up(ihid); - - enable_irq(client->irq); - - /* Instead of resetting device, simply powers the device on. This - * solves "incomplete reports" on Raydium devices 2386:3118 and - * 2386:4B33 and fixes various SIS touchscreens no longer sending - * data after a suspend/resume. - * - * However some ALPS touchpads generate IRQ storm without reset, so - * let's still reset them here. - */ - if (ihid->quirks & I2C_HID_QUIRK_RESET_ON_RESUME) - ret = i2c_hid_hwreset(ihid); - else - ret = i2c_hid_set_power(ihid, I2C_HID_PWR_ON); - - if (ret) - return ret; - - return hid_driver_reset_resume(hid); + return i2c_hid_core_resume(ihid); } const struct dev_pm_ops i2c_hid_core_pm = { - SYSTEM_SLEEP_PM_OPS(i2c_hid_core_suspend, i2c_hid_core_resume) + SYSTEM_SLEEP_PM_OPS(i2c_hid_core_pm_suspend, i2c_hid_core_pm_resume) }; EXPORT_SYMBOL_GPL(i2c_hid_core_pm); From patchwork Tue Jul 25 20:34:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 125824 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp29425vqo; Tue, 25 Jul 2023 14:52:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlFcyB9bCKoaQlzQ4lXysYm34L2wsN4coWVnsg8Lbmw0oReTBrJ0XAo323n54srxhR7xvBKJ X-Received: by 2002:a17:906:53c2:b0:99b:4ed4:5527 with SMTP id p2-20020a17090653c200b0099b4ed45527mr76476ejo.25.1690321960330; Tue, 25 Jul 2023 14:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690321960; cv=none; d=google.com; s=arc-20160816; b=CT2Hu5tj4TSuzGejSAHGbGC90emoAE4chw9xGo3xyYkpXb5W2o8Ha12g3lHyId9jJ1 jPYoEL9WYx6vEztiabxKvElqj4JT5cLgl8PWkHhXxUI3OpSzcPK3B9QMwOOalKW5Ib8T KZukr/nicZ+A2l0/FZYvDlEcNjH3tIJmVvT/4KFATXTKaZGJeEVKgvDn7sY7PL9caxH0 PNWRpjjlgSGWJhp0IulJ46P5GqBT7AsX+Wmq1n7nwwR62Y1e1ZbB3cZP/kzvH+XCZFYq yJAByHQxqgfHrYfofj/ma/Nxtr0avAsbIVI0y7vlCQIPaD+XjIyJ8BIKWOVgm/eB9t8B QMsQ== 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=pLU4GaCp6ltBfg0ajT8nW3f7rOZfzJGhG7FU81YHMIc=; fh=l9Sxp0WjWxoPPBlRLV6ri41IHQAwx7j1EblxKJXOsZc=; b=fHHhA5BCs2YBG6Sm9Iaccs8KGwEg40qvnDlMMnrt0KmcvxPGI2GE0KhWPAMXHpe/uH zMzWP4ZtRr1acI/QHlF5vewdO/kPPxSpAMt/CliQw0xoA9TVlKv6Mju5PQz21lYqzlwK ts8KnIQw4sjvVxVsNzFwGQZNwR6sRc+Ey06c+2AItccXFPovxefBwzxSqsk703y5L/oq z7b3nZx8ahpndXw7ip7ZSmVXGCJb4/nc1Ou0/MKlVLCMEkU+h1JHT1ToeGbDqqEogk5K rKInZoY7M74uuDsqivCqiZdK4ozlplTLhkifhBHXFm+sQA70SdEi16CUv4MrrR+FxGaL qMxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=StVSDcWM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a170906a40700b0098874379199si8827128ejz.163.2023.07.25.14.52.16; Tue, 25 Jul 2023 14:52:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=StVSDcWM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229506AbjGYUhu (ORCPT + 99 others); Tue, 25 Jul 2023 16:37:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231453AbjGYUhb (ORCPT ); Tue, 25 Jul 2023 16:37:31 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AAF22706 for ; Tue, 25 Jul 2023 13:37:15 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-56341268f2fso3071303a12.0 for ; Tue, 25 Jul 2023 13:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690317434; x=1690922234; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pLU4GaCp6ltBfg0ajT8nW3f7rOZfzJGhG7FU81YHMIc=; b=StVSDcWMfA7TJ+Wp3D7IahafFoAoSFplzVN3xvyQE3lKGASTqWpuH7liiDVdA661// WuvraSDsXCp7t3Br6Kq5LtSw/2aZc6JKry7bt58S2lBkYmUsVT/WKJ8Mb07wK+vzu5w/ vsG0HJJ0OrAU9h8RTO+aWvKhNSPxWSxcQrrdU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690317434; x=1690922234; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pLU4GaCp6ltBfg0ajT8nW3f7rOZfzJGhG7FU81YHMIc=; b=IgkT0yD6KKvb82GuqIJs/x7bfLiXweJwpTRIKGmnlQ+MARay9Nu0hhzVHCCrj3djHU abhGYLD0D10WKtDEdUo+NG4tr5Us+0z1HcriWE3RrZcszQljXk4Dog/rrqkyh+vU58cH traNyChRUD9JrDZiNLGFb6MBW3TcnCnocjZX3uwJIjN7+e5R5wm2mPfGWLCPqdgWBHLm 1+IeSl5faoJUWsOFpp9oLIWj8FtjyeozQf2WslFmERs72u/VZ2vxenrELyuw9clqDSql Dj4io1qH6O8b8+UynugZX+A3I3pvHWUkHaevJk0wwR5zGmaMNB4DMqbqleUYjovyE4f7 3gjg== X-Gm-Message-State: ABy/qLZKlTxT2UhBFpny9UQD8ThUooIvKRfLY6aOgHv3geBJcYAbOGzA ZyWny2iysa+82/146PfC0xdY5Q== X-Received: by 2002:a17:90a:c08:b0:267:6ea5:61dd with SMTP id 8-20020a17090a0c0800b002676ea561ddmr222775pjs.15.1690317434661; Tue, 25 Jul 2023 13:37:14 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:c363:4681:f5b8:301]) by smtp.gmail.com with ESMTPSA id bg1-20020a17090b0d8100b002676e961261sm1396951pjb.1.2023.07.25.13.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 13:37:14 -0700 (PDT) From: Douglas Anderson To: Jiri Kosina , Benjamin Tissoires , Bjorn Andersson , Konrad Dybcio , Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: cros-qcom-dts-watchers@chromium.org, Chris Morgan , linux-input@vger.kernel.org, hsinyi@google.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Torokhov , devicetree@vger.kernel.org, Daniel Vetter , yangcong5@huaqin.corp-partner.google.com, Douglas Anderson Subject: [PATCH v3 08/10] HID: i2c-hid: Support being a panel follower Date: Tue, 25 Jul 2023 13:34:43 -0700 Message-ID: <20230725133443.v3.8.Ib1a98309c455cd7e26b931c69993d4fba33bbe15@changeid> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230725203545.2260506-1-dianders@chromium.org> References: <20230725203545.2260506-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772431039545040179 X-GMAIL-MSGID: 1772431039545040179 As talked about in the patch ("drm/panel: Add a way for other devices to follow panel state"), we really want to keep the power states of a touchscreen and the panel it's attached to in sync with each other. In that spirit, add support to i2c-hid to be a panel follower. This will let the i2c-hid driver get informed when the panel is powered on and off. From there we can match the i2c-hid device's power state to that of the panel. NOTE: this patch specifically _doesn't_ use pm_runtime to keep track of / manage the power state of the i2c-hid device, even though my first instinct said that would be the way to go. Specific problems with using pm_runtime(): * The initial power up couldn't happen in a runtime resume function since it create sub-devices and, apparently, that's not good to do in your resume function. * Managing our power state with pm_runtime meant fighting to make the right thing happen at system suspend to prevent the system from trying to resume us only to suspend us again. While this might be able to be solved, it added complexity. Overall the code without pm_runtime() ended up being smaller and easier to understand. Signed-off-by: Douglas Anderson --- Changes in v3: - Add "depends on DRM || !DRM" to Kconfig to avoid randconfig error. - Split more of the panel follower code out of the core. Changes in v2: - i2c_hid_core_panel_prepared() and ..._unpreparing() are now static. drivers/hid/i2c-hid/Kconfig | 2 + drivers/hid/i2c-hid/i2c-hid-core.c | 82 +++++++++++++++++++++++++++++- 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/drivers/hid/i2c-hid/Kconfig b/drivers/hid/i2c-hid/Kconfig index 3be17109301a..2bdb55203104 100644 --- a/drivers/hid/i2c-hid/Kconfig +++ b/drivers/hid/i2c-hid/Kconfig @@ -70,5 +70,7 @@ config I2C_HID_OF_GOODIX config I2C_HID_CORE tristate + # We need to call into panel code so if DRM=m, this can't be 'y' + depends on DRM || !DRM endif diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index fa8a1ca43d7f..fa6d1f624342 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -38,6 +38,8 @@ #include #include +#include + #include "../hid-ids.h" #include "i2c-hid.h" @@ -107,6 +109,8 @@ struct i2c_hid { struct mutex reset_lock; struct i2chid_ops *ops; + struct drm_panel_follower panel_follower; + bool is_panel_follower; }; static const struct i2c_hid_quirks { @@ -1058,6 +1062,59 @@ static int i2c_hid_core_initial_power_up(struct i2c_hid *ihid) return ret; } +static int i2c_hid_core_panel_prepared(struct drm_panel_follower *follower) +{ + struct i2c_hid *ihid = container_of(follower, struct i2c_hid, panel_follower); + struct hid_device *hid = ihid->hid; + + /* + * hid->version is set on the first power up. If it's still zero then + * this is the first power on so we should perform initial power up + * steps. + */ + if (!hid->version) + return i2c_hid_core_initial_power_up(ihid); + + return i2c_hid_core_resume(ihid); +} + +static int i2c_hid_core_panel_unpreparing(struct drm_panel_follower *follower) +{ + struct i2c_hid *ihid = container_of(follower, struct i2c_hid, panel_follower); + + return i2c_hid_core_suspend(ihid); +} + +static const struct drm_panel_follower_funcs i2c_hid_core_panel_follower_funcs = { + .panel_prepared = i2c_hid_core_panel_prepared, + .panel_unpreparing = i2c_hid_core_panel_unpreparing, +}; + +static int i2c_hid_core_register_panel_follower(struct i2c_hid *ihid) +{ + struct device *dev = &ihid->client->dev; + int ret; + + ihid->is_panel_follower = true; + ihid->panel_follower.funcs = &i2c_hid_core_panel_follower_funcs; + + /* + * If we're not in control of our own power up/power down then we can't + * do the logic to manage wakeups. Give a warning if a user thought + * that was possible then force the capability off. + */ + if (device_can_wakeup(dev)) { + dev_warn(dev, "Can't wakeup if following panel\n"); + device_set_wakeup_capable(dev, false); + } + + ret = drm_panel_add_follower(dev, &ihid->panel_follower); + if (ret) + return ret; + + return 0; +} + int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, u16 hid_descriptor_address, u32 quirks) { @@ -1119,7 +1176,15 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, hid->bus = BUS_I2C; hid->initial_quirks = quirks; - ret = i2c_hid_core_initial_power_up(ihid); + /* + * If we're a panel follower, we'll register and do our initial power + * up when the panel turns on; otherwise we do it right away. + */ + if (drm_is_panel_follower(&client->dev)) + ret = i2c_hid_core_register_panel_follower(ihid); + else + ret = i2c_hid_core_initial_power_up(ihid); + if (ret) goto err_mem_free; @@ -1143,7 +1208,14 @@ void i2c_hid_core_remove(struct i2c_client *client) struct i2c_hid *ihid = i2c_get_clientdata(client); struct hid_device *hid; - i2c_hid_core_power_down(ihid); + /* + * If we're a follower, the act of unfollowing will cause us to be + * powered down. Otherwise we need to manually do it. + */ + if (ihid->is_panel_follower) + drm_panel_remove_follower(&ihid->panel_follower); + else + i2c_hid_core_power_down(ihid); hid = ihid->hid; hid_destroy_device(hid); @@ -1171,6 +1243,9 @@ static int i2c_hid_core_pm_suspend(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct i2c_hid *ihid = i2c_get_clientdata(client); + if (ihid->is_panel_follower) + return 0; + return i2c_hid_core_suspend(ihid); } @@ -1179,6 +1254,9 @@ static int i2c_hid_core_pm_resume(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct i2c_hid *ihid = i2c_get_clientdata(client); + if (ihid->is_panel_follower) + return 0; + return i2c_hid_core_resume(ihid); } From patchwork Tue Jul 25 20:34:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 125812 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp18129vqo; Tue, 25 Jul 2023 14:23:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlF6XhibMY4eT/MANEquQEdeM18u8A1sBH0cSr6LtQnqoI9+zhReCF+keJwfAGkBttCfDomJ X-Received: by 2002:a05:6a00:1887:b0:686:bd4f:3a6e with SMTP id x7-20020a056a00188700b00686bd4f3a6emr406869pfh.24.1690320184862; Tue, 25 Jul 2023 14:23:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690320184; cv=none; d=google.com; s=arc-20160816; b=qSun50LwNLoh61WAvEckBzA8vLpGYzGkJbx360uU+rZHTvdwyLrkKExc61pEzI8rdm KCeLefas3kBtQJObJT1wt4ajpiZYC/JWrbur1+F0UsT2h+UaiFydwgcwdP/MeubnLN3S UhNK4VCCW78SApXG2ZUrsA1hnjCQi8DrKAuTN1JvSn+W+rC7Wo3CjgTnpnBhqSbmVZZw 98VINO71cS3wGS9b/scUwPpdzItrj/oE4ABJZBupnEvvhIV899ZRbbaGVmL4VYytFrvz eLMUz8tVR+UHfoHJ+AlYfmlHB8ZWRQ/gK4LE1RavySJnlZUB0j+ZIQJhlHfBK6LY23kJ jN7g== 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=xwFg3zsWqs3v6aVHVxyVzqQhxIAjeJPLZHSa2wy+9Ws=; fh=l9Sxp0WjWxoPPBlRLV6ri41IHQAwx7j1EblxKJXOsZc=; b=AD+loOMNKcXNo0/bXH4sb/xiPrDylRHDbg7aFw/ANqR7bgf7jfe5T0AMTFASF5qKMy k71r7F8oOSVsyNOWDEydHiYMow6mAVF40eLs5uh0Jbiu5RSaBhGJpAra4l/CiUVhNGWW xKX+QDtJFSpncHQ2OOXPMgVb3cgRBb4xMmqwpfx1HMNw34htjS/MZzfrr8MYgq+VPV1n HlA6XdHKTSoZVK4pTsc6WdMry/OOCl7BTbF9wEVlkSmdmQOkC1sxsMHCSXltg57vmEoh bUSc3giyBE902qba0Uqbrvvnz1ESbxv4UmmnGkd7H0YDjJhg2orShPwi+VFjCeNSzVQl SAUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YEAWKLjW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cj25-20020a056a00299900b0067b77e7f46csi12204628pfb.187.2023.07.25.14.22.51; Tue, 25 Jul 2023 14:23:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YEAWKLjW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231289AbjGYUhw (ORCPT + 99 others); Tue, 25 Jul 2023 16:37:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231481AbjGYUhc (ORCPT ); Tue, 25 Jul 2023 16:37:32 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B4412724 for ; Tue, 25 Jul 2023 13:37:17 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2682e33509bso1118614a91.1 for ; Tue, 25 Jul 2023 13:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690317437; x=1690922237; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xwFg3zsWqs3v6aVHVxyVzqQhxIAjeJPLZHSa2wy+9Ws=; b=YEAWKLjWr/L+vjIF/bsCu89PM2D3kj1DnycpkaOmYXw/LwIxNJYxpJT5SL8xqbGgfh /blJGOH8ksO8YsSrNyYG9OCGGJzuY7bFfdwIwKg+FTXFyHptWrhtVCmkpQuWGGvzsS+H 6AxQXIA/4EMMdpwOdUybjh0Pskkt21KKVgBgc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690317437; x=1690922237; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xwFg3zsWqs3v6aVHVxyVzqQhxIAjeJPLZHSa2wy+9Ws=; b=XY7gz6fXcjPRq9xS0ZnvSFZcNurkJQfT1irDfsw/AH64bE0Z1lo6lCfFcF/dzZd69S 7RpxI/ffMlrycX5TOGBiFu3bqMKaoYmfgVxoDBSnKAfBiKFbY8ElDXj8982wgnIm80VN aqLMF/bWFFcEgAyXMQjndwxcKjchupkAqKdT7DY6/i7TX4rnzeSeg0CwABF74DqA95TW oAHSJrWICFQj2Yb++6rAOk27wisJfk4lNgvQCyApmVuEw+V+QtE7/V0Hjw7x1DIChvdh dPWg9bnnYtTvVKQmjIZ1qePpfbc+ma5rAX9RfWE95vlbaBbzNbAEi94zWuS9jWemF18m pHmQ== X-Gm-Message-State: ABy/qLZ4K6nX93yj24h4mDo4pjOM0Mg++gAGuDgiFyx13OPEJC65l7ln E82o/+iEM2kDAEuDQoCjeI/XsQ== X-Received: by 2002:a17:90a:a406:b0:268:7eb:f599 with SMTP id y6-20020a17090aa40600b0026807ebf599mr232634pjp.30.1690317437028; Tue, 25 Jul 2023 13:37:17 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:c363:4681:f5b8:301]) by smtp.gmail.com with ESMTPSA id bg1-20020a17090b0d8100b002676e961261sm1396951pjb.1.2023.07.25.13.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 13:37:16 -0700 (PDT) From: Douglas Anderson To: Jiri Kosina , Benjamin Tissoires , Bjorn Andersson , Konrad Dybcio , Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: cros-qcom-dts-watchers@chromium.org, Chris Morgan , linux-input@vger.kernel.org, hsinyi@google.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Torokhov , devicetree@vger.kernel.org, Daniel Vetter , yangcong5@huaqin.corp-partner.google.com, Douglas Anderson Subject: [PATCH v3 09/10] HID: i2c-hid: Do panel follower work on the system_wq Date: Tue, 25 Jul 2023 13:34:44 -0700 Message-ID: <20230725133443.v3.9.I962bb462ede779005341c49320740ed95810021d@changeid> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230725203545.2260506-1-dianders@chromium.org> References: <20230725203545.2260506-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772429178187793660 X-GMAIL-MSGID: 1772429178187793660 Turning on an i2c-hid device can be a slow process. This is why i2c-hid devices use PROBE_PREFER_ASYNCHRONOUS. Unfortunately, when we're a panel follower the i2c-hid power up sequence now blocks the power on of the panel. Let's fix that by scheduling the work on the system_wq. Signed-off-by: Douglas Anderson --- (no changes since v2) Changes in v2: - ihid_core_panel_prepare_work() is now static. - Improve documentation for smp_wmb(). drivers/hid/i2c-hid/i2c-hid-core.c | 50 +++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index fa6d1f624342..6940e74d8acb 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -110,7 +110,9 @@ struct i2c_hid { struct i2chid_ops *ops; struct drm_panel_follower panel_follower; + struct work_struct panel_follower_prepare_work; bool is_panel_follower; + bool prepare_work_finished; }; static const struct i2c_hid_quirks { @@ -1062,10 +1064,12 @@ static int i2c_hid_core_initial_power_up(struct i2c_hid *ihid) return ret; } -static int i2c_hid_core_panel_prepared(struct drm_panel_follower *follower) +static void ihid_core_panel_prepare_work(struct work_struct *work) { - struct i2c_hid *ihid = container_of(follower, struct i2c_hid, panel_follower); + struct i2c_hid *ihid = container_of(work, struct i2c_hid, + panel_follower_prepare_work); struct hid_device *hid = ihid->hid; + int ret; /* * hid->version is set on the first power up. If it's still zero then @@ -1073,15 +1077,52 @@ static int i2c_hid_core_panel_prepared(struct drm_panel_follower *follower) * steps. */ if (!hid->version) - return i2c_hid_core_initial_power_up(ihid); + ret = i2c_hid_core_initial_power_up(ihid); + else + ret = i2c_hid_core_resume(ihid); - return i2c_hid_core_resume(ihid); + if (ret) + dev_warn(&ihid->client->dev, "Power on failed: %d\n", ret); + else + WRITE_ONCE(ihid->prepare_work_finished, true); + + /* + * The work APIs provide a number of memory ordering guarantees + * including one that says that memory writes before schedule_work() + * are always visible to the work function, but they don't appear to + * guarantee that a write that happened in the work is visible after + * cancel_work_sync(). We'll add a write memory barrier here to match + * with i2c_hid_core_panel_unpreparing() to ensure that our write to + * prepare_work_finished is visible there. + */ + smp_wmb(); +} + +static int i2c_hid_core_panel_prepared(struct drm_panel_follower *follower) +{ + struct i2c_hid *ihid = container_of(follower, struct i2c_hid, panel_follower); + + /* + * Powering on a touchscreen can be a slow process. Queue the work to + * the system workqueue so we don't block the panel's power up. + */ + WRITE_ONCE(ihid->prepare_work_finished, false); + schedule_work(&ihid->panel_follower_prepare_work); + + return 0; } static int i2c_hid_core_panel_unpreparing(struct drm_panel_follower *follower) { struct i2c_hid *ihid = container_of(follower, struct i2c_hid, panel_follower); + cancel_work_sync(&ihid->panel_follower_prepare_work); + + /* Match with ihid_core_panel_prepare_work() */ + smp_rmb(); + if (!READ_ONCE(ihid->prepare_work_finished)) + return 0; + return i2c_hid_core_suspend(ihid); } @@ -1149,6 +1190,7 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, init_waitqueue_head(&ihid->wait); mutex_init(&ihid->reset_lock); + INIT_WORK(&ihid->panel_follower_prepare_work, ihid_core_panel_prepare_work); /* we need to allocate the command buffer without knowing the maximum * size of the reports. Let's use HID_MIN_BUFFER_SIZE, then we do the From patchwork Tue Jul 25 20:34:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 125823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp27900vqo; Tue, 25 Jul 2023 14:48:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlGCXfnOOnppbT9Xkw3FZhf9fuLTUUPXzQrHgW0hE/w/2Cda+q9iivNj1LH3eRHF3kAxS6Zk X-Received: by 2002:a05:6512:238c:b0:4fd:bd8e:8fab with SMTP id c12-20020a056512238c00b004fdbd8e8fabmr123932lfv.7.1690321710186; Tue, 25 Jul 2023 14:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690321710; cv=none; d=google.com; s=arc-20160816; b=v5d2IQ5X87x7pXKSJAJ+korwCSskm8fa0Rh4Fsds/9agLRnXYedTS/mZlxLZut7789 UECQRLZr3hbkwAs//v912txiAgxm/MsmK+G+o2qGE4S7GGSqXCESDI+QhxqGwnozMwx/ hBLU4tZ7D0DwCEsaQopUPW3NxS9ND5zZJRSsyZzFuUfsZe71dX6TUcJOcnyd8VdKM1UD DxiM1xTffLkXCIZ+vjXS6gQ3ucFbAObrB+i970Y+cR3lDBGjTkYYpw9qvJ+hkRxoERRn 1sGdf+0q+W2xiGdjWM1QckuBzARwevVCSuX0B7L4ubk23yiCuedOHzp6pKReK/XXHHwK REmQ== 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=kZ7YK7+MOq9X+RTweOdEeLPvYNyqsXxq2qSFOs1mT3s=; fh=l9Sxp0WjWxoPPBlRLV6ri41IHQAwx7j1EblxKJXOsZc=; b=lxq5/oU346NBOIaTFnUksvvNhH/MZXICOgqKXni3LeAPwReavtajRrs26ve5NnebIf rOCyizcJwMnjrpNAF8q6rwU9ZP8uBiB+VPFfEHioQdRuiBtI8SLNkfGDK2MhPbXIqOlb srKl/YUCVKcxLbIAG+jURVjWIrCkqPdeDRUFBlw2aDecpcdRfHl3MFt+eWqr5TsvXrB7 HQQ9Ds2u1HtnA1ilbZUYIg63brSkCpiPdkQqaD2+dsawSYnCVlhdexpgjklWBemithw9 iaxM9AQGiQzC/kO4RM/Krvi4cvmj45FziqEL5alcmHgxTzDwrnOXBxStXvA0iPGGFKnI IRiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BuN5tKld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf24-20020a0564021a5800b005221f404a63si4908635edb.380.2023.07.25.14.48.06; Tue, 25 Jul 2023 14:48:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BuN5tKld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231489AbjGYUiA (ORCPT + 99 others); Tue, 25 Jul 2023 16:38:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231404AbjGYUhi (ORCPT ); Tue, 25 Jul 2023 16:37:38 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCC6B2D50 for ; Tue, 25 Jul 2023 13:37:20 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-267fc19280bso174436a91.1 for ; Tue, 25 Jul 2023 13:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690317440; x=1690922240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kZ7YK7+MOq9X+RTweOdEeLPvYNyqsXxq2qSFOs1mT3s=; b=BuN5tKldtTLx2sEHuuuAagR2QfiguR7+L5jScpcBlZCtNRwzluFw4euj+TZAsdvP26 EDACAv0XTZF3vF/p2//utmh8C9vbXaUnVYNuAmPvGVxAktKJPkiFXYmd2itCZRx075gV Jy580G+wiVMstRe0Eq3zIfvwRU2mZmMau5NKA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690317440; x=1690922240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kZ7YK7+MOq9X+RTweOdEeLPvYNyqsXxq2qSFOs1mT3s=; b=CG70tIKmc+bwNzTp+pZ6lexaNxhmEqbwnIgYU2euPudJ60TwqePzY8vK1+lrPxG2Kt RLueBevMB/99W9Bj0n2aZnHAYFBpSafEzsU/Ut/nxvFHB4bHDBfTktQJ54D8wvznGv1Y 0EDl/Gikcd0JcvqlfPNkitZNFdxU4B2MNucXPutSJmG3KB+lV0gbcTtXVzOUx4YX/DK8 DTNxPjBcqHke5laW6X267UYtT/yS9cTWcfaR7Sxsju4LtbMd4A4qO8TjVCJTgudre592 gWly2CxKcwMrze/Owxqo4zaqhCZJFH4/5255zCs2g4zk3ZNblbROMyw2xGFJam6+IO/b 3CYA== X-Gm-Message-State: ABy/qLYzTWsPtSaFj4ASZRG3KCIp5Ak1L1xyNYkOGoXfY1m8sTJYKiow KdiECCk/NCmcYRJAW4qDKEzx1Q== X-Received: by 2002:a17:90b:1d90:b0:268:3ca4:6152 with SMTP id pf16-20020a17090b1d9000b002683ca46152mr180277pjb.15.1690317439920; Tue, 25 Jul 2023 13:37:19 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:c363:4681:f5b8:301]) by smtp.gmail.com with ESMTPSA id bg1-20020a17090b0d8100b002676e961261sm1396951pjb.1.2023.07.25.13.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 13:37:18 -0700 (PDT) From: Douglas Anderson To: Jiri Kosina , Benjamin Tissoires , Bjorn Andersson , Konrad Dybcio , Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: cros-qcom-dts-watchers@chromium.org, Chris Morgan , linux-input@vger.kernel.org, hsinyi@google.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Torokhov , devicetree@vger.kernel.org, Daniel Vetter , yangcong5@huaqin.corp-partner.google.com, Douglas Anderson Subject: [PATCH v3 10/10] arm64: dts: qcom: sc7180: Link trogdor touchscreens to the panels Date: Tue, 25 Jul 2023 13:34:45 -0700 Message-ID: <20230725133443.v3.10.Ia06c340e3482563e6bfd3106ecd0d3139f173ca4@changeid> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230725203545.2260506-1-dianders@chromium.org> References: <20230725203545.2260506-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772430777967846457 X-GMAIL-MSGID: 1772430777967846457 Let's provide the proper link from the touchscreen to the panel on trogdor devices where the touchscreen support it. This allows the OS to power sequence the touchscreen more properly. For the most part, this is just expected to marginally improve power consumption while the screen is off. However, in at least one trogdor model (wormdingler) it's suspected that this will fix some behavorial corner cases when the panel power cycles (like for a modeset) without the touchscreen power cycling. NOTE: some trogdor variants use touchscreens that don't (yet) support linking the touchscreen and the panel. Those variants are left alone. Signed-off-by: Douglas Anderson --- (no changes since v1) arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-pompom.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-quackingstick.dtsi | 1 + arch/arm64/boot/dts/qcom/sc7180-trogdor-wormdingler.dtsi | 1 + 6 files changed, 6 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi index 8b8ea8af165d..b4f328d3e1f6 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-coachz.dtsi @@ -104,6 +104,7 @@ ap_ts: touchscreen@5d { interrupt-parent = <&tlmm>; interrupts = <9 IRQ_TYPE_LEVEL_LOW>; + panel = <&panel>; reset-gpios = <&tlmm 8 GPIO_ACTIVE_LOW>; vdd-supply = <&pp3300_ts>; diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi index b3ba23a88a0b..88aeb415bd5b 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-homestar.dtsi @@ -116,6 +116,7 @@ ap_ts: touchscreen@14 { interrupt-parent = <&tlmm>; interrupts = <9 IRQ_TYPE_LEVEL_LOW>; + panel = <&panel>; reset-gpios = <&tlmm 8 GPIO_ACTIVE_LOW>; vdd-supply = <&pp3300_touch>; diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi index 269007d73162..c65f18ea3e5c 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi @@ -43,6 +43,7 @@ ap_ts: touchscreen@10 { interrupt-parent = <&tlmm>; interrupts = <9 IRQ_TYPE_LEVEL_LOW>; + panel = <&panel>; post-power-on-delay-ms = <20>; hid-descr-addr = <0x0001>; diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor-pompom.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor-pompom.dtsi index 6c5287bd27d6..d2aafd1ea672 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-pompom.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-pompom.dtsi @@ -102,6 +102,7 @@ ap_ts: touchscreen@10 { interrupt-parent = <&tlmm>; interrupts = <9 IRQ_TYPE_LEVEL_LOW>; + panel = <&panel>; post-power-on-delay-ms = <20>; hid-descr-addr = <0x0001>; diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor-quackingstick.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor-quackingstick.dtsi index 62ab6427dd65..e5d6a7898f8c 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-quackingstick.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-quackingstick.dtsi @@ -69,6 +69,7 @@ ap_ts: touchscreen@10 { interrupt-parent = <&tlmm>; interrupts = <9 IRQ_TYPE_LEVEL_LOW>; + panel = <&panel>; post-power-on-delay-ms = <20>; hid-descr-addr = <0x0001>; diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor-wormdingler.dtsi b/arch/arm64/boot/dts/qcom/sc7180-trogdor-wormdingler.dtsi index 2efa8a4bcda6..0e2b4d06b490 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-wormdingler.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-wormdingler.dtsi @@ -123,6 +123,7 @@ ap_ts: touchscreen@1 { interrupt-parent = <&tlmm>; interrupts = <9 IRQ_TYPE_EDGE_FALLING>; + panel = <&panel>; post-power-on-delay-ms = <70>; hid-descr-addr = <0x0001>;