MyungJoo Ham | ce26c5b | 2011-10-02 00:19:34 +0200 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/devfreq/governor_powersave.c |
| 3 | * |
| 4 | * Copyright (C) 2011 Samsung Electronics |
| 5 | * MyungJoo Ham <myungjoo.ham@samsung.com> |
| 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 | #include <linux/devfreq.h> |
Xiaoguang Chen | 0b7c328f | 2012-04-29 22:51:31 +0200 | [diff] [blame] | 13 | #include "governor.h" |
MyungJoo Ham | ce26c5b | 2011-10-02 00:19:34 +0200 | [diff] [blame] | 14 | |
| 15 | static int devfreq_powersave_func(struct devfreq *df, |
| 16 | unsigned long *freq) |
| 17 | { |
| 18 | /* |
| 19 | * target callback should be able to get ceiling value as |
| 20 | * said in devfreq.h |
| 21 | */ |
MyungJoo Ham | 6530b9de | 2011-12-09 16:42:19 +0900 | [diff] [blame] | 22 | *freq = df->min_freq; |
MyungJoo Ham | ce26c5b | 2011-10-02 00:19:34 +0200 | [diff] [blame] | 23 | return 0; |
| 24 | } |
| 25 | |
Rajagopal Venkat | 7e6fdd4 | 2012-10-26 01:50:09 +0200 | [diff] [blame] | 26 | static int devfreq_powersave_handler(struct devfreq *devfreq, |
| 27 | unsigned int event, void *data) |
Xiaoguang Chen | 0b7c328f | 2012-04-29 22:51:31 +0200 | [diff] [blame] | 28 | { |
Rajagopal Venkat | 7e6fdd4 | 2012-10-26 01:50:09 +0200 | [diff] [blame] | 29 | int ret = 0; |
| 30 | |
| 31 | if (event == DEVFREQ_GOV_START) { |
| 32 | mutex_lock(&devfreq->lock); |
| 33 | ret = update_devfreq(devfreq); |
| 34 | mutex_unlock(&devfreq->lock); |
| 35 | } |
| 36 | |
| 37 | return ret; |
Xiaoguang Chen | 0b7c328f | 2012-04-29 22:51:31 +0200 | [diff] [blame] | 38 | } |
| 39 | |
MyungJoo Ham | ce26c5b | 2011-10-02 00:19:34 +0200 | [diff] [blame] | 40 | const struct devfreq_governor devfreq_powersave = { |
| 41 | .name = "powersave", |
MyungJoo Ham | ce26c5b | 2011-10-02 00:19:34 +0200 | [diff] [blame] | 42 | .get_target_freq = devfreq_powersave_func, |
Rajagopal Venkat | 7e6fdd4 | 2012-10-26 01:50:09 +0200 | [diff] [blame] | 43 | .event_handler = devfreq_powersave_handler, |
MyungJoo Ham | ce26c5b | 2011-10-02 00:19:34 +0200 | [diff] [blame] | 44 | }; |