Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp888360rwr; Wed, 26 Apr 2023 07:36:05 -0700 (PDT) X-Google-Smtp-Source: AKy350YXS48gTcIjNljWdDTXHDJ8IjPK++amDv678kGQ9b+jhjOfhuFKOBx5e0IoUpOZ5dEVO68u X-Received: by 2002:a05:6a20:2d29:b0:ee:f5a4:c072 with SMTP id g41-20020a056a202d2900b000eef5a4c072mr23792205pzl.46.1682519764972; Wed, 26 Apr 2023 07:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682519764; cv=none; d=google.com; s=arc-20160816; b=ZkiuWTTLvt/5rsVrVzI1Kjs7THxv5nAAH8jh6fDiOgjQZ88CaF+zxMyyV4Xnx6sad/ sO1IYScYOIMAD5LMZUILPC85yldeeXxVXf5NoK6kRs+RnlOfpMdh/24RG9H313Ba8e8g um7GXwFaVSMQdZXEQDaCZTFOLEzXEhZfOHDPFrpQ2z3i2+f7ef6DCmnaefRtcGlTb1YH YwwRT9b8fS42zMELpwsF3jOb5Hh/wXKxd5HkWjEtgZ1pSdvce8+maGFfgTr3zT/75adZ tUoPo6lbq+OQUIS8+wT8rEKcZnfZ0ZGF2RWNIh6S2WOE7tEMcGyoGUezhaThfdHq00ly aMww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ddvLBBpo8gBKXAD/L9Fptch2H58M4jlB4+ALINISU88=; b=Iug190G98nkcm+ZXEkldwWlAJzvPPdjcRVRHWClv/rlYjkkT/zc+OEp2rjHJlDLo5A XQWZpzguMW5OikEeOIhfp7wbd8G187wkwDrS7atpFuDzEbzRbR7tPKExL6+rQi1uFXJm dRwRYFMc5V+tsJcZRP6uvI3ew3/r6/P3WGUlH9mswoVzBy8h46EzcKIZiwX7Wl104umi CZavadN0iqILEszRU2fSbagR6/i7/r2UnK8XxZUXxHALu86F7SRc4NF2vf40TgrV4+Ji wVux0z0zcSOvkYoDuq0QEf8TQvDML5Kgt49amjQ4ZhKKEfrB57GbalNJtNS/BnPAeuFY eGbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="EsIk//Qu"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v6-20020a655c46000000b0051b10dc3a47si15800337pgr.158.2023.04.26.07.35.52; Wed, 26 Apr 2023 07:36:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="EsIk//Qu"; 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 S240659AbjDZOY4 (ORCPT + 99 others); Wed, 26 Apr 2023 10:24:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241378AbjDZOYr (ORCPT ); Wed, 26 Apr 2023 10:24:47 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3BC7188 for ; Wed, 26 Apr 2023 07:24:45 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-958bb7731a9so876296466b.0 for ; Wed, 26 Apr 2023 07:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1682519084; x=1685111084; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ddvLBBpo8gBKXAD/L9Fptch2H58M4jlB4+ALINISU88=; b=EsIk//QuAOB0nhYcvEMvABSiFctSGgTTKf1hOSgUVb0WfY6twz98IR2PwzB+jVR1zt RsdwQ0rVWZJkGrsZNCQHMBxifUgWYoMdI+BEYTjFpl1plKW8ENvPAdXLkuDql2ISQvzm nmBO5llWRAKVtm75HR/oxixKUvLP1rG7GOmxg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682519084; x=1685111084; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ddvLBBpo8gBKXAD/L9Fptch2H58M4jlB4+ALINISU88=; b=cxBSzNc7UxndZ5KUJFSDHjT71f/Wa7vtZ0GvBmglnXX2/NiGF9C1iGXMGPr2Dp1c04 /T5kad4JKb6pBY5Y+M27NhOrYjyJ8Ikn+JbhtFmA4LIRJUaZlu8BmYwfpkcGrBTrza3N ebaud6FQDomnsyRTx5nPvZu9Pk2ZEZlrB7+E77b/tRa3n+Plq28vi7HNXZEE8HaVyvm7 p4BjH3Ul6RoovoyPPEdoxFStOY7WhOjFkmmk+Tgnxy9xay0mI6iEvX09uRVR/LOfx2ql ViVyuCmIuheB+swSX/LtU9RJyWMqiXwAwo6/Fn6fPPlJazWKo6MyoynN4Cku7SJ2IgJY UCxw== X-Gm-Message-State: AAQBX9cvScRk1iJ7rOgizCJQxDwMGgV2Hum2xdaF4pfQULJWuCuVt2sX GCNTMf0lJimkSMMzgQ/4sSJe5X05oCNdp1zR1aY= X-Received: by 2002:a17:907:2916:b0:878:481c:c49b with SMTP id eq22-20020a170907291600b00878481cc49bmr16288911ejc.1.1682519084117; Wed, 26 Apr 2023 07:24:44 -0700 (PDT) Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com. [209.85.128.53]) by smtp.gmail.com with ESMTPSA id e7-20020a170906844700b0094f7b713e40sm8145340ejy.126.2023.04.26.07.24.42 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Apr 2023 07:24:42 -0700 (PDT) Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-3f178da21afso48501725e9.1 for ; Wed, 26 Apr 2023 07:24:42 -0700 (PDT) X-Received: by 2002:a1c:ed01:0:b0:3f1:70cf:a2d9 with SMTP id l1-20020a1ced01000000b003f170cfa2d9mr12964153wmh.9.1682519081849; Wed, 26 Apr 2023 07:24:41 -0700 (PDT) MIME-Version: 1.0 References: <20230426093231.1466984-1-fshao@chromium.org> <20230426093231.1466984-3-fshao@chromium.org> In-Reply-To: From: Fei Shao Date: Wed, 26 Apr 2023 22:24:06 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/2] HID: i2c-hid: goodix: Add support for "goodix,no-reset-during-suspend" property To: Doug Anderson Cc: Jeff LaBundy , Benjamin Tissoires , Rob Herring , linux-mediatek , Dmitry Torokhov , Jiri Kosina , Matthias Kaehlcke , Stephen Kitt , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.3 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 On Wed, Apr 26, 2023 at 10:05=E2=80=AFPM Doug Anderson wrote: > > Hi, > > On Wed, Apr 26, 2023 at 2:33=E2=80=AFAM Fei Shao wro= te: > > > > In the beginning, commit 18eeef46d359 ("HID: i2c-hid: goodix: Tie the > > reset line to true state of the regulator") introduced a change to tie > > the reset line of the Goodix touchscreen to the state of the regulator > > to fix a power leakage issue in suspend. > > > > After some time, the change was deemed unnecessary and was reverted in > > commit 557e05fa9fdd ("HID: i2c-hid: goodix: Stop tying the reset line t= o > > the regulator") due to difficulties in managing regulator notifiers for > > designs like Evoker, which provides a second power rail to touchscreen. > > > > However, the revert caused a power regression on another Chromebook > > device Steelix in the field, which has a dedicated always-on regulator > > for touchscreen and was covered by the workaround in the first commit. > > > > To address both cases, this patch adds the support for the new > > "goodix,no-reset-during-suspend" property in the driver: > > - When set to true, the driver does not assert the reset GPIO during > > power-down. > > Instead, the GPIO will be asserted during power-up to ensure the > > touchscreen always has a clean start and consistent behavior after > > resuming. > > This is for designs with a dedicated always-on regulator. > > - When set to false or unset, the driver uses the original control flow > > and asserts GPIO and disable regulators normally. > > This is for the two-regulator and shared-regulator designs. > > > > Signed-off-by: Fei Shao > > Reviewed-by: Douglas Anderson > > > > --- > > > > Changes in v2: > > - Do not change the regulator_enable logic during power-up. > > > > drivers/hid/i2c-hid/i2c-hid-of-goodix.c | 26 +++++++++++++++++++++++++ > > 1 file changed, 26 insertions(+) > > > > diff --git a/drivers/hid/i2c-hid/i2c-hid-of-goodix.c b/drivers/hid/i2c-= hid/i2c-hid-of-goodix.c > > index 0060e3dcd775..fc4532fcadcc 100644 > > --- a/drivers/hid/i2c-hid/i2c-hid-of-goodix.c > > +++ b/drivers/hid/i2c-hid/i2c-hid-of-goodix.c > > @@ -28,6 +28,7 @@ struct i2c_hid_of_goodix { > > struct regulator *vdd; > > struct regulator *vddio; > > struct gpio_desc *reset_gpio; > > + bool no_reset_during_suspend; > > const struct goodix_i2c_hid_timing_data *timings; > > }; > > > > @@ -37,6 +38,20 @@ static int goodix_i2c_hid_power_up(struct i2chid_ops= *ops) > > container_of(ops, struct i2c_hid_of_goodix, ops); > > int ret; > > > > + if (ihid_goodix->no_reset_during_suspend) { > > + /* > > + * This is not mandatory, but we assert reset here (ins= tead of > > + * during power-down) to ensure the device will have a = clean > > + * state after powering up, just like the normal scenar= ios will > > + * have. > > + * > > + * Note that in this case we assume the regulators shou= ld be > > + * (marked as) always-on, so the regulator core knows w= hat to > > + * do with them in the following regulator_enable() cal= ls > > + * despite regulator_disable() was not called previousl= y. > > + */ > > + gpiod_set_value_cansleep(ihid_goodix->reset_gpio, 1); > > + } > > ret =3D regulator_enable(ihid_goodix->vdd); > > if (ret) > > return ret; > > @@ -60,6 +75,14 @@ static void goodix_i2c_hid_power_down(struct i2chid_= ops *ops) > > struct i2c_hid_of_goodix *ihid_goodix =3D > > container_of(ops, struct i2c_hid_of_goodix, ops); > > > > + /* > > + * Don't assert reset GPIO if it's set. > > + * Also, it's okay to skip the following regulator_disable() ca= lls > > + * because the regulators should be always-on in this case. > > + */ > > + if (ihid_goodix->no_reset_during_suspend) > > + return; > > + > > gpiod_set_value_cansleep(ihid_goodix->reset_gpio, 1); > > regulator_disable(ihid_goodix->vddio); > > regulator_disable(ihid_goodix->vdd); > > I think the above is wrong. You should just skip the GPIO call when > "no_reset_during_suspend", not the regulator calls. As your code is > written, you'll enable the regulators over and over again in > "power_up" and never in "power_down". Agree, I'll resend v3. Thanks for the feedback! Regards, Fei > > -Doug