summaryrefslogtreecommitdiffstats
path: root/extras/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
diff options
context:
space:
mode:
Diffstat (limited to 'extras/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--extras/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.patch134
1 files changed, 134 insertions, 0 deletions
diff --git a/extras/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/extras/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 00000000..576cd08f
--- /dev/null
+++ b/extras/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 @@
1From 8726f3a7218b72a1003904a24bb000b3e4f9b4d1 Mon Sep 17 00:00:00 2001
2From: Mike Turquette <mturquette@ti.com>
3Date: Tue, 17 May 2011 09:35:54 -0500
4Subject: [PATCH 1/2] cpufreq: helpers for walking the frequency table
5
6Two new functions for getting the next higher and next lower frequencies
7in the cpufreq table, based upon a frequency supplied in kHz.
8
9This is useful for cpufreq governors that do not target frequencies
10based upon a percentage or a pre-determined value, but instead access
11the cpufreq table directly.
12
13Signed-off-by: Mike Turquette <mturquette@ti.com>
14Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
15Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
16---
17 drivers/cpufreq/freq_table.c | 73 ++++++++++++++++++++++++++++++++++++++++++
18 include/linux/cpufreq.h | 9 +++++
19 2 files changed, 82 insertions(+), 0 deletions(-)
20
21diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
22index 0543221..11a307b 100644
23--- a/drivers/cpufreq/freq_table.c
24+++ b/drivers/cpufreq/freq_table.c
25@@ -13,6 +13,7 @@
26 #include <linux/module.h>
27 #include <linux/init.h>
28 #include <linux/cpufreq.h>
29+#include <linux/err.h>
30
31 #define dprintk(msg...) \
32 cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "freq-table", msg)
33@@ -174,6 +175,78 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
34 }
35 EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target);
36
37+int cpufreq_frequency_table_next_lowest(struct cpufreq_policy *policy,
38+ struct cpufreq_frequency_table *table, int *index)
39+{
40+ unsigned int cur_freq;
41+ unsigned int next_lowest_freq;
42+ int optimal_index = -1;
43+ int i = 0;
44+
45+ if (!policy || IS_ERR(policy) || !table || IS_ERR(table) ||
46+ !index || IS_ERR(index))
47+ return -ENOMEM;
48+
49+ cur_freq = policy->cur;
50+ next_lowest_freq = policy->min;
51+
52+ /* we're at the lowest frequency in the table already, bail out */
53+ if (cur_freq == policy->min)
54+ return -EINVAL;
55+
56+ /* walk the list, find closest freq to cur_freq that is below it */
57+ while(table[i].frequency != CPUFREQ_TABLE_END) {
58+ if (table[i].frequency < cur_freq &&
59+ table[i].frequency >= next_lowest_freq) {
60+ next_lowest_freq = table[i].frequency;
61+ optimal_index = table[i].index;
62+ }
63+
64+ i++;
65+ }
66+
67+ *index = optimal_index;
68+
69+ return 0;
70+}
71+EXPORT_SYMBOL_GPL(cpufreq_frequency_table_next_lowest);
72+
73+int cpufreq_frequency_table_next_highest(struct cpufreq_policy *policy,
74+ struct cpufreq_frequency_table *table, int *index)
75+{
76+ unsigned int cur_freq;
77+ unsigned int next_higher_freq;
78+ int optimal_index = -1;
79+ int i = 0;
80+
81+ if (!policy || IS_ERR(policy) || !table || IS_ERR(table) ||
82+ !index || IS_ERR(index))
83+ return -ENOMEM;
84+
85+ cur_freq = policy->cur;
86+ next_higher_freq = policy->max;
87+
88+ /* we're at the highest frequency in the table already, bail out */
89+ if (cur_freq == policy->max)
90+ return -EINVAL;
91+
92+ /* walk the list, find closest freq to cur_freq that is above it */
93+ while(table[i].frequency != CPUFREQ_TABLE_END) {
94+ if (table[i].frequency > cur_freq &&
95+ table[i].frequency <= next_higher_freq) {
96+ next_higher_freq = table[i].frequency;
97+ optimal_index = table[i].index;
98+ }
99+
100+ i++;
101+ }
102+
103+ *index = optimal_index;
104+
105+ return 0;
106+}
107+EXPORT_SYMBOL_GPL(cpufreq_frequency_table_next_highest);
108+
109 static DEFINE_PER_CPU(struct cpufreq_frequency_table *, cpufreq_show_table);
110 /**
111 * show_available_freqs - show available frequencies for the specified CPU
112diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
113index 9343dd3..a38fca8 100644
114--- a/include/linux/cpufreq.h
115+++ b/include/linux/cpufreq.h
116@@ -396,6 +396,15 @@ void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
117
118 void cpufreq_frequency_table_put_attr(unsigned int cpu);
119
120+/* the following are for use in governors, or anywhere else */
121+extern int cpufreq_frequency_table_next_lowest(struct cpufreq_policy *policy,
122+ struct cpufreq_frequency_table *table,
123+ int *index);
124+
125+extern int cpufreq_frequency_table_next_highest(struct cpufreq_policy *policy,
126+ struct cpufreq_frequency_table *table,
127+ int *index);
128+
129
130 /*********************************************************************
131 * UNIFIED DEBUG HELPERS *
132--
1331.6.6.1
134