Received: by 2002:ab2:6486:0:b0:1ef:eae8:a797 with SMTP id de6csp497480lqb; Sat, 16 Mar 2024 13:08:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXV80QTzMsDG98JuSptBSbis9nYYNRSiE2HrpBucvkhp72CfQ+ZgvbxJdRvOTCygsj7Jm5AjjwSfM4ZnB71jU5Nyu1hRn2dgTGR1t2Qbw== X-Google-Smtp-Source: AGHT+IHTBkotqHBdZr3B5nPYyrFU16Lk9aLjymKkGkdzgY9d2CsfGTfI5YufHQuIlzIUihA9886y X-Received: by 2002:a17:90a:fa18:b0:29c:735:a758 with SMTP id cm24-20020a17090afa1800b0029c0735a758mr12642327pjb.19.1710619707706; Sat, 16 Mar 2024 13:08:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710619707; cv=pass; d=google.com; s=arc-20160816; b=ePFEGYY3sX1/Vo0bTIHMtCPmG3OLi9ZHPVuDUltnQGWj+5dgLAr9mTVp4n8EZblKdj w0XHRRfxGhQPjmtG8dw3yAgT0x26q/rj4FUIMxZIr9prkJoAe8oge4XLzgFtXlsEoiCE dOayr8D9WA8aiz1RYUBHrkkAIu4kP7NTgeIu/HFlg6c6oWVrSu3q08U2Hjp3zLfBXuWT 1pkq+5oOkmPtUmBP/Rjlmo8/njbLjBk3WtWSuThs0RlcZtPazm5qzAGiguqahRxGohFK LGmGhy7oWrb5BqIc81yxk1p8YkRHqJ7FAUsLhYtl9Hzj1D7wEfJMF+nqX8ssYP4AJeCx qiHA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=2JpaoFpqOKhc09lb8y+h+CfUeeYog+DCxU/BNFNbUMw=; fh=zjzf7TiUM8sabisxn8huaQSX6+R5hci4B9NqQ6vaW9g=; b=WmNm3WXTXGYgzJkYU7VTTX6MmM2l8dwM2aFK5e7/Iehofv0FWmbQmkpsRV5dptyIkV 1jfJPSZCm+Mc8acHVvekeZal3W9BK0mh3a0TQx0ZFJ7dZfnXQzluqF/jWlRtpz8WwNMd /jfC7k3sEbh/2Z/4sk/By/j5iFfJ44iHyiJhiV50uwDwlBWs7Cs5zifXs4+HbYKFBX0e GzoznlfhEivEvL8CQP7inKd0FpZTvaCt6jWzw70nVBoul8JAoeD8yanfFsLTP+eWQ7PK UCCACLJG0dlozzoAFrq7BVT9RYSM60mUmncHEgMGMheqsNztHoPWNyLg0jD6ccETkay1 1kWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="sh/uKQxB"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-105284-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105284-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id m14-20020a17090a2c0e00b0029bbd1c1114si5143268pjd.60.2024.03.16.13.08.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Mar 2024 13:08:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-105284-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="sh/uKQxB"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-105284-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105284-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1105CB21518 for ; Sat, 16 Mar 2024 20:08:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 330C01C2BE; Sat, 16 Mar 2024 20:08:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sh/uKQxB" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A0B71C286 for ; Sat, 16 Mar 2024 20:08:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710619692; cv=none; b=t6baT3czQtkXePK1tK7QbxA/apXPnacKoE+PP4+TNHbs8kxDFU5k7nEkiENC0RX5EuBE10AzzapdbXcG0F5GmCOZY5nF1ghpDfzRGgQI/PtRsWJtSzFTB3sbVifWUuGLWkckLqEfDkTgjBZYLYOlv6Fi/v0tjJjsWX262NZc+DM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710619692; c=relaxed/simple; bh=U1gMh+s+a7WJQ50TlopQKqfh4iRR1YUGrowPcQJVT98=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=MHZubvbNMOoNA1avtSE4EPipvqeV3/OE4hrJa7q7H5DFYnenEB1oI3byFx9EwY8gf18L/d8TK19wisP6ARxBXdAq+5RQ6XcXobreBJnlnDAPP3q4/Pp4s70kcWGW6cU4nlEBxI2QrPoa0OTm4g9/dTSKzfFfz/8k/12V0ZZKLF0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sh/uKQxB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 025B3C433B1 for ; Sat, 16 Mar 2024 20:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710619692; bh=U1gMh+s+a7WJQ50TlopQKqfh4iRR1YUGrowPcQJVT98=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=sh/uKQxBuPBBW6j7uzDAo4Yc7ANSRoSglrD9g87E9arQnQZtljDZaEZPAYkPF2vki OKrlZQm84TnvpbjO70TufmXGB5BrB5NH2ymK6TlJHxwIe3IADobHQac0XXEtAptBnP UCAaVYz9z//I5sj2ck2bCp3D736vHXU8iTTh3IlwfOVPYNMOq30EShcj+32IXmhsjW KOExFltZ4SpjHLy4GLB0ptqGEq1yrMVus9+qfdq7jYJIF2VotgDqZp8AeriL2lSjp8 YQU5ukPZm+pt2/4yZOpmZDw9iifzMjpFyX2ZLev/H76dBesSyZRfBOEpqr2Wu3uyqw qkjtxJqESY80A== Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a466a27d30aso412255466b.1 for ; Sat, 16 Mar 2024 13:08:11 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWQGg2L2lsmvnrWN6YJnP0OhZSyrvt1KLGdxYVU/b1RWsDw0fgsjaKUiDYaQIx18sbetS8XzIW/FiORkbuSdpDg7YiShVjO2dw6bk+R X-Gm-Message-State: AOJu0YyVsBSqCMgngsov6qBMNVXhRr9oTap4Q3F0DVVpWYk4vWTA4h0J 1ygwI5SrIpLN/JWxvpjd2ILY0PJik+dNzEgAamdABIDfqk+/eVvi8GTFxFp3jxRnZC1Vw/tUW6y 8bAtLXFABbqSYhxWft2rKovELKBL0XJ4Hgv6cWg== X-Received: by 2002:a17:907:60ca:b0:a44:5477:bb46 with SMTP id hv10-20020a17090760ca00b00a445477bb46mr7125461ejc.61.1710619690358; Sat, 16 Mar 2024 13:08:10 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240227160928.2671-1-quic_priyjain@quicinc.com> In-Reply-To: <20240227160928.2671-1-quic_priyjain@quicinc.com> From: Amit Kucheria Date: Sun, 17 Mar 2024 01:37:58 +0530 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3] thermal/drivers/tsens: Add suspend to RAM support for tsens To: Priyansh Jain Cc: Thara Gopinath , Bjorn Andersson , Konrad Dybcio , "Rafael J . Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_manafm@quicinc.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 27, 2024 at 9:40=E2=80=AFPM Priyansh Jain wrote: > > As part of suspend to RAM, tsens hardware will be turned off. > While resume callback, re-initialize tsens hardware. > > Signed-off-by: Priyansh Jain > --- > V2 -> V3: Remove suspend callback & interrupt enablement part from > resume callback. > V1 -> V2: Update commit text to explain the necessity of this patch > > drivers/thermal/qcom/tsens-v2.c | 1 + > drivers/thermal/qcom/tsens.c | 40 +++++++++++++++++++++++++++++++++ > drivers/thermal/qcom/tsens.h | 6 +++++ > 3 files changed, 47 insertions(+) > > diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens= -v2.c > index 29a61d2d6ca3..0cb7301eca6e 100644 > --- a/drivers/thermal/qcom/tsens-v2.c > +++ b/drivers/thermal/qcom/tsens-v2.c > @@ -107,6 +107,7 @@ static const struct reg_field tsens_v2_regfields[MAX_= REGFIELDS] =3D { > static const struct tsens_ops ops_generic_v2 =3D { > .init =3D init_common, > .get_temp =3D get_temp_tsens_valid, > + .resume =3D tsens_resume_common, > }; Please add resume callbacks for the other tsens hardware too and make sure that your reinit function handles them too. > > struct tsens_plat_data data_tsens_v2 =3D { > diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c > index 6d7c16ccb44d..396c1cd71351 100644 > --- a/drivers/thermal/qcom/tsens.c > +++ b/drivers/thermal/qcom/tsens.c > @@ -17,6 +17,7 @@ > #include > #include > #include > +#include > #include > #include "../thermal_hwmon.h" > #include "tsens.h" > @@ -1193,6 +1194,45 @@ static int tsens_register_irq(struct tsens_priv *p= riv, char *irqname, > return ret; > } > > +#ifdef CONFIG_SUSPEND > +static int tsens_reinit(struct tsens_priv *priv) > +{ > + unsigned long flags; > + > + spin_lock_irqsave(&priv->ul_lock, flags); > + > + /* in VER_0 TSENS need to be explicitly enabled */ > + if (tsens_version(priv) =3D=3D VER_0) > + regmap_field_write(priv->rf[TSENS_EN], 1); > + > + /* > + * Re-enable the watchdog, unmask the bark. > + * Disable cycle completion monitoring > + */ > + if (priv->feat->has_watchdog) { > + regmap_field_write(priv->rf[WDOG_BARK_MASK], 0); > + regmap_field_write(priv->rf[CC_MON_MASK], 1); > + } > + > + /* Re-enable interrupts */ > + if (tsens_version(priv) >=3D VER_0_1) > + tsens_enable_irq(priv); > + > + spin_unlock_irqrestore(&priv->ul_lock, flags); > + > + return 0; > +} > + > +int tsens_resume_common(struct tsens_priv *priv) > +{ > + if (pm_suspend_target_state =3D=3D PM_SUSPEND_MEM) > + tsens_reinit(priv); > + > + return 0; > +} > + > +#endif /* !CONFIG_SUSPEND */ > + > static int tsens_register(struct tsens_priv *priv) > { > int i, ret; > diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h > index cb637fa289ca..7a147d9d8544 100644 > --- a/drivers/thermal/qcom/tsens.h > +++ b/drivers/thermal/qcom/tsens.h > @@ -635,6 +635,12 @@ int init_common(struct tsens_priv *priv); > int get_temp_tsens_valid(const struct tsens_sensor *s, int *temp); > int get_temp_common(const struct tsens_sensor *s, int *temp); > > +#ifdef CONFIG_SUSPEND > +int tsens_resume_common(struct tsens_priv *priv); > +#else > +#define tsens_resume_common NULL > +#endif > + > /* TSENS target */ > extern struct tsens_plat_data data_8960; > > -- > 2.17.1 >