aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/Kconfig3
-rw-r--r--drivers/cpufreq/cpufreq.c33
-rw-r--r--drivers/cpufreq/cpufreq_userspace.c40
-rw-r--r--drivers/cpufreq/freq_table.c2
4 files changed, 38 insertions, 40 deletions
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 721f86f4f008..c159ae64eeb2 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -9,9 +9,6 @@ config CPU_FREQ
9 clock speed, you need to either enable a dynamic cpufreq governor 9 clock speed, you need to either enable a dynamic cpufreq governor
10 (see below) after boot, or use a userspace tool. 10 (see below) after boot, or use a userspace tool.
11 11
12 To compile this driver as a module, choose M here: the
13 module will be called cpufreq.
14
15 For details, take a look at <file:Documentation/cpu-freq>. 12 For details, take a look at <file:Documentation/cpu-freq>.
16 13
17 If in doubt, say N. 14 If in doubt, say N.
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index b730d6709529..64926aa990db 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -287,7 +287,7 @@ static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
287 if (!l_p_j_ref_freq) { 287 if (!l_p_j_ref_freq) {
288 l_p_j_ref = loops_per_jiffy; 288 l_p_j_ref = loops_per_jiffy;
289 l_p_j_ref_freq = ci->old; 289 l_p_j_ref_freq = ci->old;
290 dprintk("saving %lu as reference value for loops_per_jiffy;" 290 dprintk("saving %lu as reference value for loops_per_jiffy; "
291 "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq); 291 "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq);
292 } 292 }
293 if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) || 293 if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) ||
@@ -295,7 +295,7 @@ static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
295 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { 295 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) {
296 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, 296 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq,
297 ci->new); 297 ci->new);
298 dprintk("scaling loops_per_jiffy to %lu" 298 dprintk("scaling loops_per_jiffy to %lu "
299 "for frequency %u kHz\n", loops_per_jiffy, ci->new); 299 "for frequency %u kHz\n", loops_per_jiffy, ci->new);
300 } 300 }
301} 301}
@@ -601,6 +601,31 @@ static ssize_t show_affected_cpus (struct cpufreq_policy * policy, char *buf)
601 return i; 601 return i;
602} 602}
603 603
604static ssize_t store_scaling_setspeed(struct cpufreq_policy *policy,
605 const char *buf, size_t count)
606{
607 unsigned int freq = 0;
608 unsigned int ret;
609
610 if (!policy->governor->store_setspeed)
611 return -EINVAL;
612
613 ret = sscanf(buf, "%u", &freq);
614 if (ret != 1)
615 return -EINVAL;
616
617 policy->governor->store_setspeed(policy, freq);
618
619 return count;
620}
621
622static ssize_t show_scaling_setspeed(struct cpufreq_policy *policy, char *buf)
623{
624 if (!policy->governor->show_setspeed)
625 return sprintf(buf, "<unsupported>\n");
626
627 return policy->governor->show_setspeed(policy, buf);
628}
604 629
605#define define_one_ro(_name) \ 630#define define_one_ro(_name) \
606static struct freq_attr _name = \ 631static struct freq_attr _name = \
@@ -624,6 +649,7 @@ define_one_ro(affected_cpus);
624define_one_rw(scaling_min_freq); 649define_one_rw(scaling_min_freq);
625define_one_rw(scaling_max_freq); 650define_one_rw(scaling_max_freq);
626define_one_rw(scaling_governor); 651define_one_rw(scaling_governor);
652define_one_rw(scaling_setspeed);
627 653
628static struct attribute * default_attrs[] = { 654static struct attribute * default_attrs[] = {
629 &cpuinfo_min_freq.attr, 655 &cpuinfo_min_freq.attr,
@@ -634,6 +660,7 @@ static struct attribute * default_attrs[] = {
634 &scaling_governor.attr, 660 &scaling_governor.attr,
635 &scaling_driver.attr, 661 &scaling_driver.attr,
636 &scaling_available_governors.attr, 662 &scaling_available_governors.attr,
663 &scaling_setspeed.attr,
637 NULL 664 NULL
638}; 665};
639 666
@@ -1313,7 +1340,7 @@ static int cpufreq_resume(struct sys_device * sysdev)
1313 struct cpufreq_freqs freqs; 1340 struct cpufreq_freqs freqs;
1314 1341
1315 if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN)) 1342 if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN))
1316 dprintk("Warning: CPU frequency" 1343 dprintk("Warning: CPU frequency "
1317 "is %u, cpufreq assumed %u kHz.\n", 1344 "is %u, cpufreq assumed %u kHz.\n",
1318 cur_freq, cpu_policy->cur); 1345 cur_freq, cpu_policy->cur);
1319 1346
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c
index f8cdde4bf6cd..cb2ac01a41a1 100644
--- a/drivers/cpufreq/cpufreq_userspace.c
+++ b/drivers/cpufreq/cpufreq_userspace.c
@@ -65,12 +65,12 @@ static struct notifier_block userspace_cpufreq_notifier_block = {
65 65
66/** 66/**
67 * cpufreq_set - set the CPU frequency 67 * cpufreq_set - set the CPU frequency
68 * @policy: pointer to policy struct where freq is being set
68 * @freq: target frequency in kHz 69 * @freq: target frequency in kHz
69 * @cpu: CPU for which the frequency is to be set
70 * 70 *
71 * Sets the CPU frequency to freq. 71 * Sets the CPU frequency to freq.
72 */ 72 */
73static int cpufreq_set(unsigned int freq, struct cpufreq_policy *policy) 73static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq)
74{ 74{
75 int ret = -EINVAL; 75 int ret = -EINVAL;
76 76
@@ -102,34 +102,11 @@ static int cpufreq_set(unsigned int freq, struct cpufreq_policy *policy)
102} 102}
103 103
104 104
105/************************** sysfs interface ************************/ 105static ssize_t show_speed(struct cpufreq_policy *policy, char *buf)
106static ssize_t show_speed (struct cpufreq_policy *policy, char *buf)
107{ 106{
108 return sprintf (buf, "%u\n", cpu_cur_freq[policy->cpu]); 107 return sprintf(buf, "%u\n", cpu_cur_freq[policy->cpu]);
109} 108}
110 109
111static ssize_t
112store_speed (struct cpufreq_policy *policy, const char *buf, size_t count)
113{
114 unsigned int freq = 0;
115 unsigned int ret;
116
117 ret = sscanf (buf, "%u", &freq);
118 if (ret != 1)
119 return -EINVAL;
120
121 cpufreq_set(freq, policy);
122
123 return count;
124}
125
126static struct freq_attr freq_attr_scaling_setspeed =
127{
128 .attr = { .name = "scaling_setspeed", .mode = 0644 },
129 .show = show_speed,
130 .store = store_speed,
131};
132
133static int cpufreq_governor_userspace(struct cpufreq_policy *policy, 110static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
134 unsigned int event) 111 unsigned int event)
135{ 112{
@@ -142,10 +119,6 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
142 return -EINVAL; 119 return -EINVAL;
143 BUG_ON(!policy->cur); 120 BUG_ON(!policy->cur);
144 mutex_lock(&userspace_mutex); 121 mutex_lock(&userspace_mutex);
145 rc = sysfs_create_file (&policy->kobj,
146 &freq_attr_scaling_setspeed.attr);
147 if (rc)
148 goto start_out;
149 122
150 if (cpus_using_userspace_governor == 0) { 123 if (cpus_using_userspace_governor == 0) {
151 cpufreq_register_notifier( 124 cpufreq_register_notifier(
@@ -160,7 +133,7 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
160 cpu_cur_freq[cpu] = policy->cur; 133 cpu_cur_freq[cpu] = policy->cur;
161 cpu_set_freq[cpu] = policy->cur; 134 cpu_set_freq[cpu] = policy->cur;
162 dprintk("managing cpu %u started (%u - %u kHz, currently %u kHz)\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu]); 135 dprintk("managing cpu %u started (%u - %u kHz, currently %u kHz)\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu]);
163start_out: 136
164 mutex_unlock(&userspace_mutex); 137 mutex_unlock(&userspace_mutex);
165 break; 138 break;
166 case CPUFREQ_GOV_STOP: 139 case CPUFREQ_GOV_STOP:
@@ -176,7 +149,6 @@ start_out:
176 cpu_min_freq[cpu] = 0; 149 cpu_min_freq[cpu] = 0;
177 cpu_max_freq[cpu] = 0; 150 cpu_max_freq[cpu] = 0;
178 cpu_set_freq[cpu] = 0; 151 cpu_set_freq[cpu] = 0;
179 sysfs_remove_file (&policy->kobj, &freq_attr_scaling_setspeed.attr);
180 dprintk("managing cpu %u stopped\n", cpu); 152 dprintk("managing cpu %u stopped\n", cpu);
181 mutex_unlock(&userspace_mutex); 153 mutex_unlock(&userspace_mutex);
182 break; 154 break;
@@ -211,6 +183,8 @@ start_out:
211struct cpufreq_governor cpufreq_gov_userspace = { 183struct cpufreq_governor cpufreq_gov_userspace = {
212 .name = "userspace", 184 .name = "userspace",
213 .governor = cpufreq_governor_userspace, 185 .governor = cpufreq_governor_userspace,
186 .store_setspeed = cpufreq_set,
187 .show_setspeed = show_speed,
214 .owner = THIS_MODULE, 188 .owner = THIS_MODULE,
215}; 189};
216EXPORT_SYMBOL(cpufreq_gov_userspace); 190EXPORT_SYMBOL(cpufreq_gov_userspace);
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 5409f3afb3f8..ae6cd60d5c14 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -171,7 +171,7 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target);
171 171
172static struct cpufreq_frequency_table *show_table[NR_CPUS]; 172static struct cpufreq_frequency_table *show_table[NR_CPUS];
173/** 173/**
174 * show_scaling_governor - show the current policy for the specified CPU 174 * show_available_freqs - show available frequencies for the specified CPU
175 */ 175 */
176static ssize_t show_available_freqs (struct cpufreq_policy *policy, char *buf) 176static ssize_t show_available_freqs (struct cpufreq_policy *policy, char *buf)
177{ 177{