From patchwork Wed Jun 7 21:49:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 104734 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp503991vqr; Wed, 7 Jun 2023 14:54:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ik6Tza/qKpCW2DcrFXuSn45LOEcP+1W9F24UcA7djbzgYZXBBVWx9mpgcliv1/n8C5Cee X-Received: by 2002:a17:90a:520c:b0:259:a56e:3130 with SMTP id v12-20020a17090a520c00b00259a56e3130mr2205413pjh.42.1686174873512; Wed, 07 Jun 2023 14:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686174873; cv=none; d=google.com; s=arc-20160816; b=Oqv0gd6yJ0KX/eAp1s08CvZszxnNv4Q2FvSSFMxds3H09GXK/7Oy6pBKPcIxLoNbK8 Nx7n+MvIA5ijLFcSgR1V7rbS01LWCZ/0DdOOCT2hmnxN+d/oy8Ug0brrgnWP1IBgX9ZK ifW6yocaI2TALHrRw3IpVaWcKAA62YbS5vXt8a9V1QR7m/OINHSRA3IlWil8XbXcDc3f It9pW4z6J78K+4xQxicOZmN2uJopL9IE7O1ZXXLuj0+H4x9GSraI025IjdPBV1Cg96m4 9TNLxqIK4Z9ZQBJUpNHJMjvtwwspgIrl6bFXAZ9Z2CIeaJtk7+sfX9OGsackA4jafNhY o7PQ== 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=7J6bms7QMm9w3IzcQHeVQuT7VvkTcEsATD8y00OpeXw=; b=X/ZI3M9Oxke8RgIk/e9vtfAvvt76jHSN14bt1XzeKqcbkyJurKTKxTxCd8zE7zy9AK 5lP6z3Ndr1luRznaJnGg2CwO2GG5AysUgI4WQVWhCR5YHlxIJD91BTTX0Yg4aGzht4XE QEcZVbogbwPRXa7CiKuObSejFX+Ki8/k62clTNERfL3oVAYfNwYAgngPcr1m9BovVhYZ lOn1KABoMb+rDVq5CrZL3yJtREQ4JmkZrwZQ7yIHZP8bGyOScyABapDXonCV+uC/WFIQ OKTU6BJtseWsbaz6oQDLokEK68Klx7eA98SFPrJMkuUinJ9OZ0qaZwdokyQh6/rNPAYW KS+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lNOTHZUj; 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 17-20020a17090a035100b0025671ab485esi1681955pjf.106.2023.06.07.14.54.21; Wed, 07 Jun 2023 14:54:33 -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=lNOTHZUj; 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 S231940AbjFGVxN (ORCPT + 99 others); Wed, 7 Jun 2023 17:53:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbjFGVxL (ORCPT ); Wed, 7 Jun 2023 17:53:11 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C8552116 for ; Wed, 7 Jun 2023 14:53:09 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-543cc9541feso1864093a12.2 for ; Wed, 07 Jun 2023 14:53:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686174789; x=1688766789; 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=7J6bms7QMm9w3IzcQHeVQuT7VvkTcEsATD8y00OpeXw=; b=lNOTHZUjf8JdjTbU6E6X/mqcY+Zwnqg/qRWUnY9Mwi3PCLRhThFa5YBIH0SWb6uJ1+ rFr2+HfY1hSDBAI2d85k+n6W6gF4wlv/tcnXPvydjr0FRk5O5EZevrutN13VURxdh3VR aQknU7zcndxDLitCgvK20aLmQb01W2KregYks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686174789; x=1688766789; 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=7J6bms7QMm9w3IzcQHeVQuT7VvkTcEsATD8y00OpeXw=; b=RMx1bS0Y8J92373agMvB5efiXlPkrt/LbJKHNayY+BXQz0SyRjxvAMj+OWlw4Gc2Mv MyfyevfPCwq0syg0imeufiPBPSpVawTT0MKMGBpX7SVi24WF7h3xftzixMyxeF35QmI2 5U8B+niaupi4u10jFd3A2nvCIG9Kfjv4OyY9w2hCwwvgHCpW1WjJKXbdu/UScJJ4dkC5 PR3haI1VkoUj1zQIRIBKArSiQl8RTLqvrFlIWoaCgQeYaBpXr3PDN0rAHLZDntWXUu35 DUKySN/iSsc22ZUzGGr/ss+Zb8DK7M15J13QiXCZvoWdjg0zzOmCg4R/sdvz9hwIyv/+ oaYQ== X-Gm-Message-State: AC+VfDzRtiNiiVqsEZi4w1YmDR9/3oqy0LNObmyk5kQ3rG1WKRp1SNmA NAxzjYEaMXiT+nIPW/UmMmmPrg== X-Received: by 2002:a05:6a21:328d:b0:10b:2214:7ab0 with SMTP id yt13-20020a056a21328d00b0010b22147ab0mr2370510pzb.21.1686174788778; Wed, 07 Jun 2023 14:53:08 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:34b2:b638:6b53:f6c2]) by smtp.gmail.com with ESMTPSA id j25-20020aa78d19000000b0065dd1e7c2c1sm1376486pfe.63.2023.06.07.14.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 14:53: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: dri-devel@lists.freedesktop.org, Dmitry Torokhov , linux-input@vger.kernel.org, Daniel Vetter , linux-kernel@vger.kernel.org, hsinyi@google.com, cros-qcom-dts-watchers@chromium.org, devicetree@vger.kernel.org, yangcong5@huaqin.corp-partner.google.com, linux-arm-msm@vger.kernel.org, Chris Morgan , Douglas Anderson Subject: [PATCH v2 01/10] dt-bindings: HID: i2c-hid: Add "panel" property to i2c-hid backed touchscreens Date: Wed, 7 Jun 2023 14:49:23 -0700 Message-ID: <20230607144931.v2.1.Id68e30343bb1e11470582a9078b086176cfec46b@changeid> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230607215224.2067679-1-dianders@chromium.org> References: <20230607215224.2067679-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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768082503886328946?= X-GMAIL-MSGID: =?utf-8?q?1768082503886328946?= 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. Signed-off-by: Douglas Anderson Reviewed-by: Krzysztof Kozlowski --- 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 ce18d7dadae2..72212382d702 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 Wed Jun 7 21:49:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 104735 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp504001vqr; Wed, 7 Jun 2023 14:54:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7YmUyYmGcOaWGJShTiMxCFSjXhEO3i4dhi5X4lR2ctORHjpFyK36cNoIYj1Cqj3+wsjldq X-Received: by 2002:a05:6a20:748d:b0:109:38b4:a210 with SMTP id p13-20020a056a20748d00b0010938b4a210mr5363804pzd.29.1686174875489; Wed, 07 Jun 2023 14:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686174875; cv=none; d=google.com; s=arc-20160816; b=HfMpd7SABvQoLeVbBYodlgR23Koc5R1Fi/WvJX2L3oHRUOSFrLdyFVvQNRJ4dijNvx NniLGqIDk5HoA4GyKQoix5Tnbai5ID0qy0CQjw1htpylqpcN7L5Swu4g7oOTvF9C9lPt uWv0lOXYLqWp08egRiSUb8uIXTnh6Voymyclt/sjLlozQ55EGjDafuhPGl+4x0o/RAl1 qETcavrt2BWGsGAnSzy0rkZVQQqBFKTKL2/Ejn22HknrhYdY6fzvWMCAAhemyHldM/Ip UhB/dIfOocBFqANbnSGXwZo4Ir6875yYqrO/r3XwfDUYmAOSR6RdBGwEDyUZlmvT5GWZ OYyA== 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=hfUG9c2qlt8kTNqx7t/idPYkBIfLX/cfnxD2deWf3W8=; b=kVLMItNUwP1v+dJOcaJO3i0FcOERpRTbRCgcTPoBojGeIEGXMlylz208kneRHs5q4a C7qrJlcapk+C+E7yOFqNyVCepO6WkFe6eZCuGYY0nIqn2L3w0edGaWv/HVFESev0sKZ3 nwsUYvyLIUPJaEhcHtzf5O+gsZJjpJC075KvcaAj7praWT3pHeHmGpHKHTcDQoizOeFC e5/ZayRgo88Qa4PYsjLFjj4vo7HM0ERb4auaN3xex682/ls8PSHL17DZ0/uBacjKWVNM 8mnrvbjM/jYbTpeAvVOy8W8mJV6Z1NtBRSG1ld1MFEglRmxf6ozXM2L5wMAW2YR+TPV8 KlGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ayuR0NPM; 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 p22-20020a63c156000000b0053f27c5efe4si9073610pgi.857.2023.06.07.14.54.22; Wed, 07 Jun 2023 14:54:35 -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=ayuR0NPM; 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 S230104AbjFGVxV (ORCPT + 99 others); Wed, 7 Jun 2023 17:53:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232093AbjFGVxN (ORCPT ); Wed, 7 Jun 2023 17:53:13 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A32711FD6 for ; Wed, 7 Jun 2023 14:53:11 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-654f8b56807so5319111b3a.1 for ; Wed, 07 Jun 2023 14:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686174791; x=1688766791; 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=hfUG9c2qlt8kTNqx7t/idPYkBIfLX/cfnxD2deWf3W8=; b=ayuR0NPMX0lCr649Ls3PcdaWJi3/pI5z6ekASxp9r2pXuUPRAKtIyY930QFx1kuFcE nOzUI88ocCNkotOwnkN5ZtWTSMimth7YMeld2HFSmbDacRlogFUCdDed5mPLGt0c4lYC KN5LqNcDew/hCZof0SBt6j5tLIkYGt873vkRE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686174791; x=1688766791; 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=hfUG9c2qlt8kTNqx7t/idPYkBIfLX/cfnxD2deWf3W8=; b=FU/kGR01/oElkQWD4l7I21RpUTsec33nlqneT8laNhp4pOqjPFze+EX9EiKoR/xz/w n08eD3WTk/CDohAlXRZM7WZVxYOlcQcWHacsOgOipKh53n+4+kJIRfCFbMWSHInFiTfI vEzQrwIp1pmzUTh5pNxMdg0L0CnX9Xxb/IgTM17CcdQ4g8fz7VmgJQbuEovSjhkshEJu HRcrCbeU0dn3/0esoGZUb6iU+K2UyO50kz3TD1T4S3Hy7x92KSHBDY3DAbI+Iza+Mft9 A6+Fc3A8+iN5M9ExVqp3foR97thLndteWOC7BU3Sau/OVMmb/O4OzF6YHoBCdHucDhVx lulQ== X-Gm-Message-State: AC+VfDx/6drmhoTN2OtVjqTpPRrJtX5beercZp1COVhjO1Tt6C19HNXq YQqQMurczxxUiw3PFQMgnBaD12jMrAWSZC/2PV8= X-Received: by 2002:a05:6a20:8f17:b0:107:1805:feea with SMTP id b23-20020a056a208f1700b001071805feeamr5073223pzk.37.1686174791064; Wed, 07 Jun 2023 14:53:11 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:34b2:b638:6b53:f6c2]) by smtp.gmail.com with ESMTPSA id j25-20020aa78d19000000b0065dd1e7c2c1sm1376486pfe.63.2023.06.07.14.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 14:53:10 -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: dri-devel@lists.freedesktop.org, Dmitry Torokhov , linux-input@vger.kernel.org, Daniel Vetter , linux-kernel@vger.kernel.org, hsinyi@google.com, cros-qcom-dts-watchers@chromium.org, devicetree@vger.kernel.org, yangcong5@huaqin.corp-partner.google.com, linux-arm-msm@vger.kernel.org, Chris Morgan , Douglas Anderson Subject: [PATCH v2 02/10] drm/panel: Check for already prepared/enabled in drm_panel Date: Wed, 7 Jun 2023 14:49:24 -0700 Message-ID: <20230607144931.v2.2.I59b417d4c29151cc2eff053369ec4822b606f375@changeid> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230607215224.2067679-1-dianders@chromium.org> References: <20230607215224.2067679-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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768082506155131888?= X-GMAIL-MSGID: =?utf-8?q?1768082506155131888?= 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 Wed Jun 7 21:49:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 104740 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp504288vqr; Wed, 7 Jun 2023 14:55:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ66rDzF2fMC4gwIXiW3W+tnuI/2gmdyS30jGHCSA/7Psb1pTZ4q+4k9xHz5NgHJZd7YEgIf X-Received: by 2002:a05:6a20:12c1:b0:10c:467a:536f with SMTP id v1-20020a056a2012c100b0010c467a536fmr5210539pzg.14.1686174919925; Wed, 07 Jun 2023 14:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686174919; cv=none; d=google.com; s=arc-20160816; b=maCkaJnnHBgf6k2HcJPdytzAx4rBFEZJFmDnP2FqZwGcXHoFdIW0Plg6YP6rTj1tY7 bcaaH4ZTboTNb40eYRPnZZVAyMfbP9PNRPJv8v4CVp337x+SiKaPWXCNaTYOaDBOO673 qehgR3prInMvU6Qe2usgy+7bToV9aY0pt+3WtCaCIeCSafuNhNkChxv1VpqUA7nA2SnJ OSN8EX69ri2ztNub1nzF+Z0WIsM5Mj9giRrtgE4IS/0M+Bs30GXNCkXCKme08Fcch6Tp KcvAyF7KLsX+KjK/Wo3ZP7QJBwvLhtx8kp8F9BmhSBGfKbRegpb80tRJptmMQoNOcr2P YRjQ== 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=YzWv/7iwI3nGNldnHc8Ct8uHrkP74/gxSdv1eA/ez8w=; b=pkFlYLufjDQdLZCJ8Z9pUQ965GeHqq3xGBzN44via0a+2m0Vm8VU/LXxIZu2JSdK1D k/s6A8OwFShDxDtNfyzliJBT3Wo70OA8mOdZsDXD5RA8/sF3UqORvi7cqKKLf/mO20Gk 7Ks/VIudYPzByU8MhnvNBTbvtYUeIUz+K8A+Jv5RAMy85hcJT/ibrFEgw10qdH72KMhN tp4ioUBZOyg9/fVM6cGC2Fk/NUSaMWwzHIwlgDvFvvlP4db21L5qU3dIyyD6WSMj0usm l/sYajkK5ob0BmTmTLS8spI9tzkYVy9MwOw8s//JWMSGp2xDwot+/g5Q40u7tPrF/UIm Kbqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Wqk0fzOk; 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 q21-20020a17090a2e1500b00252f4ca40c4si1700522pjd.34.2023.06.07.14.55.05; Wed, 07 Jun 2023 14:55: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=Wqk0fzOk; 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 S232172AbjFGVxX (ORCPT + 99 others); Wed, 7 Jun 2023 17:53:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbjFGVxR (ORCPT ); Wed, 7 Jun 2023 17:53:17 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 715B02115 for ; Wed, 7 Jun 2023 14:53:14 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-651e298be3fso7834434b3a.2 for ; Wed, 07 Jun 2023 14:53:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686174793; x=1688766793; 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=YzWv/7iwI3nGNldnHc8Ct8uHrkP74/gxSdv1eA/ez8w=; b=Wqk0fzOkhtRpfZlew1broDYr8Ugf71xl/Tr4bLpEg6YszT8mI8VgYxntps9IkDOrG5 gpDMELj3w5APz5FlnM/UI4vgi064v1Ih1q/r0YE/Ebk/W6NqAidkavAG0gv/ud2zQEK3 q5LcNBXpFzi1pPXxTAML1YXcqRXiCtkOlG76U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686174793; x=1688766793; 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=YzWv/7iwI3nGNldnHc8Ct8uHrkP74/gxSdv1eA/ez8w=; b=Zwxu9IN8QvaN9bMEeGH9TGmfta3ljJ2ZjALDvGiXltcaxhCb0uacBLp5DBC2Qtq/qP wsJ3Dl0yorKSFbtAYUZlPGljPrC0APsubK9dRLxKWwNzRg3ZC4240F0HkeOdvNf8CvXg qsrheu8IGjByN7SkBKctko7gGhXm5Vo44NHQdhmfN7Eexu7At6Z+tsLdPNcnDWsUHf0S X1Z13CseCqXLW+zF/KpRnArI9UeBAD9xoBNBvz/9oGUlcPSxe61Av9naB5obOM9mXpKD VfBFwsBeOZuFVRVm1RCT6Nw/900xtdPJJrWHNDcevl57BxqxQuGtsPkZ1ePhWxt9Tu9D 3dlA== X-Gm-Message-State: AC+VfDzPtjixxWF1r7JspIuoCkkiXOYyEyjgnGV8BpXoxQ+8vNTP7OvA zlOdp7fhJ9fxX13hkkUz+6/tOQ== X-Received: by 2002:a05:6a20:43a7:b0:10c:b9ed:6a38 with SMTP id i39-20020a056a2043a700b0010cb9ed6a38mr4596253pzl.28.1686174793560; Wed, 07 Jun 2023 14:53:13 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:34b2:b638:6b53:f6c2]) by smtp.gmail.com with ESMTPSA id j25-20020aa78d19000000b0065dd1e7c2c1sm1376486pfe.63.2023.06.07.14.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 14:53:12 -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: dri-devel@lists.freedesktop.org, Dmitry Torokhov , linux-input@vger.kernel.org, Daniel Vetter , linux-kernel@vger.kernel.org, hsinyi@google.com, cros-qcom-dts-watchers@chromium.org, devicetree@vger.kernel.org, yangcong5@huaqin.corp-partner.google.com, linux-arm-msm@vger.kernel.org, Chris Morgan , Douglas Anderson Subject: [PATCH v2 03/10] drm/panel: Add a way for other devices to follow panel state Date: Wed, 7 Jun 2023 14:49:25 -0700 Message-ID: <20230607144931.v2.3.Icd5f96342d2242051c754364f4bee13ef2b986d4@changeid> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230607215224.2067679-1-dianders@chromium.org> References: <20230607215224.2067679-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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768082552784278857?= X-GMAIL-MSGID: =?utf-8?q?1768082552784278857?= 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] 20230519032316.3464732-1-yangcong5@huaqin.corp-partner.google.com Signed-off-by: Douglas Anderson --- Changes in v2: - Add even more text to the commit message. - A few comment cleanups. drivers/gpu/drm/drm_panel.c | 151 +++++++++++++++++++++++++++++++++++- include/drm/drm_panel.h | 75 ++++++++++++++++++ 2 files changed, 222 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 4e1c4e42575b..d103eda89f8e 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,119 @@ int of_drm_get_panel_orientation(const struct device_node *np, EXPORT_SYMBOL(of_drm_get_panel_orientation); #endif +/** + * 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..e0a4d2f6f7fb 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,26 @@ static inline int of_drm_get_panel_orientation(const struct device_node *np, } #endif +#if defined(CONFIG_DRM_PANEL) +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 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 Wed Jun 7 21:49:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 104744 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp516006vqr; Wed, 7 Jun 2023 15:16:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7OFpSCg0mJ314lP+igruk/3HLxuB8kaLkEz39tFP25RX4Bhf572fRlHo85Rz5WNenb9VV7 X-Received: by 2002:a05:6a00:c8c:b0:64f:52c9:ddd5 with SMTP id a12-20020a056a000c8c00b0064f52c9ddd5mr8624466pfv.34.1686176210574; Wed, 07 Jun 2023 15:16:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686176210; cv=none; d=google.com; s=arc-20160816; b=t//+6bMQGY5Ts8c5CrsM128iqZCqjgAGL2otLakuhZ3XR0pI1RtEduGL7id4ZrrLZm ex7BS8n/9/5iQA7CzVRNAXUTwNUOWCrEoiZlKCN4hnkR6/D1N8YzcYO2bpc+QuyHQOaa vaWv2tcq9iCTz4MTGQYelUMSqW3ZCU++rx1jb+CLSeCLmeNs5cLI53PLoc3gWnAspUzk gTOVdomF3ikHLWvxA1W67icmyGUq5MjVUAykBA4TAlvX9SG4xJejNlemB2kSa8nA4JhB UC1/E0IYDCE8wfJ7pGioFIeNqrp9Qx+1PX/1m5+JQP9POnxsi1DwQZIhyWCvtK9FgCZL 0bvg== 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=crBZss5mF3gjKLwx/CqtOTtfgR9i9SC8rNyLPUKs7BQ=; b=HNFYJS+5ZCker9o9x7WsHsp2h+mQokOF8or/mIv9Jx95wvV1gqUMrTLasls64qDbaj cBHRHkqxEf4YFAuCxczRL1Vh/g0+mcrp5bho6TQBjkuTA6dSoqPNs/kNrPCPs0jZblpt EAUCGEabjQBtvd78xz5xHUO2Vy2YtKkpNTUxIauQ8sYP3Ga9mKl9gv8d6t7oe8INVh9X mMIXNhuQXtQ8wLxxTd4RQMfEWhanAI3zo5G1r0nKYlO6X1q7XOCaGgTAFODSiBNn9+Tq Kn7DK1tgBpDi8kTUkaAIaXwvsGa902g7IUKQdaj+9vT98fZrp1/1cGiKSarsLa3dQ9i0 9khg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gLEGdkrl; 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 bv5-20020a632e05000000b0052c6200e5e1si9420406pgb.649.2023.06.07.15.16.36; Wed, 07 Jun 2023 15:16:50 -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=gLEGdkrl; 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 S230526AbjFGVx2 (ORCPT + 99 others); Wed, 7 Jun 2023 17:53:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232255AbjFGVxT (ORCPT ); Wed, 7 Jun 2023 17:53:19 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5363E2126 for ; Wed, 7 Jun 2023 14:53:16 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-651f2f38634so7540394b3a.0 for ; Wed, 07 Jun 2023 14:53:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686174796; x=1688766796; 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=crBZss5mF3gjKLwx/CqtOTtfgR9i9SC8rNyLPUKs7BQ=; b=gLEGdkrlNnvMgTTGOEdCWWcfB1i72xB3KWqQx+7tAf5HZk5n8a87dTE8cDhQijzzBu lAV4kwbGPWSfrKgAixZN8QhMZX1SeEOn/DLX/dhv0PRDbO0tDOlWRmyatlez7rCoDgou WTw7bTbJbWTLjeon8Fy7dVsLN71SI8wsOrOug= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686174796; x=1688766796; 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=crBZss5mF3gjKLwx/CqtOTtfgR9i9SC8rNyLPUKs7BQ=; b=ayzXyXNpe6k0SO7VYQuULKrLfNhxq0/TkXD0SUjXLoSQvJ2Q+YqwLYt7RhPn5/FQic vppxT81LR0zqwnsf43jMm+Phlw0UsIJ4rqo3vXBt9Dzozf9g4WAHs+Kx6ZhiFk/6Otv+ P0eL4YTWGKsAMkNPLDK9ay53bpkhjtoNG0/qrRJVrenqEZ0ssHoj3h6zjG7pHJldnIFy /A7jIZRXAZK5eH/+tj1Q+k25I9ifqxL4PeaQRAefXuw8Ghev4rzoINxRYkgyrZtiX6om SmvW9ZuCD9AOVjscvaZQ3XD7JXW0IJQDE9W/yaL059Odpp+gCHa5TZF4COnTenMDAjiy 3Faw== X-Gm-Message-State: AC+VfDzhRsLSfbhXgvWcBQR4sV61AFeU0grwnRja2lkThM6OHDF0K8br XPpiWwRBfF81qE81HnHpZntu9w== X-Received: by 2002:aa7:8889:0:b0:64c:a554:f577 with SMTP id z9-20020aa78889000000b0064ca554f577mr8115023pfe.11.1686174795822; Wed, 07 Jun 2023 14:53:15 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:34b2:b638:6b53:f6c2]) by smtp.gmail.com with ESMTPSA id j25-20020aa78d19000000b0065dd1e7c2c1sm1376486pfe.63.2023.06.07.14.53.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 14:53:15 -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: dri-devel@lists.freedesktop.org, Dmitry Torokhov , linux-input@vger.kernel.org, Daniel Vetter , linux-kernel@vger.kernel.org, hsinyi@google.com, cros-qcom-dts-watchers@chromium.org, devicetree@vger.kernel.org, yangcong5@huaqin.corp-partner.google.com, linux-arm-msm@vger.kernel.org, Chris Morgan , Douglas Anderson Subject: [PATCH v2 04/10] of: property: fw_devlink: Add a devlink for panel followers Date: Wed, 7 Jun 2023 14:49:26 -0700 Message-ID: <20230607144931.v2.4.Ibf8e1342b5b7906279db2365aca45e6253857bb3@changeid> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230607215224.2067679-1-dianders@chromium.org> References: <20230607215224.2067679-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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768083906322178252?= X-GMAIL-MSGID: =?utf-8?q?1768083906322178252?= 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. Signed-off-by: Douglas Anderson Acked-by: Rob Herring --- 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. 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 Wed Jun 7 21:49:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 104736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp504042vqr; Wed, 7 Jun 2023 14:54:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4JKuqbdblHqPxs/1e/voI9V9Ihj5eVdoOEhEEpZMH7vv29UDK4sDbTxRF5oT7iGnCt0rLM X-Received: by 2002:a05:6a21:980d:b0:111:1bc4:cf0a with SMTP id ue13-20020a056a21980d00b001111bc4cf0amr2586325pzb.52.1686174884643; Wed, 07 Jun 2023 14:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686174884; cv=none; d=google.com; s=arc-20160816; b=yuYJd6hYAPxs7MsKUc+WwTTVpQaxaBD3VMrFDJMIlx9n4wobimSjrq3ZT1B5Ht5Uib 7sv9ilwM/gh4gUwoAdnFk3ViSJ7ZqCjd6/j5shHMWevfjCJQ3QruZOezIkabr9MOeQxC ptSihEAJe5yDgcjdkI1yJ3ym+xmldV8KBbOqRiaghriORNW7H35jIJMe7Q0DultUxF62 9LPVkOVkwTIAT6/ov0HyVO0ytPx5Q5WIJ3xK5ZN3HK4yntAJMPKYjaT7FnjDo1eW6dba QbCn7uo8KpDqVQCvv1tT33AbH1qjN89ukGHzRbYUfs/xIabYb3NSyFmjP22dLdqD8d1N UZsg== 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=C0TJ0M8h8FSBEytElW2U8aVLESeLFlDMicg+igIg24E=; b=uJKLL5fvhQx67nFQ5HrQ70UgGKMIj3lb9ep2RoQVbOnS/FaEiLu7VSfO8PrCwtsZ47 GW563W/ezxOOyFf0/K44TIzjB5TY3MlMyNGlcD0xZcb/QVA6UUt/7KFgzUESBz674Lyl 58qFY3uRB2AJ3ubBxA9ZWVOgzk/YtzXb/zju8BVUHbIQH1Yz/DsOoo+XD31m2WP17HE8 686djNuEXTDKt+C6FiXnRhZejnOfZ3jT+VD5KGFyduN1XA+1XwpHfEfnGoxwD7S+5+pM JiIgsvbyfsEJdcCIbDJPgkKy6Gl9RR8aIHwe6lqgcx4XHVeu7fz393U/pCfnsQ/FdGfO AURw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="ENQV/aC/"; 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 j21-20020a637a55000000b005344b36c64asi9628153pgn.786.2023.06.07.14.54.31; Wed, 07 Jun 2023 14:54:44 -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="ENQV/aC/"; 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 S230247AbjFGVxb (ORCPT + 99 others); Wed, 7 Jun 2023 17:53:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232139AbjFGVxV (ORCPT ); Wed, 7 Jun 2023 17:53:21 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B90B2129 for ; Wed, 7 Jun 2023 14:53:19 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-65242634690so4647688b3a.0 for ; Wed, 07 Jun 2023 14:53:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686174798; x=1688766798; 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=C0TJ0M8h8FSBEytElW2U8aVLESeLFlDMicg+igIg24E=; b=ENQV/aC/8MxPO5Q9yi4JEgfC7IjnKPTFvema6S7aTysVupGrZimGTZvAuJcu78oBC4 O+bmUxGBIYUyrFdYZQQHNNtYwFkENO4CGZuSUlme+FgsHKK6Yw9s3il2gcK9OpDZ+vrp xmuXwfUYInD3fPMXGm2Dnhyqk3dOQ330vO0+0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686174798; x=1688766798; 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=C0TJ0M8h8FSBEytElW2U8aVLESeLFlDMicg+igIg24E=; b=Vi5Ri230Qp7Xlnae8ewo6KI30vAoIM8p8UTWekUYVaQ5h4SSDvQndp6snJdFSRRviL 1BYLuqpWqnH5qdisy28fxolWhGrlSR1TA9+caD8gQhbMiU8bCWR5/jGc+vMPPwvFb2z4 6IKTGtjBiu2r7kx1u8DCNuwDw3hxu5ZmN5BrPFyPB6Y4BtyatmcHHLVqCV18zXzU0aK/ oGIz729zSJuxb8Bt9x0zBmGLU/cI/mXahMuj2ywzwldhy5f5v8Jlev5C8TeA2c0U+76d ukaniKYJ6U6lM0qc9hvswkOQa2QRGzZYZQ+MjNm8UO9zhEf0BznowBdUWWhiDgMZaCd2 Mkpw== X-Gm-Message-State: AC+VfDyYA6FOb/tuoo/4Yfs2TsiS/2zVqT5kl66TJX0pepYwH5AMFPZh TepAQhixDbQ0WdJUTb5yAYrXGQ== X-Received: by 2002:a05:6a00:1820:b0:65d:a631:9f39 with SMTP id y32-20020a056a00182000b0065da6319f39mr6657335pfa.32.1686174798580; Wed, 07 Jun 2023 14:53:18 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:34b2:b638:6b53:f6c2]) by smtp.gmail.com with ESMTPSA id j25-20020aa78d19000000b0065dd1e7c2c1sm1376486pfe.63.2023.06.07.14.53.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 14:53: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: dri-devel@lists.freedesktop.org, Dmitry Torokhov , linux-input@vger.kernel.org, Daniel Vetter , linux-kernel@vger.kernel.org, hsinyi@google.com, cros-qcom-dts-watchers@chromium.org, devicetree@vger.kernel.org, yangcong5@huaqin.corp-partner.google.com, linux-arm-msm@vger.kernel.org, Chris Morgan , Douglas Anderson Subject: [PATCH v2 05/10] HID: i2c-hid: Switch to SYSTEM_SLEEP_PM_OPS() Date: Wed, 7 Jun 2023 14:49:27 -0700 Message-ID: <20230607144931.v2.5.Ib2a2865bd3c0b068432259dfc7d76cebcbb512be@changeid> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230607215224.2067679-1-dianders@chromium.org> References: <20230607215224.2067679-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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768082515837682769?= X-GMAIL-MSGID: =?utf-8?q?1768082515837682769?= 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 Wed Jun 7 21:49:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 104743 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp515969vqr; Wed, 7 Jun 2023 15:16:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5E682LxpigzuKrOkhVdntGpfvxl+BiOsVIMTr0fZqfZd7cYqQVVooecfrzPjGeKpH/ehe5 X-Received: by 2002:a05:6a20:244c:b0:112:cf5:d5fb with SMTP id t12-20020a056a20244c00b001120cf5d5fbmr3594452pzc.50.1686176206692; Wed, 07 Jun 2023 15:16:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686176206; cv=none; d=google.com; s=arc-20160816; b=fPwRX8qENyZaoaT9uwwnYjLIH+sugbUlnLwwP3XLRuo+SaiUFDpruORMjrZCSG5In1 YpsqpGwaR1QGxTEwKkL28GW6w2DHRfKOJqFMD6vn+SmCOPtdXJeHG62c+AcRRJplb9Qd w4UeAhavQTkJyd2v6m6kyfVsRySH+8XRqBcEZc4tgYlS25d3NNvkfANqk10290wgk08k dGug8XiRLJexgXthx+5x5RcP0I4RwS80/2y9G3qD44b0XRHnENks8OxQXPv0qHg8KPi2 BxZ5TlHXIjJqk2tjUSpOSaBE8GYieJEdE2cfvm5XJfAGoUgMXXPXgewhgWhb/vHT8Sj1 ueLA== 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=HxkeUs5mQG1dO+8ojJ+2sMsARHixUCPNou02a3vPakk=; b=AHHWCAFYOaD8Qy3+Dho80I2SztKfMLz4vB1LGfKRyKEDPylFtGzlOkrKFgCd5brzkY Vc5O9rKrOmZja38uIBpmCADRoWildGKDBwFl+8AHWO1X1Pqvmh4uG4P9P7XG2/ahwQpI p5tuWhl6dLGMqvkU2X0jy36oeFZsgAhwpnCKJ5HVTxHkM1MEzlI4r6VSEoQ9nRn61cBr FTehCPRNhwH/RzXX37/eQDjUli4JcYNAdOXAL9VG8EM/VxNWR5BJh4cORDvlYljff9tX ZVz/6ACurnK1nkTQguBQ3L4JZhRme/jQR5q9lj851Uz0CLThdH+uMJXwwBjnjdIddQvz zKag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aaZsYlg8; 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 j24-20020a63cf18000000b0053fc3bc33e4si9223758pgg.795.2023.06.07.15.16.32; Wed, 07 Jun 2023 15:16:46 -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=aaZsYlg8; 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 S229659AbjFGVxi (ORCPT + 99 others); Wed, 7 Jun 2023 17:53:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232130AbjFGVxX (ORCPT ); Wed, 7 Jun 2023 17:53:23 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A03D41FFE for ; Wed, 7 Jun 2023 14:53:21 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-652d1d3e040so4217637b3a.1 for ; Wed, 07 Jun 2023 14:53:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686174801; x=1688766801; 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=HxkeUs5mQG1dO+8ojJ+2sMsARHixUCPNou02a3vPakk=; b=aaZsYlg8dXHFcOB3rrTa2eLeNAIjNdhofFK99V+nOVuox05+iyLw0BsIRr1oeOjkAc zYSP6PugSXxD09ad39sLlWsoiTTpi+nJyAgSU0a/9JDrdFQJ6JvsyyxddCNDhwQGhOG/ LIjagIqqChl7O0BwHPKR6r/lPsRP5p8HN0TVA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686174801; x=1688766801; 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=HxkeUs5mQG1dO+8ojJ+2sMsARHixUCPNou02a3vPakk=; b=cg1Gd1OYkkxuMSpFq28KqTFpRXXVRQOcmqv/3tus94GmOnSYjv3bcVgAIrKoIglR42 ENetAIWAtd0tdvTUJcbCPYAlof4DyY16eDDgj8Mzrnqd2CkDf64AvChSRb2tHQdSVX3u xmlUsY9w6pqzP4EB16fnrk6lckdyf2PwX4uuJe/tTT4ah1nIg68ILMqE1Trf8CrwZqko QrYlzJfyWHGSszvQmnofOVKwsV1inUhjCOeetRtcyRVmiuWlIjMF2DpUT5XmYdWLlweJ GhoLRMRSYC+UmTVTth5TAulg9hj09+oxZZKssEpoOBg1AghdtW81Q/cNBhi2PFiCGjJ4 uSFw== X-Gm-Message-State: AC+VfDw3+LGdoa9x7l97LguReDDbcUI7gnGelUCj3h+xrKh4HI2W4u1V bSnkaR+18i2DhPqG4pPRx08/PQ== X-Received: by 2002:a05:6a00:99b:b0:645:ac97:5295 with SMTP id u27-20020a056a00099b00b00645ac975295mr5982379pfg.9.1686174801115; Wed, 07 Jun 2023 14:53:21 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:34b2:b638:6b53:f6c2]) by smtp.gmail.com with ESMTPSA id j25-20020aa78d19000000b0065dd1e7c2c1sm1376486pfe.63.2023.06.07.14.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 14:53:20 -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: dri-devel@lists.freedesktop.org, Dmitry Torokhov , linux-input@vger.kernel.org, Daniel Vetter , linux-kernel@vger.kernel.org, hsinyi@google.com, cros-qcom-dts-watchers@chromium.org, devicetree@vger.kernel.org, yangcong5@huaqin.corp-partner.google.com, linux-arm-msm@vger.kernel.org, Chris Morgan , Douglas Anderson Subject: [PATCH v2 06/10] HID: i2c-hid: Rearrange probe() to power things up later Date: Wed, 7 Jun 2023 14:49:28 -0700 Message-ID: <20230607144931.v2.6.Ifcc9b0a44895d164788966f9b9511fe094ca8cf9@changeid> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230607215224.2067679-1-dianders@chromium.org> References: <20230607215224.2067679-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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768083901816839032?= X-GMAIL-MSGID: =?utf-8?q?1768083901816839032?= 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 --- 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 Wed Jun 7 21:49:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 104737 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp504142vqr; Wed, 7 Jun 2023 14:55:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4UfCJSXE+ttzTCwxyJ3GTiS3tishgQQ9KpD154FZnHPKRP61yUKFOy7Ck1C5yx7KOUN5xf X-Received: by 2002:a17:90b:30d4:b0:255:c461:6405 with SMTP id hi20-20020a17090b30d400b00255c4616405mr3118736pjb.15.1686174901714; Wed, 07 Jun 2023 14:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686174901; cv=none; d=google.com; s=arc-20160816; b=hjPGR5xLohOIClSd4WIALqjVr6dfsSVvL9siQFoJFNkJyaszwl5FHAzSVwP6EGRYOa 8Q80KgjunTKS40Z0QmqCjOqEWIzJj0Zc/AU1+th8A3DZX+Puc/wQyN7Fodt+ms1PMlEE yiYaugadz7tegvbEtcjxHihqkTlAIItwhLSDNqtE9EnqetPYOcg2n0oZstZVIIlr0+Jx VenHMGCEkaGzst39QwEatEjcHDzPP5GS8rxfewaNNSV0kEWYm0w4aQhSYOY5VTtIehYs 6EoT2TAHQUo5HXX0gX6O4Wbr2uu3hJDCqkUcTnfoRBLlmVheitdQTvt+1RlLgokBanxM z6sw== 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=3ednqd69XAn3oXLgneclhI21DyoCY28g8dUYMulq+Zo=; b=Ne1qYi5jya9ZYutT8N3m+N0RALBiwrar+rArnU8+SGZyxU64i+spAcaanpdK0nWuno hojmhp0mhpSRExktQJKWLgra15OwQ2XCfR0EnJtXCvQnFgqEk0xJNtfefyZN+NX426DS N2H0T6UgTY9MHdUtvXvYdtZWrFB8ElfdWjOheen0uZuBR8MpA754vIJNJDj97Nb+jzW3 8aiaZoTUMhiBr0mndvZm0LlDC/QPZQSbOqAJ2te+H5sD8+ChjfLj9FhTu14EV1AQYn8v tMxi3M0Ab+m/6X3JY6x+15A5YpAaww7QU2unFH4UyCeq7Xs+5YyCzUG0/PDlUEnVR37L NPDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gVjgQSnh; 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 h26-20020a63385a000000b00535bf852410si9424653pgn.313.2023.06.07.14.54.49; Wed, 07 Jun 2023 14:55:01 -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=gVjgQSnh; 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 S232125AbjFGVxp (ORCPT + 99 others); Wed, 7 Jun 2023 17:53:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231661AbjFGVx2 (ORCPT ); Wed, 7 Jun 2023 17:53:28 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF99B2109 for ; Wed, 7 Jun 2023 14:53:23 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-65314ee05c6so3956592b3a.1 for ; Wed, 07 Jun 2023 14:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686174803; x=1688766803; 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=3ednqd69XAn3oXLgneclhI21DyoCY28g8dUYMulq+Zo=; b=gVjgQSnhi/3hx1rlvHyqyVbCd6NI+puUk+72twZOtdP997vwzYC3shHqkIGuVh18GR w3q7O4cPal6lAZgclbMwq6RWi7mvY6WGZaF/Kfs3ophNAUekSjnTFS5tG0XUuUtoxouZ h27czJwMQH+Vg6Gt+RYm2j1c5SMgy9zIh9HC0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686174803; x=1688766803; 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=3ednqd69XAn3oXLgneclhI21DyoCY28g8dUYMulq+Zo=; b=NSGD7xx0l9vr3YDlVMryl9tt7N6mmigRKmUFNyczRWKoGkSXfrJ86wlr/EpLntZSZP Y8Ml2wQxgonx9PWRIJ9FcG67niuHuVHM9LLHtqh1KTG2ilNu9FDm8zAvgmO8lmdpR17V X9LB6geybrVWDo1Z6GXstRdf4WNFEbpHx+Wrw5DVylaurE8ifI7ZQozAyX/g3ic39beN WNPHXR3UTacZ6qYcUnuJSeU7IxVzDcnyrb3wD7c/eLAtpLTcJjWIrD0qL6sAJGnssbZm dALpeBPiirFo0L9wV59+MGIe8Az+bGZ3Dog7nA0502mJczuuD9eokOe339GH4xnevfpu hOeQ== X-Gm-Message-State: AC+VfDywPpXzTcY04wyRd/N56bGKSlrrScRyOrh45TNLKnr7PBur+IKX WGPmRRgfKMsPZWeH4WHC5fqzAw== X-Received: by 2002:a05:6a00:139d:b0:65e:842:7922 with SMTP id t29-20020a056a00139d00b0065e08427922mr4301906pfg.16.1686174803390; Wed, 07 Jun 2023 14:53:23 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:34b2:b638:6b53:f6c2]) by smtp.gmail.com with ESMTPSA id j25-20020aa78d19000000b0065dd1e7c2c1sm1376486pfe.63.2023.06.07.14.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 14:53:22 -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: dri-devel@lists.freedesktop.org, Dmitry Torokhov , linux-input@vger.kernel.org, Daniel Vetter , linux-kernel@vger.kernel.org, hsinyi@google.com, cros-qcom-dts-watchers@chromium.org, devicetree@vger.kernel.org, yangcong5@huaqin.corp-partner.google.com, linux-arm-msm@vger.kernel.org, Chris Morgan , Douglas Anderson Subject: [PATCH v2 07/10] HID: i2c-hid: Make suspend and resume into helper functions Date: Wed, 7 Jun 2023 14:49:29 -0700 Message-ID: <20230607144931.v2.7.I5c9894789b8b02f029bf266ae9b4f43c7907a173@changeid> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230607215224.2067679-1-dianders@chromium.org> References: <20230607215224.2067679-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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768082533619898170?= X-GMAIL-MSGID: =?utf-8?q?1768082533619898170?= 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 Wed Jun 7 21:49:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 104742 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp513495vqr; Wed, 7 Jun 2023 15:11:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Xe5+a9k3WwjFWRW4u7+VBtAYor1EfYG/YPTqi0iOkF1Z850ce2IAlZz4ciG/8//WZtRlJ X-Received: by 2002:a05:6a00:23c4:b0:65e:d5da:b3c6 with SMTP id g4-20020a056a0023c400b0065ed5dab3c6mr6750192pfc.7.1686175905085; Wed, 07 Jun 2023 15:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686175905; cv=none; d=google.com; s=arc-20160816; b=ZKGu4B0NbCxSqdBSh4NhJngU5igkIkOvwSrme5Jb60jwXMHkSvGj1NwKgLn5vCMRo4 Sob6nIr4+792d0ypT0WNXw1l2Au75Rx28BSPbJUE5WPiqiTcQojperqpl+IO92iGI/MK AYMiTTzaMDHwlmMQw9w12hfTqFDatixEEj7YRiIRUq3Hw0JiT4R7gXE0GIzYgAE4aELi 9y8zgMUWLBEkez7Ge4Kd188mvYRDlMpyrMP5vrvJKrwIOMQp/8HFcd5Cdb9iRLrii5ZW ya7uP2Re1gVyn0Kbn0gQzUZ34BvYYqDYezWCObkP8l9EDaGjp2t5wHS705uMChwAuLF7 ggNA== 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=+rHz1jZnjpSiv5HKR2V1CEWNHmLWqUe5SsAOtRVLc3E=; b=EZt8So16gbwkVEpSn5liT+3gvtUxaJt+2qJyEASv63FepQYE9GmLFBFcJq9QMAtG3l 63/QtTOKJvGcBKhnFiIQMf3yRBrpalHMzzkUfo7DN39vPGIQR46IVlvbkZ/j4paTQjkC 8LQHyLSAahO1XnTYFHyxx9KUC2VXtVt6wCKFGhX2Aa1/qqmP0AZc0CwmKESZcBPYKDlL CvFsffjbvAyp6rZpmw+74P//+y7/OCO6htrlacOACiVCqJ11f03ggJy89DwzzitNBoJh 2h6mE00c7xa7MXBiaIR3EVVL7xaqYWfMY+G/nXsI9bEK8suuZ5hEOEI1EQ869wHrPEnu o50w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hdbjyXWz; 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 h4-20020aa79f44000000b0064f7150b45bsi9123624pfr.352.2023.06.07.15.11.25; Wed, 07 Jun 2023 15:11:45 -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=hdbjyXWz; 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 S229730AbjFGVxx (ORCPT + 99 others); Wed, 7 Jun 2023 17:53:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232140AbjFGVx2 (ORCPT ); Wed, 7 Jun 2023 17:53:28 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D8BB2132 for ; Wed, 7 Jun 2023 14:53:26 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-651ffcc1d3dso4721511b3a.3 for ; Wed, 07 Jun 2023 14:53:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686174805; x=1688766805; 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=+rHz1jZnjpSiv5HKR2V1CEWNHmLWqUe5SsAOtRVLc3E=; b=hdbjyXWzHfwxcUwfwb+qucn8Y1kzJgDBVnByK1lmUyw+Rig23C+S4Y6GODf2Asa3Rj 9LFMI+tJIkfnSgqmixDuthZjEXGWhYiiE9sj2Kk1wy9zu2bWc/lao9ZXaAP0IItUKllQ EP4VvisdXYOA1Pwgd8nvslaeA7bwp/nRScBzc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686174805; x=1688766805; 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=+rHz1jZnjpSiv5HKR2V1CEWNHmLWqUe5SsAOtRVLc3E=; b=i+Odt7Glmwm58DebFJpY0OjkB9S8k0eyOTwJwkjMdl+kjFGBoozd7GfV3rIjGqvtli kgxors+6/OECnyQagknjZqDuoCsg+vCHYrVG/1Ls7WMomAcpI96zPITV9u8NgCPYxbU2 DJ+zm8881j2n8t0z+xArTsmeoW5S1qlbj8iRjcGwNGbXPjx+wN4YkfohPbUrYeZFYO9X 9KpVCN610v9ab5l/neaP3/DJtnRnzJLkyn7BogM1n6izARq9ur3OAPsDhDTE5RR7SEOS Q6SofFe9HcqHit8rj1rXUL9qBkQLCekQoiEcbCfhlKulDWDl8tpP5lJq6DUda0LVtiE0 8DYA== X-Gm-Message-State: AC+VfDzSOzAR7hSIrrTjkYP6BOZJg9SgtseeuEwSMWznp2+Uhp7t60fs 5rs40C24UttsjvZjGjQ+zuKemA== X-Received: by 2002:a05:6a00:114e:b0:643:98cb:ec1 with SMTP id b14-20020a056a00114e00b0064398cb0ec1mr5634126pfm.0.1686174805605; Wed, 07 Jun 2023 14:53:25 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:34b2:b638:6b53:f6c2]) by smtp.gmail.com with ESMTPSA id j25-20020aa78d19000000b0065dd1e7c2c1sm1376486pfe.63.2023.06.07.14.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 14:53:25 -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: dri-devel@lists.freedesktop.org, Dmitry Torokhov , linux-input@vger.kernel.org, Daniel Vetter , linux-kernel@vger.kernel.org, hsinyi@google.com, cros-qcom-dts-watchers@chromium.org, devicetree@vger.kernel.org, yangcong5@huaqin.corp-partner.google.com, linux-arm-msm@vger.kernel.org, Chris Morgan , Douglas Anderson Subject: [PATCH v2 08/10] HID: i2c-hid: Support being a panel follower Date: Wed, 7 Jun 2023 14:49:30 -0700 Message-ID: <20230607144931.v2.8.Ib1a98309c455cd7e26b931c69993d4fba33bbe15@changeid> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230607215224.2067679-1-dianders@chromium.org> References: <20230607215224.2067679-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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768083585944767139?= X-GMAIL-MSGID: =?utf-8?q?1768083585944767139?= 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 v2: - i2c_hid_core_panel_prepared() and ..._unpreparing() are now static. drivers/hid/i2c-hid/i2c-hid-core.c | 82 +++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index fa8a1ca43d7f..368db3ae612f 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,34 @@ 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, +}; + int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, u16 hid_descriptor_address, u32 quirks) { @@ -1119,6 +1151,41 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, hid->bus = BUS_I2C; hid->initial_quirks = quirks; + /* + * See if we're following a panel. If drm_panel_add_follower() + * returns no error then we are. + */ + ihid->panel_follower.funcs = &i2c_hid_core_panel_follower_funcs; + ret = drm_panel_add_follower(&client->dev, &ihid->panel_follower); + if (!ret) { + /* We're a follower. That means we'll power things up later. */ + ihid->is_panel_follower = true; + + /* + * 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(&client->dev)) { + dev_warn(&client->dev, "Can't wakeup if following panel\n"); + device_set_wakeup_capable(&client->dev, false); + } + + return 0; + } + + /* + * -ENODEV means that we're not following a panel, so any other error + * is a real problem (like -EPROBE_DEFER, -ENOMEM, ...). + */ + if (ret != -ENODEV) + goto err_mem_free; + + /* + * We're not following a panel. That's fine and means that we + * can power up right away. + */ ret = i2c_hid_core_initial_power_up(ihid); if (ret) goto err_mem_free; @@ -1143,7 +1210,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 +1245,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 +1256,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 Wed Jun 7 21:49:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 104738 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp504149vqr; Wed, 7 Jun 2023 14:55:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6sAJr4e8vEuSYKuG6fFIgJyLUFZ7cOXacpJ/jfvQXUXEKQbIFJXtj9SuYHXojeBG/qav4m X-Received: by 2002:a17:903:181:b0:1b0:276f:b26c with SMTP id z1-20020a170903018100b001b0276fb26cmr5217775plg.56.1686174902639; Wed, 07 Jun 2023 14:55:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686174902; cv=none; d=google.com; s=arc-20160816; b=t/qmjww+TJLH2Mc/mGJ2Oh6pUnUgqek5Y+d1GMPAyFTs8P4B9wpqw/h/kPN6bflKuk IgcnnF6GOizSgRrjPeMSI0YaMCclZnPYOWpPDOuCWeSLKo1DqPJTml4odEXACA1B0zPf WhIymGS8f33XwqwXwiWoMmtn1JFVJhDx+YQuKx9D06jjyPjLcVNnQiPNyegBDM8/Ae/N uzzWwpV0wnRlvCK/RpA9CcdDvpIxzcYbTefCnKnZyjfZ2I0R0RsC35vYEuVnNVUH5V0S +ao4MytYFwLhnsVpmEuvHp0RPe2bjAnwCYyG4dCgZWlf9+dr2upBajD7BEpPYXMu4ngq bWfg== 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=/h3em+INtG/UUK+PVeHaRGBuj9ZpztA48bg5EQZ3MT0=; b=l7EfE3v0684s0V0GiFaGqJbqPqrBqyyOLgtIcNDOATHpSB5kg1uYu3uatqV9yKZ6hE xVDaur8gWrg05kqrigk9Bt6dmApQfzo/HAONYKcR3mJVUfQFowOSJ+6aD56MU7tmZToV S6f5rGZpzHixKDUcTiR7s7wVPs40iweK+9931KPIukPVlRUMj0WCowkfPrvpt91qC0DT PlS9AsIpbdw/SRrmDs8R2xRBTGvrlPuYC3cWVnRty+IAfBYg3A9YTl8PC1nKkmyDgY1y YSOf8QpJW/7sKejpgrLoficnQsSUrObrOMdI+yhEXS8iBVNgfUX0p37/cIuGOMqb7Jv9 x9bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZLvHLs5d; 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 u11-20020a170902e80b00b001ab29e00303si9752202plg.426.2023.06.07.14.54.51; Wed, 07 Jun 2023 14:55:02 -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=ZLvHLs5d; 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 S231500AbjFGVx6 (ORCPT + 99 others); Wed, 7 Jun 2023 17:53:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232508AbjFGVxl (ORCPT ); Wed, 7 Jun 2023 17:53:41 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D77A1FD6 for ; Wed, 7 Jun 2023 14:53:28 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-651f2f38634so7540564b3a.0 for ; Wed, 07 Jun 2023 14:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686174808; x=1688766808; 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=/h3em+INtG/UUK+PVeHaRGBuj9ZpztA48bg5EQZ3MT0=; b=ZLvHLs5dOG1TPeYaxiFduJxz8FK7pBX6sxRTCg/aZwKCYFUfiL/X+PjM+I+zkpuBg+ V4fm2g2tewmOP3Nh+pNQNONSWT+TeKp9T5CjDmiibi6Ocgeaf+CVEG6fw3DEZI8uSS2W uF7dxpJegMiAAH0b2T/da7cBn3i7m7zQ37p8Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686174808; x=1688766808; 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=/h3em+INtG/UUK+PVeHaRGBuj9ZpztA48bg5EQZ3MT0=; b=Rh6gFoMumuxXfre0M8YqNXYag3G/F7AeaQ1bmMXKv2a8xou1GWDRSh2FH7tHaYFmCw Fc0n9GnwlWw1uQBOOf5CAJskzpEYmHz6VzR98mcXg59otgWvQ4t7cZkMPPy+QVnu88hZ itmnx0pQMbw4k0YEGp9PMfNSallPmOLzHfcwSTV2z5/9FnuiIm30tiag4gii99sap+u1 T1IUj2mx/uRao2v1g1oXEAXcXvm1OnJ6hgzZk11jvV645vputPY8nynZcb6yWy0ZU8wM na7HVXziXiwRwetnYYELIje5T9Y/AhwsoD6sNiWe9AKi6w+75OAtffKEN2mat9FX5VJW 5Aow== X-Gm-Message-State: AC+VfDxvzVpMTrQ1AFu8uQPsG26Z4XixmEQBHaehFuVzcZsIEyqipuny QjHUJTTLnlVuHcL9FOHlpK5lhw== X-Received: by 2002:a05:6a20:3d92:b0:118:b2e1:9adb with SMTP id s18-20020a056a203d9200b00118b2e19adbmr504121pzi.61.1686174807950; Wed, 07 Jun 2023 14:53:27 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:34b2:b638:6b53:f6c2]) by smtp.gmail.com with ESMTPSA id j25-20020aa78d19000000b0065dd1e7c2c1sm1376486pfe.63.2023.06.07.14.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 14:53:27 -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: dri-devel@lists.freedesktop.org, Dmitry Torokhov , linux-input@vger.kernel.org, Daniel Vetter , linux-kernel@vger.kernel.org, hsinyi@google.com, cros-qcom-dts-watchers@chromium.org, devicetree@vger.kernel.org, yangcong5@huaqin.corp-partner.google.com, linux-arm-msm@vger.kernel.org, Chris Morgan , Douglas Anderson Subject: [PATCH v2 09/10] HID: i2c-hid: Do panel follower work on the system_wq Date: Wed, 7 Jun 2023 14:49:31 -0700 Message-ID: <20230607144931.v2.9.I962bb462ede779005341c49320740ed95810021d@changeid> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230607215224.2067679-1-dianders@chromium.org> References: <20230607215224.2067679-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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768082534556347350?= X-GMAIL-MSGID: =?utf-8?q?1768082534556347350?= 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 --- 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 368db3ae612f..de1a0624be08 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); } @@ -1124,6 +1165,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 Wed Jun 7 21:49:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 104739 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp504228vqr; Wed, 7 Jun 2023 14:55:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5VNJpPie+M6vgoeoevlWBaEuuufK6RSb855U1OBNplJRlpoFeI1hdH4r7tqUH5a8GdzzKK X-Received: by 2002:a05:6808:aad:b0:398:282e:4c81 with SMTP id r13-20020a0568080aad00b00398282e4c81mr7190520oij.19.1686174913646; Wed, 07 Jun 2023 14:55:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686174913; cv=none; d=google.com; s=arc-20160816; b=SVmUfg3BpZ/oRQ8T4Nulhm1g77URd3etGrGkBEzuZS/oCJvoG+OJd0LBDe/9wozkn6 lNgIFgJxGb4dWuweKUtA5m5Rh/HLlN/OWaOYPukuAo4SbrgWq0TfmU3NEexKTae5njJf zidQ5s3zMYhfXbVv0Wi/P9AIW8p3n63alAfl8Me9nwyaB12uxKPo+8vS3bx/hYddMo/Y wGpEWnscqIRjDZN0q/PsEqg9ptEzMF+S3FzBiMtNAd9QR6iy1iUepZ3Z0EyAli2qAv87 RjfLKDVYhewayjLPh0wOqoUAX2hbaehIUCpZL/x+rcRonIRTJCPumOy7vpsa1bZkJGHU bTgw== 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=tXrYtUuCuWvkbV7L1gPu5v5c01AxUbntKP7msewlmBY=; b=AAWnhzCBFq/gvq+adiioTA5yytNbx7mdzTM5GgZD0mrWECtAhELT+nLaTGKPKiqOxC Nt6z7Wo5Vgy6Xt+0a4BKg/O41HVPNWfM8NgR/71nDXm3ynJ9Nl6eQyOWyJz2JwIHmJML ypeAXK6UwPdMeO4bsbI3isCJ7u7CySPyI2UE8w0P30tXDvx8IkizupY4RI9Wjhna7jf1 AddHW/v44Cp0MTdHvFcR7N4C2l4uuneJf/y9OGPFlIl+GrLbi6yE6PHKJHmuljP3wHsI MpkPQMsW3ynPG/2BBsKmV11zW51qI2Tj6INhxNJYztKMBiD2PVVPMbw5jtSt7Zde7lTm ztKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VPtavFwr; 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 o9-20020a170902d4c900b001b04c74f2a2si6917plg.85.2023.06.07.14.55.00; Wed, 07 Jun 2023 14:55:13 -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=VPtavFwr; 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 S231712AbjFGVyM (ORCPT + 99 others); Wed, 7 Jun 2023 17:54:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232130AbjFGVxp (ORCPT ); Wed, 7 Jun 2023 17:53:45 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BF7A269A for ; Wed, 7 Jun 2023 14:53:30 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-652328c18d5so3865982b3a.1 for ; Wed, 07 Jun 2023 14:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686174810; x=1688766810; 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=tXrYtUuCuWvkbV7L1gPu5v5c01AxUbntKP7msewlmBY=; b=VPtavFwrSLAnsChx0O9sOQZYBq1ojrqZEAOSN9K2H5D+oyhkPzKm1AqgA4P47Pf5oh O8BG7TF+uwHJXH1rO/mOL9Oga2y26MvCYhRwbSAF/7bdKs8d+B6F5pZXdFPrDqgi3EQP EzWvrRr+x12vJ7tl4U0Canch7ihXb8a8DBjks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686174810; x=1688766810; 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=tXrYtUuCuWvkbV7L1gPu5v5c01AxUbntKP7msewlmBY=; b=RL/8/OZlG4ywOQP7a3zNGeriuguoboxAej8kz0kDSPI+oEBCD9zkOaYHnWEYNt76N4 Wy8b2IAKrdcvwyugBupVcT6I8VI/DCVpJWpc+Jlg1inQOx2hy56rEVkbJC0vCqOLJIYp h7R9+xmu8LVpWMBPJh+Z80uCCuYhJZe5H4hBTk0pdEUoNxvuiQ6B2lrv2U2Qon/jNryn kjnvYan9Hht5amQXeFjaaoQge5ZTPUSp5GfwrLGdQVzKK/IyaM2rMI/4WmE8xYMycg8X +fhOt25ueU86L7yWB3sPB67STXS5spbxltkUJLd5qbgfg4eNGcneRPXNzrjnzO9X2fKN wqig== X-Gm-Message-State: AC+VfDyy9mJt65t4/pFYVnAFODrVTL5VLmnZFZBf4iNrXcsxx6E8fxKR QNzgs2MLSyv4Zk3WHvqopvyPpg== X-Received: by 2002:a05:6a20:9384:b0:111:92ef:314e with SMTP id x4-20020a056a20938400b0011192ef314emr2361644pzh.35.1686174810186; Wed, 07 Jun 2023 14:53:30 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:34b2:b638:6b53:f6c2]) by smtp.gmail.com with ESMTPSA id j25-20020aa78d19000000b0065dd1e7c2c1sm1376486pfe.63.2023.06.07.14.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 14:53:29 -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: dri-devel@lists.freedesktop.org, Dmitry Torokhov , linux-input@vger.kernel.org, Daniel Vetter , linux-kernel@vger.kernel.org, hsinyi@google.com, cros-qcom-dts-watchers@chromium.org, devicetree@vger.kernel.org, yangcong5@huaqin.corp-partner.google.com, linux-arm-msm@vger.kernel.org, Chris Morgan , Douglas Anderson Subject: [PATCH v2 10/10] arm64: dts: qcom: sc7180: Link trogdor touchscreens to the panels Date: Wed, 7 Jun 2023 14:49:32 -0700 Message-ID: <20230607144931.v2.10.Ia06c340e3482563e6bfd3106ecd0d3139f173ca4@changeid> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230607215224.2067679-1-dianders@chromium.org> References: <20230607215224.2067679-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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768082546463336171?= X-GMAIL-MSGID: =?utf-8?q?1768082546463336171?= 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 8e7b42f843d4..0785873d1345 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-quackingstick.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-quackingstick.dtsi @@ -99,6 +99,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 262d6691abd9..f70f5b42c845 100644 --- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-wormdingler.dtsi +++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-wormdingler.dtsi @@ -154,6 +154,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>;