From: David Wu Date: Fri, 26 Jun 2015 08:15:12 +0000 (+0800) Subject: rk3368: tsadc: add hw shut temp X-Git-Tag: firefly_0821_release~3965 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=1f667f18ffcb3663429964ca70d9b5df5a612058;p=firefly-linux-kernel-4.4.55.git rk3368: tsadc: add hw shut temp if temp reached hw_shut_temp three times continuously, system would power off. Signed-off-by: David Wu --- diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index b3e42d88ee8a..7767d880470c 100755 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "../../arch/arm/mach-rockchip/efuse.h" @@ -123,6 +124,7 @@ struct rockchip_thermal_data { bool logout; bool b_suspend; struct mutex suspend_lock; + int shuttemp_count; void __iomem *regs; @@ -170,6 +172,8 @@ struct rockchip_thermal_data { #define TSADC_TEST #define TSADC_TEST_SAMPLE_TIME 200/* msec */ +#define TSADC_MAX_HW_SHUT_TEMP_COUNT 3 + struct tsadc_table { unsigned long code; long temp; @@ -749,6 +753,17 @@ int rockchip_tsadc_get_temp(int chn, int voltage) if(thermal->logout) printk("cpu temp:[%d], voltage: %d\n" , temp, voltage); + + if (temp > thermal->hw_shut_temp / 1000) + thermal->shuttemp_count++; + else + thermal->shuttemp_count = 0; + if (thermal->shuttemp_count >= TSADC_MAX_HW_SHUT_TEMP_COUNT) { + dev_err(&thermal->pdev->dev, + "critical temperature reached(%ld C),shutting down\n", + thermal->hw_shut_temp / 1000); + orderly_poweroff(true); + } } mutex_unlock(&thermal->suspend_lock);