Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *  linux/drivers/devfreq/governor_powersave.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *  Copyright (C) 2011 Samsung Electronics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *	MyungJoo Ham <myungjoo.ham@samsung.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/devfreq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "governor.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static int devfreq_powersave_func(struct devfreq *df,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 				  unsigned long *freq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	 * target callback should be able to get ceiling value as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	 * said in devfreq.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	*freq = DEVFREQ_MIN_FREQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static int devfreq_powersave_handler(struct devfreq *devfreq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 				unsigned int event, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	if (event == DEVFREQ_GOV_START) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		mutex_lock(&devfreq->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		ret = update_devfreq(devfreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		mutex_unlock(&devfreq->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static struct devfreq_governor devfreq_powersave = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	.name = DEVFREQ_GOV_POWERSAVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	.get_target_freq = devfreq_powersave_func,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	.event_handler = devfreq_powersave_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static int __init devfreq_powersave_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	return devfreq_add_governor(&devfreq_powersave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) subsys_initcall(devfreq_powersave_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static void __exit devfreq_powersave_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	ret = devfreq_remove_governor(&devfreq_powersave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		pr_err("%s: failed remove governor %d\n", __func__, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) module_exit(devfreq_powersave_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) MODULE_LICENSE("GPL");