From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795425445; b=iuGnaf8Rq4TDU0WOGptI22JcoNHcr9DzwEU84T3XjAasxJgBe+l6ahAPM9cW8G6qcaUD yfh8PxLaAl27LLEAY/2MOT5xReUOGiqp2+3fAUG5pck7r+v0O3N1lA5A6wVXQDO6qqOgo IDvc5GcASJ/kk9Cqr56pPfGS2DPI8TQkyUjkksFkktSphIIX1gGeDhoCCLJ2zeYIP5gXX PmBSedtvfWqln6rH4lzQPZkBZDk2oU2BIekuMyl/13IPaVhF/mXwnXxicorowD9E5a4SN b5S/fbcFQn/Wtoi7i2Ug2jDdVIthJpXTCCvsxVZSLpKIl16xSDTUNczUfmfjY0zyXrA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795425445; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Mime-Version:Content-Transfer-Encoding:Content-Type:Date:Message-Id: Cc:Subject:From:To:X-Mailer:References:In-Reply-To; bh=bfZwdrHDy1GNoA44s3G+1XzXoMHIKEYDGfkc9JfB56s=; b=pokLJITTHSbLuqdbTYgG6f3q9F6xPG95+Q8Jq2FawrRhW20K+6yIDnJSRQUaHbpPcSvI j/oZz89BTUKboF5N3/FLIjkUcCiNP5jSEMDShbJ7ZeAuFGZhpl14vcpnUCtICh/qbVS/G 3deG+KqiD0GkQsGHfCFArshd0goAS9rX4huX8WC7GW/Yff3n/VGy3KspVym+041GtqhFw VMjI+amoxyM+uc/hxdJfYjOKA0W4gtnJA9IodDpz2d+RjFVNrypvBXCSwu3k3oldGxuLV obikDyBJkAQAjv3vBmE6y5kxcCQVCCw6BcBnJ/9l5EGf5Y2fb3jLwTGHnTgjaElgB1w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=fairphone.com; spf=pass smtp.mailfrom=fairphone.com; dkim=pass header.d=fairphone.com header.i=@fairphone.com header.a=rsa-sha256 header.s=fair header.b=mRpGJUoU; arc=none smtp.remote-ip=209.85.218.54 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8CC7606A327 for ; Mon, 23 Nov 2026 09:17:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E8CC7606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fairphone.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fairphone.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fairphone.com header.i=@fairphone.com header.a=rsa-sha256 header.s=fair header.b=mRpGJUoU Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-c4d581da0aaso392249066b.2 for ; Mon, 23 Nov 2026 01:17:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fairphone.com; s=fair; t=1795425442; x=1796030242; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=bfZwdrHDy1GNoA44s3G+1XzXoMHIKEYDGfkc9JfB56s=; b=mRpGJUoU5NoqyhwJ0w8OwZQIUnCDN/5fpynpyGn9jzsx1jYEwfaQR/bW/LIbuTv4FP HtCOvcQfOBTtQbUygTRXF6/17BZUC/CCtQwrLOvg9292Pv6dsoD7zDbaCvIJT/zRcRxO MbIKHbJ1QOBg8Wys2xzfQCj1lY6QfqsTffezatDUGaY2lnhxi2IxR+XFTONEr778NfoU UyNZzn7nVB5bVPZcpv2HM9L62dtivuQJ2UJ2jenxhlPTqevL0prFen/4YMwDGWNGpHSx IowKIORJ7A0BzCLXZe3ybGG6jO1ZdM8muAingKU/H0QnXL7koAD1dNCNemRlfty9Q4Df o5dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795425442; x=1796030242; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=bfZwdrHDy1GNoA44s3G+1XzXoMHIKEYDGfkc9JfB56s=; b=aZ8zqisa9EWmwO+A/XLV16zI3ZvZFuChkfENz94xillkIjEMaPChe/5gf5x18oRoCx kj7yf37VTp5hgt1rTZ80j3tOF1DGqdJ58QqREmwhScj4N3n8lAQqctS+zbgAwQ0/2lpZ il8/3ag4basEHHZ0L1JqSEcxQwM75E2kg3sqmSjAkdyl1GKntYVZKyMnY9bjhnTmvG7P 0yeCOODHlFN0hw8f968zhInCdrm99YJuxasbnD7VX0LfGq3IoJbrVIgMkCKk7IUddX3u elsOeodTTU9/kzcM+VimWJqnGQg0UzldNe4lehCG6TF4jtnMdW8hEVKwXKZsCz+tBx01 1s4w== X-Forwarded-Encrypted: i=1; AL+hErH0rVdBvcTxjPpbbo3TJ3nSpwQlyjqxuP9HdHT/cIHUWZvZ8RBO9YGVmKrwQBni2N3ihnkRJkcD8I6wFwU=@vger.kernel.org X-Gm-Message-State: APuU4Z+BiB0HdPe23VoaX94u2GQBZbMloJHnp29Zm7do0h381h8tGUz+ MiO3rq6tm4lVMNPUotkbNrxxxtfsMHIqRGc16nOTCQnvxLbaL4CtrCKN/ha5Y2ILu0M= X-Gm-Gg: AZFdTZdiFgJIhP9AAFvlx8trIoGCYKTgQtIP/4SCWLCQY+vC9d+ZBtHt4Ra/Ih3SFTC YG2zamaqXU6jhdljbx62nlAh82Tn4gfdufxyn8XwE30LAzEey0dP3T1cSGtR2iB32Z409ZpPoi4 ap25iE7hDgaVyGR2l72ugJ2YQ2A7p8XpG/OMeYOoroXpy7UVUl90fvgpAvS3mTGCMz/ImWnla/1 YkegguGUuart9b+beooejBJTn1RrODF6qehuPi5yYY9dZMBSVZynARd/nl51qii/de4o59+mcxo hWW6tCqu1/p0hK9wcTgzToVqm/iXO2qVMKl3uOkoZz2VGTmOQN1cE0D2yTcqozb4WG6DJc7/7DL CKHsQm3IyAaHqMqBKwzq9rPt5Ozr2H9Ps1c9AiXsvi2vseILie9uN3ZXs9pcJdkKO7cjad5vW0d yZQIbk6ZTbbQmuNXsIDCRRwyG6iS2nAtGtCSADrkc4f0PtVdrFWbCaVkeAb49UaBMOBmw0opmnV gtpsB/YSQq1G0v5vlFbLpudyWtJK3L/hxbi0p6LJ7WiQBi3f11Vs5ajkf40y8fUQfUfcv1eH8WW NtSKd5GtKuomI+H7jmMD7tODja44Byf7uzbNlD7B4Tzixzz5J2RxyfVSLSp7cU5RKvRsrUIyTA= = X-Received: by 2002:a17:907:3cc7:b0:c2e:2d8c:4585 with SMTP id a640c23a62f3a-c513ab4cd0dmr859651666b.36.1795425442222; Mon, 23 Nov 2026 01:17:22 -0800 (PST) Received: from localhost (144-178-202-142.static.ef-service.nl. [144.178.202.142]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513afca58asm371207466b.65.2026.11.23.01.17.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Nov 2026 01:17:21 -0800 (PST) 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 23 Nov 2026 10:17:21 +0100 Message-Id: Cc: "David Lechner" , =?utf-8?q?Nuno_S=C3=A1?= , "Andy Shevchenko" , "Rafael J. Wysocki" , "Zhang Rui" , "Lukasz Luba" , "Rob Herring" , "Krzysztof Kozlowski" , "Conor Dooley" , "Laxman Dewangan" , "Bjorn Andersson" , "Konrad Dybcio" , "Hans de Goede" , "Jens Reidel" , "Casey Connolly" , "Val Packett" , "Daniel Lezcano" , <~postmarketos/upstreaming@lists.sr.ht>, , , , , , Subject: Re: [PATCH v4 1/5] iio: adc: qcom-spmi-adc5: Add battery thermal channels From: "Luca Weiss" To: "Jonathan Cameron" , "Luca Weiss" X-Mailer: aerc 0.22.0-0-gc2f86b7abde3-dirty References: <20261117-bat-temp-adc-v4-0-14d5d309ebfa@fairphone.com> <20261117-bat-temp-adc-v4-1-14d5d309ebfa@fairphone.com> <20261122031305.0fdc69cd@jic23-hlaptop> In-Reply-To: <20261122031305.0fdc69cd@jic23-hlaptop> Hi Jonathan, On Sun Nov 22, 2026 at 4:13 AM CET, Jonathan Cameron wrote: > On Tue, 17 Nov 2026 09:23:11 +0100 > Luca Weiss wrote: > >> Add the BAT_THERM channels with millivolt as output, which can then be >> used along with information regarding the NTC in the battery, to get the >> actual battery temperature. >>=20 >> A static lookup table in the ADC driver won't work since different >> devices have different Ohm and Beta values in their battery NTCs, for >> example a NTC can be 10kOhm & B=3D3435K. >>=20 >> Signed-off-by: Luca Weiss > Given this is independent of the following elements other than > the dtsi changes, do you want me to pick it up now? > > You may need to use numeric values in dtsi until the header > catches up then chase with a patch flipping to the defines next cycle. > That's how we normally avoid that dependency slowing things down. Sounds good from my side. Thank you! I think realistically, there's no other option than what's implemented in this patch, even if PATCH 2/5 (dt-bindings change for generic-adc) is not reviewed yet. But I hope the dt maintainers will be okay with that as well. Regards Luca > > Thanks, > > Jonathan > >> --- >> drivers/iio/adc/qcom-spmi-adc5.c | 6 ++++++ >> drivers/iio/adc/qcom-vadc-common.c | 16 ++++++++++++++++ >> include/linux/iio/adc/qcom-vadc-common.h | 3 +++ >> 3 files changed, 25 insertions(+) >>=20 >> diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spm= i-adc5.c >> index d57ba8526e0c..24ac84580570 100644 >> --- a/drivers/iio/adc/qcom-spmi-adc5.c >> +++ b/drivers/iio/adc/qcom-spmi-adc5.c >> @@ -542,6 +542,12 @@ static const struct adc5_channels adc5_chans_pmic[A= DC5_MAX_CHANNEL] =3D { >> SCALE_HW_CALIB_DEFAULT) >> [ADC5_XO_THERM_100K_PU] =3D ADC5_CHAN_TEMP("xo_therm", 0, >> SCALE_HW_CALIB_XOTHERM) >> + [ADC5_BAT_THERM_30K_PU] =3D ADC5_CHAN_VOLT("bat_therm_30k_pu", 0, >> + SCALE_HW_CALIB_THERM_VOLT) >> + [ADC5_BAT_THERM_100K_PU] =3D ADC5_CHAN_VOLT("bat_therm_100k_pu", 0, >> + SCALE_HW_CALIB_THERM_VOLT) >> + [ADC5_BAT_THERM_400K_PU] =3D ADC5_CHAN_VOLT("bat_therm_400k_pu", 0, >> + SCALE_HW_CALIB_THERM_VOLT) >> [ADC5_BAT_ID_100K_PU] =3D ADC5_CHAN_TEMP("bat_id", 0, >> SCALE_HW_CALIB_DEFAULT) >> [ADC5_AMUX_THM1_100K_PU] =3D ADC5_CHAN_TEMP("amux_thm1_100k_pu", 0, >> diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-v= adc-common.c >> index b03cf584b165..101b3c724f8d 100644 >> --- a/drivers/iio/adc/qcom-vadc-common.c >> +++ b/drivers/iio/adc/qcom-vadc-common.c >> @@ -309,6 +309,10 @@ static int qcom_vadc_scale_hw_calib_therm( >> const struct u32_fract *prescale, >> const struct adc5_data *data, >> u16 adc_code, int *result_mdec); >> +static int qcom_vadc_scale_hw_calib_therm_volt( >> + const struct u32_fract *prescale, >> + const struct adc5_data *data, >> + u16 adc_code, int *result_mV); >> static int qcom_vadc7_scale_hw_calib_therm( >> const struct u32_fract *prescale, >> const struct adc5_data *data, >> @@ -333,6 +337,7 @@ static int qcom_vadc7_scale_hw_calib_die_temp( >> static const struct qcom_adc5_scale_type scale_adc5_fn[] =3D { >> [SCALE_HW_CALIB_DEFAULT] =3D {qcom_vadc_scale_hw_calib_volt}, >> [SCALE_HW_CALIB_THERM_100K_PULLUP] =3D {qcom_vadc_scale_hw_calib_therm= }, >> + [SCALE_HW_CALIB_THERM_VOLT] =3D {qcom_vadc_scale_hw_calib_therm_volt}, >> [SCALE_HW_CALIB_XOTHERM] =3D {qcom_vadc_scale_hw_calib_therm}, >> [SCALE_HW_CALIB_THERM_100K_PU_PM7] =3D { >> qcom_vadc7_scale_hw_calib_therm}, >> @@ -583,6 +588,17 @@ static int qcom_vadc_scale_hw_calib_therm( >> voltage, result_mdec); >> } >> =20 >> +static int qcom_vadc_scale_hw_calib_therm_volt( >> + const struct u32_fract *prescale, >> + const struct adc5_data *data, >> + u16 adc_code, int *result_mV) >> +{ >> + *result_mV =3D qcom_vadc_scale_code_voltage_factor(adc_code, >> + prescale, data, MICRO / MILLI); >> + >> + return 0; >> +} >> + >> static int qcom_vadc_scale_hw_calib_die_temp( >> const struct u32_fract *prescale, >> const struct adc5_data *data, >> diff --git a/include/linux/iio/adc/qcom-vadc-common.h b/include/linux/ii= o/adc/qcom-vadc-common.h >> index 3bf4c49726a7..7586016ff14d 100644 >> --- a/include/linux/iio/adc/qcom-vadc-common.h >> +++ b/include/linux/iio/adc/qcom-vadc-common.h >> @@ -93,6 +93,8 @@ struct vadc_linear_graph { >> * voltage (uV) with hardware applied offset/slope values to adc code. >> * @SCALE_HW_CALIB_THERM_100K_PULLUP: Returns temperature in millidegC = using >> * lookup table. The hardware applies offset/slope to adc code. >> + * @SCALE_HW_CALIB_THERM_VOLT: Returns voltage in mV of a temperature c= hannel. >> + * The hardware applies offset/slope to adc code. >> * @SCALE_HW_CALIB_XOTHERM: Returns XO thermistor voltage in millidegC = using >> * 100k pullup. The hardware applies offset/slope to adc code. >> * @SCALE_HW_CALIB_THERM_100K_PU_PM7: Returns temperature in millidegC = using >> @@ -114,6 +116,7 @@ enum vadc_scale_fn_type { >> SCALE_PMI_CHG_TEMP, >> SCALE_HW_CALIB_DEFAULT, >> SCALE_HW_CALIB_THERM_100K_PULLUP, >> + SCALE_HW_CALIB_THERM_VOLT, >> SCALE_HW_CALIB_XOTHERM, >> SCALE_HW_CALIB_THERM_100K_PU_PM7, >> SCALE_HW_CALIB_PMIC_THERM, >>=20