From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795961588; b=PgSh++Qq5rjNM/AwADF1aOykCJhKYZU9OhLydvU/v0YGxun/IwFMwZ37hQ2GxQGLJuDY eqM1COHtzdhh1O8CMkKTk9L8evYjFpvlW/0jg/RncBcQM5KOpY87SOxs00r7weOrDQ7Tm HOXgBkRjL93qUMkBcd58wGBR0MhDdISVaHwIR4K+SAid/idaLzQ+1K1VBM+tSYP7dVZG/ 88ChBMWz8XBwxSRsWHYPbIHafpRa52QCJOrNqbdoYG6nuw8PAM5wg5V4qBbHqkDsFcwbX 44yugd3i+8lmnYVXAL7kMFssL53/0DngFVoz0pyCuEpxNEF5Vw64rsnuiq4G8HgHP1w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795961588; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-Proofpoint-Spam-Info: X-Proofpoint-ORIG-GUID:X-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=2n0IFYjaUsOEkzsiFH+Fa/Fz0enlOADtZl1SSwmWJmM=; b=QTMFIjuQUIbcQ5sudbTYiuVcp0p7mVW7j5YZ9VYDuSm2ME3iJcleC1KIe7+wx6zQdkou MFw/NXenjDdTGapFRMFXd2lOoAJ/mNMheBvWyBp5LTX+uf0VNBLklhSS+z65KwOAm7dQT Om8Tw237r0IMcyeSX0fy2Zhno8clTmdFKx4L12yqwVz7Uv/PQDxthh41thupOFDIZW24w KdeJsTMgbYLfDbbTIQ/QaQptzEuU5JPjP0vOJOP5seHCD1kXItUytwTpx4ExD6xMKwWvb WFcC6DSDkuPI7hjoI2I/dcMRWslvWDBIhOWZx1MTSgW+LtS2YCf41PTgeHJiaZxdfKA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=Ky+j6rJM; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=M0NPiE8E; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FDC1606A329 for ; Sun, 29 Nov 2026 14:13:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8FDC1606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=Ky+j6rJM; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=M0NPiE8E Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ATAMAEh126131 for ; Sun, 29 Nov 2026 14:13:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 2n0IFYjaUsOEkzsiFH+Fa/Fz0enlOADtZl1SSwmWJmM=; b=Ky+j6rJMnv1StyHl 0axg6DDGu0mXsBo0ZW1b+h7C+OM6zf0r91SjSJGOm8+7a7lzZq2EX2ChhAYlJwg2 iXdkb5Oi6wGa7kAcUc36FqljZpDpCW2lDIAfHgAJN4ylj3nvo0aBRBJlCI6TW+Fr 86eDyo1uaiicwcIkFrLV8j5OCngHYGZyC9MGevSZottBRwJxUYR3oNl0UQbKN9cQ AnmenS7RX/zft4jNykzXBZdg38ZnvhHJkpsBLaRFMCxZvEvD4WUmbAIyxp4LqOir IvfeFJ9NXm2wF/1XOAAWh6gNplN/toVBdToQKarXTfr3r3gtNqA8+Hb55K1Q/Q5A G1gOKQ== Received: from mail-dl1-f70.google.com (mail-dl1-f70.google.com [74.125.82.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j7ny6b6kv-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sun, 29 Nov 2026 14:13:06 +0000 (GMT) Received: by mail-dl1-f70.google.com with SMTP id a92af1059eb24-16bc6f3fdb1so6234779c88.0 for ; Sun, 29 Nov 2026 06:13:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795961585; x=1796566385; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=2n0IFYjaUsOEkzsiFH+Fa/Fz0enlOADtZl1SSwmWJmM=; b=M0NPiE8El/g5E5naYrP01Y3UlKLo40LXP6F8S5DYgR+1rl4VaoHzKoXmtoPY/wNfPx bhDeDdRKFMxG9JVfo39hPJtBPLe3No0fLrN4ztNc7wP3Skdb4yN7h+MUArIO0PZDmZR+ ewcM+QSM7FWMs4BCa3ZaHrK291O9kTXQB3p3QgJMAhHgweXNlZ/v9TI0D4dAodMAWA98 y6Keq+ql5tK7cFBR4W9RQv0soLxztDIfoTBoGMp2X5Glq3/R0zQVDLY4ivqqs5ToD/cN AfxIDZI9yZhdKk4172L6knC11KApMZgCqrB4PV1KkUqpqr1bHdCZ8LnDh0mS1HwQrHVA YgoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795961585; x=1796566385; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=2n0IFYjaUsOEkzsiFH+Fa/Fz0enlOADtZl1SSwmWJmM=; b=KYWwarOJXJmtTAKPV8cETE9WROxN7z71YfUv56k1C58zm00szm2g29a/4Xl9BLqS9W qZXc0Tft4UwquetW+/l7qygold3Q2GthJhOGkxhb7EjqKxAZpTk7NR7vaFtBLTeUii7j KpjkXwslCzSfxJ4B18F1BZ88NJesPsPUxJGQuGY5nxMVpgCBVVpB+SfDWBVKKPnKRnFS jB0rLTegIjBDknmRIfJUomLU2SKUnyLX/reDrlXqvMKpH5oCepflFquN7Kwq70tk7+45 G4fuTxolZiBFIXAxGvUWRH3GrQzRPk18a/3QrpD2W7SsKeKM7wE0BQoH/Kqeq0HdYc+n zyHg== X-Forwarded-Encrypted: i=1; AL+hErHpU/5vvsEacb5e8W/P6n4+NMdm0qoRXIVKCtePuLSMd7HhuZ5Lk6+RnXtDsuamqqYEui6nnYsO6pbcaC0=@vger.kernel.org X-Gm-Message-State: APuU4Z803+TR6GXLLdku4gkzNA31ZjzsFiaYhta/jtTs9T3Knua+Zieb rBnFnMycKKoyrehe6Gto4ixZ+UNt+GjQppksorpvKR2/dGlWiWbKWgz27/cE8Lrmj30tTdH+y5h fJe2FtG8Lbd3/bXCz2MJn5+qIwGkMS5rVOoP7Mn0vrvSAfGtzdC1l0O2EWl4BrPsHLnM= X-Gm-Gg: AZFdTZc+C+AdUDqk4KR6/1RuSvvgFgo4gh0Qc+YHM/nKngERzyZ6/hU2ZJZEgmf8pwD fSoUO3KeL1+ZkmxNFt9Sxl88d+gi3K5H3uqeoLM16wk4Bl7S3+KCM6U9SGFEpLXGKwzh9GIrgbb lCC97z2vyv0/D1gNh7DRsnENbsrDxed/9Djw3VRxcbZMbbQgshP/qpRCzx5JG7egeJeQH0zZ33Z y2Ak0MW7VA/2CCr6eX+I6GwpI9nn5VS1V/IGCwpGKJZj8Po4WfPPUKLbu0WHm0qu9O3e7QBhYsZ 0LDYE2fG1hIbCg1i6m/F2vgwzrSsl3HnxNPBj0LM2ii4J3Orhm6EePAi4SXHmATdnhoXHgiqavj obl4+YyGZ6Cmwt42H507Ezm8wyzc5tSOdEAdmmtKKoXTsCTR6X25upvlg9g3gHnpryJe/6+GSxE VRyFAZwWiJ X-Received: by 2002:a05:701a:ccda:20b0:1b5:9075:232d with SMTP id a92af1059eb24-1b590752372mr10136189c88.29.1795961585475; Sun, 29 Nov 2026 06:13:05 -0800 (PST) X-Received: by 2002:a05:701a:ccda:20b0:1b5:9075:232d with SMTP id a92af1059eb24-1b590752372mr10136142c88.29.1795961584919; Sun, 29 Nov 2026 06:13:04 -0800 (PST) Received: from [192.168.1.102] ([157.48.135.242]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b56ef9fd16sm64625130c88.4.2026.11.29.06.12.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2026 06:13:04 -0800 (PST) Message-ID: Date: Sun, 29 Nov 2026 19:42:54 +0530 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 4/7] thermal: qcom: qcom-spmi-adc-tm5-gen3: Add support for QCOM PMIC5 Gen4 ADC To: Jonathan Cameron Cc: David Lechner , =?UTF-8?Q?Nuno_S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Amit Kucheria , Thara Gopinath , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, Kamal Wadhwa , Anjelique Melendez , Manaf Meethalavalappu Pallikunhi , Priyansh Jain References: <20261120-pmic5_gen4_adc-v2-0-94d0e1fd6847@oss.qualcomm.com> <20261120-pmic5_gen4_adc-v2-4-94d0e1fd6847@oss.qualcomm.com> <20261121210747.0ab59a9f@jic23-hlaptop> Content-Language: en-US From: Jishnu Prakash In-Reply-To: <20261121210747.0ab59a9f@jic23-hlaptop> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Info: AW1haW4tMjYxMTI5MDA1NiBTYWx0ZWRfX1R1rHTPyMbwr SnAl9IhGnYiHQZKmBVqVTFvRQ/e2bOhTnWtyrw3Rjpg0+4q4FeF3S1vC5jYxpUPU7Li119QVsdu G4bLomztcgINo2novsjywr/f5V4qwXI= X-Proofpoint-ORIG-GUID: ig4cH-J-1KDN1pLhQc2W-C3vW1LuyK57 X-Authority-Analysis: v=2.4 cv=TMfQ2Fla c=1 sm=1 tr=0 ts=6b0c32f2 cx=c_pps a=SvEPeNj+VMjHSW//kvnxuw==:117 a=nc1psVOndk8T/X+6wm4l9g==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=0zkqlJ-050QcqRmRxHIA:9 a=QEXdDO2ut3YA:10 a=Kq8ClHjjuc5pcCNDwlU0:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTI5MDA1NiBTYWx0ZWRfX1nexoEO8ZYtF L+BexHy2MMolWy+Pxg540oxYbN8IkosbB2R65UoYIzjz1JLJRqzZxgq5RR6b05J4L+R0BlyT3Jc d66O1HVpEoZMqsjxlEVejRpy8pI7/zH1vXr0IpdPq/sqCGAcMh3LruooXrtUKxyFJEnMHS9NX0Q gInnbDxBoyGbc5oum4ptnSMIrFSqxia9eYRpAnHUKklIIDXyz2AjMpt0zBHoSG1bTfAYGmj8E2C +5zAPaEdUiazeZJ5rYYMOaDUQyahqGxPLxaIjk0NRHRRvDbVoPUzKh37GevT0cQBK2/brgYdp5y 5ZfKcyuIIsuhr/9UuPB9uW2nCEabmsSHstCshO8Jeu7IknRan0IjHJN/HsMi9rYNOHK+kwXCzkt foT8+r99oI/CpTyDF2Kdei4hQg8LMCceAkr5ysxdxIZZjJfpKhdxo4yVExD3QZfukjucncJ7QCE 0enSinJbCrv39vvRxcw== X-Proofpoint-GUID: ig4cH-J-1KDN1pLhQc2W-C3vW1LuyK57 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-29_03,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 phishscore=0 impostorscore=0 spamscore=0 bulkscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611290056 Hi Jonathan, On 11/22/2026 2:37 AM, Jonathan Cameron wrote: > On Fri, 20 Nov 2026 14:49:44 +0530 > Jishnu Prakash wrote: > >> PMIC5 Gen4 ADC is similar to PMIC5 Gen3 ADC, with several changes made >> for improved performance, mostly at the hardware level. >> >> One significant software change is that ratiometric conversion resolution >> has been increased from 14 bits to 16 bits. Add a reverse scaling function >> for Gen4 ADC thermistor channels. >> >> In the latest PMIC arbiter version (v8), there can be up to 4 buses >> under the PMIC arbiter and 32 PMICs under each bus. In order to >> support communication between ADC on the master PMIC and ADCs on any >> of the other PMICs, a field of width 2 bits is added for bus index >> and the bits for SID are extended from 4 to 5 bits, in the SID >> register. Add support for this. >> >> Co-developed-by: Anjelique Melendez >> Signed-off-by: Anjelique Melendez >> Signed-off-by: Jishnu Prakash >> --- >> drivers/iio/adc/qcom-vadc-common.c | 11 +++++++++++ >> drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c | 19 ++++++++++++++----- >> include/linux/iio/adc/qcom-vadc-common.h | 2 ++ >> 3 files changed, 27 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c >> index 5c4052f6f24f..779c2a66a858 100644 >> --- a/drivers/iio/adc/qcom-vadc-common.c >> +++ b/drivers/iio/adc/qcom-vadc-common.c >> @@ -718,6 +718,17 @@ u16 qcom_adc_tm5_gen2_temp_res_scale(int temp) >> } >> EXPORT_SYMBOL(qcom_adc_tm5_gen2_temp_res_scale); >> >> +u16 qcom_adc_tm5_gen4_temp_res_scale(int temp) >> +{ >> + s64 resistance; >> + >> + resistance = qcom_vadc_map_temp_voltage(adcmap7_100k, >> + ARRAY_SIZE(adcmap7_100k), temp); >> + >> + return div64_s64(resistance * RATIO_MAX_ADC5_GEN4, resistance + R_PU_100K); > > If you were keeping this (See below) I'd have a helper that does the maths > called by both the gen2 and gen4 versions. I think it just has that multiplier > different. With the changes in struct adc5_data I mentioned in the patch 3 thread, we can eliminate this function, reusing the existing qcom_adc_tm5_gen2_temp_res_scale with an additional input argument. > >> +} >> +EXPORT_SYMBOL(qcom_adc_tm5_gen4_temp_res_scale); >> + >> int qcom_adc5_hw_scale(enum vadc_scale_fn_type scaletype, >> unsigned int prescale_ratio, >> const struct adc5_data *data, >> diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c >> index 910b241fa94d..aeaf13f4fc66 100644 >> --- a/drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c >> +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5-gen3.c >> @@ -207,15 +207,23 @@ static int adc_tm5_gen3_disable_channel(struct adc_tm5_gen3_channel_props *prop) >> ADC5_GEN3_CONV_REQ, &val, sizeof(val)); >> } >> >> +typedef u16 (*temp_res_scale)(int temp); >> + >> static int adc_tm5_gen3_configure(struct adc_tm5_gen3_channel_props *prop, >> int low_temp, int high_temp) >> { >> struct adc_tm5_gen3_chip *adc_tm5 = prop->chip; >> u8 buf[ADC_TM5_GEN3_CONFIG_REGS]; >> + temp_res_scale tm_scal_fn; >> u8 conv_req; >> u16 adc_code; >> int ret; >> >> + if (prop->common_props.generation == ADC5_GEN4) >> + tm_scal_fn = qcom_adc_tm5_gen4_temp_res_scale; >> + else >> + tm_scal_fn = qcom_adc_tm5_gen2_temp_res_scale; > > A little messy patch ordering wise, but I think those should > be function pointers in common_props.data and set in the adc > driver (where it currently sets generation). > > That will put all the information in one place rather > than a mix of data and stuff patched in the code in various > other places. > > For anyone not reading review of previous patch, I want that > generation value to go away. > > However, the two callbacks differ (I think) in only one value. > Just put that value in the data instead of having two callbacks > and add a parameter to the function to pass it in. With the change in struct adc5_data, we can differentiate Gen3 and Gen4 based on the new raw code field added, and that same value can also be passed as a parameter to qcom_adc_tm5_gen2_temp_res_scale() as you mentioned here. Thanks, Jishnu > >> + >> ret = adc5_gen3_poll_wait_hs(adc_tm5->dev_data, prop->sdam_index); >> if (ret < 0) >> return ret; >> @@ -225,8 +233,9 @@ static int adc_tm5_gen3_configure(struct adc_tm5_gen3_channel_props *prop, >> if (ret < 0) >> return ret; >>