Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Viresh Kumar | bb176f7 | 2013-06-19 14:19:33 +0530 | [diff] [blame] | 2 | * linux/drivers/cpufreq/cpufreq_powersave.c |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
Viresh Kumar | bb176f7 | 2013-06-19 14:19:33 +0530 | [diff] [blame] | 4 | * Copyright (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | * |
| 11 | */ |
| 12 | |
Viresh Kumar | db70115 | 2012-10-23 01:29:03 +0200 | [diff] [blame] | 13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/cpufreq.h> |
| 16 | #include <linux/init.h> |
Viresh Kumar | 5ff0a26 | 2013-08-06 22:53:03 +0530 | [diff] [blame] | 17 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | static int cpufreq_governor_powersave(struct cpufreq_policy *policy, |
| 20 | unsigned int event) |
| 21 | { |
| 22 | switch (event) { |
| 23 | case CPUFREQ_GOV_START: |
| 24 | case CPUFREQ_GOV_LIMITS: |
Dominik Brodowski | 2d06d8c | 2011-03-27 15:04:46 +0200 | [diff] [blame] | 25 | pr_debug("setting to %u kHz because of event %u\n", |
Gautham R Shenoy | e08f5f5 | 2006-10-26 16:20:58 +0530 | [diff] [blame] | 26 | policy->min, event); |
| 27 | __cpufreq_driver_target(policy, policy->min, |
| 28 | CPUFREQ_RELATION_L); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | break; |
| 30 | default: |
| 31 | break; |
| 32 | } |
| 33 | return 0; |
| 34 | } |
Dave Jones | 32ee8c3 | 2006-02-28 00:43:23 -0500 | [diff] [blame] | 35 | |
Rafael J. Wysocki | de1df26 | 2016-02-05 02:37:42 +0100 | [diff] [blame] | 36 | static struct cpufreq_governor cpufreq_gov_powersave = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | .name = "powersave", |
| 38 | .governor = cpufreq_governor_powersave, |
| 39 | .owner = THIS_MODULE, |
| 40 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
| 42 | static int __init cpufreq_gov_powersave_init(void) |
| 43 | { |
| 44 | return cpufreq_register_governor(&cpufreq_gov_powersave); |
| 45 | } |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | static void __exit cpufreq_gov_powersave_exit(void) |
| 48 | { |
| 49 | cpufreq_unregister_governor(&cpufreq_gov_powersave); |
| 50 | } |
| 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); |
| 53 | MODULE_DESCRIPTION("CPUfreq policy governor 'powersave'"); |
| 54 | MODULE_LICENSE("GPL"); |
| 55 | |
Alessandro Guido | 30d221d | 2008-04-18 13:31:13 -0700 | [diff] [blame] | 56 | #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE |
Rafael J. Wysocki | de1df26 | 2016-02-05 02:37:42 +0100 | [diff] [blame] | 57 | struct cpufreq_governor *cpufreq_default_governor(void) |
| 58 | { |
| 59 | return &cpufreq_gov_powersave; |
| 60 | } |
| 61 | |
Alessandro Guido | 30d221d | 2008-04-18 13:31:13 -0700 | [diff] [blame] | 62 | fs_initcall(cpufreq_gov_powersave_init); |
| 63 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | module_init(cpufreq_gov_powersave_init); |
Alessandro Guido | 30d221d | 2008-04-18 13:31:13 -0700 | [diff] [blame] | 65 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | module_exit(cpufreq_gov_powersave_exit); |