29 #include <linux/kernel.h>
30 #include <linux/module.h>
34 #include <asm/uaccess.h>
40 #define PREFIX "ACPI: "
42 #define ACPI_PROCESSOR_CLASS "processor"
43 #define _COMPONENT ACPI_PROCESSOR_COMPONENT
46 #ifdef CONFIG_CPU_FREQ
54 #define CPUFREQ_THERMAL_MIN_STEP 0
55 #define CPUFREQ_THERMAL_MAX_STEP 3
57 static DEFINE_PER_CPU(
unsigned int, cpufreq_thermal_reduction_pctg);
58 static unsigned int acpi_thermal_cpufreq_is_init = 0;
60 #define reduction_pctg(cpu) \
61 per_cpu(cpufreq_thermal_reduction_pctg, phys_package_first_cpu(cpu))
70 static int phys_package_first_cpu(
int cpu)
81 static
int cpu_has_cpufreq(
unsigned int cpu)
89 static int acpi_thermal_cpufreq_notifier(
struct notifier_block *nb,
93 unsigned long max_freq = 0;
100 (100 - reduction_pctg(policy->
cpu) * 20)
103 cpufreq_verify_within_limits(policy, 0, max_freq);
109 static struct notifier_block acpi_thermal_cpufreq_notifier_block = {
113 static int cpufreq_get_max_state(
unsigned int cpu)
115 if (!cpu_has_cpufreq(cpu))
118 return CPUFREQ_THERMAL_MAX_STEP;
121 static int cpufreq_get_cur_state(
unsigned int cpu)
123 if (!cpu_has_cpufreq(cpu))
126 return reduction_pctg(cpu);
129 static int cpufreq_set_cur_state(
unsigned int cpu,
int state)
133 if (!cpu_has_cpufreq(cpu))
136 reduction_pctg(cpu) =
state;
151 void acpi_thermal_cpufreq_init(
void)
158 acpi_thermal_cpufreq_is_init = 1;
161 void acpi_thermal_cpufreq_exit(
void)
163 if (acpi_thermal_cpufreq_is_init)
165 (&acpi_thermal_cpufreq_notifier_block,
168 acpi_thermal_cpufreq_is_init = 0;
172 static int cpufreq_get_max_state(
unsigned int cpu)
177 static int cpufreq_get_cur_state(
unsigned int cpu)
182 static int cpufreq_set_cur_state(
unsigned int cpu,
int state)
195 if (pr->
flags.throttling)
210 max_state += cpufreq_get_max_state(pr->
id);
211 if (pr->
flags.throttling)
218 unsigned long *state)
226 *state = acpi_processor_max_state(pr);
232 unsigned long *cur_state)
234 struct acpi_device *device = cdev->
devdata;
240 *cur_state = cpufreq_get_cur_state(pr->
id);
241 if (pr->
flags.throttling)
250 struct acpi_device *device = cdev->
devdata;
258 max_pstate = cpufreq_get_max_state(pr->
id);
260 if (state > acpi_processor_max_state(pr))
263 if (state <= max_pstate) {
266 cpufreq_set_cur_state(pr->
id, state);
268 cpufreq_set_cur_state(pr->
id, max_pstate);
270 state - max_pstate,
false);
276 .get_max_state = processor_get_max_state,
277 .get_cur_state = processor_get_cur_state,
278 .set_cur_state = processor_set_cur_state,