From eb910e20eecb4466c018a6d854eeb322cb7684c8 Mon Sep 17 00:00:00 2001 From: Finley Xiao Date: Mon, 7 Mar 2022 10:14:06 +0800 Subject: [PATCH] soc: rockchip_system_monitor: Add support to change mem volt when low temp Signed-off-by: Finley Xiao Change-Id: I7ce9959bb56617c2fc1111d047af5ec7e88ce60e --- drivers/soc/rockchip/rockchip_system_monitor.c | 18 ++++++++++++++++++ include/soc/rockchip/rockchip_system_monitor.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/drivers/soc/rockchip/rockchip_system_monitor.c b/drivers/soc/rockchip/rockchip_system_monitor.c index 824fb4ae67cc..b8ea29e6210c 100644 --- a/drivers/soc/rockchip/rockchip_system_monitor.c +++ b/drivers/soc/rockchip/rockchip_system_monitor.c @@ -523,6 +523,8 @@ static int rockchip_init_temp_opp_table(struct monitor_dev_info *info) info->opp_table[i].rate = opp->rate; info->opp_table[i].volt = opp->supplies[0].u_volt; info->opp_table[i].max_volt = opp->supplies[0].u_volt_max; + if (opp_table->regulator_count > 1) + info->opp_table[i].mem_volt = opp->supplies[1].u_volt; if (opp->supplies[0].u_volt <= info->high_temp_max_volt) { if (!reach_high_temp_max_volt) @@ -814,11 +816,27 @@ static int rockchip_adjust_low_temp_opp_volt(struct monitor_dev_info *info, opp->supplies[0].u_volt = info->opp_table[i].low_temp_volt; opp->supplies[0].u_volt_min = opp->supplies[0].u_volt; + if (opp_table->regulator_count > 1) { + opp->supplies[1].u_volt_max = + opp->supplies[0].u_volt_max; + opp->supplies[1].u_volt = + opp->supplies[0].u_volt; + opp->supplies[1].u_volt_min = + opp->supplies[0].u_volt_min; + } } else { opp->supplies[0].u_volt_min = info->opp_table[i].volt; opp->supplies[0].u_volt = opp->supplies[0].u_volt_min; opp->supplies[0].u_volt_max = info->opp_table[i].max_volt; + if (opp_table->regulator_count > 1) { + opp->supplies[1].u_volt_min = + info->opp_table[i].mem_volt; + opp->supplies[1].u_volt = + opp->supplies[1].u_volt_min; + opp->supplies[1].u_volt_max = + info->opp_table[i].max_volt; + } } i++; } diff --git a/include/soc/rockchip/rockchip_system_monitor.h b/include/soc/rockchip/rockchip_system_monitor.h index f6821c305bc2..25dfe6421e86 100644 --- a/include/soc/rockchip/rockchip_system_monitor.h +++ b/include/soc/rockchip/rockchip_system_monitor.h @@ -26,12 +26,14 @@ struct temp_freq_table { * struct temp_opp_table - System monitor device OPP description structure * @rate: Frequency in hertz * @volt: Target voltage in microvolt + * @mem_volt: Target voltage for memory in microvolt * @low_temp_volt: Target voltage when low temperature, in microvolt * @max_volt: Maximum voltage in microvolt */ struct temp_opp_table { unsigned long rate; unsigned long volt; + unsigned long mem_volt; unsigned long low_temp_volt; unsigned long max_volt; };