blob: 5dbc1e56ec08c561a7732350aa027d37b28aa03c [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
MyungJoo Hamce26c5b2011-10-02 00:19:34 +02002/*
3 * linux/drivers/devfreq/governor_performance.c
4 *
5 * Copyright (C) 2011 Samsung Electronics
6 * MyungJoo Ham <myungjoo.ham@samsung.com>
MyungJoo Hamce26c5b2011-10-02 00:19:34 +02007 */
8
9#include <linux/devfreq.h>
Nishanth Menoneff607f2012-10-29 15:01:46 -050010#include <linux/module.h>
Xiaoguang Chen0b7c3282012-04-29 22:51:31 +020011#include "governor.h"
MyungJoo Hamce26c5b2011-10-02 00:19:34 +020012
13static int devfreq_performance_func(struct devfreq *df,
14 unsigned long *freq)
15{
16 /*
17 * target callback should be able to get floor value as
18 * said in devfreq.h
19 */
Matthias Kaehlcke6ff66e22018-08-03 13:05:10 -070020 *freq = DEVFREQ_MAX_FREQ;
MyungJoo Hamce26c5b2011-10-02 00:19:34 +020021 return 0;
22}
23
Rajagopal Venkat7e6fdd42012-10-26 01:50:09 +020024static int devfreq_performance_handler(struct devfreq *devfreq,
25 unsigned int event, void *data)
Xiaoguang Chen0b7c3282012-04-29 22:51:31 +020026{
Rajagopal Venkat7e6fdd42012-10-26 01:50:09 +020027 int ret = 0;
28
29 if (event == DEVFREQ_GOV_START) {
30 mutex_lock(&devfreq->lock);
31 ret = update_devfreq(devfreq);
32 mutex_unlock(&devfreq->lock);
33 }
34
35 return ret;
Xiaoguang Chen0b7c3282012-04-29 22:51:31 +020036}
37
Nishanth Menon1b5c1be2012-10-29 15:01:45 -050038static struct devfreq_governor devfreq_performance = {
Chanwoo Choiaa7c3522017-10-23 10:32:12 +090039 .name = DEVFREQ_GOV_PERFORMANCE,
MyungJoo Hamce26c5b2011-10-02 00:19:34 +020040 .get_target_freq = devfreq_performance_func,
Rajagopal Venkat7e6fdd42012-10-26 01:50:09 +020041 .event_handler = devfreq_performance_handler,
MyungJoo Hamce26c5b2011-10-02 00:19:34 +020042};
Nishanth Menon83116e62012-10-29 15:01:44 -050043
44static int __init devfreq_performance_init(void)
45{
46 return devfreq_add_governor(&devfreq_performance);
47}
48subsys_initcall(devfreq_performance_init);
49
50static void __exit devfreq_performance_exit(void)
51{
52 int ret;
53
54 ret = devfreq_remove_governor(&devfreq_performance);
55 if (ret)
56 pr_err("%s: failed remove governor %d\n", __func__, ret);
57
58 return;
59}
60module_exit(devfreq_performance_exit);
Nishanth Menoneff607f2012-10-29 15:01:46 -050061MODULE_LICENSE("GPL");