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=oxh9339vnrT+mOJtbKcZ4KrrOPECwVRjHl2rxoW6NbO5Gqh/yGIOkUnZ5j/oIrQ+veNR I0OnYKywIeqjJXOSQVJyV1Oa7FPKqbjXnS3bhZOKPxNj+bNvFtW+sbgFQQw0DtizJEsRK 3wchwLFLtDXlLYdPmr3I6WWpbbwjFrTTSC5aPqsQzMhMfGSSHL0O9KEQiRoqxOoR/cCKO HAjWtZqaGj9PpcpJXvWdpUyMeWSdVe8rsUQWIwt5Fc0IKLvRKZILCcyVsjsn8lO7YSDI2 k8PVrCXfJ5sOW8daExci7Za2zaWBlgmtRpkbOUxKFMdG0pP6i28dz3kqGgZMgSwTNuA== 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-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Spam-Info:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=cGNfEnSk3IgI9vq0w2ghDc5em/4RfwTTtAe14XHVCiA=; b=IP6BOZk4HO0uRRHWqntxMTBooq67wis+7P+BJQbxbxWsLhLIqmyU+SRsuDuRlSaKwV16 JM6ivCD/7/G+EGQCHQczEy6JdZNABLVEX9NovlyAbE687ascYi0ag37XUbbcdw69vC1ui iHEX6BokwQLhciA/Nm4pruCvPOR0FHhg/VSMj7dzF2sVjo0LgStG3GpsMIVayJEDX0rgP Y9UFcsNQjiTILNm3VVd/VSMAQQ//Kci2mGufC6/46IYXy2rzJq0QPmWKhRxb0A5Zg7pk6 KYcP6CJou/Qmg/bO4DoOvWkxyh+Cnjl/R/+ChIn0pkF6LouIk3eERuu+niphr+GxXTg== 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 C4FC9606A31C for ; Sun, 29 Nov 2026 14:12:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C4FC9606A31C 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 (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ATALBkB333462 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 4j7mnekbw4-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-382af5cfc58so1466756eec.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=T22g8IeJNuzXEmP2mcNNTnA7/QgDkvviolt8UwD+a5xZiITtPyn1Dj4FF2u7orNGnq TGM5G/Pezd6z7/YJIlxQMb/oeAqx3tZZDp8CxKbYG6dBY4qYIE+tj+D6rczl7CA4bzxz wWiq6JIBba6qdblx5c5C8cukwfx3+fCRGhCliMpUZ7DW0UCxhVg8PQhH7JeJM1pPj1C1 FbY0SFZ6vMvp/i9e6M+0fpvq5NddqhN9/wf7PDjRDwf0X2PkafwAH7jVTX23avwjY/8w GtDu56YeU+o3dBjvckfZiYXIti0Dh5be/RsglcUuvqhc7ewaQ+iAc/EjG+eKRTW1g/td xUhQ== X-Forwarded-Encrypted: i=1; AL+hErH996wV0jIA7xC+ev2Tf6p2i5XaG/qYC52BhMpa1e6H43ovaLzJZDz4udz4d6BHE8eP6fk2UrR8kQ==@vger.kernel.org X-Gm-Message-State: APuU4Z+PPuL0HsbGIixG2CaAhIn/egj5KUax4CsFvJYzKqqTydOxFOjS 6iEfx6jsdlDfrBWJ4vvZtz7/HV9NSBEIcn/Q6I0o8qmTJoeKe117KwjeHcOhLjeeE71eeroGadM 4sjJ0pFs3tMfWMvFZ2+l620gU6ADF7ARF0JY7e1OKhEzhpvGesLNHMdYuKscPqg== X-Gm-Gg: AZFdTZe28SqVUKy7pEZVrHidZU19spIytMgV5gxoEp7BKBi1zn1idA8EwYRJAgvn3YP Pl1Y1YhDJZibBu7E3FRotyRZRrqoeouNUCQ0rVEnfmSmqgi4uE+GJ7SpaJELDVkmNSPaC0qRcCD NLaY7ZEOVyFHsiS7QfPfP5EnNJy+5Wg3ziyly4ZLFWU0at9k3BViOGaz8a4Xy8W5nls4dmODly4 Ibv4WoacWqmAP2IbDm/9fm+Dv62q+W1Oq5TLCv/GjjKmO8BsYr5S0L9MVRiexTmtSP3BR4OHcVE +fuNWFV4fv6h7PmkH2KO/RcxU6GmIP7ABOPfdOqhSMtU7+bjq90rbC2/yVl5Ygu9gLK09T+cKnF HOFmA2AEXKPezkNl0Bv1dsgL2ZvLUIuj8lfmE3r8909dz8H9kfn5hAa9o1R6A6FS3hocD3aaQSZ yEKhWQRPeY X-Received: by 2002:a05:7301:4d0c:b0:376:a6d7:8f6f with SMTP id 5a478bee46e88-3856ec3ec8bmr31912261eec.17.1795961545248; 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-pm@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: XViFxrZhf3d7Gd-c6fhrLpKPg5PykRjg X-Authority-Analysis: v=2.4 cv=Rf8FmFtv 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=eoimf2acIAo5FJnRuUoq:22 a=ym8kKHoqxc5kBy3WF_oA:9 a=QEXdDO2ut3YA:10 a=scEy_gLbYbu1JhEsrz4S:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTI5MDA1NiBTYWx0ZWRfXyjwlkQr/xAba RZUqgzKHkJVgMKy1eC8z9FDEiNEZJc7ihfdYf2qaVBot8wf72r6+H8+SwiCqZqcfP6PwHFAcjW2 bq5BsH+2K2LkpeIoV7I/aFMYTyiWx0VhRgZFQr/AzQDJ3yL3s1wdqhXfrxQ1rZDvLweM8BSkvEw maUKK3ehiSJ17IgFp9B/fCBrka2elE55ZsPdchVNXSWmAWMwf2U/ll4Fb0Xzjr5dUKpikHKZXsG nwa/eLLx8pV3y3riHqyY+7Hh6Eg7T4R1S4Tw2vA/dSMFyd5kKdaZ7aGy9KTy2B692veoaxPQsdg 78wubLnix0Ln6WIjHN6RBAYMuzBWUPB8mokGHv3MdHD4FPH5Iqb7ErFgK0ZBV6J5GJrrqgNx+EV eLUnVbC1d+iKv93Zenappw0/9wbBcUojKoFqHZWcb3zIcNaUykl1yGh6uOJrrlXXJ+H+v14dC8p 6zSgddHpJ3OknrS3xXw== X-Proofpoint-GUID: XViFxrZhf3d7Gd-c6fhrLpKPg5PykRjg X-Proofpoint-Spam-Info: AW1haW4tMjYxMTI5MDA1NiBTYWx0ZWRfXzNm2J1ujpYVD 2ZaL0eCjjRYhiqTOhZuIIlpHS/NbB0R1iqdWMM2czRVAXH0T8GTjxYHN8jvq91m4T9LF+suTcb/ fBGXtSVy0nksNQAPvjsHaUugo8k3B3k= 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 phishscore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 suspectscore=0 adultscore=0 malwarescore=0 bulkscore=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; >> +} >