Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ce26c5bb authored by MyungJoo Ham's avatar MyungJoo Ham Committed by Rafael J. Wysocki
Browse files

PM / devfreq: Add basic governors



Four cpufreq-like governors are provided as examples.

powersave: use the lowest frequency possible. The user (device) should
set the polling_ms as 0 because polling is useless for this governor.

performance: use the highest freqeuncy possible. The user (device)
should set the polling_ms as 0 because polling is useless for this
governor.

userspace: use the user specified frequency stored at
devfreq.user_set_freq. With sysfs support in the following patch, a user
may set the value with the sysfs interface.

simple_ondemand: simplified version of cpufreq's ondemand governor.

When a user updates OPP entries (enable/disable/add), OPP framework
automatically notifies devfreq to update operating frequency
accordingly. Thus, devfreq users (device drivers) do not need to update
devfreq manually with OPP entry updates or set polling_ms for powersave
, performance, userspace, or any other "static" governors.

Note that these are given only as basic examples for governors and any
devices with devfreq may implement their own governors with the drivers
and use them.

Signed-off-by: default avatarMyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: default avatarMike Turquette <mturquette@ti.com>
Acked-by: default avatarKevin Hilman <khilman@ti.com>
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
parent 9005b650
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -42,3 +42,11 @@ Description:
		devfreq-provided central polling
		(/sys/class/devfreq/.../central_polling is 0), this value
		may be useless.

What:		/sys/class/devfreq/.../userspace/set_freq
Date:		September 2011
Contact:	MyungJoo Ham <myungjoo.ham@samsung.com>
Description:
		The /sys/class/devfreq/.../userspace/set_freq shows and
		sets the requested frequency for the devfreq object if
		userspace governor is in effect.
+36 −0
Original line number Diff line number Diff line
@@ -34,6 +34,42 @@ menuconfig PM_DEVFREQ

if PM_DEVFREQ

comment "DEVFREQ Governors"

config DEVFREQ_GOV_SIMPLE_ONDEMAND
	bool "Simple Ondemand"
	help
	  Chooses frequency based on the recent load on the device. Works
	  similar as ONDEMAND governor of CPUFREQ does. A device with
	  Simple-Ondemand should be able to provide busy/total counter
	  values that imply the usage rate. A device may provide tuned
	  values to the governor with data field at devfreq_add_device().

config DEVFREQ_GOV_PERFORMANCE
	bool "Performance"
	help
	  Sets the frequency at the maximum available frequency.
	  This governor always returns UINT_MAX as frequency so that
	  the DEVFREQ framework returns the highest frequency available
	  at any time.

config DEVFREQ_GOV_POWERSAVE
	bool "Powersave"
	help
	  Sets the frequency at the minimum available frequency.
	  This governor always returns 0 as frequency so that
	  the DEVFREQ framework returns the lowest frequency available
	  at any time.

config DEVFREQ_GOV_USERSPACE
	bool "Userspace"
	help
	  Sets the frequency at the user specified one.
	  This governor returns the user configured frequency if there
	  has been an input to /sys/devices/.../power/devfreq_set_freq.
	  Otherwise, the governor does not change the frequnecy
	  given at the initialization.

comment "DEVFREQ Drivers"

endif # PM_DEVFREQ
+4 −0
Original line number Diff line number Diff line
obj-$(CONFIG_PM_DEVFREQ)	+= devfreq.o
obj-$(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)	+= governor_simpleondemand.o
obj-$(CONFIG_DEVFREQ_GOV_PERFORMANCE)	+= governor_performance.o
obj-$(CONFIG_DEVFREQ_GOV_POWERSAVE)	+= governor_powersave.o
obj-$(CONFIG_DEVFREQ_GOV_USERSPACE)	+= governor_userspace.o
+29 −0
Original line number Diff line number Diff line
/*
 *  linux/drivers/devfreq/governor_performance.c
 *
 *  Copyright (C) 2011 Samsung Electronics
 *	MyungJoo Ham <myungjoo.ham@samsung.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/devfreq.h>

static int devfreq_performance_func(struct devfreq *df,
				    unsigned long *freq)
{
	/*
	 * target callback should be able to get floor value as
	 * said in devfreq.h
	 */
	*freq = UINT_MAX;
	return 0;
}

const struct devfreq_governor devfreq_performance = {
	.name = "performance",
	.get_target_freq = devfreq_performance_func,
	.no_central_polling = true,
};
+29 −0
Original line number Diff line number Diff line
/*
 *  linux/drivers/devfreq/governor_powersave.c
 *
 *  Copyright (C) 2011 Samsung Electronics
 *	MyungJoo Ham <myungjoo.ham@samsung.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/devfreq.h>

static int devfreq_powersave_func(struct devfreq *df,
				  unsigned long *freq)
{
	/*
	 * target callback should be able to get ceiling value as
	 * said in devfreq.h
	 */
	*freq = 0;
	return 0;
}

const struct devfreq_governor devfreq_powersave = {
	.name = "powersave",
	.get_target_freq = devfreq_powersave_func,
	.no_central_polling = true,
};
Loading