* [PATCH 0/2] thermal: imx: Add calibration offset support
@ 2026-07-09 5:43 HaoNing Cheng via B4 Relay
2026-07-09 5:43 ` [PATCH 1/2] dt-bindings: thermal: imx: Document calibration offset property HaoNing Cheng via B4 Relay
2026-07-09 5:43 ` [PATCH 2/2] thermal/drivers/imx: Add calibration offset support HaoNing Cheng via B4 Relay
0 siblings, 2 replies; 6+ messages in thread
From: HaoNing Cheng via B4 Relay @ 2026-07-09 5:43 UTC (permalink / raw)
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, devicetree, imx, linux-arm-kernel, linux-kernel,
Haoning CHENG
Some i.MX boards need a small per-design correction to align the
reported CPU temperature with board-level measurements. This series
adds an optional DT property to specify such a calibration offset
and implements the corresponding support in the imx_thermal driver.
Patch 1 documents the new fsl,temp-calibration-offset-millicelsius
property in the i.MX thermal DT binding.
Patch 2 reads this property in the imx_thermal driver and applies
the offset to the i.MX6/6SX/7D calibration formulas. When the
property is absent, the default offset remains 0, preserving the
current behaviour.
Signed-off-by: Haoning CHENG <Haoning.CHENG@cn.bosch.com>
---
HaoNing Cheng (2):
dt-bindings: thermal: imx: Document calibration offset property
thermal/drivers/imx: Add calibration offset support
Documentation/devicetree/bindings/thermal/imx-thermal.yaml | 8 ++++++++
drivers/thermal/imx_thermal.c | 11 ++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
---
base-commit: c50a940dcde35c647e097e89a9150003abd48329
change-id: 20260709-b4-symana21-11221-imx-thermal-support-upstream-6-18-a084984deb76
Best regards,
--
Haoning CHENG <Haoning.CHENG@cn.bosch.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] dt-bindings: thermal: imx: Document calibration offset property
2026-07-09 5:43 [PATCH 0/2] thermal: imx: Add calibration offset support HaoNing Cheng via B4 Relay
@ 2026-07-09 5:43 ` HaoNing Cheng via B4 Relay
2026-07-09 5:50 ` sashiko-bot
2026-07-09 6:26 ` Rob Herring (Arm)
2026-07-09 5:43 ` [PATCH 2/2] thermal/drivers/imx: Add calibration offset support HaoNing Cheng via B4 Relay
1 sibling, 2 replies; 6+ messages in thread
From: HaoNing Cheng via B4 Relay @ 2026-07-09 5:43 UTC (permalink / raw)
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, devicetree, imx, linux-arm-kernel, linux-kernel,
Haoning CHENG
From: HaoNing Cheng <Haoning.CHENG@cn.bosch.com>
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.
Signed-off-by: HaoNing Cheng <Haoning.CHENG@cn.bosch.com>
---
Documentation/devicetree/bindings/thermal/imx-thermal.yaml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/devicetree/bindings/thermal/imx-thermal.yaml b/Documentation/devicetree/bindings/thermal/imx-thermal.yaml
index 949b154856c5..29bdcb921a96 100644
--- a/Documentation/devicetree/bindings/thermal/imx-thermal.yaml
+++ b/Documentation/devicetree/bindings/thermal/imx-thermal.yaml
@@ -59,6 +59,13 @@ properties:
clocks:
maxItems: 1
+ fsl,temp-calibration-offset-millicelsius:
+ 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.
+ $ref: /schemas/types.yaml#/definitions/int32
+
"#thermal-sensor-cells":
const: 0
@@ -109,6 +116,7 @@ examples:
nvmem-cells = <&tempmon_calib>, <&tempmon_temp_grade>;
nvmem-cell-names = "calib", "temp_grade";
clocks = <&clks IMX6SX_CLK_PLL3_USB_OTG>;
+ fsl,temp-calibration-offset-millicelsius = <(-6400)>;
#thermal-sensor-cells = <0>;
};
};
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] thermal/drivers/imx: Add calibration offset support
2026-07-09 5:43 [PATCH 0/2] thermal: imx: Add calibration offset support HaoNing Cheng via B4 Relay
2026-07-09 5:43 ` [PATCH 1/2] dt-bindings: thermal: imx: Document calibration offset property HaoNing Cheng via B4 Relay
@ 2026-07-09 5:43 ` HaoNing Cheng via B4 Relay
2026-07-09 5:54 ` sashiko-bot
1 sibling, 1 reply; 6+ messages in thread
From: HaoNing Cheng via B4 Relay @ 2026-07-09 5:43 UTC (permalink / raw)
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, devicetree, imx, linux-arm-kernel, linux-kernel,
Haoning CHENG
From: HaoNing Cheng <Haoning.CHENG@cn.bosch.com>
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 <Haoning.CHENG@cn.bosch.com>
---
drivers/thermal/imx_thermal.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 38c993d1bcb3..c65400b51ed8 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;
@@ -241,7 +242,7 @@ static void imx_set_alarm_temp(struct imx_thermal_data *data,
data->alarm_temp = alarm_temp;
if (data->socdata->version == TEMPMON_IMX7D)
- alarm_value = alarm_temp / 1000 + data->c1 - 25;
+ alarm_value = (alarm_temp - data->calibration_offset) / 1000 + data->c1 - 25;
else
alarm_value = (data->c2 - alarm_temp) / data->c1;
@@ -274,7 +275,7 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
/* See imx_init_calib() for formula derivation */
if (data->socdata->version == TEMPMON_IMX7D)
- *temp = (n_meas - data->c1 + 25) * 1000;
+ *temp = (n_meas - data->c1 + 25) * 1000 + data->calibration_offset;
else
*temp = data->c2 - n_meas * data->c1;
@@ -413,7 +414,7 @@ static int imx_init_calib(struct platform_device *pdev, u32 ocotp_ana1)
temp64 *= 1000; /* to get result in °mC */
do_div(temp64, 15423 * n1 - 4148468);
data->c1 = temp64;
- data->c2 = n1 * data->c1 + 28581;
+ data->c2 = n1 * data->c1 + 28581 + data->calibration_offset;
return 0;
}
@@ -629,6 +630,10 @@ static int imx_thermal_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, data);
+ 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 = imx_init_from_nvmem_cells(pdev);
if (ret)
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: thermal: imx: Document calibration offset property
2026-07-09 5:43 ` [PATCH 1/2] dt-bindings: thermal: imx: Document calibration offset property HaoNing Cheng via B4 Relay
@ 2026-07-09 5:50 ` sashiko-bot
2026-07-09 6:26 ` Rob Herring (Arm)
1 sibling, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-07-09 5:50 UTC (permalink / raw)
To: HaoNing Cheng; +Cc: imx, devicetree, robh, Frank.Li, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Inconsistent indentation in the device tree example for the newly added property.
--
--- Patch [1]: [PATCH 1/2] dt-bindings: thermal: imx: Document calibration offset property ---
commit 1a75813b8a61f5ee87309553dc49a0dab98ae1c1
Author: HaoNing Cheng <Haoning.CHENG@cn.bosch.com>
dt-bindings: thermal: imx: Document calibration offset property
This commit documents a new optional property,
fsl,temp-calibration-offset-millicelsius, to align the reported CPU
temperature with board-level measurements. The binding example is also
updated to demonstrate its usage.
> diff --git a/Documentation/devicetree/bindings/thermal/imx-thermal.yaml b/Documentation/devicetree/bindings/thermal/imx-thermal.yaml
> --- a/Documentation/devicetree/bindings/thermal/imx-thermal.yaml
> +++ b/Documentation/devicetree/bindings/thermal/imx-thermal.yaml
[ ... ]
> @@ -109,6 +116,7 @@ examples:
> nvmem-cells = <&tempmon_calib>, <&tempmon_temp_grade>;
> nvmem-cell-names = "calib", "temp_grade";
> clocks = <&clks IMX6SX_CLK_PLL3_USB_OTG>;
> + fsl,temp-calibration-offset-millicelsius = <(-6400)>;
[Severity: Low]
This isn't a bug, but does this line have an extra leading space? It appears
to be indented with 13 spaces instead of 12, misaligning it slightly with the
surrounding properties in the example.
> #thermal-sensor-cells = <0>;
> };
> };
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-b4-symana21-11221-imx-thermal-support-upstream-6-18-v1-0-00f88f42930b@cn.bosch.com?part=1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] thermal/drivers/imx: Add calibration offset support
2026-07-09 5:43 ` [PATCH 2/2] thermal/drivers/imx: Add calibration offset support HaoNing Cheng via B4 Relay
@ 2026-07-09 5:54 ` sashiko-bot
0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-07-09 5:54 UTC (permalink / raw)
To: HaoNing Cheng; +Cc: conor+dt, robh, imx, Frank.Li, devicetree
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] The i.MX7D alarm temperature calculation truncates towards zero, leading to an early hardware trigger and an IRQ storm when the calibration offset is not a multiple of 1000.
Pre-existing issues:
- [High] The computed `alarm_value` is shifted and written to the high alarm control hardware register without bitwise masking, allowing out-of-bounds or negative values to corrupt adjacent register fields.
--
--- Patch [2]: [PATCH 2/2] thermal/drivers/imx: Add calibration offset support ---
commit b15c0dce27dccd66bd58b8f22bb746933db67a41
Author: HaoNing Cheng <Haoning.CHENG@cn.bosch.com>
thermal/drivers/imx: Add calibration offset support
Some boards need a small per-design correction to align the reported CPU
temperature with board-level measurements.
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index 5aaacbc534786..3e1eec2fc3613 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -241,7 +242,7 @@ static void imx_set_alarm_temp(struct imx_thermal_data *data,
> data->alarm_temp = alarm_temp;
>
> if (data->socdata->version == TEMPMON_IMX7D)
> - alarm_value = alarm_temp / 1000 + data->c1 - 25;
> + alarm_value = (alarm_temp - data->calibration_offset) / 1000 + data->c1 - 25;
[Severity: High]
If the device tree property fsl,temp-calibration-offset-millicelsius is set
to a value that is not a multiple of 1000 (e.g., 500), does this integer
division truncate towards zero and cause an early hardware alarm trigger?
When the hardware asserts the thermal interrupt due to the truncated threshold,
the IRQ handler would read the temperature, calculate that the temperature is
still below the alarm_temp, and immediately re-enable the IRQ. Could this
regression lead to an infinite IRQ storm?
[Severity: High]
This is a pre-existing issue, but the computed alarm_value is shifted and
written to the high alarm control register shortly after this without masking:
regmap_write(map, soc_data->high_alarm_ctrl + REG_SET,
alarm_value << soc_data->high_alarm_shift);
Since the newly introduced calibration offset could make alarm_value negative
or exceed its 9-bit mask, shifting a negative signed value will set the upper
bits to 1.
Because this is a bit-set operation, could writing this value overwrite and
corrupt the adjacent IMX7_TEMPSENSE0_PANIC_ALARM field (bits 18-26)? The same
pattern appears to exist for the panic alarm threshold in imx_set_panic_temp().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-b4-symana21-11221-imx-thermal-support-upstream-6-18-v1-0-00f88f42930b@cn.bosch.com?part=2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: thermal: imx: Document calibration offset property
2026-07-09 5:43 ` [PATCH 1/2] dt-bindings: thermal: imx: Document calibration offset property HaoNing Cheng via B4 Relay
2026-07-09 5:50 ` sashiko-bot
@ 2026-07-09 6:26 ` Rob Herring (Arm)
1 sibling, 0 replies; 6+ messages in thread
From: Rob Herring (Arm) @ 2026-07-09 6:26 UTC (permalink / raw)
To: HaoNing Cheng
Cc: Zhang Rui, linux-arm-kernel, devicetree, Conor Dooley, imx,
Fabio Estevam, Sascha Hauer, Rafael J. Wysocki, linux-pm,
Lukasz Luba, Daniel Lezcano, Shawn Guo, Pengutronix Kernel Team,
Krzysztof Kozlowski, linux-kernel
On Thu, 09 Jul 2026 13:43:27 +0800, HaoNing Cheng wrote:
> 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.
>
> Signed-off-by: HaoNing Cheng <Haoning.CHENG@cn.bosch.com>
> ---
> Documentation/devicetree/bindings/thermal/imx-thermal.yaml | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/thermal/imx-thermal.yaml: properties:fsl,temp-calibration-offset-millicelsius: '$ref' should not be valid under {'const': '$ref'}
hint: Standard unit suffix properties don't need a type $ref
from schema $id: http://devicetree.org/meta-schemas/core.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/thermal/imx-thermal.example.dtb: tempmon (fsl,imx6sx-tempmon): fsl,temp-calibration-offset-millicelsius: -6400 is not of type 'array'
from schema $id: http://devicetree.org/schemas/property-units.yaml
doc reference errors (make refcheckdocs):
See https://patchwork.kernel.org/project/devicetree/patch/20260709-b4-symana21-11221-imx-thermal-support-upstream-6-18-v1-1-00f88f42930b@cn.bosch.com
The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-07-09 6:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09 5:43 [PATCH 0/2] thermal: imx: Add calibration offset support HaoNing Cheng via B4 Relay
2026-07-09 5:43 ` [PATCH 1/2] dt-bindings: thermal: imx: Document calibration offset property HaoNing Cheng via B4 Relay
2026-07-09 5:50 ` sashiko-bot
2026-07-09 6:26 ` Rob Herring (Arm)
2026-07-09 5:43 ` [PATCH 2/2] thermal/drivers/imx: Add calibration offset support HaoNing Cheng via B4 Relay
2026-07-09 5:54 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox