ARM: tegra11: clock: Add direct access to CPU backup source
Alex Frid [Fri, 18 Jan 2013 20:31:22 +0000 (12:31 -0800)]
Added CPU backup source access API for CPU idle driver to directly
manipulate rate underneath cpufreq governor.

Change-Id: I837e591148c5ea82e036c6b236c115690313d2c2
Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-on: http://git-master/r/192490
Reviewed-on: http://git-master/r/194440
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bo Yan <byan@nvidia.com>

arch/arm/mach-tegra/cpuidle.h
arch/arm/mach-tegra/tegra11_clocks.c

index 86e6bdd..a9fe5a7 100644 (file)
@@ -41,6 +41,7 @@ int tegra2_cpuidle_init_soc(struct tegra_cpuidle_ops *ops);
 int tegra3_cpuidle_init_soc(struct tegra_cpuidle_ops *ops);
 int tegra11x_cpuidle_init_soc(struct tegra_cpuidle_ops *ops);
 int tegra14x_cpuidle_init_soc(struct tegra_cpuidle_ops *ops);
+int tegra11_cpu_backup_rate_exchange(unsigned long *rate);
 
 static inline int tegra_cpuidle_init_soc(struct tegra_cpuidle_ops *ops)
 {
@@ -58,6 +59,15 @@ static inline int tegra_cpuidle_init_soc(struct tegra_cpuidle_ops *ops)
 #endif
 }
 
+static inline int tegra_cpu_backup_rate_exchange(unsigned long *rate)
+{
+#ifdef CONFIG_ARCH_TEGRA_11x_SOC
+       return tegra11_cpu_backup_rate_exchange(rate);
+#else
+       return -ENOSYS;
+#endif
+}
+
 static inline void tegra_pd_set_global_latency(struct cpuidle_state *state)
 {
 #ifdef CONFIG_ARCH_TEGRA_2x_SOC
index a0853bb..1a01876 100644 (file)
@@ -6816,6 +6816,18 @@ static void tegra11_init_one_clock(struct clk *c)
        clkdev_add(&c->lookup);
 }
 
+int tegra11_cpu_backup_rate_exchange(unsigned long *rate)
+{
+       struct clk *backup = tegra_clk_cpu_cmplx.parent->u.cpu.backup;
+       unsigned long old_rate = clk_get_rate(backup);
+       unsigned long new_rate = min(
+               *rate, tegra_clk_cpu_cmplx.parent->u.cpu.backup_rate);
+       *rate = old_rate;
+       if (new_rate != old_rate)
+               return clk_set_rate(backup, new_rate);
+       return 0;
+}
+
 void tegra_edp_throttle_cpu_now(u8 factor)
 {
        /* empty definition for tegra11 */