summaryrefslogtreecommitdiff
path: root/drivers/cpufreq
diff options
context:
space:
mode:
authorAnson Huang <Anson.Huang@nxp.com>2017-08-25 13:06:24 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commit84db8592b341a907127f0ea06ea170539245ce51 (patch)
tree8c6e3df218690471bcead34a4cf6d884c5d7470a /drivers/cpufreq
parent8d2322a1d90a282751b76098fbff97b602c34415 (diff)
MLK-16165-2 cpufreq: imx8mq: remove non-necessary opp table initialization
For i.MX8MQ, suspend freq can use policy->max after cpu freq table is validated, so no need to get OPP number and MAX frequency for suspend freq now, also add necessary resource free when probe failed. Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/imx8mq-cpufreq.c42
1 files changed, 10 insertions, 32 deletions
diff --git a/drivers/cpufreq/imx8mq-cpufreq.c b/drivers/cpufreq/imx8mq-cpufreq.c
index 073426764904..16feb3fb86b5 100644
--- a/drivers/cpufreq/imx8mq-cpufreq.c
+++ b/drivers/cpufreq/imx8mq-cpufreq.c
@@ -27,7 +27,6 @@ static bool free_opp;
static struct cpufreq_frequency_table *freq_table;
static struct mutex set_cpufreq_lock;
static unsigned int transition_latency;
-static unsigned int suspend_freq;
static struct clk *a53_clk;
static struct clk *arm_a53_src_clk;
static struct clk *arm_pll_clk;
@@ -62,7 +61,7 @@ static int imx8mq_set_target(struct cpufreq_policy *policy, unsigned int index)
dev_dbg(cpu_dev, "%u MHz --> %u MHz\n",
old_freq / 1000, new_freq / 1000);
- if (new_freq == suspend_freq) {
+ if (new_freq == policy->max) {
if (!IS_ERR(dc_reg)) {
ret = regulator_set_voltage_tol(dc_reg, DC_VOLTAGE_MAX, 0);
if (ret) {
@@ -77,7 +76,7 @@ static int imx8mq_set_target(struct cpufreq_policy *policy, unsigned int index)
clk_set_rate(arm_pll_clk, new_freq * 1000);
clk_set_parent(arm_a53_src_clk, arm_pll_out_clk);
- if (old_freq == suspend_freq) {
+ if (old_freq == policy->max) {
if (!IS_ERR(dc_reg)) {
ret = regulator_set_voltage_tol(dc_reg, DC_VOLTAGE_MIN, 0);
if (ret) {
@@ -122,7 +121,6 @@ static int imx8mq_cpufreq_init(struct cpufreq_policy *policy)
policy->clk = a53_clk;
policy->cur = clk_get_rate(a53_clk) / 1000;
- policy->suspend_freq = suspend_freq;
ret = cpufreq_generic_init(policy, freq_table, transition_latency);
if (ret) {
@@ -130,6 +128,8 @@ static int imx8mq_cpufreq_init(struct cpufreq_policy *policy)
return ret;
}
+ policy->suspend_freq = policy->max;
+
return 0;
}
@@ -150,7 +150,7 @@ static struct cpufreq_driver imx8mq_cpufreq_driver = {
static int imx8mq_cpufreq_probe(struct platform_device *pdev)
{
struct device_node *np;
- int num, ret;
+ int ret;
cpu_dev = get_cpu_device(0);
if (!cpu_dev) {
@@ -179,28 +179,10 @@ static int imx8mq_cpufreq_probe(struct platform_device *pdev)
dc_reg = regulator_get_optional(cpu_dev, "dc");
- /*
- * We expect an OPP table supplied by platform.
- * Just, incase the platform did not supply the OPP
- * table, it will try to get it.
- */
- num = dev_pm_opp_get_opp_count(cpu_dev);
- if (num < 0) {
- ret = dev_pm_opp_of_add_table(cpu_dev);
- if (ret < 0) {
- dev_err(cpu_dev, "failed to init OPP table: %d\n", ret);
- goto put_clk;
- }
-
- /* Because we have added the OPPs here, we must free them */
- free_opp = true;
-
- num = dev_pm_opp_get_opp_count(cpu_dev);
- if (num < 0) {
- ret = num;
- dev_err(cpu_dev, "no OPP table is found: %d\n", ret);
- goto out_free_opp;
- }
+ ret = dev_pm_opp_of_add_table(cpu_dev);
+ if (ret < 0) {
+ dev_err(cpu_dev, "failed to init OPP table: %d\n", ret);
+ goto put_clk;
}
ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
@@ -209,9 +191,6 @@ static int imx8mq_cpufreq_probe(struct platform_device *pdev)
goto out_free_opp;
}
- /* use MAX freq to suspend */
- suspend_freq = freq_table[num - 1].frequency;
-
if (of_property_read_u32(np, "clock-latency", &transition_latency))
transition_latency = CPUFREQ_ETERNAL;
@@ -231,8 +210,7 @@ static int imx8mq_cpufreq_probe(struct platform_device *pdev)
free_freq_table:
dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
out_free_opp:
- if (free_opp)
- dev_pm_opp_of_remove_table(cpu_dev);
+ dev_pm_opp_of_remove_table(cpu_dev);
put_clk:
if (!IS_ERR(a53_clk))
clk_put(a53_clk);