cpufreq: rockchip: parse 'leakage-scaling-sel'
authorFinley Xiao <finley.xiao@rock-chips.com>
Mon, 24 Apr 2017 11:52:01 +0000 (19:52 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 25 Apr 2017 06:44:47 +0000 (14:44 +0800)
Change-Id: Ia473f960dbf0d1cc6c68fdd0e67b1d5cd8ddfa17
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
drivers/cpufreq/rockchip-cpufreq.c

index c2f7b1c61319d3aacabea32cec67e5719848bba9..136c0d04fcec2c5ac7d0e35d0be236d4549c6adf 100644 (file)
@@ -13,6 +13,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/clk.h>
 #include <linux/cpu.h>
 #include <linux/err.h>
 #include <linux/init.h>
@@ -24,6 +25,8 @@
 #include <linux/pm_opp.h>
 #include <linux/slab.h>
 
+#include "../clk/rockchip/clk.h"
+
 #define MAX_CLUSTERS           2
 #define MAX_PROP_NAME_LEN      3
 #define LEAKAGE_TABLE_END      ~1
@@ -186,7 +189,8 @@ static int rockchip_cpufreq_of_parse_dt(struct device *dev,
        int (*get_soc_version)(struct device_node *np, int *soc_version);
        const struct of_device_id *match;
        struct device_node *node, *np;
-       int ret;
+       struct clk *clk;
+       int ret, lkg_scaling_sel = -1;
 
        np = of_parse_phandle(dev->of_node, "operating-points-v2", 0);
        if (!np) {
@@ -221,6 +225,25 @@ static int rockchip_cpufreq_of_parse_dt(struct device *dev,
                return ret;
        }
 
+       ret = rockchip_get_leakage_sel(np, "leakage-scaling-sel",
+                                      cluster->leakage,
+                                      &lkg_scaling_sel);
+       if (ret) {
+               dev_err(dev, "Failed to get scaling-sel\n");
+               return ret;
+       } else if (lkg_scaling_sel >= 0) {
+               clk = of_clk_get_by_name(np, NULL);
+               if (IS_ERR(clk)) {
+                       dev_err(dev, "Failed to get opp clk");
+                       return PTR_ERR(clk);
+               }
+               ret = rockchip_pll_clk_adaptive_scaling(clk, lkg_scaling_sel);
+               if (ret) {
+                       dev_err(dev, "Failed to adaptive scaling\n");
+                       return ret;
+               }
+       }
+
        return 0;
 }