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=Dofp8/4IRs8A9xDJgBsGTDWY+EuBMvXdZ24iB5cCAfvrj0asABcCinIywx7lufcbL12W ircrmpnT9VCKpnJ5gm3Jc3MA5h6BgJE0jc7mTgQv0u/URTJKcgGfyCx9XTmtRK+EEOcyc eK1dzrhReC3nq9/ALOcB6fGPBxl+MchDuOzWr42qkB3PQe3H6wKGvf8qKO26xCkoLle+Z qPwA6pnvkHs7eZwsHmnF5HWcL1GyFK/X4Y4gdNWmLRVh6pmDQCdRF7ii0euwASPB5aoaX PF4rqHgF7V1YnuH+1+r3zUvIs7gANQAqE87jqDVun1Y0RLBgasMuq2f3wwviDdGOE/g== 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-Spam-Info:X-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=cGNfEnSk3IgI9vq0w2ghDc5em/4RfwTTtAe14XHVCiA=; b=aXbcAddwyqralnHBlTGXvcZldcP4JJ3rqx/VsMRQVbZXdZXZAkzvBDOYHBT9vDh4hknJ rUPpQyPX2vJp+DFG8UMMs8+1s2HudxKXmXm/E7om4SEXkzDSzQVJckQ6fOJvBtFlR9GNl LirZF422o7RnRmQxn7+Kp4b+OukI/EwfuG5KZuvE2muwTvmO33gjXjUCg+cbcapZeGQN2 3wqLUaMpAqai/bzgSUYuQ5eI1XAKCEbvxETBOQnBD3JBms+wcrAmY9F8yZcKVn5NFRrzr t1Y8OqdVkKH2dRVnEp5SKa7a4l3O9PpLUJBlaHBHLP8J3W8J+uZ4B6nvKMpU4TeZCwA== 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 C95AC606A325 for ; Sun, 29 Nov 2026 14:12:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C95AC606A325 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 (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ATALtcI2668185 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 4j7r89awqy-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sun, 29 Nov 2026 14:12:25 +0000 (GMT) Received: by mail-dy1-f199.google.com with SMTP id 5a478bee46e88-382af5cfc58so1466749eec.0 for ; Sun, 29 Nov 2026 06:12:25 -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=ZQxWoRE6SDB7Y8apNvNlXHbLW1mVRfj+253Ofmo+ecR8BZEghI+AXqTsbFctT4EGa3 TQTTFU1uuw/1oiIUbxtSVR3psoNuPxvFhVIbjQuHBU8FUNCtis50FxFTqfQzIU2PUu4k coMMchghHl2KSqGb7p9PXGxHrD8LRywWaRrTlSEWCbxNPXWfMdOD41D4y5bJEItMrKIg mz0k3fpDB3nQ1bnAeQIgw0CDBbWdb7VULDR7PUX4jNlEoXqw6fr9FfPDw5sXtleNt7iQ lcqcTmHKZQYjMNOzm5JwPtNLmg8+guhYw6XjIMXS9uTrOnITFzhusMTyNhriE3aTU9Ex /pFg== X-Forwarded-Encrypted: i=1; AL+hErH3seVwIqIKOvohzHAjckx0WYovCFCjzIEky2q8/CmiWHmIVjrxHgAkIune6om0DVzx45tuj1k/SWOTUOc=@vger.kernel.org X-Gm-Message-State: APuU4Z9JR9X6rPitkiCPe+KBQShpt2pkIDqRtWZrlYQ/GE6FbVkgTQRB Im7bF6ssj6ENgazEuZ31GXfxRa7PiI49syAfD3A3C9o6Uj8q6+Yh+7lrAUqXJTxRXEa8aFXsM7q KVGNnclEOJ/d/0UgM+2hVwEklBhUzzF882oAMM4gNVRk/dhh2z3nsxNMmqbkVmqcLrtigNfwdbC s= X-Gm-Gg: AZFdTZf7+UzvXtSfVeAajZT9OpGvW2mK34fpl+XEMLTECWZu/9rQ8Ha4U3oA4eOFfD2 aMyvVBfWYyiXVP7+K4Uk0jPFWlC18dXMQ0JeKXDKVNugETF1TOWtW5JFnDie5ZAzLi/IXkxdcKE 4897Lk91Qk+BLrvrbJPvzPFltegeJj9arHAcFvtOFXb3RYZuxZPXVb/Aeaq3c1v/0GTM1SOx8kR fJ8vsCb0PLM7z6/RBSjjQoGz9nO91LWodC4jZoXgcvjnccXon2pRpw5eab3mCkGhJZdP7wlqK0W UxawK5VV0QWmm0nAkvGq2W+9XmVsgk7o2jpzRc+xGGX8H4GHOyr6HD1+4uVkyciA/3xcuTcBF9h ThWqwaFFD76NgQVAkzleZMaU07CDLZJYcS0MFkJCBqwR858X2doys9bVao3x/EzXrmYkoGlFa87 /HcfSsHb5t X-Received: by 2002:a05:7301:4d0c:b0:376:a6d7:8f6f with SMTP id 5a478bee46e88-3856ec3ec8bmr31912275eec.17.1795961545275; 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: 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 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: AoD4CY_UBES_nJcChS4f-hkhcqwZkC0s X-Proofpoint-Spam-Info: AW1haW4tMjYxMTI5MDA1NiBTYWx0ZWRfX3E6Hj/2EXYN6 WwrSHMohXB54uLeU5IxVGFLXWD7n+uxgZO/oCiibiL05wZk+CT0mnMTqCtr7QuMnr+TvJO0Dd2X StCSjxHnnarfLzEERtw/VzYTavL4sdQ= X-Authority-Analysis: v=2.4 cv=Eedd0/mC c=1 sm=1 tr=0 ts=6b0c32c9 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=YMgV9FUhrdKAYTUUvYB2:22 a=ym8kKHoqxc5kBy3WF_oA:9 a=QEXdDO2ut3YA:10 a=scEy_gLbYbu1JhEsrz4S:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTI5MDA1NiBTYWx0ZWRfX67tLEDLhr0Tt ClBkKC9QNLSsSFJbj2HjXhvykOX33ab+oXVGGCtQbCPjbP9ifTIblv6FSKuer8x8uzg+nJ8+vQO 2irdFdAos0G4qlWByxRF5pKVcLGSdtTdRFwKffK90FuQW0xh6URWapN2wylFOcJxyWntNylqrSB 0kMfvnRIBoKB2FOshTRQn16ZHcfY1JqduYpw4yIWhgMlZsAKXQQLw6BRqZfEZiezzzKHzTFGL/z gV4MmT7cCKmwVXazV1HVntjPUPkr5rzQh7wYnSvt9+PERSdeJ9ielK0EbduQupkmpNVc1P902DU QE5TiExRf3NI7N2YE9P1DRO5ThpVewL6jIXvrWZKC+/7fZgJAv0ieWPTCYzG8eVA1zDvbDX8G3V UeNrkar/sWJPuhDKMOett0Ltrd+Eouaf9swzs9dRHNX1L087r55ELFDxjQPyQrztPsMcTrFZ3D4 zObBboQV6WbW5QrLnnA== X-Proofpoint-GUID: AoD4CY_UBES_nJcChS4f-hkhcqwZkC0s 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 priorityscore=1501 impostorscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 spamscore=0 suspectscore=0 malwarescore=0 adultscore=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; >> +} >