From: Frank Li <Frank.li@oss.nxp.com>
To: Haoning.CHENG@cn.bosch.com
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] thermal/drivers/imx: Add calibration offset support
Date: Fri, 10 Jul 2026 10:35:12 -0500 [thread overview]
Message-ID: <alERMKAParbbrEAg@SMW015318> (raw)
In-Reply-To: <20260710-b4-symana21-11221-imx-thermal-support-upstream-6-18-v4-2-1fef97d1c750@cn.bosch.com>
On Fri, Jul 10, 2026 at 11:03:37AM +0800, HaoNing Cheng via B4 Relay wrote:
> [You don't often get email from devnull+haoning.cheng.cn.bosch.com@kernel.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> 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 | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index 38c993d1bcb3..8062d34ffed8 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;
> @@ -240,10 +241,13 @@ 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;
> - else
> + if (data->socdata->version == TEMPMON_IMX7D) {
> + alarm_value = DIV_ROUND_UP(alarm_temp - data->calibration_offset,
> + 1000) + data->c1 - 25;
> + alarm_value = clamp(alarm_value, 0, 0x1ff);
> + } else {
> alarm_value = (data->c2 - alarm_temp) / data->c1;
> + }
you can direct change alarm_temp before if block
alarm_temp -= data->calibration_offset;
which fix for all SoC, not only IMX7D
Frank
>
> regmap_write(map, soc_data->high_alarm_ctrl + REG_CLR,
> soc_data->high_alarm_mask);
> @@ -274,7 +278,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 +417,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 +633,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
>
>
>
prev parent reply other threads:[~2026-07-10 15:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 3:03 [PATCH v4 0/2] thermal: imx: Add calibration offset support HaoNing Cheng via B4 Relay
2026-07-10 3:03 ` [PATCH v4 1/2] dt-bindings: thermal: imx: Document calibration offset property HaoNing Cheng via B4 Relay
2026-07-10 7:28 ` Krzysztof Kozlowski
2026-07-10 15:33 ` Frank Li
2026-07-10 3:03 ` [PATCH v4 2/2] thermal/drivers/imx: Add calibration offset support HaoNing Cheng via B4 Relay
2026-07-10 15:35 ` Frank Li [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alERMKAParbbrEAg@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Haoning.CHENG@cn.bosch.com \
--cc=conor+dt@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rui.zhang@intel.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox