From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795961547; b=W6N0Xu1XE57yLPtkFr+MlFE6e+WLJnjL6bK1XtWdOBPoVk22Omcydcfd50A11Ji6PC1D 8zhwysdRo3IJ7eSvJE6GR8/InOveAGQdW6eLQSUp435L2DlTmExfE/AXvoBKnhCyYfNOg Sz1KvYOdeo+Nn68A4WZTicfKsAe6txWkUACTDAyV7As4LQod/J8l+u+KpJ6SDsISUCZ4k jMpBJrdirtDAeN1vuTpKGUzRF0SeQgK/Y7VY8buHcQ5KxU/Zw9yiLadC9udMABD/u0bgq EqxFkKdE9H5xS0XtpOquVXmeK2PKaQyjqrp/ZrjGxxV/NjfZ0zGCXhRpK4MbU9LypNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795961547; 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-ORIG-GUID:X-Proofpoint-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Spam-Info: X-Authority-Analysis:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=cGNfEnSk3IgI9vq0w2ghDc5em/4RfwTTtAe14XHVCiA=; b=eYhVho1ADJzuSML8Efn6aw6lwXfHpMg39ulqd/PAaVMlMa7svQ7xnw66Dss5qqZaehYU XUOOBBgIUo0vC/WCDRufM1LNbZqHjLEzwsOjIuMBiY7ApgtycbNyMvzyWuCuzvuI6DJY9 4Bf7LWjhaiV0AS9uxWStG/rJwrDMhzeKsYiypsb0Gltp+IVlco4C47e6niHGkZgHIi0Xl 5fIu7LkxQYlGqSSC0o67ZYDmKmpfkf/hjzTbHLMK6c8HCVlovQBzz+SUzN1ad6lDwgP42 Ked+q3cnKo7Hr8/vt0tKRcbmpLrLorbwGDbDMPwTIKCDI/twaa0SvxWSaWEFbszOgkA== 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="QBGsdnp/"; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=CJWlPrr8; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 23C53606A329 for ; Sun, 29 Nov 2026 14:12:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 23C53606A329 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=QBGsdnp/; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=CJWlPrr8 Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ATALNMo1885087 for ; Sun, 29 Nov 2026 14:12:26 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= cGNfEnSk3IgI9vq0w2ghDc5em/4RfwTTtAe14XHVCiA=; b=QBGsdnp/xhZBM0Nt 6cEikSmlTx3zZgeuOSAGnN/E8AaOrrbD4AZslohFhxSp9ZO3mUtBxvj9Dfb4VvYN bcXSWqwT0fkWv5MtfFRwhKfbf7dhNJUc4qBcK5uUZ0srhSvI1aqMIAwDa4zcE3Yr bEiCGxE6u+XGthpyRsnLwwLnw2Dz5hEA2wMk6qN1yFaPhmHGwj33zqUr5VCkoJ/R vclgll0L81fJLZ2y4zKPJY5Zpa6i/h5thG6s5usJmU/fQ2G3jv9Wt7g40wI30S4N JNGZyhux/M2te149zxAsSJxWAWaWOSudtR2MhiO3rgSkbRHoIqzBvF9vX8GhCYEW HXVViw== Received: from mail-dy1-f199.google.com (mail-dy1-f199.google.com [74.125.82.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j7r4jawgb-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sun, 29 Nov 2026 14:12:26 +0000 (GMT) Received: by mail-dy1-f199.google.com with SMTP id 5a478bee46e88-386177b0516so1723169eec.1 for ; Sun, 29 Nov 2026 06:12:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795961545; x=1796566345; 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=cGNfEnSk3IgI9vq0w2ghDc5em/4RfwTTtAe14XHVCiA=; b=CJWlPrr8TcGJMNvvWf77xiRXctht+oHkg9oycRN1RM+PN6c9PU4okxCk50yVdP5Ql+ hVgfwZUd7SU3JsranpKdxRBCOjSjlyesGmfh7LIm6FLBBoV19IWYdaz21Gn3UlqEQGyw QPBfshbcldFe64vGRDTuN3UOAhU17lSLI5ffHdrW/M08AcMX0B0KHBkG50JnEFqAu/Vr 5LnUjHSgUwTPmEnBKzEkKj3UBf/UzE8qRgXBj0scl0JTjB9S6s6ohmAwNsqQ0suusMQW 2cj+nGQ4besth3NYjDiWv1X2pByLBOaiCVElCRkCkeK0aKejK37putsHO2IyzSITeFTj Jujg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795961545; x=1796566345; 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=cGNfEnSk3IgI9vq0w2ghDc5em/4RfwTTtAe14XHVCiA=; b=BCjXoekWoIcsooXVcFJn2thf9NvGZ3fniNF5bjkMyPANId5OfNEwbreP/XqxeRVzzF x3HL/TYfmytJGQ7X1rQcMzbn4GxyPpaIT6t87yyHSa/tO5Z6oSBNTs+4rSoak5gKC08Q QIpfZO3ldpKW1QXy6bMR1zAli3ZnwvleIE+ruuTGwRWKzIPOU01q5kaLgKS+xKkeRfUk A8esaZ4MdFCWDVcZnq22DDsP9HxgnJuxCuFJnCJ6gvXqReass2zfxW27tLulJ4jYy15s bFkpNP2HFTqgcDF1ebtwH7NkwsL9iwGw6DdUwgeGmTSdte7MuBZuci2sPQDu2/MBtp2m hoEA== X-Forwarded-Encrypted: i=1; AL+hErG3uVVwzDsYtswAlbLzFgAuocn+mRGJMh6CyWUTkDzMldKkXuisGsOKTWzSJIWJEgFjbjnrhvAZmuvj@vger.kernel.org X-Gm-Message-State: APuU4Z+JG+NAWoPuAswFZcMxnqJ0Ud6KhWZIWNLACcPrMBCER9/FE+oB Oau1OyAdwZRKHR3LT1NjKtPqWMoBUxqxrSKtTesZoEz20BagU5kudeFkjX9ohFX2tqKpVrgDZXC yTBRc0jdxF+lxywGPle5izjkJ9l81pzrnwS9qtWCws74xlFdjHpcMA0IMoum5VD09 X-Gm-Gg: AZFdTZeYkN8JY0O3QIruXI1rS6gnXh8Ukpk4Q2TZPN2USWsX3UTxvnkWiRLyNXpbxNn U5nB0U5SaEAGuBDYIC00+SJHHIyK2SD3t3/EisFSVIvemPs/mBj2JpNedu/NA6bEVPl3v35+Y1b eeuWkR/Ja+Is+7+9jfTPC5frN5mR98CavYtssP51eAeg9WIZnn7ZTdNlpLFFKeC22DHfun4g5pD Hu+pGQN4vZLIKa981otR/zIXC+6V8bv1ycaJeJNPH1pdE5DNfG583yhttkA6yeie6j5Qz5j8H1w FWQkbav4CTw/xglnNA67jTVcwFt5GBs3MhC6LY6jmXT57jLdhiYzjkQH0JhUK6TzhznxW1y71TT rFEYfTC06+pin10gWHAonrRKjozuxT/FGr1mKJ6sxDH9zACwt/Y7nFIk3PrfyfuQB05t0Lij/3P BC8WeJLpnn X-Received: by 2002:a05:7301:4d0c:b0:376:a6d7:8f6f with SMTP id 5a478bee46e88-3856ec3ec8bmr31912280eec.17.1795961545312; Sun, 29 Nov 2026 06:12:25 -0800 (PST) X-Received: by 2002:a05:7301:4d0c:b0:376:a6d7:8f6f with SMTP id 5a478bee46e88-3856ec3ec8bmr31912240eec.17.1795961544722; Sun, 29 Nov 2026 06:12:24 -0800 (PST) Received: from [192.168.1.102] ([157.48.135.242]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386f6651e2asm17234480eec.27.2026.11.29.06.12.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2026 06:12:24 -0800 (PST) Message-ID: Date: Sun, 29 Nov 2026 19:42:14 +0530 X-Mailing-List: devicetree@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 3/7] iio: adc: qcom-spmi-adc5-gen3: Add support for QCOM PMIC5 Gen4 ADC To: Andy Shevchenko Cc: Jonathan Cameron , 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-3-94d0e1fd6847@oss.qualcomm.com> Content-Language: en-US From: Jishnu Prakash In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: XZkNvcjBshI79JNBAsbioiYsYmWqDra7 X-Proofpoint-GUID: XZkNvcjBshI79JNBAsbioiYsYmWqDra7 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTI5MDA1NiBTYWx0ZWRfX0hiV0/vfAoVP zsauZfHTzJv/TDkfDLWwdg431vVyCI5ZOq/in19XYlrrYrqt4uGJnFQNMV2Wa5Ve/4Qlf0X3Dxd pkAl0zahGbGJWDXfdgwlr+bg18XLfPSZLmAk1cuTf23Dfc3YgdHyyf4Qoh5q5uNlaxAek9OGL+/ lz7n28wj51hN0YHWPeM0gwqEY/aZbv1FRXsWVroGAQseztZVBfkjbsmP8bNVMoZai1269JaKf9f Oxpq/XQOAOTgIRz0HK0uD6AHwDlLCSs3a9yVzN2AXHYuPPjK4Ye2pASQ2/om58AEkshTUsbPyXC htrzx2sNU4D0Fqq8FI9pFJavGYMhZr0h0Od3yBoHBxDBAgN+tgQNgnPB2Ia5V+ZRuHlY1dRdxX/ RtcNPRISqADnHnwQQw/9b9XPwO3a+Kcw1GkSu7/kc/TPkj0gm2uQ4zPFK83+SHC9OwSh8mFTmWN eoNtwE68tpQY6tLkN/Q== X-Proofpoint-Spam-Info: AW1haW4tMjYxMTI5MDA1NiBTYWx0ZWRfX/CMNSfiR6S3A EgzYnfW9kcEheLruLjzwXukBvlxXL18nM+MTiIWcqqFQcHCTQDNOwOXj7ryhw3iUL76+0STwCfK DXDDLvUaxIkP2timj8dW3mgKISZMO8M= X-Authority-Analysis: v=2.4 cv=Mdr5KJ/f c=1 sm=1 tr=0 ts=6b0c32ca cx=c_pps a=cFYjgdjTJScbgFmBucgdfQ==: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=DJpcGTmdVt4CTyJn9g5Z:22 a=ym8kKHoqxc5kBy3WF_oA:9 a=QEXdDO2ut3YA:10 a=scEy_gLbYbu1JhEsrz4S:22 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 impostorscore=0 phishscore=0 adultscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 spamscore=0 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611290056 Hi Andy, On 11/20/2026 3:44 PM, Andy Shevchenko wrote: > On Fri, Nov 20, 2026 at 02:49:43PM +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, so the maximum value of >> these measurements needs to be updated for Gen4. Add a new scaling >> function for thermistor channels which use this type of conversion. >> >> It is possible that the master PMIC has ADC of one generation and it needs >> to communicate with another PMIC with ADC of a different generation. For >> example, on SM8750, PMK8550 is the master PMIC with Gen3 ADC and it >> communicates with PMIH0108, which has Gen4 ADC. Add a new DT property >> "qcom,adc5-gen4" to distinguish Gen4 channels under a Gen3 master, to >> ensure that their conversions are handled correctly. >> >> 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. > > ... > >> - /* Write SID */ >> - buf[0] = FIELD_PREP(ADC5_GEN3_SID_MASK, prop->sid); >> + /* Write SID and bus_id*/ > > Missed space. > >> + buf[0] = FIELD_PREP(ADC5_GEN4_BUS_INDEX_MASK, prop->bus_index) | >> + FIELD_PREP(ADC5_GEN4_SID_MASK, prop->sid); > > ... > >> -static const struct adc5_data adc5_gen3_data_pmic = { >> - .full_scale_code_volt = 0x70e4, >> - .adc_chans = adc5_gen3_chans_pmic, >> - .info = &adc5_gen3_info, >> - .decimation = (unsigned int [ADC5_DECIMATION_SAMPLES_MAX]) >> - { 85, 340, 1360 }, >> - .hw_settle_1 = (unsigned int [VADC_HW_SETTLE_SAMPLES_MAX]) >> - { 15, 100, 200, 300, >> - 400, 500, 600, 700, >> - 1000, 2000, 4000, 8000, >> - 16000, 32000, 64000, 128000 }, >> -}; > > Seems like this is existing piece and you moved it up. Please, split that part > to a separate prerequisite patch. I think I moved it upwards because it was referenced in adc5_gen3_get_fw_channel_data(), which came before this point, but that was not really needed, as I could use a forward declaration instead. I'll move it back here and keep a forward declaration for it in the next patch version. > > ... > >> +static int qcom_adc5_gen4_scale_hw_calib_therm( >> + const struct u32_fract *prescale, >> + const struct adc5_data *data, >> + u16 adc_code, int *result_mdec) > > Even if the rest of the file uses this ugly indentation, correct it for a new code. > Not a problem if lines will be a bit longer. Will fix this in the next version. > >> +{ >> + s64 resistance = adc_code; >> + int ret, result; >> + >> + if (adc_code >= RATIO_MAX_ADC5_GEN4) >> + return -EINVAL; >> + >> + /* (ADC code * R_PULLUP (100Kohm)) / (full_scale_code - ADC code)*/ > > Again, missing space. > >> + resistance *= R_PU_100K; >> + resistance = div64_s64(resistance, RATIO_MAX_ADC5_GEN4 - adc_code); > > I would put it like this > > resistance = div64_s64(adc_code * R_PU_100K, RATIO_MAX_ADC5_GEN4 - adc_code); > > OR this > > resistance = > div64_s64(adc_code * R_PU_100K, RATIO_MAX_ADC5_GEN4 - adc_code); > > (but it still uses two lines, so I find the previous one slightly better). I'll make this update and also address your other comments. Thanks, Jishnu > >> + ret = qcom_vadc_map_voltage_temp(adcmap7_100k, ARRAY_SIZE(adcmap7_100k), >> + resistance, &result); >> + if (ret) >> + return ret; >> + >> + *result_mdec = result; >> + >> + return 0; >> +} >