]> git.hungrycats.org Git - linux/commitdiff
[CPUFREQ] Add the "performance" and "powersave" governors as modules.
authorDave Jones <davej@redhat.com>
Wed, 3 Sep 2003 01:57:16 +0000 (02:57 +0100)
committerDave Jones <davej@redhat.com>
Wed, 3 Sep 2003 01:57:16 +0000 (02:57 +0100)
Also add a config option so that the default governor [which is loaded
and enabled at boot] is started. Note that if you select "performance"
here, the CPU will be set to the highest possible frequency even if
the CPU was booted at a lower frequency. If you select "userspace",
the frequency will stay the same.

drivers/cpufreq/Kconfig
drivers/cpufreq/Makefile
drivers/cpufreq/cpufreq_performance.c [new file with mode: 0644]
drivers/cpufreq/cpufreq_powersave.c [new file with mode: 0644]

index 88686c3d71f0308388e11121bcf5d391ec64573a..0f591d9613ac6beccf91991a401b97866576c136 100644 (file)
@@ -10,9 +10,54 @@ config CPU_FREQ_PROC_INTF
          
          If in doubt, say N.
 
+choice
+       prompt "Default CPUFreq governor"
+       depends on CPU_FREQ
+       default CPU_FREQ_DEFAULT_GOV_PERFORMANCE
+       help
+         This option sets which CPUFreq governor shall be loaded at
+         startup. If in doubt, select 'performance'.
+
+config CPU_FREQ_DEFAULT_GOV_PERFORMANCE
+       bool "performance"
+       select CPU_FREQ_GOV_PERFORMANCE
+       help
+         Use the CPUFreq governor 'performance' as default. This sets
+         the frequency statically to the highest frequency supported by
+         the CPU.
+
+config CPU_FREQ_DEFAULT_GOV_USERSPACE
+       bool "userspace"
+       select CPU_FREQ_GOV_USERSPACE
+       help
+         Use the CPUFreq governor 'userspace' as default. This allows
+         you to set the CPU frequency manually or when an userspace 
+         programm shall be able to set the CPU dynamically without having
+         to enable the userspace governor manually.
+
+endchoice
+
+config CPU_FREQ_GOV_PERFORMANCE
+       tristate "'powersave' governor"
+       depends on CPU_FREQ
+       help
+         This cpufreq governors set the frequency statically to the
+         highest available CPU frequency.
+
+         If in doubt, say Y.
+
+config CPU_FREQ_GOV_POWERSAVE
+       tristate "'powersave' governor"
+       depends on CPU_FREQ
+       help
+         Theis cpufreq governors set the frequency statically to the
+         lowest available CPU frequency.
+
+         If in doubt, say Y.
+
 config CPU_FREQ_GOV_USERSPACE
        tristate "'userspace' governor for userspace frequency scaling"
-       depends on CPU_FREQ
+       depends on CPU_FREQ 
        help
          Enable this cpufreq governor when you either want to set the
          CPU frequency manually or when an userspace programm shall
index e65dca095a531736b2a12d2e5e794bd06a774a68..1eebf3c6edc381eb3b40ef916f8ed89000efeca0 100644 (file)
@@ -2,6 +2,8 @@
 obj-$(CONFIG_CPU_FREQ)                 += cpufreq.o
 
 # CPUfreq governors 
+obj-$(CONFIG_CPU_FREQ_GOV_PERFORMANCE) += cpufreq_performance.o
+obj-$(CONFIG_CPU_FREQ_GOV_POWERSAVE)   += cpufreq_powersave.o
 obj-$(CONFIG_CPU_FREQ_GOV_USERSPACE)   += cpufreq_userspace.o
 
 # CPUfreq cross-arch helpers
diff --git a/drivers/cpufreq/cpufreq_performance.c b/drivers/cpufreq/cpufreq_performance.c
new file mode 100644 (file)
index 0000000..f2348e7
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ *  linux/drivers/cpufreq/cpufreq_performance.c
+ *
+ *  Copyright (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/cpufreq.h>
+#include <linux/init.h>
+
+static int cpufreq_governor_performance(struct cpufreq_policy *policy,
+                                       unsigned int event)
+{
+       switch (event) {
+       case CPUFREQ_GOV_START:
+       case CPUFREQ_GOV_LIMITS:
+               __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
+               break;
+       default:
+               break;
+       }
+       return 0;
+}
+                                                            
+struct cpufreq_governor cpufreq_gov_performance = {
+       .name           = "performance",
+       .governor       = cpufreq_governor_performance,
+       .owner          = THIS_MODULE,
+};
+EXPORT_SYMBOL(cpufreq_gov_performance);
+
+
+static int __init cpufreq_gov_performance_init(void)
+{
+       return cpufreq_register_governor(&cpufreq_gov_performance);
+}
+
+
+static void __exit cpufreq_gov_performance_exit(void)
+{
+       cpufreq_unregister_governor(&cpufreq_gov_performance);
+}
+
+
+MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>");
+MODULE_DESCRIPTION("CPUfreq policy governor 'performance'");
+MODULE_LICENSE("GPL");
+
+fs_initcall(cpufreq_gov_performance_init);
+module_exit(cpufreq_gov_performance_exit);
diff --git a/drivers/cpufreq/cpufreq_powersave.c b/drivers/cpufreq/cpufreq_powersave.c
new file mode 100644 (file)
index 0000000..ec85448
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *  linux/drivers/cpufreq/cpufreq_powersave.c
+ *
+ *  Copyright (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/cpufreq.h>
+#include <linux/init.h>
+
+static int cpufreq_governor_powersave(struct cpufreq_policy *policy,
+                                       unsigned int event)
+{
+       switch (event) {
+       case CPUFREQ_GOV_START:
+       case CPUFREQ_GOV_LIMITS:
+               __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L);
+               break;
+       default:
+               break;
+       }
+       return 0;
+}
+                                                            
+static struct cpufreq_governor cpufreq_gov_powersave = {
+       .name           = "powersave",
+       .governor       = cpufreq_governor_powersave,
+       .owner          = THIS_MODULE,
+};
+
+
+static int __init cpufreq_gov_powersave_init(void)
+{
+       return cpufreq_register_governor(&cpufreq_gov_powersave);
+}
+
+
+static void __exit cpufreq_gov_powersave_exit(void)
+{
+       cpufreq_unregister_governor(&cpufreq_gov_powersave);
+}
+
+
+MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>");
+MODULE_DESCRIPTION("CPUfreq policy governor 'powersave'");
+MODULE_LICENSE("GPL");
+
+module_init(cpufreq_gov_powersave_init);
+module_exit(cpufreq_gov_powersave_exit);