summaryrefslogtreecommitdiff
path: root/drivers/cpufreq/imx8mq-cpufreq.c
diff options
context:
space:
mode:
authorAnson Huang <Anson.Huang@nxp.com>2017-08-25 13:06:24 +0800
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:28:14 +0800
commit5542b5a931eaac90ae38624700cdfca723a08073 (patch)
tree5a6dcc957d1f80455a2eea0b61c85c0c09640859 /drivers/cpufreq/imx8mq-cpufreq.c
parentd1096697124beb82bea739b66c3bff11c498868f (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/imx8mq-cpufreq.c')
-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 63a9006d2855..a55b3399e6ca 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) {
@@ -121,7 +120,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) {
@@ -129,6 +127,8 @@ static int imx8mq_cpufreq_init(struct cpufreq_policy *policy)
return ret;
}
+ policy->suspend_freq = policy->max;
+
return 0;
}
@@ -149,7 +149,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) {
@@ -178,28 +178,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);
@@ -208,9 +190,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;
@@ -230,8 +209,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);