From nobody Sat Jul 25 22:02:26 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FF27360EE1; Mon, 13 Jul 2026 05:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783921899; cv=none; b=rTybV4PJmvJeV9QlYSJV7F4TOkchTHtTXvdmE1LTJggKU09VuzavQyezu14iDF+JN+QDizDFEPSQN3TliwjO7h/uufYQtNtSCqNWSsbcNjfMYQkZ929Sxn5EjKm2CRm3rGtiQMceZ7rMb/j81Jn3fmoMxJrI4nRV6Vz2BnNA4oI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783921899; c=relaxed/simple; bh=oCll8We+b6Ponr2uyiTBpEh+oMTBvWauOBvBly2V1Do=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EugUU4e3G957xQ2Waw/MkpZFmJ6hiEg3ydleTfBDN6/RX7TY4h755/INrUC+KU3B7PpetHJbPXbpdn25P8VcyqmNgWieQw0dqW5PkClAOs25W4PM4FoVFaDwH3iV66c0t9dFNvWO/8Rf7SOwT7VoQLYamxQBc1qOHOqfA8cFuzw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=flKIobHQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="flKIobHQ" Received: by smtp.kernel.org (Postfix) with ESMTPS id D9240C2BCF4; Mon, 13 Jul 2026 05:51:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1783921898; bh=oCll8We+b6Ponr2uyiTBpEh+oMTBvWauOBvBly2V1Do=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=flKIobHQqR286Nhgygiour3pDzSDRE9c4oq4767RxopoKJRsEy2gkRM+XiQGpnVav je1ORONca0VMvZpyU1bPlk510M3ACCsoNCX6L8/+wEGPfZtkz7GZdO61KOeO+yCRS0 tSd17RZXN+R24LqHGjnP64TOhzSv6eEc+8hx752/rdRZFB6RVoa6orgAkPVH5DSQ28 eh2gFaPZBcYgv4Z4cLkXptznXjNrM2QcO8m8WXtzQ7pSVgWUk7CdZ6yj06yar3HJNX dq97N3HDcxW19G0M/Oavl2gCWCyaiQgSPF5hGmpcSY00naMk+bfcqZcm71gehPofSM bxSXzeLuUQG/w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9D68C44506; Mon, 13 Jul 2026 05:51:38 +0000 (UTC) From: HaoNing Cheng via B4 Relay Date: Mon, 13 Jul 2026 13:51:33 +0800 Subject: [PATCH v5 1/2] dt-bindings: thermal: imx: Document calibration offset property Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v5-1-69405c306c6b@cn.bosch.com> References: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v5-0-69405c306c6b@cn.bosch.com> In-Reply-To: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v5-0-69405c306c6b@cn.bosch.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Haoning CHENG , Krzysztof Kozlowski X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1783921893; l=1753; i=Haoning.CHENG@cn.bosch.com; s=20260709; h=from:subject:message-id; bh=ZivBI22a3qS0TqHZ23fVePBLGsXub0NAoZFnOZ7FWno=; b=Xxio6LCNhOYSAf+kovPkzVuaYHSwWnE3Mn0GO93XO9M7eVk232Zt8Pverwudm2v9b2n+/+pO9 oHc4DJr+i5RDivNDZhIG+pkRJnL0o/8AeSl4hWm3jwiwu2laFcksLnq X-Developer-Key: i=Haoning.CHENG@cn.bosch.com; a=ed25519; pk=glQGwad/fosRS5gZUJYbLDPPLGe7rFTrTV2VxY/ySdc= X-Endpoint-Received: by B4 Relay for Haoning.CHENG@cn.bosch.com/20260709 with auth_id=860 X-Original-From: HaoNing Cheng Reply-To: Haoning.CHENG@cn.bosch.com From: HaoNing Cheng Some boards need a small per-design correction to align the reported CPU temperature with board-level measurements. Document the optional fsl,temp-calibration-offset-millicelsius property, a signed offset in millicelsius that is added to the calculated sensor temperature. The property is optional and the existing behaviour is kept when it is omitted. Update the binding example to show its usage. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Haoning CHENG --- Documentation/devicetree/bindings/thermal/imx-thermal.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/thermal/imx-thermal.yaml b/D= ocumentation/devicetree/bindings/thermal/imx-thermal.yaml index 949b154856c5..b9afffd98f84 100644 --- a/Documentation/devicetree/bindings/thermal/imx-thermal.yaml +++ b/Documentation/devicetree/bindings/thermal/imx-thermal.yaml @@ -59,6 +59,14 @@ properties: clocks: maxItems: 1 =20 + fsl,temp-calibration-offset-millicelsius: + minimum: -28580 + maximum: 28580 + description: + A signed calibration offset, in millicelsius, added to the calculated + sensor temperature to compensate for board-level measurement + differences. When absent, no offset is applied. + "#thermal-sensor-cells": const: 0 =20 @@ -109,6 +117,7 @@ examples: nvmem-cells =3D <&tempmon_calib>, <&tempmon_temp_grade>; nvmem-cell-names =3D "calib", "temp_grade"; clocks =3D <&clks IMX6SX_CLK_PLL3_USB_OTG>; + fsl,temp-calibration-offset-millicelsius =3D <(-6400)>; #thermal-sensor-cells =3D <0>; }; }; --=20 2.43.0 From nobody Sat Jul 25 22:02:26 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FEAB360EDC; Mon, 13 Jul 2026 05:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783921899; cv=none; b=XT0wQpUjiAEcOW3TmIhY6d4GfrlExVP+/mAstQ/XpMt6tlzeMldYKjhPIyRoPg3AVUeFmYLo+a0UagxGzBQVVEGFA0O2JBCZpMFmRQQRjvZ0aPW1wuUF6zSo9PwJgqpTrzkpnFUjqRf+4UXh/3vfp5oK8/VfgOXA9v+qEa/ETcI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783921899; c=relaxed/simple; bh=NqsYvoPObx4tRY5M+T/QipNFYfyhGBpP8fWEUfWIYlg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ndi+Z71NV3OkARVTq9v0CInJXYpHqa7L2oaE0MF0g7qfzsXcq72iLFeCQNfBUaiqt437G82wpAalO/DfUyDd7uECY3cdgAtWZUHuB+/1B54xigHu7JatJoVrogSplklkjgmwDM1BlR5C/aL+v9hleFEWHm4Xw1QVvJXzaPl28WI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aLj/25Cc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aLj/25Cc" Received: by smtp.kernel.org (Postfix) with ESMTPS id E9AECC2BCC7; Mon, 13 Jul 2026 05:51:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1783921899; bh=NqsYvoPObx4tRY5M+T/QipNFYfyhGBpP8fWEUfWIYlg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=aLj/25Ccl0GQJEgDbb31uT/LJ7oOzGanRf/0RWWSE2eczhhj07Ly9hzg1fouozQQb Uz1jqt/I8XHiP8lMB/y28eed1s4NTgoCPgmDP9jIp/WcyFXDMo7ZFU5Mz8VjhpJBXM kSeZE31Tr6ISdSOsmyytKo6/1nA0RHqCkT6Co3DALFqAaZnNXM2lmZ0KV6jH1cAKEv 5BBOXdUDv5DMX+lOPY172ncRVQvRiZbDIXCme18uzOnqFTqyYZ5dQWpSfhTSEetIp4 7n2YwsseqcnMZp21RlqzWDwSVnGACCIZCpthiilPjR39rbEJVL8YnUrI0juLLoxxyX hr6/e3lDWm+/Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC384C44501; Mon, 13 Jul 2026 05:51:38 +0000 (UTC) From: HaoNing Cheng via B4 Relay Date: Mon, 13 Jul 2026 13:51:34 +0800 Subject: [PATCH v5 2/2] thermal/drivers/imx: Add calibration offset support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v5-2-69405c306c6b@cn.bosch.com> References: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v5-0-69405c306c6b@cn.bosch.com> In-Reply-To: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v5-0-69405c306c6b@cn.bosch.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Haoning CHENG X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1783921893; l=2618; i=Haoning.CHENG@cn.bosch.com; s=20260709; h=from:subject:message-id; bh=4RI3KwRlC8Yl5nDcFypymQ95vC8TXe4NB1RjWrUCQYE=; b=PE28GS7jCEZkFmW2gN2/FX2Qk8TCsqJlffhYSmDjpOmN7A8hOepF5Lqh2WHKJMXriDwxz+Dva RW61JO6wgsOAKfEEMneU9s0MonXBId7yhMbxCSpzckRtjNRCtDN31Wk X-Developer-Key: i=Haoning.CHENG@cn.bosch.com; a=ed25519; pk=glQGwad/fosRS5gZUJYbLDPPLGe7rFTrTV2VxY/ySdc= X-Endpoint-Received: by B4 Relay for Haoning.CHENG@cn.bosch.com/20260709 with auth_id=860 X-Original-From: HaoNing Cheng Reply-To: Haoning.CHENG@cn.bosch.com From: HaoNing Cheng Some boards need a small per-design correction to align the reported CPU temperature with board-level measurements. Read the optional fsl,temp-calibration-offset-millicelsius property from DT and apply it to the i.MX6/6SX/7D calibration formulas. When the property is not present, the default offset remains 0, preserving the current behaviour. Signed-off-by: HaoNing Cheng --- drivers/thermal/imx_thermal.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 38c993d1bcb3..0a443e608957 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -207,6 +207,7 @@ struct imx_thermal_data { struct regmap *tempmon; u32 c1, c2; /* See formula in imx_init_calib() */ int temp_max; + s32 calibration_offset; int alarm_temp; int last_temp; bool irq_enabled; @@ -223,6 +224,7 @@ static void imx_set_panic_temp(struct imx_thermal_data = *data, struct regmap *map =3D data->tempmon; int critical_value; =20 + panic_temp -=3D data->calibration_offset; critical_value =3D (data->c2 - panic_temp) / data->c1; =20 regmap_write(map, soc_data->panic_alarm_ctrl + REG_CLR, @@ -239,11 +241,14 @@ static void imx_set_alarm_temp(struct imx_thermal_dat= a *data, int alarm_value; =20 data->alarm_temp =3D alarm_temp; + alarm_temp -=3D data->calibration_offset; =20 - if (data->socdata->version =3D=3D TEMPMON_IMX7D) - alarm_value =3D alarm_temp / 1000 + data->c1 - 25; - else + if (data->socdata->version =3D=3D TEMPMON_IMX7D) { + alarm_value =3D DIV_ROUND_UP(alarm_temp, 1000) + data->c1 - 25; + alarm_value =3D clamp(alarm_value, 0, 0x1ff); + } else { alarm_value =3D (data->c2 - alarm_temp) / data->c1; + } =20 regmap_write(map, soc_data->high_alarm_ctrl + REG_CLR, soc_data->high_alarm_mask); @@ -277,6 +282,7 @@ static int imx_get_temp(struct thermal_zone_device *tz,= int *temp) *temp =3D (n_meas - data->c1 + 25) * 1000; else *temp =3D data->c2 - n_meas * data->c1; + *temp +=3D data->calibration_offset; =20 /* Update alarm value to next higher trip point for TEMPMON_IMX6Q */ if (data->socdata->version =3D=3D TEMPMON_IMX6Q) { @@ -629,6 +635,10 @@ static int imx_thermal_probe(struct platform_device *p= dev) =20 platform_set_drvdata(pdev, data); =20 + of_property_read_s32(dev->of_node, + "fsl,temp-calibration-offset-millicelsius", + &data->calibration_offset); + if (of_property_present(dev->of_node, "nvmem-cells")) { ret =3D imx_init_from_nvmem_cells(pdev); if (ret) --=20 2.43.0