[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aT9mE63WtVqCxIPC@shlinux89>
Date: Mon, 15 Dec 2025 09:36:19 +0800
From: Peng Fan <peng.fan@....nxp.com>
To: Frank Li <Frank.li@....com>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Zhang Rui <rui.zhang@...el.com>, Lukasz Luba <lukasz.luba@....com>,
Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>, linux-pm@...r.kernel.org,
imx@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, Peng Fan <peng.fan@....com>
Subject: Re: [PATCH 1/3] thermal/drivers/imx91: Check status before reading
data
On Fri, Dec 12, 2025 at 12:25:48PM -0500, Frank Li wrote:
>On Fri, Dec 12, 2025 at 03:51:14PM +0800, Peng Fan (OSS) wrote:
>> From: Peng Fan <peng.fan@....com>
>>
>> Per periodic mode from reference mannual:
>> Write 1b to CTRL1[START]. Wait until STATm[DRDYn] becomes 1.
>> Read DATAn[DATA_VAL]. It clears the corresponding STATm[DRDYn].
>> DATAn[DATA_VAL] and STATm[DRDYn_IF] keep refreshing at a periodic interval
>> of time, corresponding to PERIOD_CTRL[MEAS_FREQ].
>
>It should get last time sample value without check DRDYn_IF bit. it should
>only be a PERIOD_CTRL[MEAS_FREQ] delay.
>
>worst case get value at previous's PERIOD_CTRL[MEAS_FREQ] sample.
>
>PERIOD_CTRL[MEAS_FREQ] is quite short compare to call get_temp frequency.
>
>Do you get invalidate data?
No, this is just to align what we tested in LTS tree.
It should be fine to use last value, so drop this patch.
Thanks,
Peng
>
>>
>> Need to check STAT[DRDY] before reading the DATA register.
>>
>> And check the returned temperature to make sure it fits into the supported
>> range (-40°C to +125°C).
>
>https://lore.kernel.org/imx/aAIkAF_AHta8_vuS@mai.linaro.org/
>
>Do you answer Daniel Lezcano's question
> ""When the measured temperature can be out of limits ?" at v6 resend
>patch.
>
>Frank
>>
>> Signed-off-by: Peng Fan <peng.fan@....com>
>> ---
>> drivers/thermal/imx91_thermal.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/drivers/thermal/imx91_thermal.c b/drivers/thermal/imx91_thermal.c
>> index 9b20be03d6dec18553967548d0ca31d1c1fb387c..77e8e6a921c6af308b830c36721293c007256ca6 100644
>> --- a/drivers/thermal/imx91_thermal.c
>> +++ b/drivers/thermal/imx91_thermal.c
>> @@ -108,10 +108,20 @@ static int imx91_tmu_get_temp(struct thermal_zone_device *tz, int *temp)
>> {
>> struct imx91_tmu *tmu = thermal_zone_device_priv(tz);
>> s16 data;
>> + int ret;
>> + u32 val;
>> +
>> + ret = readl_relaxed_poll_timeout(tmu->base + IMX91_TMU_STAT0, val,
>> + val & IMX91_TMU_STAT0_DRDY0_IF_MASK, 1000,
>> + 40000);
>> + if (ret)
>> + return -EAGAIN;
>>
>> /* DATA0 is 16bit signed number */
>> data = readw_relaxed(tmu->base + IMX91_TMU_DATA0);
>> *temp = imx91_tmu_to_mcelsius(data);
>> + if (*temp < IMX91_TMU_TEMP_LOW_LIMIT || *temp > IMX91_TMU_TEMP_HIGH_LIMIT)
>> + return -EAGAIN;
>>
>> return 0;
>> }
>>
>> --
>> 2.37.1
>>
Powered by blists - more mailing lists