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/dev/acpica/acpi_cpu.c | |
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/dev/acpica/acpi_cpu.c')
-rw-r--r-- | sys/dev/acpica/acpi_cpu.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index ab55023..7014705 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -30,6 +30,7 @@ #include <sys/param.h> #include <sys/kernel.h> #include <sys/bus.h> +#include <sys/power.h> #include <machine/bus_pio.h> #include <machine/bus.h> @@ -99,7 +100,7 @@ static int acpi_cpu_probe(device_t dev); static int acpi_cpu_attach(device_t dev); static void acpi_cpu_init_throttling(void *arg); static void acpi_cpu_set_speed(u_int32_t speed); -static void acpi_cpu_powerprofile(void *arg); +static void acpi_cpu_power_profile(void *arg); static int acpi_cpu_speed_sysctl(SYSCTL_HANDLER_ARGS); static device_method_t acpi_cpu_methods[] = { @@ -280,7 +281,7 @@ acpi_cpu_init_throttling(void *arg) cpu_economy_state = cpu_temp_speed; /* register performance profile change handler */ - EVENTHANDLER_REGISTER(powerprofile_change, acpi_cpu_powerprofile, NULL, 0); + EVENTHANDLER_REGISTER(power_profile_change, acpi_cpu_power_profile, NULL, 0); /* if ACPI 2.0+, signal platform that we are taking over throttling */ if (cpu_pstate_cnt != 0) { @@ -291,7 +292,7 @@ acpi_cpu_init_throttling(void *arg) ACPI_UNLOCK; /* set initial speed */ - acpi_cpu_powerprofile(NULL); + acpi_cpu_power_profile(NULL); printf("acpi_cpu: CPU throttling enabled, %d steps from 100%% to %d.%d%%\n", CPU_MAX_SPEED, CPU_SPEED_PRINTABLE(1)); @@ -347,13 +348,31 @@ acpi_cpu_set_speed(u_int32_t speed) * Uses the ACPI lock to avoid reentrancy. */ static void -acpi_cpu_powerprofile(void *arg) +acpi_cpu_power_profile(void *arg) { + int state; u_int32_t new; + state = power_profile_get_state(); + if (state != POWER_PROFILE_PERFORMANCE && + state != POWER_PROFILE_ECONOMY) { + return; + } + ACPI_LOCK; - new = (powerprofile_get_state() == POWERPROFILE_PERFORMANCE) ? cpu_performance_state : cpu_economy_state; + switch (state) { + case POWER_PROFILE_PERFORMANCE: + new = cpu_performance_state; + break; + case POWER_PROFILE_ECONOMY: + new = cpu_economy_state; + break; + default: + new = cpu_current_state; + break; + } + if (cpu_current_state != new) acpi_cpu_set_speed(new); @@ -387,7 +406,7 @@ acpi_cpu_speed_sysctl(SYSCTL_HANDLER_ARGS) /* set new value and possibly switch */ *argp = arg; - acpi_cpu_powerprofile(NULL); + acpi_cpu_power_profile(NULL); return(0); } |