Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4612196rdb; Fri, 15 Sep 2023 07:25:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGiNXxMHlDjpgZV6KI39+Znnt2nWDkWv8hKa+GgQwIhaDAtpjUivvOxMatjuLnt4yPcDF2d X-Received: by 2002:a17:902:ce8b:b0:1bf:3378:6808 with SMTP id f11-20020a170902ce8b00b001bf33786808mr2066515plg.56.1694787939897; Fri, 15 Sep 2023 07:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694787939; cv=none; d=google.com; s=arc-20160816; b=FOCZQTM2DQTLOgYdzTDGHUzA8IOdl0YSx02A/tNLuP5l31a7HnEvIGuHw4jq+yq++1 B7WTynF9rwgcHc6++ztKFryb8N8hX8PQLIPwwiOxTQurh2tC687shuFkhthUHdH8cRS5 VK2+5RSDhO+Hna7Sp8YthcXIAkIg7ncvNZNMynbtAIAK7zWeGZXVU+jQpVLj6YeiSQSZ IRR8MY/IibZP+jX+6OWX49+93xCj5dw3NyDrwqwjPU+SODKd7YIhQM0kqG2UfXdnnE0N CBM9MsdV+5i8HVvlD9zDrgZF/tVKAVo49Qt2HVwhcql5juO0FZYJv/rdxInrJDWAM5xb pPXw== 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:to:from :dkim-signature; bh=z7EdD7gnN29RfjnjGry9rnKgrLgOu5D5ie3Dn+GEn3s=; fh=dOaw2PqmxVZTDVHEgD0EK3XNKxFmRSJS3QIL+0LrAqw=; b=iT1jAiFzVMk4+8zYwaVm/2iX/N+thDniWzSjTYAMcrkoZnlCURQ5SuSXEal6v7rueO Pku20oKsExcnp5nytL0yS4AXLVnYQewZA+0a3b8oO3nCPIQRlxSg8qPru1+c0ouAmrew IRZ8YLVpOE98kBG7j5JCDYfGi7cykZdxix8UHW2fEC9rUIGi73LR47IMZvk7ga5xfuhz aR18JirjlONy2ZToKxKWK5dVz3M7TcCa3NzHZBxOztX/Ix5TNTJN8EgIRmyUNXAnx6HQ UuKFQPUjSXuns14hLyXyLzYpHI7ItIMEVwayyzgbBoWSMRyzLb4oFTO7b9gtKQriQrAb e+jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=N8jwnP6C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id kv3-20020a17090328c300b001c3886b091asi3296672plb.127.2023.09.15.07.25.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 07:25:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=N8jwnP6C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9C7248382187; Fri, 15 Sep 2023 05:16:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234672AbjIOMQ1 (ORCPT + 99 others); Fri, 15 Sep 2023 08:16:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234686AbjIOMQ0 (ORCPT ); Fri, 15 Sep 2023 08:16:26 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EBA72D62; Fri, 15 Sep 2023 05:16:02 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38FAwQoG020152; Fri, 15 Sep 2023 12:15:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=z7EdD7gnN29RfjnjGry9rnKgrLgOu5D5ie3Dn+GEn3s=; b=N8jwnP6CYz78lPCbI8RPELo4XIrshCTB+Hl2b8QB6k3mDrz6pMTQqVAc0XFTSr6drqZR w4n1bzZlhbzfyJ++RN4nk21nC0wzngJbpAM4HBlI7WUw8M7YjZu/6nsVYLY1nGEcxNFn y2SOnIK3gTWRJtx8NpzvRJxr/J6vMbvz3KbVwuIVs1r3vkTIyqV93Jl4mKPtH3ZxS/qc K1wMSpDntTBy7LMabBgOxN03ZzaPQb0YfR0s1vQ0gyY/NYXIvN0RHbcPQF7kFq7H7VtS KLfXcm6xV5LWBMDuthBI5XbXZDhr7PhnzJwonAyhVjy5EL7ruwdrlr5E54iE32m6qP7m nQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t4g07111u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Sep 2023 12:15:52 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38FCFpZI010358 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Sep 2023 12:15:51 GMT Received: from win-platform-upstream01.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Fri, 15 Sep 2023 05:15:46 -0700 From: Sricharan Ramabadhran To: , , , , , , , , , , , , , , , , Subject: [PATCH V2 3/4] thermal/drivers/tsens: Add support for IPQ5018 tsens Date: Fri, 15 Sep 2023 17:45:03 +0530 Message-ID: <20230915121504.806672-4-quic_srichara@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915121504.806672-1-quic_srichara@quicinc.com> References: <20230915121504.806672-1-quic_srichara@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: z7-F87IANLbT9oA9AICOUmPotA8PnUMO X-Proofpoint-ORIG-GUID: z7-F87IANLbT9oA9AICOUmPotA8PnUMO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-15_08,2023-09-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1015 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309150109 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 15 Sep 2023 05:16:35 -0700 (PDT) IPQ5018 has tsens IP V1.0, 4 sensors and 1 interrupt. The soc does not have a RPM, hence tsens has to be reset and enabled in the driver init. Adding the driver support for same. Signed-off-by: Sricharan Ramabadhran --- [v2] Used tsens_calibrate_common instead of legacy and addressed comments from Dmitry. drivers/thermal/qcom/tsens-v1.c | 58 +++++++++++++++++++++++++++++++++ drivers/thermal/qcom/tsens.c | 3 ++ drivers/thermal/qcom/tsens.h | 2 +- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c index dc1c4ae2d8b0..ed5c017905ab 100644 --- a/drivers/thermal/qcom/tsens-v1.c +++ b/drivers/thermal/qcom/tsens-v1.c @@ -79,6 +79,18 @@ static struct tsens_features tsens_v1_feat = { .trip_max_temp = 120000, }; +static struct tsens_features tsens_v1_ipq5018_feat = { + .ver_major = VER_1_X, + .crit_int = 0, + .combo_int = 0, + .adc = 1, + .srot_split = 1, + .max_sensors = 11, + .trip_min_temp = -40000, + .trip_max_temp = 120000, + .ignore_enable = 1, +}; + static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = { /* ----- SROT ------ */ /* VERSION */ @@ -150,6 +162,39 @@ static int __init init_8956(struct tsens_priv *priv) { return init_common(priv); } +static int init_ipq5018(struct tsens_priv *priv) +{ + int ret; + u32 mask; + + init_common(priv); + if (!priv->tm_map) + return -ENODEV; + + ret = regmap_field_write(priv->rf[TSENS_SW_RST], 1); + if (ret) { + dev_err(priv->dev, "Reset failed\n"); + return ret; + } + + mask = GENMASK(priv->num_sensors, 0); + ret = regmap_field_update_bits(priv->rf[SENSOR_EN], mask, mask); + if (ret) { + dev_err(priv->dev, "Sensor Enable failed\n"); + return ret; + } + + ret = regmap_field_write(priv->rf[TSENS_EN], 1); + if (ret) { + dev_err(priv->dev, "Enable failed\n"); + return ret; + } + + ret = regmap_field_write(priv->rf[TSENS_SW_RST], 0); + + return ret; +} + static const struct tsens_ops ops_generic_v1 = { .init = init_common, .calibrate = calibrate_v1, @@ -187,3 +232,16 @@ struct tsens_plat_data data_8976 = { .feat = &tsens_v1_feat, .fields = tsens_v1_regfields, }; + +const struct tsens_ops ops_ipq5018 = { + .init = init_ipq5018, + .calibrate = tsens_calibrate_common, + .get_temp = get_temp_tsens_valid, +}; + +struct tsens_plat_data data_ipq5018 = { + .num_sensors = 5, + .ops = &ops_ipq5018, + .feat = &tsens_v1_ipq5018_feat, + .fields = tsens_v1_regfields, +}; diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 0a43ccf02ec4..c792b9dc6676 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -1101,6 +1101,9 @@ static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume); static const struct of_device_id tsens_table[] = { { + .compatible = "qcom,ipq5018-tsens", + .data = &data_ipq5018, + }, { .compatible = "qcom,ipq8064-tsens", .data = &data_8960, }, { diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index e254cd2df904..b6594b546d11 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -645,7 +645,7 @@ extern struct tsens_plat_data data_8960; 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; +extern struct tsens_plat_data data_tsens_v1, data_8976, data_8956, data_ipq5018; /* TSENS v2 targets */ extern struct tsens_plat_data data_8996, data_ipq8074, data_tsens_v2; -- 2.34.1