diff options
author | Koen Kooi <koen@dominion.thruhere.net> | 2011-05-24 09:33:43 +0200 |
---|---|---|
committer | Koen Kooi <koen@dominion.thruhere.net> | 2011-05-24 09:34:30 +0200 |
commit | e2ccc5ca9985c70387664b5923af83c9dcb1e4aa (patch) | |
tree | 987730958e2a49c76f7cda2668759ee13c923a95 /recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-hotplug/0001-cpufreq-helpers-for-walking-the-frequency-table.patch | |
parent | 5f38b5661d5ec24cc863e5ffc2d84130a8ca9c25 (diff) | |
download | openembedded-core-contrib-e2ccc5ca9985c70387664b5923af83c9dcb1e4aa.tar.gz |
linux-omap 2.6.39: refresh patchset
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Diffstat (limited to 'recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-hotplug/0001-cpufreq-helpers-for-walking-the-frequency-table.patch')
-rw-r--r-- | recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-hotplug/0001-cpufreq-helpers-for-walking-the-frequency-table.patch | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-hotplug/0001-cpufreq-helpers-for-walking-the-frequency-table.patch b/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-hotplug/0001-cpufreq-helpers-for-walking-the-frequency-table.patch new file mode 100644 index 0000000000..e8a250b387 --- /dev/null +++ b/recipes-kernel/linux/linux-omap-2.6.39/pm/linux-omap-2.6.39-ti-pm-wip-cpufreq-hotplug/0001-cpufreq-helpers-for-walking-the-frequency-table.patch @@ -0,0 +1,134 @@ +From b581872eacd6342a890b1c6d2596c16fac5875b5 Mon Sep 17 00:00:00 2001 +From: Mike Turquette <mturquette@ti.com> +Date: Tue, 17 May 2011 09:35:54 -0500 +Subject: [PATCH 1/2] cpufreq: helpers for walking the frequency table + +Two new functions for getting the next higher and next lower frequencies +in the cpufreq table, based upon a frequency supplied in kHz. + +This is useful for cpufreq governors that do not target frequencies +based upon a percentage or a pre-determined value, but instead access +the cpufreq table directly. + +Signed-off-by: Mike Turquette <mturquette@ti.com> +Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com> +Signed-off-by: Koen Kooi <koen@dominion.thruhere.net> +--- + drivers/cpufreq/freq_table.c | 73 ++++++++++++++++++++++++++++++++++++++++++ + include/linux/cpufreq.h | 9 +++++ + 2 files changed, 82 insertions(+), 0 deletions(-) + +diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c +index 0543221..11a307b 100644 +--- a/drivers/cpufreq/freq_table.c ++++ b/drivers/cpufreq/freq_table.c +@@ -13,6 +13,7 @@ + #include <linux/module.h> + #include <linux/init.h> + #include <linux/cpufreq.h> ++#include <linux/err.h> + + #define dprintk(msg...) \ + cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "freq-table", msg) +@@ -174,6 +175,78 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, + } + EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target); + ++int cpufreq_frequency_table_next_lowest(struct cpufreq_policy *policy, ++ struct cpufreq_frequency_table *table, int *index) ++{ ++ unsigned int cur_freq; ++ unsigned int next_lowest_freq; ++ int optimal_index = -1; ++ int i = 0; ++ ++ if (!policy || IS_ERR(policy) || !table || IS_ERR(table) || ++ !index || IS_ERR(index)) ++ return -ENOMEM; ++ ++ cur_freq = policy->cur; ++ next_lowest_freq = policy->min; ++ ++ /* we're at the lowest frequency in the table already, bail out */ ++ if (cur_freq == policy->min) ++ return -EINVAL; ++ ++ /* walk the list, find closest freq to cur_freq that is below it */ ++ while(table[i].frequency != CPUFREQ_TABLE_END) { ++ if (table[i].frequency < cur_freq && ++ table[i].frequency >= next_lowest_freq) { ++ next_lowest_freq = table[i].frequency; ++ optimal_index = table[i].index; ++ } ++ ++ i++; ++ } ++ ++ *index = optimal_index; ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(cpufreq_frequency_table_next_lowest); ++ ++int cpufreq_frequency_table_next_highest(struct cpufreq_policy *policy, ++ struct cpufreq_frequency_table *table, int *index) ++{ ++ unsigned int cur_freq; ++ unsigned int next_higher_freq; ++ int optimal_index = -1; ++ int i = 0; ++ ++ if (!policy || IS_ERR(policy) || !table || IS_ERR(table) || ++ !index || IS_ERR(index)) ++ return -ENOMEM; ++ ++ cur_freq = policy->cur; ++ next_higher_freq = policy->max; ++ ++ /* we're at the highest frequency in the table already, bail out */ ++ if (cur_freq == policy->max) ++ return -EINVAL; ++ ++ /* walk the list, find closest freq to cur_freq that is above it */ ++ while(table[i].frequency != CPUFREQ_TABLE_END) { ++ if (table[i].frequency > cur_freq && ++ table[i].frequency <= next_higher_freq) { ++ next_higher_freq = table[i].frequency; ++ optimal_index = table[i].index; ++ } ++ ++ i++; ++ } ++ ++ *index = optimal_index; ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(cpufreq_frequency_table_next_highest); ++ + static DEFINE_PER_CPU(struct cpufreq_frequency_table *, cpufreq_show_table); + /** + * show_available_freqs - show available frequencies for the specified CPU +diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h +index 9343dd3..a38fca8 100644 +--- a/include/linux/cpufreq.h ++++ b/include/linux/cpufreq.h +@@ -396,6 +396,15 @@ void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, + + void cpufreq_frequency_table_put_attr(unsigned int cpu); + ++/* the following are for use in governors, or anywhere else */ ++extern int cpufreq_frequency_table_next_lowest(struct cpufreq_policy *policy, ++ struct cpufreq_frequency_table *table, ++ int *index); ++ ++extern int cpufreq_frequency_table_next_highest(struct cpufreq_policy *policy, ++ struct cpufreq_frequency_table *table, ++ int *index); ++ + + /********************************************************************* + * UNIFIED DEBUG HELPERS * +-- +1.6.6.1 + |