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 28FCC3624C2; Mon, 13 Jul 2026 10:23:02 +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=1783938182; cv=none; b=EHS64jk8nuQPtbzoLpSH+ueajjuB7ZhydZ/Q0BqyuI9Tu43xOUQQfDvJrEtl8iGywyGYEmBUEyKCpGOf290CGmlJeLkqBIY/x9lSJCcchjh2cXPQnXcgVPXUIgGpgI/VlbJeahmkJ1EwsnIdvYZXukC38ZCnlA1SY5pPjDrZuUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783938182; c=relaxed/simple; bh=5R5wab56J1UaNbgqfoC2zM6MpZsUaaP2yXp95KCdfi8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cLj410N8XX9rvLICy0zZAUxnroL3BpEP/YTLmHBE5QmOfMQAxCuJaod8z24yzviqyMdzgdDJQbM5CXJj5q2OUR7Wpve2yhfckrha/hhxqv3UdlCRLLpXqUDb/OW7rEQ3BM8xjOqXOQ1sCwAd2vOFlbrJQtNxsjtU/CBzvcSrPz8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h/Mnx81U; 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="h/Mnx81U" Received: by smtp.kernel.org (Postfix) with ESMTPS id D3306C2BCB8; Mon, 13 Jul 2026 10:23:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1783938181; bh=5R5wab56J1UaNbgqfoC2zM6MpZsUaaP2yXp95KCdfi8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=h/Mnx81UK08Rxz96ml0YOyYwBI/NT5+dADjHMQtiN916dQK0RwiJXhPKjpVuaA7OH WTUHean/NkLM5MZ5gWoNNT8jYa5aaTalTGGShp73+3GCG3eP9636M5INhj4i9nz8S+ vtq/fahrisMdGH23IuEZ27UdBMEKDN7rWSLwHbqpAzzTJT/cBR0VaPy5Dk20aTuYv8 i1v3wzj/rVxr0f8bG8epN54xYY7dWR9kit+nlcriOgG2sNaXGaRUxtdzr/ssVxNrHM Dw/PafktDgj+7cXuIjqu/Gp3orPs2MTuH0w29PFeWfIH9MSoiYTC+e4Lm67cTSTgJn LAN2+ffzFgncQ== 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 B4327C44501; Mon, 13 Jul 2026 10:23:01 +0000 (UTC) From: Haoning CHENG via B4 Relay Date: Mon, 13 Jul 2026 18:22:56 +0800 Subject: [PATCH v7 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-v7-1-09b6b7669be1@cn.bosch.com> References: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v7-0-09b6b7669be1@cn.bosch.com> In-Reply-To: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v7-0-09b6b7669be1@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=1783938176; l=1753; i=Haoning.CHENG@cn.bosch.com; s=20260709; h=from:subject:message-id; bh=ZivBI22a3qS0TqHZ23fVePBLGsXub0NAoZFnOZ7FWno=; b=7Tx/FalTg2xObW+sDv69BZgEXPHmUmkiLXDHlLVI7bkqm1MzRVPqs3jy6BjeiVzoL5igYQe41 rr0DNCyyZL7DQpaitC/tBlR4eiZY/Pm3Gj73mdLC5Vxi0WZAhGD13RU 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 290763B6C09; Mon, 13 Jul 2026 10:23:02 +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=1783938182; cv=none; b=GlBUjWUWhGELXd4QwzgAcqZfn683gxhBDVTCItxSI0jZgxpYRkMCr64PRwFwnikc0+HECU3i+3Bivt780Qm/2npQf/0iEWHiC4oTR0yLpgpBs5KwEZJ7RrSWW5mOKhTJ4bKc/IPIL+RHxdeB42auZu97xjyYAHuqLYuW1eD/R5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783938182; c=relaxed/simple; bh=zaUpn2RrM7Y+SSqHxGeW2rP9JqogW0joe+/cvW4lYcY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qfO8m1CMpQ1nWzzsUE0lRnm7kTf7ZJECSinRgJcwxetaDChgd9nRzWGWLgrwsBQVy63N7fGPH8OJpnQKsPzeUa2oxobUsc8s++V1hhTElcFd6lG0U/f1ksucxu68ABbXKfw/nAtDSkqJdwOd7GE6oSBlNCHBnhGBm/YSJaxWtNg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U9F9hB52; 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="U9F9hB52" Received: by smtp.kernel.org (Postfix) with ESMTPS id E3224C2BCF5; Mon, 13 Jul 2026 10:23:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1783938182; bh=zaUpn2RrM7Y+SSqHxGeW2rP9JqogW0joe+/cvW4lYcY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=U9F9hB52rz5r4d602qYR3BxykfSbTekoANHUIYLO57jcqTk/m/IBj9PUt9szz/iGc A3g8aW2SEreGvomqQt2dww5jJTkrWQ/H9ppe++Gl7e29B5Gl1R+ZoCFp3hc/fWGDpU ITuUb00Sr6unYjjGtutoc4YFIVNIBgr9sbjPIstcUaN4x3xqlFnJkYdCxDxar8GCha EpjetJnLjcR8Nd5uPbFNuTpZbGYFowSDlJ3ft5iB4kvrzM5dHi48I/Nw+xuisQHYxi +ETBYz+WRlW71reLP/8hL3QEgHXG0IZSZBtcLdRS0LfgLpsj1JexwZi6vgSzLm9o4j vC1DHlVCa4gQA== 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 C35ACC44508; Mon, 13 Jul 2026 10:23:01 +0000 (UTC) From: Haoning CHENG via B4 Relay Date: Mon, 13 Jul 2026 18:22:57 +0800 Subject: [PATCH v7 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-v7-2-09b6b7669be1@cn.bosch.com> References: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v7-0-09b6b7669be1@cn.bosch.com> In-Reply-To: <20260713-b4-symana21-11221-imx-thermal-support-upstream-6-18-v7-0-09b6b7669be1@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=1783938176; l=2618; i=Haoning.CHENG@cn.bosch.com; s=20260709; h=from:subject:message-id; bh=bBpFP+2j2uwCjyUMOrcBLytMZH7uDdWsbUe0+yWT120=; b=B44Xe7ZO3h9ajmQFbldZ65vzHa9ls5or9QlPwBlJJ42B28NcJ1O36v7O+7sOEv9zSN3kZhAEE DTS0wBORdpcBPl3ygHl6si+zwn+6M7/7uFKZjraVy5WnwFGDpcwsw9l 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