diff options
| -rw-r--r-- | drivers/cpufreq/tegra-cpufreq.c | 46 |
1 files changed, 5 insertions, 41 deletions
diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c index e652c1bd8d0f..bcfed7761029 100644 --- a/drivers/cpufreq/tegra-cpufreq.c +++ b/drivers/cpufreq/tegra-cpufreq.c | |||
| @@ -26,7 +26,6 @@ | |||
| 26 | #include <linux/err.h> | 26 | #include <linux/err.h> |
| 27 | #include <linux/clk.h> | 27 | #include <linux/clk.h> |
| 28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
| 29 | #include <linux/suspend.h> | ||
| 30 | 29 | ||
| 31 | static struct cpufreq_frequency_table freq_table[] = { | 30 | static struct cpufreq_frequency_table freq_table[] = { |
| 32 | { .frequency = 216000 }, | 31 | { .frequency = 216000 }, |
| @@ -47,9 +46,6 @@ static struct clk *pll_x_clk; | |||
| 47 | static struct clk *pll_p_clk; | 46 | static struct clk *pll_p_clk; |
| 48 | static struct clk *emc_clk; | 47 | static struct clk *emc_clk; |
| 49 | 48 | ||
| 50 | static DEFINE_MUTEX(tegra_cpu_lock); | ||
| 51 | static bool is_suspended; | ||
| 52 | |||
| 53 | static int tegra_cpu_clk_set_rate(unsigned long rate) | 49 | static int tegra_cpu_clk_set_rate(unsigned long rate) |
| 54 | { | 50 | { |
| 55 | int ret; | 51 | int ret; |
| @@ -112,42 +108,9 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy, | |||
| 112 | 108 | ||
| 113 | static int tegra_target(struct cpufreq_policy *policy, unsigned int index) | 109 | static int tegra_target(struct cpufreq_policy *policy, unsigned int index) |
| 114 | { | 110 | { |
| 115 | int ret = -EBUSY; | 111 | return tegra_update_cpu_speed(policy, freq_table[index].frequency); |
| 116 | |||
| 117 | mutex_lock(&tegra_cpu_lock); | ||
| 118 | |||
| 119 | if (!is_suspended) | ||
| 120 | ret = tegra_update_cpu_speed(policy, | ||
| 121 | freq_table[index].frequency); | ||
| 122 | |||
| 123 | mutex_unlock(&tegra_cpu_lock); | ||
| 124 | return ret; | ||
| 125 | } | 112 | } |
| 126 | 113 | ||
| 127 | static int tegra_pm_notify(struct notifier_block *nb, unsigned long event, | ||
| 128 | void *dummy) | ||
| 129 | { | ||
| 130 | mutex_lock(&tegra_cpu_lock); | ||
| 131 | if (event == PM_SUSPEND_PREPARE) { | ||
| 132 | struct cpufreq_policy *policy = cpufreq_cpu_get(0); | ||
| 133 | is_suspended = true; | ||
| 134 | pr_info("Tegra cpufreq suspend: setting frequency to %d kHz\n", | ||
| 135 | freq_table[0].frequency); | ||
| 136 | if (clk_get_rate(cpu_clk) / 1000 != freq_table[0].frequency) | ||
| 137 | tegra_update_cpu_speed(policy, freq_table[0].frequency); | ||
| 138 | cpufreq_cpu_put(policy); | ||
| 139 | } else if (event == PM_POST_SUSPEND) { | ||
| 140 | is_suspended = false; | ||
| 141 | } | ||
| 142 | mutex_unlock(&tegra_cpu_lock); | ||
| 143 | |||
| 144 | return NOTIFY_OK; | ||
| 145 | } | ||
| 146 | |||
| 147 | static struct notifier_block tegra_cpu_pm_notifier = { | ||
| 148 | .notifier_call = tegra_pm_notify, | ||
| 149 | }; | ||
| 150 | |||
| 151 | static int tegra_cpu_init(struct cpufreq_policy *policy) | 114 | static int tegra_cpu_init(struct cpufreq_policy *policy) |
| 152 | { | 115 | { |
| 153 | int ret; | 116 | int ret; |
| @@ -166,10 +129,8 @@ static int tegra_cpu_init(struct cpufreq_policy *policy) | |||
| 166 | return ret; | 129 | return ret; |
| 167 | } | 130 | } |
| 168 | 131 | ||
| 169 | if (policy->cpu == 0) | ||
| 170 | register_pm_notifier(&tegra_cpu_pm_notifier); | ||
| 171 | |||
| 172 | policy->clk = cpu_clk; | 132 | policy->clk = cpu_clk; |
| 133 | policy->suspend_freq = freq_table[0].frequency; | ||
| 173 | return 0; | 134 | return 0; |
| 174 | } | 135 | } |
| 175 | 136 | ||
| @@ -190,6 +151,9 @@ static struct cpufreq_driver tegra_cpufreq_driver = { | |||
| 190 | .exit = tegra_cpu_exit, | 151 | .exit = tegra_cpu_exit, |
| 191 | .name = "tegra", | 152 | .name = "tegra", |
| 192 | .attr = cpufreq_generic_attr, | 153 | .attr = cpufreq_generic_attr, |
| 154 | #ifdef CONFIG_PM | ||
| 155 | .suspend = cpufreq_generic_suspend, | ||
| 156 | #endif | ||
| 193 | }; | 157 | }; |
| 194 | 158 | ||
| 195 | static int __init tegra_cpufreq_init(void) | 159 | static int __init tegra_cpufreq_init(void) |
