From 78a2ebce79c92202adf632b38636258e154ea03f Mon Sep 17 00:00:00 2001 From: Finley Xiao Date: Thu, 9 Jan 2020 17:16:55 +0800 Subject: [PATCH] soc: rockchip: system_monitor: set the initial state to low temprature The all cpus of big cluster will be closed when suspend, and cpu is booted before thermal when resume, the cpu frequency and voltage will be changed before thermal start, if the ambient temperature is low, the voltage may not be enough, so this path set the initial state to low temperature state and change the OPP Table before cpufreq start. Change-Id: I37ae1086e05df4dc4391f80ce5cc25a22d217b4a Signed-off-by: Finley Xiao --- .../soc/rockchip/rockchip_system_monitor.c | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/soc/rockchip/rockchip_system_monitor.c b/drivers/soc/rockchip/rockchip_system_monitor.c index 5cd2c3a17c4d..cffb408cbc35 100644 --- a/drivers/soc/rockchip/rockchip_system_monitor.c +++ b/drivers/soc/rockchip/rockchip_system_monitor.c @@ -900,18 +900,36 @@ rockchip_system_monitor_wide_temp_init(struct monitor_dev_info *info) { int ret, temp; + /* + * set the init state to low temperature that the voltage will be enough + * when cpu up at low temperature. + */ + if (!info->is_low_temp) { + if (info->opp_table) + rockchip_adjust_low_temp_opp_volt(info, true); + info->wide_temp_limit = info->low_limit; + info->is_low_temp = true; + } + ret = thermal_zone_get_temp(system_monitor->tz, &temp); if (ret || temp == THERMAL_TEMP_INVALID) { dev_err(info->dev, "failed to read out thermal zone (%d)\n", ret); return; } - if (temp < info->low_temp) { + + if (temp > info->high_temp) { if (info->opp_table) - rockchip_adjust_low_temp_opp_volt(info, true); - info->wide_temp_limit = info->low_limit; - } else if (temp > info->high_temp) { + rockchip_adjust_low_temp_opp_volt(info, false); + info->is_low_temp = false; + info->wide_temp_limit = info->high_limit; + info->is_high_temp = true; + } else if (temp > (info->low_temp + info->temp_hysteresis)) { + if (info->opp_table) + rockchip_adjust_low_temp_opp_volt(info, false); + info->is_low_temp = false; + info->wide_temp_limit = 0; } }