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 D8DDF3E2754; Mon, 13 Jul 2026 10:13:04 +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=1783937584; cv=none; b=kanK6PjVA2w7l3D875JYj7ZJWjmVS9cdzgVTKt2hg50u6oD0A9MtDZZoYwbcylfky7w3c+Pr83oI7FsjmS0kVFQHzyNKl/7AiZTbOzN696DRU8QvMqRkPyXOL67PCYEc/4TrCz0lDiBv7xxQZwlA3MKu3PNJr/R3ZKdPfdFIg4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783937584; c=relaxed/simple; bh=5R5wab56J1UaNbgqfoC2zM6MpZsUaaP2yXp95KCdfi8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=emmrPoOrJr4VidvTugQrDPhUvKSXR5GYerfye1t1i7Ij9sdWKrmmDtPhBP6tSJYLFSt7nY9E8VIp3DlyDSLSjtTrRV0+Xpjh8S+JHpOz2d8tjkaCib9glvaoqSJdVUZ6hdNtTIJ4JBK9Dk5bicOuDGjkGEi742hss7IjEKpejfA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eX/sAqrP; 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="eX/sAqrP" Received: by smtp.kernel.org (Postfix) with ESMTPS id 85AA4C2BCF5; Mon, 13 Jul 2026 10:13:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1783937584; bh=5R5wab56J1UaNbgqfoC2zM6MpZsUaaP2yXp95KCdfi8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=eX/sAqrPjZAODzDI74j6Xz9vi+14/HUwmCT/XXGOV/XO9sl4jFy1PeBGUxV6hM3Fh LjhVokG1S+j2v3G2S28sN575hI73JyTucLeIyqqXYmB+wMX3F8rxu0gpKG1jaaYBTp ++WAERUonlSk7A5s0SnbZbtRAwACIsjLITziH3Y4rbiMzgVctTfPcqmVQNh5CKM+VA Kbvd5BFiUnybs4525W59zAJQ7C+nkopHXnfOQdLanJyJLBucv4blRCEOOA3MyctQd4 QREz9fO2dWsWBLuQPjN34M2aA0A6BF6E2MvHKxCCwrN/JRewQiVRWoPcL0hcB88KxK Gl+Jfe8f43jXQ== 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 73F70C44507; Mon, 13 Jul 2026 10:13:04 +0000 (UTC) From: Haoning CHENG via B4 Relay Date: Mon, 13 Jul 2026 18:12:39 +0800 Subject: [PATCH v6 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-v6-1-88a378faeca5@cn.bosch.com> References: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v6-0-88a378faeca5@cn.bosch.com> In-Reply-To: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v6-0-88a378faeca5@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=1783937579; l=1753; i=Haoning.CHENG@cn.bosch.com; s=20260709; h=from:subject:message-id; bh=ZivBI22a3qS0TqHZ23fVePBLGsXub0NAoZFnOZ7FWno=; b=7nYw10WjTXIQsaivz4U+/bx+VnMUEcRHtDvUNgpSmh1AQCcCGHQgjAF/Lw4+oMcvTsXSzcOLF jwfptF1qozvBltJt0qJZnPPahe7RCt0XMfEo89EZP6eK4767jRXXM0A 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 D8D463D9530; Mon, 13 Jul 2026 10:13:04 +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=1783937584; cv=none; b=mIfh6v3Y81azQFd7ePaqs9ATi3A58NSiITTlSR2NWKGmxXcuRx4fKCpJP/eIRUlHbI9dBtrJp0Y8eGQS1iOEdDnDnwrdpxHnEpUGFPcGS0sLCw+v7afSp9waUTKTz2MaPKxLYVSvK8CYgORlQZKTBZsajdU8arrv5aV+9Q5OfS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783937584; c=relaxed/simple; bh=r+wAQb9yhTvl6rPXmFGVyfFSB1IhImatws4R7IYEpqo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MmEmpUkOciEGvO4vynku3EPX0DTjKcXJU8eIxUSqZEtUeHsfSJIiIK4GHNowJ0opfX8fCuV2GpzLIiOpkQOwAYlpcXzvQoarsouGKX//LendeSLI4aBwvaD+h5NWUcttxqhhSehVO3jbQjTZL3Sw4a9j4fITWF2GfPCoaAp9cOA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ijk97rTV; 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="Ijk97rTV" Received: by smtp.kernel.org (Postfix) with ESMTPS id 96C43C2BCB8; Mon, 13 Jul 2026 10:13:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1783937584; bh=r+wAQb9yhTvl6rPXmFGVyfFSB1IhImatws4R7IYEpqo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Ijk97rTVcVnPNkgNWd210ObIDMVErrctqOYdx887NtBXygC1JkzyVpHttaFQMqgHE 8So2tMVzCjjJ4ZxEeQCfcrY+xA3+1ZNn7vGeWjGu85f4u9TMduI/wMaBwDLZQkODa+ SEKaU7fDCuaMtkZqynLChdPDXIzndUyN03rwOwHtvsNwhbC0BYey1u+Sgq/S7Kj8Ku Oc1S9HD2i9UKtvHFwG+PF5aVvlOFskaN38IQm23q5CMpk/q7IuvQGUOpja9eoDvp9g 1wQfenZ20MaelDcwDSTRkUA5rfT8G8sg1PWnF2yGIwe4opHz7NWgjRW7M+7brkJHfB msrq4pArZ5rFQ== 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 832EAC44501; Mon, 13 Jul 2026 10:13:04 +0000 (UTC) From: Haoning CHENG via B4 Relay Date: Mon, 13 Jul 2026 18:12:40 +0800 Subject: [PATCH v6 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-v6-2-88a378faeca5@cn.bosch.com> References: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v6-0-88a378faeca5@cn.bosch.com> In-Reply-To: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v6-0-88a378faeca5@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=1783937579; l=2618; i=Haoning.CHENG@cn.bosch.com; s=20260709; h=from:subject:message-id; bh=4RI3KwRlC8Yl5nDcFypymQ95vC8TXe4NB1RjWrUCQYE=; b=ZjXUHUSzr1P2LOslVCEvFksBcDLlIQ10c85S/WRlXJSDB1+GkJ+rmpryb0wvvghE5XBZHKLlQ +8+OgeSYfcIDzDg0yuhhUt2ily+rJ9QsoYxKH+hcMK7qQCe5hhrCJ6S 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