Re: [PATCH v2 3/5] thermal/drivers/mediatek/lvts_thermal: Add mt8192 support

From: Nícolas F. R. A. Prado
Date: Fri Apr 28 2023 - 16:10:54 EST


On Tue, Apr 25, 2023 at 03:30:50PM +0200, bchihi@xxxxxxxxxxxx wrote:
> From: Balsam CHIHI <bchihi@xxxxxxxxxxxx>
>
> Add LVTS Driver support for MT8192.
>
> Signed-off-by: Balsam CHIHI <bchihi@xxxxxxxxxxxx>
> Co-developed-by : Nícolas F. R. A. Prado <nfraprado@xxxxxxxxxxxxx>
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@xxxxxxxxxxxxx>
> ---
> drivers/thermal/mediatek/lvts_thermal.c | 92 +++++++++++++++++++++++++
> 1 file changed, 92 insertions(+)
>
> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
> index 5ea8a9d569ea6..8df7b4c72a658 100644
> --- a/drivers/thermal/mediatek/lvts_thermal.c
> +++ b/drivers/thermal/mediatek/lvts_thermal.c
[..]
> +static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
> + {
> + .cal_offset = { 0x04, 0x08 },
> + .lvts_sensor = {
> + { .dt_id = MT8192_MCU_BIG_CPU0 },
> + { .dt_id = MT8192_MCU_BIG_CPU1 }
> + },
> + .num_lvts_sensor = 2,
> + .offset = 0x0,
> + .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8192,

Hi Balsam,

during the investigation I did to fix the interrupt issues I mentioned in v1, I
noticed that the threshold interrupts (hot, hot to normal, cold), only trigger
when the controller is configured to filtered mode. In immediate mode the
threshold interrupts are not triggered.

So I say we add

.mode = LVTS_MSR_FILTERED_MODE,

for all the controllers here. Same for MT8195, although I guess that'd be better
done in a separate series. And I haven't had time to test more on MT8195 to see
if I can get any interrupts there.

One issue with filtered mode is that the data read is often not ready (valid bit
unset), so most of the time it returns -EAGAIN. But I think that should be easy
to address by reading with a timeout (equal to the measurement interval we
already know), instead of a single time, if on filtered mode.

I'll also try to review the other commits in this series, though that'll have to
wait for next week.

Thanks,
Nícolas