processor.h 6.3 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6
#ifndef __ACPI_PROCESSOR_H
#define __ACPI_PROCESSOR_H

#include <linux/kernel.h>
#include <linux/config.h>

7 8
#include <asm/acpi.h>

L
Linus Torvalds 已提交
9 10 11 12 13 14 15 16 17 18
#define ACPI_PROCESSOR_BUSY_METRIC	10

#define ACPI_PROCESSOR_MAX_POWER	8
#define ACPI_PROCESSOR_MAX_C2_LATENCY	100
#define ACPI_PROCESSOR_MAX_C3_LATENCY	1000

#define ACPI_PROCESSOR_MAX_THROTTLING	16
#define ACPI_PROCESSOR_MAX_THROTTLE	250	/* 25% */
#define ACPI_PROCESSOR_MAX_DUTY_WIDTH	4

19 20
#define ACPI_PDC_REVISION_ID		0x1

L
Linus Torvalds 已提交
21 22 23 24 25
/* Power Management */

struct acpi_processor_cx;

struct acpi_power_register {
L
Len Brown 已提交
26 27 28 29 30 31 32
	u8 descriptor;
	u16 length;
	u8 space_id;
	u8 bit_width;
	u8 bit_offset;
	u8 reserved;
	u64 address;
L
Linus Torvalds 已提交
33 34 35
} __attribute__ ((packed));

struct acpi_processor_cx_policy {
L
Len Brown 已提交
36
	u32 count;
L
Linus Torvalds 已提交
37 38
	struct acpi_processor_cx *state;
	struct {
L
Len Brown 已提交
39 40 41 42 43
		u32 time;
		u32 ticks;
		u32 count;
		u32 bm;
	} threshold;
L
Linus Torvalds 已提交
44 45 46
};

struct acpi_processor_cx {
L
Len Brown 已提交
47 48 49 50 51 52 53
	u8 valid;
	u8 type;
	u32 address;
	u32 latency;
	u32 latency_ticks;
	u32 power;
	u32 usage;
L
Linus Torvalds 已提交
54 55 56 57 58 59
	struct acpi_processor_cx_policy promotion;
	struct acpi_processor_cx_policy demotion;
};

struct acpi_processor_power {
	struct acpi_processor_cx *state;
L
Len Brown 已提交
60 61 62 63
	unsigned long bm_check_timestamp;
	u32 default_state;
	u32 bm_activity;
	int count;
L
Linus Torvalds 已提交
64
	struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
65 66 67

	/* the _PDC objects passed by the driver, if any */
	struct acpi_object_list *pdc;
L
Linus Torvalds 已提交
68 69 70 71 72
};

/* Performance Management */

struct acpi_pct_register {
L
Len Brown 已提交
73 74 75 76 77 78 79
	u8 descriptor;
	u16 length;
	u8 space_id;
	u8 bit_width;
	u8 bit_offset;
	u8 reserved;
	u64 address;
L
Linus Torvalds 已提交
80 81 82
} __attribute__ ((packed));

struct acpi_processor_px {
L
Len Brown 已提交
83 84 85 86 87 88
	acpi_integer core_frequency;	/* megahertz */
	acpi_integer power;	/* milliWatts */
	acpi_integer transition_latency;	/* microseconds */
	acpi_integer bus_master_latency;	/* microseconds */
	acpi_integer control;	/* control value */
	acpi_integer status;	/* success indicator */
L
Linus Torvalds 已提交
89 90 91
};

struct acpi_processor_performance {
L
Len Brown 已提交
92 93
	unsigned int state;
	unsigned int platform_limit;
L
Linus Torvalds 已提交
94 95
	struct acpi_pct_register control_register;
	struct acpi_pct_register status_register;
L
Len Brown 已提交
96
	unsigned int state_count;
L
Linus Torvalds 已提交
97 98 99 100 101 102 103 104 105
	struct acpi_processor_px *states;

	/* the _PDC objects passed by the driver, if any */
	struct acpi_object_list *pdc;
};

/* Throttling Control */

struct acpi_processor_tx {
L
Len Brown 已提交
106 107
	u16 power;
	u16 performance;
L
Linus Torvalds 已提交
108 109 110
};

struct acpi_processor_throttling {
L
Len Brown 已提交
111 112 113 114 115
	int state;
	u32 address;
	u8 duty_offset;
	u8 duty_width;
	int state_count;
L
Linus Torvalds 已提交
116 117 118 119 120 121
	struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
};

/* Limit Interface */

struct acpi_processor_lx {
L
Len Brown 已提交
122 123
	int px;			/* performace state */
	int tx;			/* throttle level */
L
Linus Torvalds 已提交
124 125 126
};

struct acpi_processor_limit {
L
Len Brown 已提交
127
	struct acpi_processor_lx state;	/* current limit */
L
Linus Torvalds 已提交
128
	struct acpi_processor_lx thermal;	/* thermal limit */
L
Len Brown 已提交
129
	struct acpi_processor_lx user;	/* user limit */
L
Linus Torvalds 已提交
130 131 132
};

struct acpi_processor_flags {
L
Len Brown 已提交
133 134 135 136 137 138 139 140
	u8 power:1;
	u8 performance:1;
	u8 throttling:1;
	u8 limit:1;
	u8 bm_control:1;
	u8 bm_check:1;
	u8 has_cst:1;
	u8 power_setup_done:1;
L
Linus Torvalds 已提交
141 142 143
};

struct acpi_processor {
L
Len Brown 已提交
144 145 146 147 148
	acpi_handle handle;
	u32 acpi_id;
	u32 id;
	u32 pblk;
	int performance_platform_limit;
L
Linus Torvalds 已提交
149 150 151 152 153 154 155 156
	struct acpi_processor_flags flags;
	struct acpi_processor_power power;
	struct acpi_processor_performance *performance;
	struct acpi_processor_throttling throttling;
	struct acpi_processor_limit limit;
};

struct acpi_processor_errata {
L
Len Brown 已提交
157
	u8 smp;
L
Linus Torvalds 已提交
158
	struct {
L
Len Brown 已提交
159 160 161 162 163
		u8 throttle:1;
		u8 fdma:1;
		u8 reserved:6;
		u32 bmisx;
	} piix4;
L
Linus Torvalds 已提交
164 165
};

L
Len Brown 已提交
166 167 168 169 170 171
extern int acpi_processor_register_performance(struct acpi_processor_performance
					       *performance, unsigned int cpu);
extern void acpi_processor_unregister_performance(struct
						  acpi_processor_performance
						  *performance,
						  unsigned int cpu);
L
Linus Torvalds 已提交
172 173 174 175 176 177

/* note: this locks both the calling module and the processor module
         if a _PPC object exists, rmmod is disallowed then */
int acpi_processor_notify_smm(struct module *calling_module);

/* for communication between multiple parts of the processor kernel module */
L
Len Brown 已提交
178
extern struct acpi_processor *processors[NR_CPUS];
L
Linus Torvalds 已提交
179 180
extern struct acpi_processor_errata errata;

181
int acpi_processor_set_pdc(struct acpi_processor *pr,
L
Len Brown 已提交
182
			   struct acpi_object_list *pdc_in);
183 184 185

#ifdef ARCH_HAS_POWER_PDC_INIT
void acpi_processor_power_init_pdc(struct acpi_processor_power *pow,
L
Len Brown 已提交
186
				   unsigned int cpu);
187
void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
L
Len Brown 已提交
188
					unsigned int cpu);
189
#else
L
Len Brown 已提交
190 191
static inline void acpi_processor_power_init_pdc(struct acpi_processor_power
						 *pow, unsigned int cpu)
192 193 194 195 196
{
	pow->pdc = NULL;
	return;
}

L
Len Brown 已提交
197 198 199
static inline void acpi_processor_power_init_bm_check(struct
						      acpi_processor_flags
						      *flags, unsigned int cpu)
200 201 202 203 204 205
{
	flags->bm_check = 1;
	return;
}
#endif

L
Linus Torvalds 已提交
206
/* in processor_perflib.c */
207

L
Linus Torvalds 已提交
208 209 210 211 212
#ifdef CONFIG_CPU_FREQ
void acpi_processor_ppc_init(void);
void acpi_processor_ppc_exit(void);
int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
#else
L
Len Brown 已提交
213 214 215 216 217 218 219 220 221 222
static inline void acpi_processor_ppc_init(void)
{
	return;
}
static inline void acpi_processor_ppc_exit(void)
{
	return;
}
static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
{
L
Linus Torvalds 已提交
223 224
	static unsigned int printout = 1;
	if (printout) {
L
Len Brown 已提交
225 226 227 228
		printk(KERN_WARNING
		       "Warning: Processor Platform Limit event detected, but not handled.\n");
		printk(KERN_WARNING
		       "Consider compiling CPUfreq support into your kernel.\n");
L
Linus Torvalds 已提交
229 230 231 232
		printout = 0;
	}
	return 0;
}
L
Len Brown 已提交
233
#endif				/* CONFIG_CPU_FREQ */
L
Linus Torvalds 已提交
234 235

/* in processor_throttling.c */
L
Len Brown 已提交
236 237 238 239 240
int acpi_processor_get_throttling_info(struct acpi_processor *pr);
int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
ssize_t acpi_processor_write_throttling(struct file *file,
					const char __user * buffer,
					size_t count, loff_t * data);
L
Linus Torvalds 已提交
241 242 243
extern struct file_operations acpi_processor_throttling_fops;

/* in processor_idle.c */
L
Len Brown 已提交
244 245 246 247 248
int acpi_processor_power_init(struct acpi_processor *pr,
			      struct acpi_device *device);
int acpi_processor_cst_has_changed(struct acpi_processor *pr);
int acpi_processor_power_exit(struct acpi_processor *pr,
			      struct acpi_device *device);
L
Linus Torvalds 已提交
249 250

/* in processor_thermal.c */
L
Len Brown 已提交
251 252 253 254
int acpi_processor_get_limit_info(struct acpi_processor *pr);
ssize_t acpi_processor_write_limit(struct file *file,
				   const char __user * buffer,
				   size_t count, loff_t * data);
L
Linus Torvalds 已提交
255 256 257 258 259 260
extern struct file_operations acpi_processor_limit_fops;

#ifdef CONFIG_CPU_FREQ
void acpi_thermal_cpufreq_init(void);
void acpi_thermal_cpufreq_exit(void);
#else
L
Len Brown 已提交
261 262 263 264 265 266 267 268
static inline void acpi_thermal_cpufreq_init(void)
{
	return;
}
static inline void acpi_thermal_cpufreq_exit(void)
{
	return;
}
L
Linus Torvalds 已提交
269 270 271
#endif

#endif