1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2ce26c5bbSMyungJoo Ham /*
3ce26c5bbSMyungJoo Ham * linux/drivers/devfreq/governor_powersave.c
4ce26c5bbSMyungJoo Ham *
5ce26c5bbSMyungJoo Ham * Copyright (C) 2011 Samsung Electronics
6ce26c5bbSMyungJoo Ham * MyungJoo Ham <myungjoo.ham@samsung.com>
7ce26c5bbSMyungJoo Ham */
8ce26c5bbSMyungJoo Ham
9ce26c5bbSMyungJoo Ham #include <linux/devfreq.h>
10eff607fdSNishanth Menon #include <linux/module.h>
110b7c328fSXiaoguang Chen #include "governor.h"
12ce26c5bbSMyungJoo Ham
devfreq_powersave_func(struct devfreq * df,unsigned long * freq)13ce26c5bbSMyungJoo Ham static int devfreq_powersave_func(struct devfreq *df,
14ce26c5bbSMyungJoo Ham unsigned long *freq)
15ce26c5bbSMyungJoo Ham {
16ce26c5bbSMyungJoo Ham /*
17ce26c5bbSMyungJoo Ham * target callback should be able to get ceiling value as
18ce26c5bbSMyungJoo Ham * said in devfreq.h
19ce26c5bbSMyungJoo Ham */
206ff66e2aSMatthias Kaehlcke *freq = DEVFREQ_MIN_FREQ;
21ce26c5bbSMyungJoo Ham return 0;
22ce26c5bbSMyungJoo Ham }
23ce26c5bbSMyungJoo Ham
devfreq_powersave_handler(struct devfreq * devfreq,unsigned int event,void * data)247e6fdd4bSRajagopal Venkat static int devfreq_powersave_handler(struct devfreq *devfreq,
257e6fdd4bSRajagopal Venkat unsigned int event, void *data)
260b7c328fSXiaoguang Chen {
277e6fdd4bSRajagopal Venkat int ret = 0;
287e6fdd4bSRajagopal Venkat
297e6fdd4bSRajagopal Venkat if (event == DEVFREQ_GOV_START) {
307e6fdd4bSRajagopal Venkat mutex_lock(&devfreq->lock);
317e6fdd4bSRajagopal Venkat ret = update_devfreq(devfreq);
327e6fdd4bSRajagopal Venkat mutex_unlock(&devfreq->lock);
337e6fdd4bSRajagopal Venkat }
347e6fdd4bSRajagopal Venkat
357e6fdd4bSRajagopal Venkat return ret;
360b7c328fSXiaoguang Chen }
370b7c328fSXiaoguang Chen
381b5c1be2SNishanth Menon static struct devfreq_governor devfreq_powersave = {
39aa7c352fSChanwoo Choi .name = DEVFREQ_GOV_POWERSAVE,
40ce26c5bbSMyungJoo Ham .get_target_freq = devfreq_powersave_func,
417e6fdd4bSRajagopal Venkat .event_handler = devfreq_powersave_handler,
42ce26c5bbSMyungJoo Ham };
4383116e66SNishanth Menon
devfreq_powersave_init(void)4483116e66SNishanth Menon static int __init devfreq_powersave_init(void)
4583116e66SNishanth Menon {
4683116e66SNishanth Menon return devfreq_add_governor(&devfreq_powersave);
4783116e66SNishanth Menon }
4883116e66SNishanth Menon subsys_initcall(devfreq_powersave_init);
4983116e66SNishanth Menon
devfreq_powersave_exit(void)5083116e66SNishanth Menon static void __exit devfreq_powersave_exit(void)
5183116e66SNishanth Menon {
5283116e66SNishanth Menon int ret;
5383116e66SNishanth Menon
5483116e66SNishanth Menon ret = devfreq_remove_governor(&devfreq_powersave);
5583116e66SNishanth Menon if (ret)
5683116e66SNishanth Menon pr_err("%s: failed remove governor %d\n", __func__, ret);
5783116e66SNishanth Menon
5883116e66SNishanth Menon return;
5983116e66SNishanth Menon }
6083116e66SNishanth Menon module_exit(devfreq_powersave_exit);
61*53e4e2b5SJeff Johnson MODULE_DESCRIPTION("DEVFREQ Powersave governor");
62eff607fdSNishanth Menon MODULE_LICENSE("GPL");
63