Re: [v2,2/3] thermal: mediatek: Add LVTS drivers for SoC theraml zones
From: Nicolas Boichat <hidden>
Date: 2021-02-14 01:59:58
Also in:
linux-arm-kernel, linux-mediatek, linux-pm, lkml
On Fri, Jan 29, 2021 at 5:40 PM Michael Kao [off-list ref] wrote:
quoted hunk
Add a LVTS (Low voltage thermal sensor) driver to report junction temperatures in Mediatek SoC and register the maximum temperature of sensors and each sensor as a thermal zone. Signed-off-by: Yu-Chia Chang <redacted> Signed-off-by: Michael Kao <redacted> --- drivers/thermal/mediatek/Kconfig | 10 + drivers/thermal/mediatek/Makefile | 1 + drivers/thermal/mediatek/soc_temp_lvts.c | 1287 ++++++++++++++++++++++ drivers/thermal/mediatek/soc_temp_lvts.h | 312 ++++++ 4 files changed, 1610 insertions(+) create mode 100644 drivers/thermal/mediatek/soc_temp_lvts.c create mode 100644 drivers/thermal/mediatek/soc_temp_lvts.h [snip]diff --git a/drivers/thermal/mediatek/Makefile b/drivers/thermal/mediatek/Makefile index f75313ddce5e..16ce166e5916 100644 --- a/drivers/thermal/mediatek/Makefile +++ b/drivers/thermal/mediatek/Makefile@@ -1 +1,2 @@ obj-$(CONFIG_MTK_SOC_THERMAL) += soc_temp.o +obj-$(CONFIG_MTK_SOC_THERMAL_LVTS) += soc_temp_lvts.odiff --git a/drivers/thermal/mediatek/soc_temp_lvts.c b/drivers/thermal/mediatek/soc_temp_lvts.c new file mode 100644 index 000000000000..b56c2cd3cb39 --- /dev/null +++ b/drivers/thermal/mediatek/soc_temp_lvts.c@@ -0,0 +1,1287 @@[snip] + +static unsigned int lvts_temp_to_raw(struct formula_coeff *co, int temp) +{ + unsigned int msr_raw; + + msr_raw = ((long long)((co->golden_temp * 500 + co->b - temp)) << 14) + / (-1 * co->a);
This fails to build test on arm (32-bit):
ERROR: "__aeabi_ldivmod" [drivers/thermal/mediatek/soc_temp_lvts.ko] undefined!
Recommend using div_s64:
msr_raw = div_s64((s64)((co->golden_temp * 500 + co->b - temp)) << 14,
-1 * co->a);
+ + return msr_raw; +} [snip]