Re: [PATCH 1/2] thermal: mediatek: add support for MT7986 and MT7981

From: Henry Yen (顏修溫)
Date: Tue Nov 29 2022 - 06:54:18 EST


On Mon, 2022-10-31 at 23:07 +0000, Daniel Golle wrote:
> diff --git a/drivers/thermal/mtk_thermal.c
> b/drivers/thermal/mtk_thermal.c
>
> +static int raw_to_mcelsius_v3(struct mtk_thermal *mt, int sensno,
> s32 raw)
> +{
> + s32 tmp;
> +
> + if (raw == 0)
> + return 0;
> +
> + raw &= 0xfff;
> + tmp = 100000 * 15 / 16 * 10000;
> + tmp /= 4096 - 512 + mt->adc_ge;
> + tmp /= 1490;
> + tmp *= raw - mt->vts[sensno] - 2900 - mt->adc_oe + 512;

Hi Daniel,

Regarding the conversion formula, I would suggest following the
original one, i.e., discarding "adc_oe" parameter as shown in [1].
This equation is derived based on hardware-specific theory, so any
arbitrary change could possibly lead to incorrect temperature output.
Thanks.

[1]

https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/baf36c7eef477aae1f8f2653b6c29e2caf48475b%5E%21/#F0


Henry

> +
> + return mt->degc_cali * 500 - tmp;
> +}
> +
> /**
> * mtk_thermal_get_bank - get bank
> * @bank: The bank