[PATCH v2 3/4] thermal: qoriq: workaround the tmu temp jump on imx93
Jacky Bai
ping.bai at nxp.com
Fri Aug 1 08:10:29 PDT 2025
> Subject: Re: [PATCH v2 3/4] thermal: qoriq: workaround the tmu temp jump
> on imx93
>
> On Fri, Aug 01, 2025 at 04:11:18PM +0800, Jacky Bai wrote:
> > On i.MX93, the temp read from tmu may jump wrongly(ERR052243), and
> > invalid temp will be read out. To workaround such issue, we need to
> > use the raising/falling edge threshold to filter out the wrong temp.
> > When reading the temp, need to check the TIDR register to make sure no
> jump happens.
> >
> > Please refer to NXP errata ERR052243 for more details.
>
> Add download link here.
>
Thx, will add the url here.
> >
> > Signed-off-by: Jacky Bai <ping.bai at nxp.com>
> > ---
> > drivers/thermal/qoriq_thermal.c | 31
> +++++++++++++++++++++++++++++--
> > 1 file changed, 29 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/thermal/qoriq_thermal.c
> > b/drivers/thermal/qoriq_thermal.c index fd4d162fc188..664cd5f7d8af
> > 100644
> > --- a/drivers/thermal/qoriq_thermal.c
> > +++ b/drivers/thermal/qoriq_thermal.c
> > @@ -46,6 +46,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(x) ((x) & 0xFF)
>
> use GET_FIELD()
OK, will refine it will FILED_PREP macro.
BR
>
> > +#define TMFTRCTR 0x74
> > +#define TMFTRCTR_EN BIT(31)
> > +#define TMFTRCTR_TEMP(x) ((x) & 0xFF)
> >
> > #define REGS_TTCFGR 0x080 /* Temperature Configuration Register
> */
> > #define REGS_TSCFGR 0x084 /* Sensor Configuration Register */
> > @@ -93,7 +100,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:
> > *
> > @@ -118,6 +125,15 @@ static int tmu_get_temp(struct
> thermal_zone_device *tz, int *temp)
> > if (!(val & TMR_ME))
> > return -EAGAIN;
> >
> > + /* ERR052243: If there raising or falling edge happens, try later */
> > + if (qdata->ver == TMU_VER93) {
> > + 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,
> > @@ -126,6 +142,15 @@ static int tmu_get_temp(struct
> thermal_zone_device *tz, int *temp)
> > 10 * USEC_PER_MSEC))
> > return -ENODATA;
> >
> > + /*ERR052243: If there raising or falling edge happens, try later */
> > + if (qdata->ver == TMU_VER93) {
> > + regmap_read(qdata->regmap, REGS_TIDR, &tidr);
> > + if (tidr & GENMASK(25, 24)) {
> > + 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 {
> > @@ -232,12 +257,14 @@ static void qoriq_tmu_init_device(struct
> qoriq_tmu_data *data)
> > regmap_write(data->regmap, REGS_TIER, TIER_DISABLE);
> >
> > /* Set update_interval */
> > -
> > if (data->ver == TMU_VER1) {
> > regmap_write(data->regmap, REGS_TMTMIR, TMTMIR_DEFAULT);
> > } else if (data->ver == TMU_VER93) {
> > regmap_write(data->regmap, REGS_V2_TMTMIR,
> TMTMIR_DEFAULT);
> > regmap_write(data->regmap, REGS_V2_TEUMR(0), TEUMR0_V21);
> > + /* ERR052243: Set the raising & falling edge monitor */
> > + regmap_write(data->regmap, TMRTRCTR, TMRTRCTR_EN |
> TMRTRCTR_TEMP(0x7));
> > + regmap_write(data->regmap, TMFTRCTR, TMFTRCTR_EN |
> > +TMFTRCTR_TEMP(0x7));
> > } else {
> > regmap_write(data->regmap, REGS_V2_TMTMIR,
> TMTMIR_DEFAULT);
> > regmap_write(data->regmap, REGS_V2_TEUMR(0), TEUMR0_V2);
> > --
> > 2.34.1
> >
More information about the linux-arm-kernel
mailing list