diff options
author | iwasaki <iwasaki@FreeBSD.org> | 2002-03-04 18:46:13 +0000 |
---|---|---|
committer | iwasaki <iwasaki@FreeBSD.org> | 2002-03-04 18:46:13 +0000 |
commit | 3f245d8dd193f05b337f1358ec6b33ed212f9cc1 (patch) | |
tree | 8012c8174b9cc8503bad897aec51d04ec2c4490b /sys/amd64 | |
parent | 3fe10323bf98b7928a3f885f578ec703252ee6b7 (diff) | |
download | FreeBSD-src-3f245d8dd193f05b337f1358ec6b33ed212f9cc1.zip FreeBSD-src-3f245d8dd193f05b337f1358ec6b33ed212f9cc1.tar.gz |
Add generalized power profile code.
This makes other power-management system (APM for now) to be able to
generate power profile change events (ie. AC-line status changes), and
other kernel components, not only the ACPI components, can be notified
the events.
- move subroutines in acpi_powerprofile.c (removed) to kern/subr_power.c
- call power_profile_set_state() also from APM driver when AC-line
status changes
- add call-back function for Crusoe LongRun controlling on power
profile changes for a example
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/amd64/identcpu.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/sys/amd64/amd64/identcpu.c b/sys/amd64/amd64/identcpu.c index 156d2c0..6aa0967 100644 --- a/sys/amd64/amd64/identcpu.c +++ b/sys/amd64/amd64/identcpu.c @@ -48,6 +48,7 @@ #include <sys/systm.h> #include <sys/kernel.h> #include <sys/sysctl.h> +#include <sys/power.h> #include <machine/asmacros.h> #include <machine/clock.h> @@ -1135,9 +1136,40 @@ static u_int crusoe_longrun; static u_int crusoe_frequency; static u_int crusoe_voltage; static u_int crusoe_percentage; +static u_int crusoe_performance_longrun = LONGRUN_MODE_PERFORMANCE; +static u_int crusoe_economy_longrun = LONGRUN_MODE_ECONOMY; static struct sysctl_ctx_list crusoe_sysctl_ctx; static struct sysctl_oid *crusoe_sysctl_tree; +static void +tmx86_longrun_power_profile(void *arg) +{ + int state; + u_int new; + + state = power_profile_get_state(); + if (state != POWER_PROFILE_PERFORMANCE && + state != POWER_PROFILE_ECONOMY) { + return; + } + + switch (state) { + case POWER_PROFILE_PERFORMANCE: + new =crusoe_performance_longrun; + break; + case POWER_PROFILE_ECONOMY: + new = crusoe_economy_longrun; + break; + default: + new = tmx86_get_longrun_mode(); + break; + } + + if (tmx86_get_longrun_mode() != new) { + tmx86_set_longrun_mode(new); + } +} + static int tmx86_longrun_sysctl(SYSCTL_HANDLER_ARGS) { @@ -1175,6 +1207,34 @@ tmx86_status_sysctl(SYSCTL_HANDLER_ARGS) return (error); } +static int +tmx86_longrun_profile_sysctl(SYSCTL_HANDLER_ARGS) +{ + u_int32_t *argp; + u_int32_t arg; + int error; + + argp = (u_int32_t *)oidp->oid_arg1; + arg = *argp; + error = sysctl_handle_int(oidp, &arg, 0, req); + + /* error or no new value */ + if ((error != 0) || (req->newptr == NULL)) + return (error); + + /* range check */ + if (arg >= LONGRUN_MODE_UNKNOWN) + return (EINVAL); + + /* set new value and possibly switch */ + *argp = arg; + + tmx86_longrun_power_profile(NULL); + + return (0); + +} + static void setup_tmx86_longrun(void) { @@ -1205,6 +1265,16 @@ setup_tmx86_longrun(void) OID_AUTO, "percentage", CTLTYPE_INT | CTLFLAG_RD, &crusoe_percentage, 0, tmx86_status_sysctl, "I", "Processing performance (%)"); + SYSCTL_ADD_PROC(&crusoe_sysctl_ctx, SYSCTL_CHILDREN(crusoe_sysctl_tree), + OID_AUTO, "performance_longrun", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_RW, + &crusoe_performance_longrun, 0, tmx86_longrun_profile_sysctl, "I", ""); + SYSCTL_ADD_PROC(&crusoe_sysctl_ctx, SYSCTL_CHILDREN(crusoe_sysctl_tree), + OID_AUTO, "economy_longrun", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_RW, + &crusoe_economy_longrun, 0, tmx86_longrun_profile_sysctl, "I", ""); + + /* register performance profile change handler */ + EVENTHANDLER_REGISTER(power_profile_change, tmx86_longrun_power_profile, NULL, 0); + } static void |