processor.h 9.2 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/thermal.h>
7 8
#include <asm/acpi.h>

9 10 11 12
#define ACPI_PROCESSOR_CLASS		"processor"
#define ACPI_PROCESSOR_DEVICE_NAME	"Processor"
#define ACPI_PROCESSOR_DEVICE_HID	"ACPI0007"

L
Linus Torvalds 已提交
13 14 15 16 17 18 19 20 21 22
#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

23 24
#define ACPI_PDC_REVISION_ID		0x1

L
Len Brown 已提交
25
#define ACPI_PSD_REV0_REVISION		0	/* Support for _PSD as in ACPI 3.0 */
26 27
#define ACPI_PSD_REV0_ENTRIES		5

28 29
#define ACPI_TSD_REV0_REVISION		0	/* Support for _PSD as in ACPI 3.0 */
#define ACPI_TSD_REV0_ENTRIES		5
30 31 32 33 34 35 36 37
/*
 * 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

38 39 40 41 42
#define ACPI_CSTATE_SYSTEMIO	0
#define ACPI_CSTATE_FFH		1
#define ACPI_CSTATE_HALT	2

#define ACPI_CX_DESC_LEN	32
43

L
Linus Torvalds 已提交
44 45 46 47 48
/* Power Management */

struct acpi_processor_cx;

struct acpi_power_register {
L
Len Brown 已提交
49 50 51 52 53
	u8 descriptor;
	u16 length;
	u8 space_id;
	u8 bit_width;
	u8 bit_offset;
54
	u8 access_size;
L
Len Brown 已提交
55
	u64 address;
56
} __packed;
L
Linus Torvalds 已提交
57 58

struct acpi_processor_cx {
L
Len Brown 已提交
59 60 61
	u8 valid;
	u8 type;
	u32 address;
62
	u8 entry_method;
63
	u8 index;
L
Len Brown 已提交
64
	u32 latency;
65
	u8 bm_sts_skip;
66
	char desc[ACPI_CX_DESC_LEN];
L
Linus Torvalds 已提交
67 68 69
};

struct acpi_processor_power {
L
Len Brown 已提交
70
	int count;
L
Linus Torvalds 已提交
71
	struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
72
	int timer_broadcast_on_state;
L
Linus Torvalds 已提交
73 74 75 76
};

/* Performance Management */

77
struct acpi_psd_package {
L
Lin Ming 已提交
78 79 80 81 82
	u64 num_entries;
	u64 revision;
	u64 domain;
	u64 coord_type;
	u64 num_processors;
83
} __packed;
84

L
Linus Torvalds 已提交
85
struct acpi_pct_register {
L
Len Brown 已提交
86 87 88 89 90 91 92
	u8 descriptor;
	u16 length;
	u8 space_id;
	u8 bit_width;
	u8 bit_offset;
	u8 reserved;
	u64 address;
93
} __packed;
L
Linus Torvalds 已提交
94 95

struct acpi_processor_px {
L
Lin Ming 已提交
96 97 98 99 100 101
	u64 core_frequency;	/* megahertz */
	u64 power;	/* milliWatts */
	u64 transition_latency;	/* microseconds */
	u64 bus_master_latency;	/* microseconds */
	u64 control;	/* control value */
	u64 status;	/* success indicator */
L
Linus Torvalds 已提交
102 103 104
};

struct acpi_processor_performance {
L
Len Brown 已提交
105 106
	unsigned int state;
	unsigned int platform_limit;
L
Linus Torvalds 已提交
107 108
	struct acpi_pct_register control_register;
	struct acpi_pct_register status_register;
L
Len Brown 已提交
109
	unsigned int state_count;
L
Linus Torvalds 已提交
110
	struct acpi_processor_px *states;
111
	struct acpi_psd_package domain_info;
112
	cpumask_var_t shared_cpu_map;
113
	unsigned int shared_type;
L
Linus Torvalds 已提交
114 115 116 117
};

/* Throttling Control */

118
struct acpi_tsd_package {
L
Lin Ming 已提交
119 120 121 122 123
	u64 num_entries;
	u64 revision;
	u64 domain;
	u64 coord_type;
	u64 num_processors;
124
} __packed;
125 126 127 128 129 130 131 132 133

struct acpi_ptc_register {
	u8 descriptor;
	u16 length;
	u8 space_id;
	u8 bit_width;
	u8 bit_offset;
	u8 reserved;
	u64 address;
134
} __packed;
135 136

struct acpi_processor_tx_tss {
L
Lin Ming 已提交
137 138 139 140 141
	u64 freqpercentage;	/* */
	u64 power;	/* milliWatts */
	u64 transition_latency;	/* microseconds */
	u64 control;	/* control value */
	u64 status;	/* success indicator */
142
};
L
Linus Torvalds 已提交
143
struct acpi_processor_tx {
L
Len Brown 已提交
144 145
	u16 power;
	u16 performance;
L
Linus Torvalds 已提交
146 147
};

148
struct acpi_processor;
L
Linus Torvalds 已提交
149
struct acpi_processor_throttling {
150 151 152 153 154 155 156
	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;
157
	cpumask_var_t shared_cpu_map;
158 159
	int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
	int (*acpi_processor_set_throttling) (struct acpi_processor * pr,
160
					      int state, bool force);
161

L
Len Brown 已提交
162 163 164
	u32 address;
	u8 duty_offset;
	u8 duty_width;
165 166
	u8 tsd_valid_flag;
	unsigned int shared_type;
L
Linus Torvalds 已提交
167 168 169 170 171 172
	struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
};

/* Limit Interface */

struct acpi_processor_lx {
J
Joe Perches 已提交
173
	int px;			/* performance state */
L
Len Brown 已提交
174
	int tx;			/* throttle level */
L
Linus Torvalds 已提交
175 176 177
};

struct acpi_processor_limit {
L
Len Brown 已提交
178
	struct acpi_processor_lx state;	/* current limit */
L
Linus Torvalds 已提交
179
	struct acpi_processor_lx thermal;	/* thermal limit */
L
Len Brown 已提交
180
	struct acpi_processor_lx user;	/* user limit */
L
Linus Torvalds 已提交
181 182 183
};

struct acpi_processor_flags {
L
Len Brown 已提交
184 185 186 187 188 189 190 191
	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;
192
	u8 bm_rld_set:1;
193
	u8 need_hotplug_init:1;
L
Linus Torvalds 已提交
194 195 196
};

struct acpi_processor {
L
Len Brown 已提交
197 198
	acpi_handle handle;
	u32 acpi_id;
199 200
	u32 phys_id;	/* CPU hardware ID such as APIC ID for x86 */
	u32 id;		/* CPU logical ID allocated by OS */
L
Len Brown 已提交
201 202
	u32 pblk;
	int performance_platform_limit;
203
	int throttling_platform_limit;
204
	/* 0 - states 0..n-th state available */
205

L
Linus Torvalds 已提交
206 207 208 209 210
	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;
211
	struct thermal_cooling_device *cdev;
212
	struct device *dev; /* Processor device. */
L
Linus Torvalds 已提交
213 214 215
};

struct acpi_processor_errata {
L
Len Brown 已提交
216
	u8 smp;
L
Linus Torvalds 已提交
217
	struct {
L
Len Brown 已提交
218 219 220 221 222
		u8 throttle:1;
		u8 fdma:1;
		u8 reserved:6;
		u32 bmisx;
	} piix4;
L
Linus Torvalds 已提交
223 224
};

L
Len Brown 已提交
225 226
extern int acpi_processor_preregister_performance(struct
						  acpi_processor_performance
227
						  __percpu *performance);
228

L
Len Brown 已提交
229 230 231 232 233 234
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 已提交
235 236 237 238 239

/* 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);

240 241 242
/* parsing the _P* objects. */
extern int acpi_processor_get_performance_info(struct acpi_processor *pr);

L
Linus Torvalds 已提交
243
/* for communication between multiple parts of the processor kernel module */
244
DECLARE_PER_CPU(struct acpi_processor *, processors);
L
Linus Torvalds 已提交
245 246
extern struct acpi_processor_errata errata;

247
#ifdef ARCH_HAS_POWER_INIT
248
void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
L
Len Brown 已提交
249
					unsigned int cpu);
250
int acpi_processor_ffh_cstate_probe(unsigned int cpu,
L
Len Brown 已提交
251 252
				    struct acpi_processor_cx *cx,
				    struct acpi_power_register *reg);
253
void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
254
#else
L
Len Brown 已提交
255 256 257
static inline void acpi_processor_power_init_bm_check(struct
						      acpi_processor_flags
						      *flags, unsigned int cpu)
258 259 260 261
{
	flags->bm_check = 1;
	return;
}
262
static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu,
L
Len Brown 已提交
263 264 265
						  struct acpi_processor_cx *cx,
						  struct acpi_power_register
						  *reg)
266 267 268
{
	return -1;
}
L
Len Brown 已提交
269 270
static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
						   *cstate)
271 272 273
{
	return;
}
274 275
#endif

L
Linus Torvalds 已提交
276
/* in processor_perflib.c */
277

L
Linus Torvalds 已提交
278 279 280
#ifdef CONFIG_CPU_FREQ
void acpi_processor_ppc_init(void);
void acpi_processor_ppc_exit(void);
281
int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag);
282
extern int acpi_processor_get_bios_limit(int cpu, unsigned int *limit);
L
Linus Torvalds 已提交
283
#else
L
Len Brown 已提交
284 285 286 287 288 289 290 291
static inline void acpi_processor_ppc_init(void)
{
	return;
}
static inline void acpi_processor_ppc_exit(void)
{
	return;
}
292 293
static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr,
								int event_flag)
L
Len Brown 已提交
294
{
L
Linus Torvalds 已提交
295 296
	static unsigned int printout = 1;
	if (printout) {
L
Len Brown 已提交
297 298 299 300
		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 已提交
301 302 303 304
		printout = 0;
	}
	return 0;
}
305 306 307 308 309
static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
{
	return -ENODEV;
}

L
Len Brown 已提交
310
#endif				/* CONFIG_CPU_FREQ */
L
Linus Torvalds 已提交
311

312
/* in processor_core.c */
313 314
int acpi_get_phys_id(acpi_handle, int type, u32 acpi_id);
int acpi_map_cpuid(int phys_id, u32 acpi_id);
315
int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
A
Alex Chiang 已提交
316

317 318 319
/* in processor_pdc.c */
void acpi_processor_set_pdc(acpi_handle handle);

L
Linus Torvalds 已提交
320
/* in processor_throttling.c */
321
int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
L
Len Brown 已提交
322
int acpi_processor_get_throttling_info(struct acpi_processor *pr);
323 324
extern int acpi_processor_set_throttling(struct acpi_processor *pr,
					 int state, bool force);
325 326 327 328 329 330
/*
 * Reevaluate whether the T-state is invalid after one cpu is
 * onlined/offlined. In such case the flags.throttling will be updated.
 */
extern void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
			unsigned long action);
J
Jan Engelhardt 已提交
331
extern const struct file_operations acpi_processor_throttling_fops;
332
extern void acpi_processor_throttling_init(void);
L
Linus Torvalds 已提交
333
/* in processor_idle.c */
334 335
int acpi_processor_power_init(struct acpi_processor *pr);
int acpi_processor_power_exit(struct acpi_processor *pr);
L
Len Brown 已提交
336
int acpi_processor_cst_has_changed(struct acpi_processor *pr);
337
int acpi_processor_hotplug(struct acpi_processor *pr);
338
extern struct cpuidle_driver acpi_idle_driver;
L
Linus Torvalds 已提交
339

340 341 342 343 344 345 346 347
#ifdef CONFIG_PM_SLEEP
void acpi_processor_syscore_init(void);
void acpi_processor_syscore_exit(void);
#else
static inline void acpi_processor_syscore_init(void) {}
static inline void acpi_processor_syscore_exit(void) {}
#endif

L
Linus Torvalds 已提交
348
/* in processor_thermal.c */
L
Len Brown 已提交
349
int acpi_processor_get_limit_info(struct acpi_processor *pr);
V
Vasiliy Kulikov 已提交
350
extern const struct thermal_cooling_device_ops processor_cooling_ops;
L
Linus Torvalds 已提交
351 352 353 354
#ifdef CONFIG_CPU_FREQ
void acpi_thermal_cpufreq_init(void);
void acpi_thermal_cpufreq_exit(void);
#else
L
Len Brown 已提交
355 356 357 358 359 360 361 362
static inline void acpi_thermal_cpufreq_init(void)
{
	return;
}
static inline void acpi_thermal_cpufreq_exit(void)
{
	return;
}
L
Linus Torvalds 已提交
363 364 365
#endif

#endif