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

#include <linux/kernel.h>
5
#include <linux/cpu.h>
6
#include <linux/cpuidle.h>
L
Linus Torvalds 已提交
7

8 9
#include <asm/acpi.h>

L
Linus Torvalds 已提交
10 11 12 13 14 15 16 17 18 19
#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

20 21
#define ACPI_PDC_REVISION_ID		0x1

L
Len Brown 已提交
22
#define ACPI_PSD_REV0_REVISION		0	/* Support for _PSD as in ACPI 3.0 */
23 24
#define ACPI_PSD_REV0_ENTRIES		5

25 26
#define ACPI_TSD_REV0_REVISION		0	/* Support for _PSD as in ACPI 3.0 */
#define ACPI_TSD_REV0_ENTRIES		5
27 28 29 30 31 32 33 34
/*
 * Types of coordination defined in ACPI 3.0. Same macros can be used across
 * P, C and T states
 */
#define DOMAIN_COORD_TYPE_SW_ALL	0xfc
#define DOMAIN_COORD_TYPE_SW_ANY	0xfd
#define DOMAIN_COORD_TYPE_HW_ALL	0xfe

35 36 37
#define ACPI_CSTATE_SYSTEMIO	(0)
#define ACPI_CSTATE_FFH		(1)

L
Linus Torvalds 已提交
38 39 40 41 42
/* Power Management */

struct acpi_processor_cx;

struct acpi_power_register {
L
Len Brown 已提交
43 44 45 46 47 48 49
	u8 descriptor;
	u16 length;
	u8 space_id;
	u8 bit_width;
	u8 bit_offset;
	u8 reserved;
	u64 address;
L
Linus Torvalds 已提交
50 51 52
} __attribute__ ((packed));

struct acpi_processor_cx_policy {
L
Len Brown 已提交
53
	u32 count;
L
Linus Torvalds 已提交
54 55
	struct acpi_processor_cx *state;
	struct {
L
Len Brown 已提交
56 57 58 59 60
		u32 time;
		u32 ticks;
		u32 count;
		u32 bm;
	} threshold;
L
Linus Torvalds 已提交
61 62 63
};

struct acpi_processor_cx {
L
Len Brown 已提交
64 65 66
	u8 valid;
	u8 type;
	u32 address;
67 68
	u8 space_id;
	u8 index;
L
Len Brown 已提交
69 70 71 72
	u32 latency;
	u32 latency_ticks;
	u32 power;
	u32 usage;
73
	u64 time;
L
Linus Torvalds 已提交
74 75 76 77 78
	struct acpi_processor_cx_policy promotion;
	struct acpi_processor_cx_policy demotion;
};

struct acpi_processor_power {
79
	struct cpuidle_device dev;
L
Linus Torvalds 已提交
80
	struct acpi_processor_cx *state;
L
Len Brown 已提交
81 82 83 84
	unsigned long bm_check_timestamp;
	u32 default_state;
	u32 bm_activity;
	int count;
L
Linus Torvalds 已提交
85
	struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
86
	int timer_broadcast_on_state;
L
Linus Torvalds 已提交
87 88 89 90
};

/* Performance Management */

91 92 93 94 95 96 97 98
struct acpi_psd_package {
	acpi_integer num_entries;
	acpi_integer revision;
	acpi_integer domain;
	acpi_integer coord_type;
	acpi_integer num_processors;
} __attribute__ ((packed));

L
Linus Torvalds 已提交
99
struct acpi_pct_register {
L
Len Brown 已提交
100 101 102 103 104 105 106
	u8 descriptor;
	u16 length;
	u8 space_id;
	u8 bit_width;
	u8 bit_offset;
	u8 reserved;
	u64 address;
L
Linus Torvalds 已提交
107 108 109
} __attribute__ ((packed));

struct acpi_processor_px {
L
Len Brown 已提交
110 111 112 113 114 115
	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 已提交
116 117 118
};

struct acpi_processor_performance {
L
Len Brown 已提交
119 120
	unsigned int state;
	unsigned int platform_limit;
L
Linus Torvalds 已提交
121 122
	struct acpi_pct_register control_register;
	struct acpi_pct_register status_register;
L
Len Brown 已提交
123
	unsigned int state_count;
L
Linus Torvalds 已提交
124
	struct acpi_processor_px *states;
125 126 127
	struct acpi_psd_package domain_info;
	cpumask_t shared_cpu_map;
	unsigned int shared_type;
L
Linus Torvalds 已提交
128 129 130 131
};

/* Throttling Control */

132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
struct acpi_tsd_package {
	acpi_integer num_entries;
	acpi_integer revision;
	acpi_integer domain;
	acpi_integer coord_type;
	acpi_integer num_processors;
} __attribute__ ((packed));

struct acpi_ptc_register {
	u8 descriptor;
	u16 length;
	u8 space_id;
	u8 bit_width;
	u8 bit_offset;
	u8 reserved;
	u64 address;
} __attribute__ ((packed));

struct acpi_processor_tx_tss {
	acpi_integer freqpercentage;	/* */
	acpi_integer power;	/* milliWatts */
	acpi_integer transition_latency;	/* microseconds */
	acpi_integer control;	/* control value */
	acpi_integer status;	/* success indicator */
};
L
Linus Torvalds 已提交
157
struct acpi_processor_tx {
L
Len Brown 已提交
158 159
	u16 power;
	u16 performance;
L
Linus Torvalds 已提交
160 161
};

162
struct acpi_processor;
L
Linus Torvalds 已提交
163
struct acpi_processor_throttling {
164 165 166 167 168 169 170 171
	unsigned int state;
	unsigned int platform_limit;
	struct acpi_pct_register control_register;
	struct acpi_pct_register status_register;
	unsigned int state_count;
	struct acpi_processor_tx_tss *states_tss;
	struct acpi_tsd_package domain_info;
	cpumask_t shared_cpu_map;
172 173 174
	int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
	int (*acpi_processor_set_throttling) (struct acpi_processor * pr,
					      int state);
175

L
Len Brown 已提交
176 177 178
	u32 address;
	u8 duty_offset;
	u8 duty_width;
L
Linus Torvalds 已提交
179 180 181 182 183 184
	struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
};

/* Limit Interface */

struct acpi_processor_lx {
J
Joe Perches 已提交
185
	int px;			/* performance state */
L
Len Brown 已提交
186
	int tx;			/* throttle level */
L
Linus Torvalds 已提交
187 188 189
};

struct acpi_processor_limit {
L
Len Brown 已提交
190
	struct acpi_processor_lx state;	/* current limit */
L
Linus Torvalds 已提交
191
	struct acpi_processor_lx thermal;	/* thermal limit */
L
Len Brown 已提交
192
	struct acpi_processor_lx user;	/* user limit */
L
Linus Torvalds 已提交
193 194 195
};

struct acpi_processor_flags {
L
Len Brown 已提交
196 197 198 199 200 201 202 203
	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;
204
	u8 bm_rld_set:1;
L
Linus Torvalds 已提交
205 206 207
};

struct acpi_processor {
L
Len Brown 已提交
208 209 210 211 212
	acpi_handle handle;
	u32 acpi_id;
	u32 id;
	u32 pblk;
	int performance_platform_limit;
213
	int throttling_platform_limit;
214
	/* 0 - states 0..n-th state available */
215

L
Linus Torvalds 已提交
216 217 218 219 220
	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;
221 222 223

	/* the _PDC objects for this processor, if any */
	struct acpi_object_list *pdc;
L
Linus Torvalds 已提交
224 225 226
};

struct acpi_processor_errata {
L
Len Brown 已提交
227
	u8 smp;
L
Linus Torvalds 已提交
228
	struct {
L
Len Brown 已提交
229 230 231 232 233
		u8 throttle:1;
		u8 fdma:1;
		u8 reserved:6;
		u32 bmisx;
	} piix4;
L
Linus Torvalds 已提交
234 235
};

L
Len Brown 已提交
236 237
extern int acpi_processor_preregister_performance(struct
						  acpi_processor_performance
238
						  *performance);
239

L
Len Brown 已提交
240 241 242 243 244 245
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 已提交
246 247 248 249 250 251

/* 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 已提交
252
extern struct acpi_processor *processors[NR_CPUS];
L
Linus Torvalds 已提交
253 254
extern struct acpi_processor_errata errata;

255
void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
256

257
#ifdef ARCH_HAS_POWER_INIT
258
void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
L
Len Brown 已提交
259
					unsigned int cpu);
260
int acpi_processor_ffh_cstate_probe(unsigned int cpu,
L
Len Brown 已提交
261 262
				    struct acpi_processor_cx *cx,
				    struct acpi_power_register *reg);
263
void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
264
#else
L
Len Brown 已提交
265 266 267
static inline void acpi_processor_power_init_bm_check(struct
						      acpi_processor_flags
						      *flags, unsigned int cpu)
268 269 270 271
{
	flags->bm_check = 1;
	return;
}
272
static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu,
L
Len Brown 已提交
273 274 275
						  struct acpi_processor_cx *cx,
						  struct acpi_power_register
						  *reg)
276 277 278
{
	return -1;
}
L
Len Brown 已提交
279 280
static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
						   *cstate)
281 282 283
{
	return;
}
284 285
#endif

L
Linus Torvalds 已提交
286
/* in processor_perflib.c */
287

L
Linus Torvalds 已提交
288 289 290 291 292
#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 已提交
293 294 295 296 297 298 299 300 301 302
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 已提交
303 304
	static unsigned int printout = 1;
	if (printout) {
L
Len Brown 已提交
305 306 307 308
		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 已提交
309 310 311 312
		printout = 0;
	}
	return 0;
}
L
Len Brown 已提交
313
#endif				/* CONFIG_CPU_FREQ */
L
Linus Torvalds 已提交
314 315

/* in processor_throttling.c */
L
Len Brown 已提交
316
int acpi_processor_get_throttling_info(struct acpi_processor *pr);
317
extern int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
L
Linus Torvalds 已提交
318 319 320
extern struct file_operations acpi_processor_throttling_fops;

/* in processor_idle.c */
L
Len Brown 已提交
321 322 323 324 325
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);
326 327
int acpi_processor_suspend(struct acpi_device * device, pm_message_t state);
int acpi_processor_resume(struct acpi_device * device);
328
extern struct cpuidle_driver acpi_idle_driver;
L
Linus Torvalds 已提交
329 330

/* in processor_thermal.c */
L
Len Brown 已提交
331
int acpi_processor_get_limit_info(struct acpi_processor *pr);
L
Linus Torvalds 已提交
332 333 334 335 336 337
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 已提交
338 339 340 341 342 343 344 345
static inline void acpi_thermal_cpufreq_init(void)
{
	return;
}
static inline void acpi_thermal_cpufreq_exit(void)
{
	return;
}
L
Linus Torvalds 已提交
346 347 348
#endif

#endif