From: Frank Li <Frank.li@nxp.com>
To: Jacky Bai <ping.bai@nxp.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>,
Fabio Estevam <festevam@gmail.com>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 3/4] thermal: qoriq: workaround unexpected temperature readings from tmu
Date: Mon, 18 Aug 2025 11:51:11 -0400 [thread overview]
Message-ID: <aKNL7/uLHW3Xsrnc@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250818-imx93_tmu-v3-3-35f79a86c072@nxp.com>
On Mon, Aug 18, 2025 at 05:33:13PM +0800, Jacky Bai wrote:
> Invalid temperature measurements may be observed across the temperature
> range specified in the device data sheet. The invalid temperature can be
> read from any remote site and from any capture or report registers. The
> invalid change in temperature can be positive or negative and the resulting
> temperature can be outside the calibrated range, in which case the TSR[ORL]
> or TSR[ORH] bit will be set.
>
> Workaround:
> Use the raising/falling edge threshold to filter out the invalid temp.
> Check the TIDR register to make sure no jump happens When reading the temp.
>
> i.MX93 ERR052243:
> (https://www.nxp.com/webapp/Download?colCode=IMX93_2P87F&appType=license)
>
> Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> ---
> - v3 changes:
> - refine the code with FIELD_PREP macro
> - add errata doc url link and refine the commit log
>
> - v2 changes:
> - no
> ---
> drivers/thermal/qoriq_thermal.c | 42 +++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 40 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c
> index b2e634547271dcf512c714907baa162921d2d527..134a63abb482d44b5cc78e672e6312fbdce5ba31 100644
> --- a/drivers/thermal/qoriq_thermal.c
> +++ b/drivers/thermal/qoriq_thermal.c
> @@ -30,6 +30,9 @@
> #define TMU_VER1 0x1
> #define TMU_VER2 0x2
>
> +/* errata ID info define */
> +#define TMU_ERR052243 BIT(0)
> +
> #define REGS_TMR 0x000 /* Mode Register */
> #define TMR_DISABLE 0x0
> #define TMR_ME 0x80000000
> @@ -45,6 +48,13 @@
> #define REGS_TIER 0x020 /* Interrupt Enable Register */
> #define TIER_DISABLE 0x0
>
> +#define REGS_TIDR 0x24
> +#define TMRTRCTR 0x70
> +#define TMRTRCTR_EN BIT(31)
> +#define TMRTRCTR_TEMP_MASK GENMASK(7, 0)
> +#define TMFTRCTR 0x74
> +#define TMFTRCTR_EN BIT(31)
> +#define TMFTRCTR_TEMP_MASK GENMASK(7, 0)
>
> #define REGS_TTCFGR 0x080 /* Temperature Configuration Register */
> #define REGS_TSCFGR 0x084 /* Sensor Configuration Register */
> @@ -69,6 +79,7 @@
> #define REGS_V2_TEUMR(n) (0xf00 + 4 * (n))
>
> #define GET_TEUMR0(drvdata) (drvdata && drvdata->teumr0 ? drvdata->teumr0 : TEUMR0_V2)
> +#define CHECK_ERRATA_FLAG(drvdata, flag) (drvdata ? drvdata->tmu_errata & (flag) : 0)
>
> /*
> * Thermal zone data
> @@ -79,6 +90,7 @@ struct qoriq_sensor {
>
> struct tmu_drvdata {
> u32 teumr0;
> + u32 tmu_errata;
> };
>
> struct qoriq_tmu_data {
> @@ -99,7 +111,7 @@ static int tmu_get_temp(struct thermal_zone_device *tz, int *temp)
> {
> struct qoriq_sensor *qsensor = thermal_zone_device_priv(tz);
> struct qoriq_tmu_data *qdata = qoriq_sensor_to_data(qsensor);
> - u32 val;
> + u32 val, tidr;
> /*
> * REGS_TRITSR(id) has the following layout:
> *
> @@ -124,6 +136,15 @@ static int tmu_get_temp(struct thermal_zone_device *tz, int *temp)
> if (!(val & TMR_ME))
> return -EAGAIN;
>
> + /* ERR052243: If a raising or falling edge happens, try later */
> + if (CHECK_ERRATA_FLAG(qdata->drvdata, TMU_ERR052243)) {
> + regmap_read(qdata->regmap, REGS_TIDR, &tidr);
> + if (tidr & GENMASK(25, 24)) {
> + regmap_write(qdata->regmap, REGS_TIDR, GENMASK(25, 24));
> + return -EAGAIN;
> + }
> + }
> +
> if (regmap_read_poll_timeout(qdata->regmap,
> REGS_TRITSR(qsensor->id),
> val,
> @@ -132,6 +153,15 @@ static int tmu_get_temp(struct thermal_zone_device *tz, int *temp)
> 10 * USEC_PER_MSEC))
> return -ENODATA;
>
> + /*ERR052243: If a raising or falling edge happens, try later */
> + if (CHECK_ERRATA_FLAG(qdata->drvdata, TMU_ERR052243)) {
> + regmap_read(qdata->regmap, REGS_TIDR, &tidr);
> + if (tidr & GENMASK(25, 24)) {
you use GENMASK(25, 24) twice, define it as macro.
> + regmap_write(qdata->regmap, REGS_TIDR, GENMASK(25, 24));
> + return -EAGAIN;
> + }
> + }
> +
> if (qdata->ver == TMU_VER1) {
> *temp = (val & GENMASK(7, 0)) * MILLIDEGREE_PER_DEGREE;
> } else {
> @@ -238,7 +268,6 @@ static void qoriq_tmu_init_device(struct qoriq_tmu_data *data)
> regmap_write(data->regmap, REGS_TIER, TIER_DISABLE);
>
> /* Set update_interval */
> -
uncessary change.
> if (data->ver == TMU_VER1) {
> regmap_write(data->regmap, REGS_TMTMIR, TMTMIR_DEFAULT);
> } else {
> @@ -246,6 +275,14 @@ static void qoriq_tmu_init_device(struct qoriq_tmu_data *data)
> regmap_write(data->regmap, REGS_V2_TEUMR(0), GET_TEUMR0(data->drvdata));
> }
>
> + /* ERR052243: Set the raising & falling edge monitor */
> + if (CHECK_ERRATA_FLAG(data->drvdata, TMU_ERR052243)) {
> + regmap_write(data->regmap, TMRTRCTR, TMRTRCTR_EN |
> + FIELD_PREP(TMRTRCTR_TEMP_MASK, 0x7));
> + regmap_write(data->regmap, TMFTRCTR, TMFTRCTR_EN |
> + FIELD_PREP(TMFTRCTR_TEMP_MASK, 0x7));
the same here for 0x7
Frank
> +
> + }
> /* Disable monitoring */
> regmap_write(data->regmap, REGS_TMR, TMR_DISABLE);
> }
> @@ -389,6 +426,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(qoriq_tmu_pm_ops,
>
> static const struct tmu_drvdata imx93_data = {
> .teumr0 = TEUMR0_V21,
> + .tmu_errata = TMU_ERR052243,
> };
>
> static const struct of_device_id qoriq_tmu_match[] = {
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-08-18 17:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-18 9:33 [PATCH v3 0/4] Update the thermal support for imx93 Jacky Bai
2025-08-18 9:33 ` [PATCH v3 1/4] dt-bindings: thermal: qoriq: Add compatible string " Jacky Bai
2025-08-18 15:45 ` Frank Li
2025-08-18 17:01 ` Conor Dooley
2025-08-18 9:33 ` [PATCH v3 2/4] thermal: qoriq: add i.MX93 tmu support Jacky Bai
2025-08-18 15:48 ` Frank Li
2025-08-18 9:33 ` [PATCH v3 3/4] thermal: qoriq: workaround unexpected temperature readings from tmu Jacky Bai
2025-08-18 15:51 ` Frank Li [this message]
2025-08-19 2:01 ` Jacky Bai
2025-08-19 4:38 ` kernel test robot
2025-08-18 9:33 ` [PATCH v3 4/4] arm64: dts: imx93: update the tmu compatible string Jacky Bai
2025-08-18 15:51 ` Frank Li
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=aKNL7/uLHW3Xsrnc@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.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-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=ping.bai@nxp.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