From patchwork Wed Jun 7 10:47:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 104402 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp166115vqr; Wed, 7 Jun 2023 03:58:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ604OfbbwA+ct9byzbwBys/1jVw0ozTcu6sJefvY/w8xZ/wkjuENGDpjKiJtbkmvuXwoRr5 X-Received: by 2002:a17:903:1252:b0:1b0:5304:5b4e with SMTP id u18-20020a170903125200b001b053045b4emr6594303plh.43.1686135506951; Wed, 07 Jun 2023 03:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686135506; cv=none; d=google.com; s=arc-20160816; b=GHIxcpiPVK4zoYxmDHx7ejHzzL6emCoc82qG0AIIS+kZv+yOwTHiS4KtdpbxcJJZIb K1+2p6P/wo9f9ZEka1DgEREU52oS4UlTDogeZ4ziCGKOvwyNCRt4EZV16hiPQ4yyG3kc MdM+BIHFwHfgGhXx9Lf9l4WmtUrCGpKru5tC38A1r8lSri+3sIqDvXqDG71Lnshg9+cI ++Fpf6TI0Zjm2jaxEUcBrztgircqVxiWjwcO8+1it0aQ4EQ8SCihVj4VaaxyPKulOPZS DgGtz+ZC+G7V3B15aksYakd7YW0XCXO9KIbgPUQIb/ZoMTvFgMFBSD1kFaopAwY5Jsr2 u++g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Du2Hg8eWo8TN3RCAEt+biisl8e0xVlaEapus0jGGoCI=; b=A819ZGEVWfppG1ywxLK62DcstGjDh8BTfeftJuvmSFtj/XTEQGXKI2KhvTnv9UFJXY uK9sSM4SeyDKvUD6sT30ekZm5L/qNBAjjm1WkyUtUcwmfv3siTBBL3EpVKTaTEXt/G3E LggRYoNRRFIN0tlSbMC3dHVinhIhnS/nsifmstFIn54i3R7KsZHHuCW+b+WstG/LC1vT PfVNWMNJ9aOLMjD/+eDh7ITdIYR2965M0Zjl/FV4sI0TbR8iU0hjkQ9Dz7NWDOt75xjv oYPWHGeHs2P54s5hy27sHo1jh9qpOsaLDtYCbbfikh3BQ8YylUH+VE4md6KZDV71B2tL /wgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=Z5U7dsmX; 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=kernkonzept.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u16-20020a17090341d000b001b23d4573b4si2129111ple.4.2023.06.07.03.58.14; Wed, 07 Jun 2023 03:58:26 -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=@kernkonzept.com header.s=mx1 header.b=Z5U7dsmX; 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=kernkonzept.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239736AbjFGKsf (ORCPT + 99 others); Wed, 7 Jun 2023 06:48:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239309AbjFGKs2 (ORCPT ); Wed, 7 Jun 2023 06:48:28 -0400 Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7B8F1BE6; Wed, 7 Jun 2023 03:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description; bh=Du2Hg8eWo8TN3RCAEt+biisl8e0xVlaEapus0jGGoCI=; b=Z5U7dsmXqCONrNBw4MlGEy2Aqv 8zLJ35adAkobtcgjvV90nPNi+9DiAN947XETRd7nqrwDTiP7IG769rA+Sb7nHC/s57PU4CtqZ26aM JTfjZ2WaSmvZDEPlWRDqbcblL0KkTlF/3J9tCMTkmUuBasIRWN3ce9ccU4oIJOrNwGHNQHJ+YNI3M gBbwSIgAgKaYSq2pPgpVa1BlbR6x3iPMta97ZUL5hJN8rVvvqwuU+1eItqNUD4/GwoufpYknWaK/V Hbz4YTrcEE2K0M9MV91451Ia9Z8Jw9Qn783vymLlMRFkTKb8KdR21955hf+dyKaM3A3XvEsLMBH/H RJlLRl6w==; Received: from [10.22.3.24] (helo=serv1.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) id 1q6qi8-0069NL-IF; Wed, 07 Jun 2023 12:48:16 +0200 From: Stephan Gerhold Date: Wed, 07 Jun 2023 12:47:49 +0200 Subject: [PATCH v5 6/6] thermal: qcom: tsens-v0_1: Add MSM8909 data MIME-Version: 1.0 Message-Id: <20230508-msm8909-tsens-v5-6-5eb632235ba7@kernkonzept.com> References: <20230508-msm8909-tsens-v5-0-5eb632235ba7@kernkonzept.com> In-Reply-To: <20230508-msm8909-tsens-v5-0-5eb632235ba7@kernkonzept.com> To: Daniel Lezcano Cc: Amit Kucheria , Thara Gopinath , Andy Gross , Bjorn Andersson , Konrad Dybcio , "Rafael J. Wysocki" , Zhang Rui , Dmitry Baryshkov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Stephan Gerhold , Stephan Gerhold X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1768041225264458209?= X-GMAIL-MSGID: =?utf-8?q?1768041225264458209?= The MSM8909 SoC has 5 thermal sensors in a TSENS v0.1 block. Like MDM9607 it uses a non-standard default slope value of 3000 [1] and needs per-sensor "correction factors" to workaround issues with the factory calibration [2]. [1]: https://git.codelinaro.org/clo/la/kernel/msm-3.18/-/blob/LA.UM.7.7.c26-09100-8x09.0/arch/arm/boot/dts/qcom/msm8909.dtsi#L476 [2]: https://git.codelinaro.org/clo/la/kernel/msm-3.18/-/commit/6df022c6d0c2c1b4a5a6c2124dba4d57910c0911 Reviewed-by: Konrad Dybcio Reviewed-by: Dmitry Baryshkov Signed-off-by: Stephan Gerhold --- drivers/thermal/qcom/tsens-v0_1.c | 36 +++++++++++++++++++++++++++++++++++- drivers/thermal/qcom/tsens.c | 3 +++ drivers/thermal/qcom/tsens.h | 2 +- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c index 4a55a8ea0043..a941b4241b0a 100644 --- a/drivers/thermal/qcom/tsens-v0_1.c +++ b/drivers/thermal/qcom/tsens-v0_1.c @@ -219,6 +219,27 @@ static int __init init_8226(struct tsens_priv *priv) return init_common(priv); } +static int __init init_8909(struct tsens_priv *priv) +{ + int i; + + for (i = 0; i < priv->num_sensors; ++i) + priv->sensor[i].slope = 3000; + + priv->sensor[0].p1_calib_offset = 0; + priv->sensor[0].p2_calib_offset = 0; + priv->sensor[1].p1_calib_offset = -10; + priv->sensor[1].p2_calib_offset = -6; + priv->sensor[2].p1_calib_offset = 0; + priv->sensor[2].p2_calib_offset = 0; + priv->sensor[3].p1_calib_offset = -9; + priv->sensor[3].p2_calib_offset = -9; + priv->sensor[4].p1_calib_offset = -8; + priv->sensor[4].p2_calib_offset = -10; + + return init_common(priv); +} + static int __init init_8939(struct tsens_priv *priv) { priv->sensor[0].slope = 2911; priv->sensor[1].slope = 2789; @@ -255,7 +276,7 @@ static int __init init_9607(struct tsens_priv *priv) return init_common(priv); } -/* v0.1: 8226, 8916, 8939, 8974, 9607 */ +/* v0.1: 8226, 8909, 8916, 8939, 8974, 9607 */ static struct tsens_features tsens_v0_1_feat = { .ver_major = VER_0_1, @@ -323,6 +344,19 @@ struct tsens_plat_data data_8226 = { .fields = tsens_v0_1_regfields, }; +static const struct tsens_ops ops_8909 = { + .init = init_8909, + .calibrate = tsens_calibrate_common, + .get_temp = get_temp_common, +}; + +struct tsens_plat_data data_8909 = { + .num_sensors = 5, + .ops = &ops_8909, + .feat = &tsens_v0_1_feat, + .fields = tsens_v0_1_regfields, +}; + static const struct tsens_ops ops_8916 = { .init = init_common, .calibrate = calibrate_8916, diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 9dd5e4b70911..1ab165370fb0 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -1112,6 +1112,9 @@ static const struct of_device_id tsens_table[] = { }, { .compatible = "qcom,msm8226-tsens", .data = &data_8226, + }, { + .compatible = "qcom,msm8909-tsens", + .data = &data_8909, }, { .compatible = "qcom,msm8916-tsens", .data = &data_8916, diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 1cd8f4fe0971..2805de1c6827 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -639,7 +639,7 @@ int get_temp_common(const struct tsens_sensor *s, int *temp); extern struct tsens_plat_data data_8960; /* TSENS v0.1 targets */ -extern struct tsens_plat_data data_8226, data_8916, data_8939, data_8974, data_9607; +extern struct tsens_plat_data data_8226, data_8909, data_8916, data_8939, data_8974, data_9607; /* TSENS v1 targets */ extern struct tsens_plat_data data_tsens_v1, data_8976, data_8956;