MLK-9739 cpufreq: imx: add request busfreq support for cpufreq
authorBai Ping <b51503@freescale.com>
Fri, 24 Oct 2014 08:13:51 +0000 (16:13 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:48:39 +0000 (14:48 -0500)
Request high bus frequency before scaling up the CPU frequency
and release high bus frequency after scaling down the CPU frequency

Doing so makes a balance between high performance and lower power
consumption.

Signed-off-by: Bai Ping <b51503@freescale.com>
(cherry picked from commit 35c91da2591a70858d5eec184c662851e39082d2)

drivers/cpufreq/imx6q-cpufreq.c

index e63fa32..4059228 100644 (file)
@@ -6,6 +6,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/busfreq-imx.h>
 #include <linux/clk.h>
 #include <linux/cpu.h>
 #include <linux/cpufreq.h>
@@ -71,6 +72,12 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
        dev_dbg(cpu_dev, "%u MHz, %ld mV --> %u MHz, %ld mV\n",
                old_freq / 1000, volt_old / 1000,
                new_freq / 1000, volt / 1000);
+       /*
+        * CPU freq is increasing, so need to ensure
+        * that bus frequency is increased too.
+        */
+       if (old_freq == freq_table[0].frequency)
+               request_bus_freq(BUS_FREQ_HIGH);
 
        /* scaling up?  scale voltage before frequency */
        if (new_freq > old_freq) {
@@ -159,6 +166,12 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
                        }
                }
        }
+       /*
+        * If CPU is dropped to the lowest level, release the need
+        * for a high bus frequency.
+        */
+       if (new_freq == freq_table[0].frequency)
+               release_bus_freq(BUS_FREQ_HIGH);
 
        return 0;
 }