From patchwork Mon May 8 13:13:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 91158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2166461vqo; Mon, 8 May 2023 06:42:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7M8y4EgMIqZRKmkgUvKWx+BeZ+7qe6rLD9PM5aUM/xoRZ9HQ7vWIo1W0up7B2ohtejL6Mu X-Received: by 2002:a05:6a20:a11a:b0:f0:d50c:4ac5 with SMTP id q26-20020a056a20a11a00b000f0d50c4ac5mr13483315pzk.51.1683553377983; Mon, 08 May 2023 06:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683553377; cv=none; d=google.com; s=arc-20160816; b=ngd0hkP2LcrXFN8RrB3SofasJVXbY+ExBWv/D/IqWgitoFU+H2ZBGSDPeofrjQCRGF deISulqkNcU8RGe8Ul/EClZP0egpReynmZWURQZYQedCAw/iam+WL04ebAcn3LgtA+I7 kqAcezUO35hhHD4gpxcCGA6J7K8XdvkYSOpXgJu6L5fc6Q/1HJnMOtNCzLli7puJ13br 19aVlbI8DBwQLcWxO0T1tU3ILeHHVzjl6xIYdqQzyTrE29jbERukTKWNN/4QX6n3xCQg fhwzFTatQ4VtbA9ZGxtdZacB0gFbB7/+FDIFMO2jh2flAQXoYbCj2Mp+PtyKRs5L8n4H 94uw== 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=NOkAIQUPJO28ZJg22Jb1eVbFAiUIZlNRpNU5m2FRP5E=; b=BjfOAqa/6SvNpW9+fSY8b9CywDmWbBPc3K7XXCjml1NHC2goQ/JEGN9rvjfYDB/ldS uXqzJ4SPy1kEtaBfZJgAF0C0dxBf2my7LkY5d+bF9RSgWC1AJMh89CyyVOIhDjbFQ0FY kNirmJFf/hfeFbXzy03Urws2QPoErRljxGZRLrffoDK3cIQxqhJTkFVGfjQ4QeyTXZPC laquuysB2eJERfrGUomw5xKhU0TPNUj6TXQQO/dDrmijZ/Cf1j/Svzn5VkP1ngRQIgHM s+FXEBf4MQvihwjgrfih66c1BrlM6NEENM1HnzdpjY4uvD0gXgnOMDJp2h0o5AJ5UMAT tysw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=EE5V4tWp; 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 u11-20020a6540cb000000b0051a6292309fsi8297117pgp.894.2023.05.08.06.42.44; Mon, 08 May 2023 06:42:57 -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=EE5V4tWp; 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 S234358AbjEHNhz (ORCPT + 99 others); Mon, 8 May 2023 09:37:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234379AbjEHNht (ORCPT ); Mon, 8 May 2023 09:37:49 -0400 Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29E2A33865; Mon, 8 May 2023 06:37:40 -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:Sender: Reply-To:Content-ID:Content-Description; bh=NOkAIQUPJO28ZJg22Jb1eVbFAiUIZlNRpNU5m2FRP5E=; b=EE5V4tWpDwtjBnTfbVkN+3p7ci sg2A6hiutkktUQSXBF8ueZMosQDNH4Qfw1SyG359v5u3w32dPJh2y6jepyG/+uWPfQoWmT7RHPHAp SXE3SWmC6c2CYP/4hQSl0NSSu2XMjxtFZMAmXQTOFcP3wocr/otRM1XOQm83zSCN/pyOFnIWvQS/y TlWmY1ZZidMDAxZbqFAk8gIf0AN3AUD8OUPYKuDOp4QuPDwHHqORG3/wunnCa5LJ/hGaFEuTG7cE4 YZ+DAvCVpA+rhYLAJUJKBrizMjqnVUM2Z93nih58AM+ckZLORRYF3uSLi999il+h0yxJijI6x2ztr G+CH5APA==; 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 1pw0hW-009LZn-Bf; Mon, 08 May 2023 15:14:50 +0200 From: Stephan Gerhold Date: Mon, 08 May 2023 15:13:43 +0200 Subject: [PATCH v4 6/6] thermal: qcom: tsens-v0_1: Add MSM8909 data MIME-Version: 1.0 Message-Id: <20230508-msm8909-tsens-v4-6-d9119622cb19@kernkonzept.com> References: <20230508-msm8909-tsens-v4-0-d9119622cb19@kernkonzept.com> In-Reply-To: <20230508-msm8909-tsens-v4-0-d9119622cb19@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 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 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?1765333456860017797?= X-GMAIL-MSGID: =?utf-8?q?1765333666967415011?= 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 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 e69889dd524a..f97d313f0536 100644 --- a/drivers/thermal/qcom/tsens-v0_1.c +++ b/drivers/thermal/qcom/tsens-v0_1.c @@ -207,6 +207,27 @@ static int calibrate_8974(struct tsens_priv *priv) return 0; } +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; @@ -243,7 +264,7 @@ static int __init init_9607(struct tsens_priv *priv) return init_common(priv); } -/* v0.1: 8916, 8939, 8974, 9607 */ +/* v0.1: 8909, 8916, 8939, 8974, 9607 */ static struct tsens_features tsens_v0_1_feat = { .ver_major = VER_0_1, @@ -292,6 +313,19 @@ static const struct reg_field tsens_v0_1_regfields[MAX_REGFIELDS] = { [TRDY] = REG_FIELD(TM_TRDY_OFF, 0, 0), }; +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 065d0f9728a5..1d7c149038e0 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -1109,6 +1109,9 @@ static const struct of_device_id tsens_table[] = { }, { .compatible = "qcom,mdm9607-tsens", .data = &data_9607, + }, { + .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 880be6be5c3f..c88287dede96 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_8916, data_8939, data_8974, data_9607; +extern struct tsens_plat_data 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;