Commit bffcd333 authored by Jia-Wei Chang's avatar Jia-Wei Chang Committed by Viresh Kumar

cpufreq: mediatek: Record previous target vproc value

We found the buck voltage may not be exactly the same with what we set
because CPU may share the same buck with other module.
Therefore, we need to record the previous desired value instead of reading
it from regulators.
Signed-off-by: default avatarAndrew-sh.Cheng <andrew-sh.cheng@mediatek.com>
Signed-off-by: default avatarJia-Wei Chang <jia-wei.chang@mediatek.com>
Signed-off-by: default avatarRex-BC Chen <rex-bc.chen@mediatek.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent 4aef4aea
...@@ -40,6 +40,7 @@ struct mtk_cpu_dvfs_info { ...@@ -40,6 +40,7 @@ struct mtk_cpu_dvfs_info {
struct list_head list_head; struct list_head list_head;
int intermediate_voltage; int intermediate_voltage;
bool need_voltage_tracking; bool need_voltage_tracking;
int pre_vproc;
}; };
static LIST_HEAD(dvfs_info_list); static LIST_HEAD(dvfs_info_list);
...@@ -191,11 +192,17 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info, ...@@ -191,11 +192,17 @@ static int mtk_cpufreq_voltage_tracking(struct mtk_cpu_dvfs_info *info,
static int mtk_cpufreq_set_voltage(struct mtk_cpu_dvfs_info *info, int vproc) static int mtk_cpufreq_set_voltage(struct mtk_cpu_dvfs_info *info, int vproc)
{ {
int ret;
if (info->need_voltage_tracking) if (info->need_voltage_tracking)
return mtk_cpufreq_voltage_tracking(info, vproc); ret = mtk_cpufreq_voltage_tracking(info, vproc);
else else
return regulator_set_voltage(info->proc_reg, vproc, ret = regulator_set_voltage(info->proc_reg, vproc,
vproc + VOLT_TOL); MAX_VOLT_LIMIT);
if (!ret)
info->pre_vproc = vproc;
return ret;
} }
static int mtk_cpufreq_set_target(struct cpufreq_policy *policy, static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
...@@ -213,7 +220,12 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy, ...@@ -213,7 +220,12 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
inter_vproc = info->intermediate_voltage; inter_vproc = info->intermediate_voltage;
pre_freq_hz = clk_get_rate(cpu_clk); pre_freq_hz = clk_get_rate(cpu_clk);
pre_vproc = regulator_get_voltage(info->proc_reg);
if (unlikely(info->pre_vproc <= 0))
pre_vproc = regulator_get_voltage(info->proc_reg);
else
pre_vproc = info->pre_vproc;
if (pre_vproc < 0) { if (pre_vproc < 0) {
dev_err(cpu_dev, "invalid Vproc value: %d\n", pre_vproc); dev_err(cpu_dev, "invalid Vproc value: %d\n", pre_vproc);
return pre_vproc; return pre_vproc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment