xref: /openbmc/linux/drivers/devfreq/governor_powersave.c (revision 7e6fdd4bad033fa2d73716377b184fa975b0d985)
1ce26c5bbSMyungJoo Ham /*
2ce26c5bbSMyungJoo Ham  *  linux/drivers/devfreq/governor_powersave.c
3ce26c5bbSMyungJoo Ham  *
4ce26c5bbSMyungJoo Ham  *  Copyright (C) 2011 Samsung Electronics
5ce26c5bbSMyungJoo Ham  *	MyungJoo Ham <myungjoo.ham@samsung.com>
6ce26c5bbSMyungJoo Ham  *
7ce26c5bbSMyungJoo Ham  * This program is free software; you can redistribute it and/or modify
8ce26c5bbSMyungJoo Ham  * it under the terms of the GNU General Public License version 2 as
9ce26c5bbSMyungJoo Ham  * published by the Free Software Foundation.
10ce26c5bbSMyungJoo Ham  */
11ce26c5bbSMyungJoo Ham 
12ce26c5bbSMyungJoo Ham #include <linux/devfreq.h>
130b7c328fSXiaoguang Chen #include "governor.h"
14ce26c5bbSMyungJoo Ham 
15ce26c5bbSMyungJoo Ham static int devfreq_powersave_func(struct devfreq *df,
16ce26c5bbSMyungJoo Ham 				  unsigned long *freq)
17ce26c5bbSMyungJoo Ham {
18ce26c5bbSMyungJoo Ham 	/*
19ce26c5bbSMyungJoo Ham 	 * target callback should be able to get ceiling value as
20ce26c5bbSMyungJoo Ham 	 * said in devfreq.h
21ce26c5bbSMyungJoo Ham 	 */
226530b9deSMyungJoo Ham 	*freq = df->min_freq;
23ce26c5bbSMyungJoo Ham 	return 0;
24ce26c5bbSMyungJoo Ham }
25ce26c5bbSMyungJoo Ham 
26*7e6fdd4bSRajagopal Venkat static int devfreq_powersave_handler(struct devfreq *devfreq,
27*7e6fdd4bSRajagopal Venkat 				unsigned int event, void *data)
280b7c328fSXiaoguang Chen {
29*7e6fdd4bSRajagopal Venkat 	int ret = 0;
30*7e6fdd4bSRajagopal Venkat 
31*7e6fdd4bSRajagopal Venkat 	if (event == DEVFREQ_GOV_START) {
32*7e6fdd4bSRajagopal Venkat 		mutex_lock(&devfreq->lock);
33*7e6fdd4bSRajagopal Venkat 		ret = update_devfreq(devfreq);
34*7e6fdd4bSRajagopal Venkat 		mutex_unlock(&devfreq->lock);
35*7e6fdd4bSRajagopal Venkat 	}
36*7e6fdd4bSRajagopal Venkat 
37*7e6fdd4bSRajagopal Venkat 	return ret;
380b7c328fSXiaoguang Chen }
390b7c328fSXiaoguang Chen 
40ce26c5bbSMyungJoo Ham const struct devfreq_governor devfreq_powersave = {
41ce26c5bbSMyungJoo Ham 	.name = "powersave",
42ce26c5bbSMyungJoo Ham 	.get_target_freq = devfreq_powersave_func,
43*7e6fdd4bSRajagopal Venkat 	.event_handler = devfreq_powersave_handler,
44ce26c5bbSMyungJoo Ham };
45