blob: aa31f2294a9768a3e607a20757ab93ac0eb90ced [file] [log] [blame]
diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c
index b23b6d2..147a224 100644
--- a/drivers/cpufreq/mediatek-cpufreq.c
+++ b/drivers/cpufreq/mediatek-cpufreq.c
@@ -15,6 +15,7 @@
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/thermal.h>
+#include <linux/nvmem-consumer.h>
#define MIN_VOLT_SHIFT (100000)
#define MAX_VOLT_SHIFT (200000)
@@ -539,6 +540,11 @@ static int mtk_cpufreq_init(struct cpufreq_policy *policy)
struct mtk_cpu_dvfs_info *info;
struct cpufreq_frequency_table *freq_table;
int ret;
+ int target_vproc;
+ u8 reg_val;
+ struct nvmem_cell *cell;
+ size_t len;
+ u8 *buf;
info = mtk_cpu_dvfs_info_lookup(policy->cpu);
if (!info) {
@@ -547,6 +553,22 @@ static int mtk_cpufreq_init(struct cpufreq_policy *policy)
return -EINVAL;
}
+ cell = nvmem_cell_get(info->cpu_dev, "calibration-data");
+ if (!IS_ERR(cell)) {
+ buf = (u8 *)nvmem_cell_read(cell, &len);
+ nvmem_cell_put(cell);
+ if (!IS_ERR(buf)) {
+ reg_val = buf[0] & 0x1f;
+ pr_debug("%s: read vbinning value: %d\n", __func__, reg_val);
+ if (reg_val > 0) {
+ target_vproc = 850000 + reg_val * 10000;
+ dev_pm_opp_remove(info->cpu_dev, 1800000000);
+ dev_pm_opp_add(info->cpu_dev, 1800000000, target_vproc);
+ }
+ kfree(buf);
+ }
+ }
+
ret = dev_pm_opp_init_cpufreq_table(info->cpu_dev, &freq_table);
if (ret) {
pr_err("failed to init cpufreq table for cpu%d: %d\n",