aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/acpi/acconfig.h2
-rw-r--r--include/acpi/acexcep.h8
-rw-r--r--include/acpi/acnames.h26
-rw-r--r--include/acpi/acpi_bus.h21
-rw-r--r--include/acpi/acpiosxf.h155
-rw-r--r--include/acpi/acpixf.h93
-rw-r--r--include/acpi/actbl.h19
-rw-r--r--include/acpi/actbl2.h4
-rw-r--r--include/acpi/actypes.h77
-rw-r--r--include/acpi/platform/acenv.h8
-rw-r--r--include/acpi/platform/aclinux.h131
-rw-r--r--include/acpi/processor.h4
-rw-r--r--include/linux/acpi.h2
-rw-r--r--include/linux/backlight.h4
-rw-r--r--include/linux/bitops.h3
-rw-r--r--include/linux/cpu.h13
-rw-r--r--include/linux/cpufreq.h75
-rw-r--r--include/linux/cpuidle.h8
-rw-r--r--include/linux/devfreq.h6
-rw-r--r--include/linux/opp.h134
-rw-r--r--include/linux/pm_opp.h139
-rw-r--r--include/linux/powercap.h325
22 files changed, 955 insertions, 302 deletions
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h
index 1c16f821434f..d98c67001840 100644
--- a/include/acpi/acconfig.h
+++ b/include/acpi/acconfig.h
@@ -100,7 +100,9 @@
100 * ACPI PM timer 100 * ACPI PM timer
101 * FACS table (Waking vectors and Global Lock) 101 * FACS table (Waking vectors and Global Lock)
102 */ 102 */
103#ifndef ACPI_REDUCED_HARDWARE
103#define ACPI_REDUCED_HARDWARE FALSE 104#define ACPI_REDUCED_HARDWARE FALSE
105#endif
104 106
105/****************************************************************************** 107/******************************************************************************
106 * 108 *
diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h
index cf051e05a8fe..4e280bd226dd 100644
--- a/include/acpi/acexcep.h
+++ b/include/acpi/acexcep.h
@@ -125,8 +125,9 @@ struct acpi_exception_info {
125#define AE_NO_HANDLER EXCEP_ENV (0x001A) 125#define AE_NO_HANDLER EXCEP_ENV (0x001A)
126#define AE_OWNER_ID_LIMIT EXCEP_ENV (0x001B) 126#define AE_OWNER_ID_LIMIT EXCEP_ENV (0x001B)
127#define AE_NOT_CONFIGURED EXCEP_ENV (0x001C) 127#define AE_NOT_CONFIGURED EXCEP_ENV (0x001C)
128#define AE_ACCESS EXCEP_ENV (0x001D)
128 129
129#define AE_CODE_ENV_MAX 0x001C 130#define AE_CODE_ENV_MAX 0x001D
130 131
131/* 132/*
132 * Programmer exceptions 133 * Programmer exceptions
@@ -227,7 +228,7 @@ static const struct acpi_exception_info acpi_gbl_exception_names_env[] = {
227 EXCEP_TXT("AE_NO_ACPI_TABLES", "ACPI tables could not be found"), 228 EXCEP_TXT("AE_NO_ACPI_TABLES", "ACPI tables could not be found"),
228 EXCEP_TXT("AE_NO_NAMESPACE", "A namespace has not been loaded"), 229 EXCEP_TXT("AE_NO_NAMESPACE", "A namespace has not been loaded"),
229 EXCEP_TXT("AE_NO_MEMORY", "Insufficient dynamic memory"), 230 EXCEP_TXT("AE_NO_MEMORY", "Insufficient dynamic memory"),
230 EXCEP_TXT("AE_NOT_FOUND", "The name was not found in the namespace"), 231 EXCEP_TXT("AE_NOT_FOUND", "A requested entity is not found"),
231 EXCEP_TXT("AE_NOT_EXIST", "A required entity does not exist"), 232 EXCEP_TXT("AE_NOT_EXIST", "A required entity does not exist"),
232 EXCEP_TXT("AE_ALREADY_EXISTS", "An entity already exists"), 233 EXCEP_TXT("AE_ALREADY_EXISTS", "An entity already exists"),
233 EXCEP_TXT("AE_TYPE", "The object type is incorrect"), 234 EXCEP_TXT("AE_TYPE", "The object type is incorrect"),
@@ -259,7 +260,8 @@ static const struct acpi_exception_info acpi_gbl_exception_names_env[] = {
259 EXCEP_TXT("AE_OWNER_ID_LIMIT", 260 EXCEP_TXT("AE_OWNER_ID_LIMIT",
260 "There are no more Owner IDs available for ACPI tables or control methods"), 261 "There are no more Owner IDs available for ACPI tables or control methods"),
261 EXCEP_TXT("AE_NOT_CONFIGURED", 262 EXCEP_TXT("AE_NOT_CONFIGURED",
262 "The interface is not part of the current subsystem configuration") 263 "The interface is not part of the current subsystem configuration"),
264 EXCEP_TXT("AE_ACCESS", "Permission denied for the requested operation")
263}; 265};
264 266
265static const struct acpi_exception_info acpi_gbl_exception_names_pgm[] = { 267static const struct acpi_exception_info acpi_gbl_exception_names_pgm[] = {
diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h
index ce08ef7d969c..1f36777e26fe 100644
--- a/include/acpi/acnames.h
+++ b/include/acpi/acnames.h
@@ -46,25 +46,25 @@
46 46
47/* Method names - these methods can appear anywhere in the namespace */ 47/* Method names - these methods can appear anywhere in the namespace */
48 48
49#define METHOD_NAME__SB_ "_SB_"
50#define METHOD_NAME__HID "_HID"
51#define METHOD_NAME__CID "_CID"
52#define METHOD_NAME__UID "_UID"
53#define METHOD_NAME__SUB "_SUB"
54#define METHOD_NAME__ADR "_ADR" 49#define METHOD_NAME__ADR "_ADR"
55#define METHOD_NAME__INI "_INI" 50#define METHOD_NAME__AEI "_AEI"
56#define METHOD_NAME__STA "_STA"
57#define METHOD_NAME__REG "_REG"
58#define METHOD_NAME__SEG "_SEG"
59#define METHOD_NAME__BBN "_BBN" 51#define METHOD_NAME__BBN "_BBN"
60#define METHOD_NAME__PRT "_PRT" 52#define METHOD_NAME__CBA "_CBA"
53#define METHOD_NAME__CID "_CID"
61#define METHOD_NAME__CRS "_CRS" 54#define METHOD_NAME__CRS "_CRS"
55#define METHOD_NAME__HID "_HID"
56#define METHOD_NAME__INI "_INI"
57#define METHOD_NAME__PLD "_PLD"
62#define METHOD_NAME__PRS "_PRS" 58#define METHOD_NAME__PRS "_PRS"
63#define METHOD_NAME__AEI "_AEI" 59#define METHOD_NAME__PRT "_PRT"
64#define METHOD_NAME__PRW "_PRW" 60#define METHOD_NAME__PRW "_PRW"
61#define METHOD_NAME__REG "_REG"
62#define METHOD_NAME__SB_ "_SB_"
63#define METHOD_NAME__SEG "_SEG"
65#define METHOD_NAME__SRS "_SRS" 64#define METHOD_NAME__SRS "_SRS"
66#define METHOD_NAME__CBA "_CBA" 65#define METHOD_NAME__STA "_STA"
67#define METHOD_NAME__PLD "_PLD" 66#define METHOD_NAME__SUB "_SUB"
67#define METHOD_NAME__UID "_UID"
68 68
69/* Method names - these methods must appear at the namespace root */ 69/* Method names - these methods must appear at the namespace root */
70 70
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index d9019821aa60..89c60b0f6408 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -222,7 +222,8 @@ struct acpi_device_power_flags {
222 u32 power_resources:1; /* Power resources */ 222 u32 power_resources:1; /* Power resources */
223 u32 inrush_current:1; /* Serialize Dx->D0 */ 223 u32 inrush_current:1; /* Serialize Dx->D0 */
224 u32 power_removed:1; /* Optimize Dx->D0 */ 224 u32 power_removed:1; /* Optimize Dx->D0 */
225 u32 reserved:28; 225 u32 ignore_parent:1; /* Power is independent of parent power state */
226 u32 reserved:27;
226}; 227};
227 228
228struct acpi_device_power_state { 229struct acpi_device_power_state {
@@ -338,20 +339,6 @@ struct acpi_bus_event {
338 u32 data; 339 u32 data;
339}; 340};
340 341
341struct acpi_eject_event {
342 struct acpi_device *device;
343 u32 event;
344};
345
346struct acpi_hp_work {
347 struct work_struct work;
348 acpi_handle handle;
349 u32 type;
350 void *context;
351};
352void alloc_acpi_hp_work(acpi_handle handle, u32 type, void *context,
353 void (*func)(struct work_struct *work));
354
355extern struct kobject *acpi_kobj; 342extern struct kobject *acpi_kobj;
356extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int); 343extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
357void acpi_bus_private_data_handler(acpi_handle, void *); 344void acpi_bus_private_data_handler(acpi_handle, void *);
@@ -390,7 +377,6 @@ int acpi_scan_add_handler(struct acpi_scan_handler *handler);
390int acpi_bus_register_driver(struct acpi_driver *driver); 377int acpi_bus_register_driver(struct acpi_driver *driver);
391void acpi_bus_unregister_driver(struct acpi_driver *driver); 378void acpi_bus_unregister_driver(struct acpi_driver *driver);
392int acpi_bus_scan(acpi_handle handle); 379int acpi_bus_scan(acpi_handle handle);
393void acpi_bus_hot_remove_device(void *context);
394void acpi_bus_trim(struct acpi_device *start); 380void acpi_bus_trim(struct acpi_device *start);
395acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd); 381acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
396int acpi_match_device_ids(struct acpi_device *device, 382int acpi_match_device_ids(struct acpi_device *device,
@@ -398,6 +384,9 @@ int acpi_match_device_ids(struct acpi_device *device,
398int acpi_create_dir(struct acpi_device *); 384int acpi_create_dir(struct acpi_device *);
399void acpi_remove_dir(struct acpi_device *); 385void acpi_remove_dir(struct acpi_device *);
400 386
387typedef void (*acpi_hp_callback)(void *data, u32 src);
388
389acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src);
401 390
402/** 391/**
403 * module_acpi_driver(acpi_driver) - Helper macro for registering an ACPI driver 392 * module_acpi_driver(acpi_driver) - Helper macro for registering an ACPI driver
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 64b8c7639520..01e6c6d8b7e1 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -77,54 +77,80 @@ struct acpi_signal_fatal_info {
77/* 77/*
78 * OSL Initialization and shutdown primitives 78 * OSL Initialization and shutdown primitives
79 */ 79 */
80acpi_status __init acpi_os_initialize(void); 80#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
81acpi_status acpi_os_initialize(void);
82#endif
81 83
84#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
82acpi_status acpi_os_terminate(void); 85acpi_status acpi_os_terminate(void);
86#endif
83 87
84/* 88/*
85 * ACPI Table interfaces 89 * ACPI Table interfaces
86 */ 90 */
91#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_root_pointer
87acpi_physical_address acpi_os_get_root_pointer(void); 92acpi_physical_address acpi_os_get_root_pointer(void);
93#endif
88 94
95#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_predefined_override
89acpi_status 96acpi_status
90acpi_os_predefined_override(const struct acpi_predefined_names *init_val, 97acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
91 acpi_string * new_val); 98 acpi_string * new_val);
99#endif
92 100
101#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_table_override
93acpi_status 102acpi_status
94acpi_os_table_override(struct acpi_table_header *existing_table, 103acpi_os_table_override(struct acpi_table_header *existing_table,
95 struct acpi_table_header **new_table); 104 struct acpi_table_header **new_table);
105#endif
96 106
107#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_physical_table_override
97acpi_status 108acpi_status
98acpi_os_physical_table_override(struct acpi_table_header *existing_table, 109acpi_os_physical_table_override(struct acpi_table_header *existing_table,
99 acpi_physical_address * new_address, 110 acpi_physical_address * new_address,
100 u32 *new_table_length); 111 u32 *new_table_length);
112#endif
101 113
102/* 114/*
103 * Spinlock primitives 115 * Spinlock primitives
104 */ 116 */
105#ifndef acpi_os_create_lock 117#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
106acpi_status acpi_os_create_lock(acpi_spinlock * out_handle); 118acpi_status acpi_os_create_lock(acpi_spinlock * out_handle);
107#endif 119#endif
108 120
121#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_lock
109void acpi_os_delete_lock(acpi_spinlock handle); 122void acpi_os_delete_lock(acpi_spinlock handle);
123#endif
110 124
125#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_lock
111acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock handle); 126acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock handle);
127#endif
112 128
129#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_lock
113void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags); 130void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags);
131#endif
114 132
115/* 133/*
116 * Semaphore primitives 134 * Semaphore primitives
117 */ 135 */
136#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_semaphore
118acpi_status 137acpi_status
119acpi_os_create_semaphore(u32 max_units, 138acpi_os_create_semaphore(u32 max_units,
120 u32 initial_units, acpi_semaphore * out_handle); 139 u32 initial_units, acpi_semaphore * out_handle);
140#endif
121 141
142#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_semaphore
122acpi_status acpi_os_delete_semaphore(acpi_semaphore handle); 143acpi_status acpi_os_delete_semaphore(acpi_semaphore handle);
144#endif
123 145
146#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_semaphore
124acpi_status 147acpi_status
125acpi_os_wait_semaphore(acpi_semaphore handle, u32 units, u16 timeout); 148acpi_os_wait_semaphore(acpi_semaphore handle, u32 units, u16 timeout);
149#endif
126 150
151#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_signal_semaphore
127acpi_status acpi_os_signal_semaphore(acpi_semaphore handle, u32 units); 152acpi_status acpi_os_signal_semaphore(acpi_semaphore handle, u32 units);
153#endif
128 154
129/* 155/*
130 * Mutex primitives. May be configured to use semaphores instead via 156 * Mutex primitives. May be configured to use semaphores instead via
@@ -132,29 +158,48 @@ acpi_status acpi_os_signal_semaphore(acpi_semaphore handle, u32 units);
132 */ 158 */
133#if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE) 159#if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE)
134 160
161#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_mutex
135acpi_status acpi_os_create_mutex(acpi_mutex * out_handle); 162acpi_status acpi_os_create_mutex(acpi_mutex * out_handle);
163#endif
136 164
165#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_mutex
137void acpi_os_delete_mutex(acpi_mutex handle); 166void acpi_os_delete_mutex(acpi_mutex handle);
167#endif
138 168
169#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_mutex
139acpi_status acpi_os_acquire_mutex(acpi_mutex handle, u16 timeout); 170acpi_status acpi_os_acquire_mutex(acpi_mutex handle, u16 timeout);
171#endif
140 172
173#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_mutex
141void acpi_os_release_mutex(acpi_mutex handle); 174void acpi_os_release_mutex(acpi_mutex handle);
142#endif 175#endif
143 176
177#endif
178
144/* 179/*
145 * Memory allocation and mapping 180 * Memory allocation and mapping
146 */ 181 */
182#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
147void *acpi_os_allocate(acpi_size size); 183void *acpi_os_allocate(acpi_size size);
184#endif
148 185
186#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
187void *acpi_os_allocate_zeroed(acpi_size size);
188#endif
189
190#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
149void acpi_os_free(void *memory); 191void acpi_os_free(void *memory);
192#endif
150 193
151void __iomem *acpi_os_map_memory(acpi_physical_address where, 194#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_map_memory
152 acpi_size length); 195void *acpi_os_map_memory(acpi_physical_address where, acpi_size length);
196#endif
153 197
154void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size); 198#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_unmap_memory
155void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size); 199void acpi_os_unmap_memory(void *logical_address, acpi_size size);
200#endif
156 201
157#ifdef ACPI_FUTURE_USAGE 202#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_physical_address
158acpi_status 203acpi_status
159acpi_os_get_physical_address(void *logical_address, 204acpi_os_get_physical_address(void *logical_address,
160 acpi_physical_address * physical_address); 205 acpi_physical_address * physical_address);
@@ -163,117 +208,195 @@ acpi_os_get_physical_address(void *logical_address,
163/* 208/*
164 * Memory/Object Cache 209 * Memory/Object Cache
165 */ 210 */
211#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_cache
166acpi_status 212acpi_status
167acpi_os_create_cache(char *cache_name, 213acpi_os_create_cache(char *cache_name,
168 u16 object_size, 214 u16 object_size,
169 u16 max_depth, acpi_cache_t ** return_cache); 215 u16 max_depth, acpi_cache_t ** return_cache);
216#endif
170 217
218#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_cache
171acpi_status acpi_os_delete_cache(acpi_cache_t * cache); 219acpi_status acpi_os_delete_cache(acpi_cache_t * cache);
220#endif
172 221
222#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_purge_cache
173acpi_status acpi_os_purge_cache(acpi_cache_t * cache); 223acpi_status acpi_os_purge_cache(acpi_cache_t * cache);
224#endif
174 225
226#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
175void *acpi_os_acquire_object(acpi_cache_t * cache); 227void *acpi_os_acquire_object(acpi_cache_t * cache);
228#endif
176 229
230#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_object
177acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object); 231acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object);
232#endif
178 233
179/* 234/*
180 * Interrupt handlers 235 * Interrupt handlers
181 */ 236 */
237#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_install_interrupt_handler
182acpi_status 238acpi_status
183acpi_os_install_interrupt_handler(u32 interrupt_number, 239acpi_os_install_interrupt_handler(u32 interrupt_number,
184 acpi_osd_handler service_routine, 240 acpi_osd_handler service_routine,
185 void *context); 241 void *context);
242#endif
186 243
244#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_remove_interrupt_handler
187acpi_status 245acpi_status
188acpi_os_remove_interrupt_handler(u32 interrupt_number, 246acpi_os_remove_interrupt_handler(u32 interrupt_number,
189 acpi_osd_handler service_routine); 247 acpi_osd_handler service_routine);
190 248#endif
191void acpi_os_gpe_count(u32 gpe_number);
192void acpi_os_fixed_event_count(u32 fixed_event_number);
193 249
194/* 250/*
195 * Threads and Scheduling 251 * Threads and Scheduling
196 */ 252 */
253#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
197acpi_thread_id acpi_os_get_thread_id(void); 254acpi_thread_id acpi_os_get_thread_id(void);
255#endif
198 256
257#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_execute
199acpi_status 258acpi_status
200acpi_os_execute(acpi_execute_type type, 259acpi_os_execute(acpi_execute_type type,
201 acpi_osd_exec_callback function, void *context); 260 acpi_osd_exec_callback function, void *context);
261#endif
202 262
203acpi_status 263#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_wait_events_complete
204acpi_os_hotplug_execute(acpi_osd_exec_callback function, void *context);
205
206void acpi_os_wait_events_complete(void); 264void acpi_os_wait_events_complete(void);
265#endif
207 266
267#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_sleep
208void acpi_os_sleep(u64 milliseconds); 268void acpi_os_sleep(u64 milliseconds);
269#endif
209 270
271#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_stall
210void acpi_os_stall(u32 microseconds); 272void acpi_os_stall(u32 microseconds);
273#endif
211 274
212/* 275/*
213 * Platform and hardware-independent I/O interfaces 276 * Platform and hardware-independent I/O interfaces
214 */ 277 */
215acpi_status acpi_os_read_port(acpi_io_address address, u32 * value, u32 width); 278#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_port
279acpi_status acpi_os_read_port(acpi_io_address address, u32 *value, u32 width);
280#endif
216 281
282#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_port
217acpi_status acpi_os_write_port(acpi_io_address address, u32 value, u32 width); 283acpi_status acpi_os_write_port(acpi_io_address address, u32 value, u32 width);
284#endif
218 285
219/* 286/*
220 * Platform and hardware-independent physical memory interfaces 287 * Platform and hardware-independent physical memory interfaces
221 */ 288 */
289#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_memory
222acpi_status 290acpi_status
223acpi_os_read_memory(acpi_physical_address address, u64 *value, u32 width); 291acpi_os_read_memory(acpi_physical_address address, u64 *value, u32 width);
292#endif
224 293
294#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_memory
225acpi_status 295acpi_status
226acpi_os_write_memory(acpi_physical_address address, u64 value, u32 width); 296acpi_os_write_memory(acpi_physical_address address, u64 value, u32 width);
297#endif
227 298
228/* 299/*
229 * Platform and hardware-independent PCI configuration space access 300 * Platform and hardware-independent PCI configuration space access
230 * Note: Can't use "Register" as a parameter, changed to "Reg" -- 301 * Note: Can't use "Register" as a parameter, changed to "Reg" --
231 * certain compilers complain. 302 * certain compilers complain.
232 */ 303 */
304#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_pci_configuration
233acpi_status 305acpi_status
234acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id, 306acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id,
235 u32 reg, u64 *value, u32 width); 307 u32 reg, u64 *value, u32 width);
308#endif
236 309
310#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_pci_configuration
237acpi_status 311acpi_status
238acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id, 312acpi_os_write_pci_configuration(struct acpi_pci_id *pci_id,
239 u32 reg, u64 value, u32 width); 313 u32 reg, u64 value, u32 width);
314#endif
240 315
241/* 316/*
242 * Miscellaneous 317 * Miscellaneous
243 */ 318 */
319#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
320u8 acpi_os_readable(void *pointer, acpi_size length);
321#endif
322
323#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
324u8 acpi_os_writable(void *pointer, acpi_size length);
325#endif
326
327#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_timer
244u64 acpi_os_get_timer(void); 328u64 acpi_os_get_timer(void);
329#endif
245 330
331#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_signal
246acpi_status acpi_os_signal(u32 function, void *info); 332acpi_status acpi_os_signal(u32 function, void *info);
333#endif
247 334
248/* 335/*
249 * Debug print routines 336 * Debug print routines
250 */ 337 */
338#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_printf
251void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *format, ...); 339void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *format, ...);
340#endif
252 341
342#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_vprintf
253void acpi_os_vprintf(const char *format, va_list args); 343void acpi_os_vprintf(const char *format, va_list args);
344#endif
254 345
346#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
255void acpi_os_redirect_output(void *destination); 347void acpi_os_redirect_output(void *destination);
348#endif
256 349
257#ifdef ACPI_FUTURE_USAGE
258/* 350/*
259 * Debug input 351 * Debug input
260 */ 352 */
261u32 acpi_os_get_line(char *buffer); 353#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_line
354acpi_status acpi_os_get_line(char *buffer, u32 buffer_length, u32 *bytes_read);
355#endif
356
357/*
358 * Obtain ACPI table(s)
359 */
360#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name
361acpi_status
362acpi_os_get_table_by_name(char *signature,
363 u32 instance,
364 struct acpi_table_header **table,
365 acpi_physical_address * address);
366#endif
367
368#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index
369acpi_status
370acpi_os_get_table_by_index(u32 index,
371 struct acpi_table_header **table,
372 u32 *instance, acpi_physical_address * address);
373#endif
374
375#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address
376acpi_status
377acpi_os_get_table_by_address(acpi_physical_address address,
378 struct acpi_table_header **table);
262#endif 379#endif
263 380
264/* 381/*
265 * Directory manipulation 382 * Directory manipulation
266 */ 383 */
384#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory
267void *acpi_os_open_directory(char *pathname, 385void *acpi_os_open_directory(char *pathname,
268 char *wildcard_spec, char requested_file_type); 386 char *wildcard_spec, char requested_file_type);
387#endif
269 388
270/* requeste_file_type values */ 389/* requeste_file_type values */
271 390
272#define REQUEST_FILE_ONLY 0 391#define REQUEST_FILE_ONLY 0
273#define REQUEST_DIR_ONLY 1 392#define REQUEST_DIR_ONLY 1
274 393
394#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
275char *acpi_os_get_next_filename(void *dir_handle); 395char *acpi_os_get_next_filename(void *dir_handle);
396#endif
276 397
398#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
277void acpi_os_close_directory(void *dir_handle); 399void acpi_os_close_directory(void *dir_handle);
400#endif
278 401
279#endif /* __ACPIOSXF_H__ */ 402#endif /* __ACPIOSXF_H__ */
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 85bfdbe17805..d8f9457755b4 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -46,7 +46,7 @@
46 46
47/* Current ACPICA subsystem version in YYYYMMDD format */ 47/* Current ACPICA subsystem version in YYYYMMDD format */
48 48
49#define ACPI_CA_VERSION 0x20130725 49#define ACPI_CA_VERSION 0x20130927
50 50
51#include <acpi/acconfig.h> 51#include <acpi/acconfig.h>
52#include <acpi/actypes.h> 52#include <acpi/actypes.h>
@@ -54,6 +54,7 @@
54#include <acpi/acbuffer.h> 54#include <acpi/acbuffer.h>
55 55
56extern u8 acpi_gbl_permanent_mmap; 56extern u8 acpi_gbl_permanent_mmap;
57extern u32 acpi_rsdt_forced;
57 58
58/* 59/*
59 * Globals that are publically available 60 * Globals that are publically available
@@ -106,39 +107,41 @@ extern u8 acpi_gbl_disable_ssdt_table_load;
106 static ACPI_INLINE prototype {return(AE_OK);} 107 static ACPI_INLINE prototype {return(AE_OK);}
107 108
108#define ACPI_HW_DEPENDENT_RETURN_VOID(prototype) \ 109#define ACPI_HW_DEPENDENT_RETURN_VOID(prototype) \
109 static ACPI_INLINE prototype {} 110 static ACPI_INLINE prototype {return;}
110 111
111#endif /* !ACPI_REDUCED_HARDWARE */ 112#endif /* !ACPI_REDUCED_HARDWARE */
112 113
113extern u32 acpi_rsdt_forced;
114/* 114/*
115 * Initialization 115 * Initialization
116 */ 116 */
117acpi_status 117acpi_status __init
118acpi_initialize_tables(struct acpi_table_desc *initial_storage, 118acpi_initialize_tables(struct acpi_table_desc *initial_storage,
119 u32 initial_table_count, u8 allow_resize); 119 u32 initial_table_count, u8 allow_resize);
120 120
121acpi_status __init acpi_initialize_subsystem(void); 121acpi_status __init acpi_initialize_subsystem(void);
122 122
123acpi_status acpi_enable_subsystem(u32 flags); 123acpi_status __init acpi_enable_subsystem(u32 flags);
124 124
125acpi_status acpi_initialize_objects(u32 flags); 125acpi_status __init acpi_initialize_objects(u32 flags);
126 126
127acpi_status acpi_terminate(void); 127acpi_status __init acpi_terminate(void);
128 128
129/* 129/*
130 * Miscellaneous global interfaces 130 * Miscellaneous global interfaces
131 */ 131 */
132ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable(void)) 132ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable(void))
133
133ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable(void)) 134ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable(void))
134#ifdef ACPI_FUTURE_USAGE 135#ifdef ACPI_FUTURE_USAGE
135acpi_status acpi_subsystem_status(void); 136 acpi_status acpi_subsystem_status(void);
136#endif 137#endif
137 138
138#ifdef ACPI_FUTURE_USAGE 139#ifdef ACPI_FUTURE_USAGE
139acpi_status acpi_get_system_info(struct acpi_buffer *ret_buffer); 140acpi_status acpi_get_system_info(struct acpi_buffer *ret_buffer);
140#endif 141#endif
141 142
143acpi_status acpi_get_statistics(struct acpi_statistics *stats);
144
142const char *acpi_format_exception(acpi_status exception); 145const char *acpi_format_exception(acpi_status exception);
143 146
144acpi_status acpi_purge_cached_objects(void); 147acpi_status acpi_purge_cached_objects(void);
@@ -159,29 +162,20 @@ acpi_decode_pld_buffer(u8 *in_buffer,
159 acpi_size length, struct acpi_pld_info **return_buffer); 162 acpi_size length, struct acpi_pld_info **return_buffer);
160 163
161/* 164/*
162 * ACPI Memory management
163 */
164void *acpi_allocate(u32 size);
165
166void *acpi_callocate(u32 size);
167
168void acpi_free(void *address);
169
170/*
171 * ACPI table load/unload interfaces 165 * ACPI table load/unload interfaces
172 */ 166 */
173acpi_status acpi_load_table(struct acpi_table_header *table); 167acpi_status acpi_load_table(struct acpi_table_header *table);
174 168
175acpi_status acpi_unload_parent_table(acpi_handle object); 169acpi_status acpi_unload_parent_table(acpi_handle object);
176 170
177acpi_status acpi_load_tables(void); 171acpi_status __init acpi_load_tables(void);
178 172
179/* 173/*
180 * ACPI table manipulation interfaces 174 * ACPI table manipulation interfaces
181 */ 175 */
182acpi_status acpi_reallocate_root_table(void); 176acpi_status __init acpi_reallocate_root_table(void);
183 177
184acpi_status acpi_find_root_pointer(acpi_size *rsdp_address); 178acpi_status __init acpi_find_root_pointer(acpi_size *rsdp_address);
185 179
186acpi_status acpi_unload_table_id(acpi_owner_id id); 180acpi_status acpi_unload_table_id(acpi_owner_id id);
187 181
@@ -193,6 +187,7 @@ acpi_status
193acpi_get_table_with_size(acpi_string signature, 187acpi_get_table_with_size(acpi_string signature,
194 u32 instance, struct acpi_table_header **out_table, 188 u32 instance, struct acpi_table_header **out_table,
195 acpi_size *tbl_size); 189 acpi_size *tbl_size);
190
196acpi_status 191acpi_status
197acpi_get_table(acpi_string signature, 192acpi_get_table(acpi_string signature,
198 u32 instance, struct acpi_table_header **out_table); 193 u32 instance, struct acpi_table_header **out_table);
@@ -280,8 +275,18 @@ acpi_status
280acpi_install_initialization_handler(acpi_init_handler handler, u32 function); 275acpi_install_initialization_handler(acpi_init_handler handler, u32 function);
281 276
282ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 277ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
283 acpi_install_global_event_handler 278 acpi_install_sci_handler(acpi_sci_handler
284 (acpi_gbl_event_handler handler, void *context)) 279 address,
280 void *context))
281
282ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
283 acpi_remove_sci_handler(acpi_sci_handler
284 address))
285
286ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
287 acpi_install_global_event_handler
288 (acpi_gbl_event_handler handler,
289 void *context))
285 290
286ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 291ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
287 acpi_install_fixed_event_handler(u32 292 acpi_install_fixed_event_handler(u32
@@ -290,10 +295,12 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
290 handler, 295 handler,
291 void 296 void
292 *context)) 297 *context))
298
293ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 299ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
294 acpi_remove_fixed_event_handler(u32 acpi_event, 300 acpi_remove_fixed_event_handler(u32 acpi_event,
295 acpi_event_handler 301 acpi_event_handler
296 handler)) 302 handler))
303
297ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 304ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
298 acpi_install_gpe_handler(acpi_handle 305 acpi_install_gpe_handler(acpi_handle
299 gpe_device, 306 gpe_device,
@@ -302,6 +309,7 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
302 acpi_gpe_handler 309 acpi_gpe_handler
303 address, 310 address,
304 void *context)) 311 void *context))
312
305ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 313ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
306 acpi_remove_gpe_handler(acpi_handle gpe_device, 314 acpi_remove_gpe_handler(acpi_handle gpe_device,
307 u32 gpe_number, 315 u32 gpe_number,
@@ -338,6 +346,7 @@ acpi_status acpi_install_interface_handler(acpi_interface_handler handler);
338ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 346ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
339 acpi_acquire_global_lock(u16 timeout, 347 acpi_acquire_global_lock(u16 timeout,
340 u32 *handle)) 348 u32 *handle))
349
341ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 350ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
342 acpi_release_global_lock(u32 handle)) 351 acpi_release_global_lock(u32 handle))
343 352
@@ -364,6 +373,7 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
364 acpi_get_event_status(u32 event, 373 acpi_get_event_status(u32 event,
365 acpi_event_status 374 acpi_event_status
366 *event_status)) 375 *event_status))
376
367/* 377/*
368 * General Purpose Event (GPE) Interfaces 378 * General Purpose Event (GPE) Interfaces
369 */ 379 */
@@ -394,10 +404,12 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
394 parent_device, 404 parent_device,
395 acpi_handle gpe_device, 405 acpi_handle gpe_device,
396 u32 gpe_number)) 406 u32 gpe_number))
407
397ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 408ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
398 acpi_set_gpe_wake_mask(acpi_handle gpe_device, 409 acpi_set_gpe_wake_mask(acpi_handle gpe_device,
399 u32 gpe_number, 410 u32 gpe_number,
400 u8 action)) 411 u8 action))
412
401ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 413ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
402 acpi_get_gpe_status(acpi_handle gpe_device, 414 acpi_get_gpe_status(acpi_handle gpe_device,
403 u32 gpe_number, 415 u32 gpe_number,
@@ -419,6 +431,7 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
419 *gpe_block_address, 431 *gpe_block_address,
420 u32 register_count, 432 u32 register_count,
421 u32 interrupt_number)) 433 u32 interrupt_number))
434
422ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 435ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
423 acpi_remove_gpe_block(acpi_handle gpe_device)) 436 acpi_remove_gpe_block(acpi_handle gpe_device))
424 437
@@ -493,13 +506,13 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
493 * Sleep/Wake interfaces 506 * Sleep/Wake interfaces
494 */ 507 */
495acpi_status 508acpi_status
496acpi_get_sleep_type_data(u8 sleep_state, u8 * slp_typ_a, u8 * slp_typ_b); 509acpi_get_sleep_type_data(u8 sleep_state, u8 *slp_typ_a, u8 *slp_typ_b);
497 510
498acpi_status acpi_enter_sleep_state_prep(u8 sleep_state); 511acpi_status acpi_enter_sleep_state_prep(u8 sleep_state);
499 512
500acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state); 513acpi_status acpi_enter_sleep_state(u8 sleep_state);
501 514
502ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)) 515ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enter_sleep_state_s4bios(void))
503 516
504acpi_status acpi_leave_sleep_state_prep(u8 sleep_state); 517acpi_status acpi_leave_sleep_state_prep(u8 sleep_state);
505 518
@@ -508,7 +521,6 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state);
508ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 521ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
509 acpi_set_firmware_waking_vector(u32 522 acpi_set_firmware_waking_vector(u32
510 physical_address)) 523 physical_address))
511
512#if ACPI_MACHINE_WIDTH == 64 524#if ACPI_MACHINE_WIDTH == 64
513ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 525ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
514 acpi_set_firmware_waking_vector64(u64 526 acpi_set_firmware_waking_vector64(u64
@@ -532,50 +544,53 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
532/* 544/*
533 * Error/Warning output 545 * Error/Warning output
534 */ 546 */
547ACPI_PRINTF_LIKE(3)
535void ACPI_INTERNAL_VAR_XFACE 548void ACPI_INTERNAL_VAR_XFACE
536acpi_error(const char *module_name, 549acpi_error(const char *module_name, u32 line_number, const char *format, ...);
537 u32 line_number, const char *format, ...) ACPI_PRINTF_LIKE(3);
538 550
551ACPI_PRINTF_LIKE(4)
539void ACPI_INTERNAL_VAR_XFACE 552void ACPI_INTERNAL_VAR_XFACE
540acpi_exception(const char *module_name, 553acpi_exception(const char *module_name,
541 u32 line_number, 554 u32 line_number, acpi_status status, const char *format, ...);
542 acpi_status status, const char *format, ...) ACPI_PRINTF_LIKE(4);
543 555
556ACPI_PRINTF_LIKE(3)
544void ACPI_INTERNAL_VAR_XFACE 557void ACPI_INTERNAL_VAR_XFACE
545acpi_warning(const char *module_name, 558acpi_warning(const char *module_name, u32 line_number, const char *format, ...);
546 u32 line_number, const char *format, ...) ACPI_PRINTF_LIKE(3);
547 559
560ACPI_PRINTF_LIKE(3)
548void ACPI_INTERNAL_VAR_XFACE 561void ACPI_INTERNAL_VAR_XFACE
549acpi_info(const char *module_name, 562acpi_info(const char *module_name, u32 line_number, const char *format, ...);
550 u32 line_number, const char *format, ...) ACPI_PRINTF_LIKE(3);
551 563
564ACPI_PRINTF_LIKE(3)
552void ACPI_INTERNAL_VAR_XFACE 565void ACPI_INTERNAL_VAR_XFACE
553acpi_bios_error(const char *module_name, 566acpi_bios_error(const char *module_name,
554 u32 line_number, const char *format, ...) ACPI_PRINTF_LIKE(3); 567 u32 line_number, const char *format, ...);
555 568
569ACPI_PRINTF_LIKE(3)
556void ACPI_INTERNAL_VAR_XFACE 570void ACPI_INTERNAL_VAR_XFACE
557acpi_bios_warning(const char *module_name, 571acpi_bios_warning(const char *module_name,
558 u32 line_number, const char *format, ...) ACPI_PRINTF_LIKE(3); 572 u32 line_number, const char *format, ...);
559 573
560/* 574/*
561 * Debug output 575 * Debug output
562 */ 576 */
563#ifdef ACPI_DEBUG_OUTPUT 577#ifdef ACPI_DEBUG_OUTPUT
564 578
579ACPI_PRINTF_LIKE(6)
565void ACPI_INTERNAL_VAR_XFACE 580void ACPI_INTERNAL_VAR_XFACE
566acpi_debug_print(u32 requested_debug_level, 581acpi_debug_print(u32 requested_debug_level,
567 u32 line_number, 582 u32 line_number,
568 const char *function_name, 583 const char *function_name,
569 const char *module_name, 584 const char *module_name,
570 u32 component_id, const char *format, ...) ACPI_PRINTF_LIKE(6); 585 u32 component_id, const char *format, ...);
571 586
587ACPI_PRINTF_LIKE(6)
572void ACPI_INTERNAL_VAR_XFACE 588void ACPI_INTERNAL_VAR_XFACE
573acpi_debug_print_raw(u32 requested_debug_level, 589acpi_debug_print_raw(u32 requested_debug_level,
574 u32 line_number, 590 u32 line_number,
575 const char *function_name, 591 const char *function_name,
576 const char *module_name, 592 const char *module_name,
577 u32 component_id, 593 u32 component_id, const char *format, ...);
578 const char *format, ...) ACPI_PRINTF_LIKE(6);
579#endif 594#endif
580 595
581#endif /* __ACXFACE_H__ */ 596#endif /* __ACXFACE_H__ */
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index 9b58a8f43771..94970880126f 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -146,7 +146,24 @@ struct acpi_table_rsdp {
146 u8 reserved[3]; /* Reserved, must be zero */ 146 u8 reserved[3]; /* Reserved, must be zero */
147}; 147};
148 148
149#define ACPI_RSDP_REV0_SIZE 20 /* Size of original ACPI 1.0 RSDP */ 149/* Standalone struct for the ACPI 1.0 RSDP */
150
151struct acpi_rsdp_common {
152 char signature[8];
153 u8 checksum;
154 char oem_id[ACPI_OEM_ID_SIZE];
155 u8 revision;
156 u32 rsdt_physical_address;
157};
158
159/* Standalone struct for the extended part of the RSDP (ACPI 2.0+) */
160
161struct acpi_rsdp_extension {
162 u32 length;
163 u64 xsdt_physical_address;
164 u8 extended_checksum;
165 u8 reserved[3];
166};
150 167
151/******************************************************************************* 168/*******************************************************************************
152 * 169 *
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index ffaac0e7e0c6..40f7ed115452 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -444,8 +444,8 @@ enum acpi_dmar_scope_type {
444}; 444};
445 445
446struct acpi_dmar_pci_path { 446struct acpi_dmar_pci_path {
447 u8 dev; 447 u8 device;
448 u8 fn; 448 u8 function;
449}; 449};
450 450
451/* 451/*
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index b748aefce929..809b1a0fee7f 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -299,13 +299,57 @@ typedef u32 acpi_physical_address;
299#endif 299#endif
300 300
301/* 301/*
302 * All ACPICA functions that are available to the rest of the kernel are 302 * All ACPICA external functions that are available to the rest of the kernel
303 * tagged with this macro which can be defined as appropriate for the host. 303 * are tagged with thes macros which can be defined as appropriate for the host.
304 *
305 * Notes:
306 * ACPI_EXPORT_SYMBOL_INIT is used for initialization and termination
307 * interfaces that may need special processing.
308 * ACPI_EXPORT_SYMBOL is used for all other public external functions.
304 */ 309 */
310#ifndef ACPI_EXPORT_SYMBOL_INIT
311#define ACPI_EXPORT_SYMBOL_INIT(symbol)
312#endif
313
305#ifndef ACPI_EXPORT_SYMBOL 314#ifndef ACPI_EXPORT_SYMBOL
306#define ACPI_EXPORT_SYMBOL(symbol) 315#define ACPI_EXPORT_SYMBOL(symbol)
307#endif 316#endif
308 317
318/*
319 * Compiler/Clibrary-dependent debug initialization. Used for ACPICA
320 * utilities only.
321 */
322#ifndef ACPI_DEBUG_INITIALIZE
323#define ACPI_DEBUG_INITIALIZE()
324#endif
325
326/*******************************************************************************
327 *
328 * Configuration
329 *
330 ******************************************************************************/
331
332#ifdef ACPI_DBG_TRACK_ALLOCATIONS
333/*
334 * Memory allocation tracking (used by acpi_exec to detect memory leaks)
335 */
336#define ACPI_MEM_PARAMETERS _COMPONENT, _acpi_module_name, __LINE__
337#define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track ((acpi_size) (a), ACPI_MEM_PARAMETERS)
338#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track ((acpi_size) (a), ACPI_MEM_PARAMETERS)
339#define ACPI_FREE(a) acpi_ut_free_and_track (a, ACPI_MEM_PARAMETERS)
340#define ACPI_MEM_TRACKING(a) a
341
342#else
343/*
344 * Normal memory allocation directly via the OS services layer
345 */
346#define ACPI_ALLOCATE(a) acpi_os_allocate ((acpi_size) (a))
347#define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed ((acpi_size) (a))
348#define ACPI_FREE(a) acpi_os_free (a)
349#define ACPI_MEM_TRACKING(a)
350
351#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
352
309/****************************************************************************** 353/******************************************************************************
310 * 354 *
311 * ACPI Specification constants (Do not change unless the specification changes) 355 * ACPI Specification constants (Do not change unless the specification changes)
@@ -322,6 +366,7 @@ typedef u32 acpi_physical_address;
322#define ACPI_PM1_REGISTER_WIDTH 16 366#define ACPI_PM1_REGISTER_WIDTH 16
323#define ACPI_PM2_REGISTER_WIDTH 8 367#define ACPI_PM2_REGISTER_WIDTH 8
324#define ACPI_PM_TIMER_WIDTH 32 368#define ACPI_PM_TIMER_WIDTH 32
369#define ACPI_RESET_REGISTER_WIDTH 8
325 370
326/* Names within the namespace are 4 bytes long */ 371/* Names within the namespace are 4 bytes long */
327 372
@@ -474,6 +519,11 @@ typedef u64 acpi_integer;
474#define ACPI_MOVE_NAME(dest,src) (ACPI_STRNCPY (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAME_SIZE)) 519#define ACPI_MOVE_NAME(dest,src) (ACPI_STRNCPY (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAME_SIZE))
475#endif 520#endif
476 521
522/* Support for the special RSDP signature (8 characters) */
523
524#define ACPI_VALIDATE_RSDP_SIG(a) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_SIG_RSDP, 8))
525#define ACPI_MAKE_RSDP_SIG(dest) (ACPI_MEMCPY (ACPI_CAST_PTR (char, (dest)), ACPI_SIG_RSDP, 8))
526
477/******************************************************************************* 527/*******************************************************************************
478 * 528 *
479 * Miscellaneous constants 529 * Miscellaneous constants
@@ -886,9 +936,13 @@ struct acpi_buffer {
886 void *pointer; /* pointer to buffer */ 936 void *pointer; /* pointer to buffer */
887}; 937};
888 938
889/* Free a buffer created in an struct acpi_buffer via ACPI_ALLOCATE_LOCAL_BUFFER */ 939/*
890 940 * Free a buffer created in an struct acpi_buffer via ACPI_ALLOCATE_BUFFER.
891#define ACPI_FREE_BUFFER(b) ACPI_FREE(b.pointer) 941 * Note: We use acpi_os_free here because acpi_os_allocate was used to allocate
942 * the buffer. This purposefully bypasses the internal allocation tracking
943 * mechanism (if it is enabled).
944 */
945#define ACPI_FREE_BUFFER(b) acpi_os_free((b).pointer)
892 946
893/* 947/*
894 * name_type for acpi_get_name 948 * name_type for acpi_get_name
@@ -927,6 +981,16 @@ struct acpi_system_info {
927 u32 debug_layer; 981 u32 debug_layer;
928}; 982};
929 983
984/*
985 * System statistics returned by acpi_get_statistics()
986 */
987struct acpi_statistics {
988 u32 sci_count;
989 u32 gpe_count;
990 u32 fixed_event_count[ACPI_NUM_FIXED_EVENTS];
991 u32 method_count;
992};
993
930/* Table Event Types */ 994/* Table Event Types */
931 995
932#define ACPI_TABLE_EVENT_LOAD 0x0 996#define ACPI_TABLE_EVENT_LOAD 0x0
@@ -946,6 +1010,9 @@ typedef void
946 * Various handlers and callback procedures 1010 * Various handlers and callback procedures
947 */ 1011 */
948typedef 1012typedef
1013u32 (*acpi_sci_handler) (void *context);
1014
1015typedef
949void (*acpi_gbl_event_handler) (u32 event_type, 1016void (*acpi_gbl_event_handler) (u32 event_type,
950 acpi_handle device, 1017 acpi_handle device,
951 u32 event_number, void *context); 1018 u32 event_number, void *context);
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index ef04b36ca6ed..974d3ef7c141 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -96,10 +96,11 @@
96#endif 96#endif
97 97
98/* 98/*
99 * acpi_bin/acpi_help/acpi_src configuration. All single threaded, with 99 * acpi_bin/acpi_dump/acpi_src/acpi_xtract configuration. All single
100 * no debug output. 100 * threaded, with no debug output.
101 */ 101 */
102#if (defined ACPI_BIN_APP) || \ 102#if (defined ACPI_BIN_APP) || \
103 (defined ACPI_DUMP_APP) || \
103 (defined ACPI_SRC_APP) || \ 104 (defined ACPI_SRC_APP) || \
104 (defined ACPI_XTRACT_APP) 105 (defined ACPI_XTRACT_APP)
105#define ACPI_APPLICATION 106#define ACPI_APPLICATION
@@ -147,6 +148,9 @@
147#if defined(_LINUX) || defined(__linux__) 148#if defined(_LINUX) || defined(__linux__)
148#include <acpi/platform/aclinux.h> 149#include <acpi/platform/aclinux.h>
149 150
151#elif defined(_APPLE) || defined(__APPLE__)
152#include "acmacosx.h"
153
150#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) 154#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
151#include "acfreebsd.h" 155#include "acfreebsd.h"
152 156
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 68534ef86ec8..28f4f4dba0b6 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -50,7 +50,6 @@
50#define ACPI_USE_DO_WHILE_0 50#define ACPI_USE_DO_WHILE_0
51#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE 51#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE
52 52
53
54#ifdef __KERNEL__ 53#ifdef __KERNEL__
55 54
56#include <linux/string.h> 55#include <linux/string.h>
@@ -58,11 +57,13 @@
58#include <linux/ctype.h> 57#include <linux/ctype.h>
59#include <linux/sched.h> 58#include <linux/sched.h>
60#include <linux/atomic.h> 59#include <linux/atomic.h>
61#include <asm/div64.h> 60#include <linux/math64.h>
62#include <asm/acpi.h>
63#include <linux/slab.h> 61#include <linux/slab.h>
64#include <linux/spinlock_types.h> 62#include <linux/spinlock_types.h>
65#include <asm/current.h> 63#ifdef EXPORT_ACPI_INTERFACES
64#include <linux/export.h>
65#endif
66#include <asm/acpi.h>
66 67
67/* Host-dependent types and defines for in-kernel ACPICA */ 68/* Host-dependent types and defines for in-kernel ACPICA */
68 69
@@ -74,7 +75,7 @@
74#define acpi_spinlock spinlock_t * 75#define acpi_spinlock spinlock_t *
75#define acpi_cpu_flags unsigned long 76#define acpi_cpu_flags unsigned long
76 77
77#else /* !__KERNEL__ */ 78#else /* !__KERNEL__ */
78 79
79#include <stdarg.h> 80#include <stdarg.h>
80#include <string.h> 81#include <string.h>
@@ -87,7 +88,7 @@
87#define ACPI_FLUSH_CPU_CACHE() 88#define ACPI_FLUSH_CPU_CACHE()
88#define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread)) 89#define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread))
89 90
90#if defined(__ia64__) || defined(__x86_64__) 91#if defined(__ia64__) || defined(__x86_64__) || defined(__aarch64__)
91#define ACPI_MACHINE_WIDTH 64 92#define ACPI_MACHINE_WIDTH 64
92#define COMPILER_DEPENDENT_INT64 long 93#define COMPILER_DEPENDENT_INT64 long
93#define COMPILER_DEPENDENT_UINT64 unsigned long 94#define COMPILER_DEPENDENT_UINT64 unsigned long
@@ -102,21 +103,35 @@
102#define __cdecl 103#define __cdecl
103#endif 104#endif
104 105
105#endif /* __KERNEL__ */ 106#endif /* __KERNEL__ */
106 107
107/* Linux uses GCC */ 108/* Linux uses GCC */
108 109
109#include <acpi/platform/acgcc.h> 110#include <acpi/platform/acgcc.h>
110 111
111#ifdef __KERNEL__ 112#ifdef __KERNEL__
113
114/*
115 * FIXME: Inclusion of actypes.h
116 * Linux kernel need this before defining inline OSL interfaces as
117 * actypes.h need to be included to find ACPICA type definitions.
118 * Since from ACPICA's perspective, the actypes.h should be included after
119 * acenv.h (aclinux.h), this leads to a inclusion mis-ordering issue.
120 */
112#include <acpi/actypes.h> 121#include <acpi/actypes.h>
122
113/* 123/*
114 * Overrides for in-kernel ACPICA 124 * Overrides for in-kernel ACPICA
115 */ 125 */
116static inline acpi_thread_id acpi_os_get_thread_id(void) 126acpi_status __init acpi_os_initialize(void);
117{ 127#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
118 return (acpi_thread_id)(unsigned long)current; 128
119} 129acpi_status acpi_os_terminate(void);
130#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
131
132/*
133 * Memory allocation/deallocation
134 */
120 135
121/* 136/*
122 * The irqs_disabled() check is for resume from RAM. 137 * The irqs_disabled() check is for resume from RAM.
@@ -126,25 +141,45 @@ static inline acpi_thread_id acpi_os_get_thread_id(void)
126 */ 141 */
127static inline void *acpi_os_allocate(acpi_size size) 142static inline void *acpi_os_allocate(acpi_size size)
128{ 143{
129 return kmalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); 144 return kmalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
130} 145}
131 146
147#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
148
149/* Use native linux version of acpi_os_allocate_zeroed */
150
132static inline void *acpi_os_allocate_zeroed(acpi_size size) 151static inline void *acpi_os_allocate_zeroed(acpi_size size)
133{ 152{
134 return kzalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); 153 return kzalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
154}
155
156#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
157#define USE_NATIVE_ALLOCATE_ZEROED
158
159static inline void acpi_os_free(void *memory)
160{
161 kfree(memory);
135} 162}
136 163
164#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
165
137static inline void *acpi_os_acquire_object(acpi_cache_t * cache) 166static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
138{ 167{
139 return kmem_cache_zalloc(cache, 168 return kmem_cache_zalloc(cache,
140 irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); 169 irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
170}
171
172#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
173
174static inline acpi_thread_id acpi_os_get_thread_id(void)
175{
176 return (acpi_thread_id) (unsigned long)current;
141} 177}
142 178
143#define ACPI_ALLOCATE(a) acpi_os_allocate(a) 179#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
144#define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed(a)
145#define ACPI_FREE(a) kfree(a)
146 180
147#ifndef CONFIG_PREEMPT 181#ifndef CONFIG_PREEMPT
182
148/* 183/*
149 * Used within ACPICA to show where it is safe to preempt execution 184 * Used within ACPICA to show where it is safe to preempt execution
150 * when CONFIG_PREEMPT=n 185 * when CONFIG_PREEMPT=n
@@ -154,6 +189,7 @@ static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
154 if (!irqs_disabled()) \ 189 if (!irqs_disabled()) \
155 cond_resched(); \ 190 cond_resched(); \
156 } while (0) 191 } while (0)
192
157#endif 193#endif
158 194
159/* 195/*
@@ -163,17 +199,50 @@ static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
163 * all locks to the name of the argument of acpi_os_create_lock(), which 199 * all locks to the name of the argument of acpi_os_create_lock(), which
164 * prevents lockdep from reporting false positives for ACPICA locks. 200 * prevents lockdep from reporting false positives for ACPICA locks.
165 */ 201 */
166#define acpi_os_create_lock(__handle) \ 202#define acpi_os_create_lock(__handle) \
167({ \ 203 ({ \
168 spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \ 204 spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \
169 \ 205 if (lock) { \
170 if (lock) { \ 206 *(__handle) = lock; \
171 *(__handle) = lock; \ 207 spin_lock_init(*(__handle)); \
172 spin_lock_init(*(__handle)); \ 208 } \
173 } \ 209 lock ? AE_OK : AE_NO_MEMORY; \
174 lock ? AE_OK : AE_NO_MEMORY; \ 210 })
175}) 211#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
176 212
177#endif /* __KERNEL__ */ 213void __iomem *acpi_os_map_memory(acpi_physical_address where, acpi_size length);
178 214#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_map_memory
179#endif /* __ACLINUX_H__ */ 215
216void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
217#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_unmap_memory
218
219/*
220 * OSL interfaces used by debugger/disassembler
221 */
222#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
223#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
224
225/*
226 * OSL interfaces used by utilities
227 */
228#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
229#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_line
230#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name
231#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index
232#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address
233#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory
234#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
235#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
236
237/*
238 * OSL interfaces added by Linux
239 */
240void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size);
241
242void acpi_os_gpe_count(u32 gpe_number);
243
244void acpi_os_fixed_event_count(u32 fixed_event_number);
245
246#endif /* __KERNEL__ */
247
248#endif /* __ACLINUX_H__ */
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 66096d06925e..6eb1d3cb5104 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -199,6 +199,7 @@ struct acpi_processor_flags {
199struct acpi_processor { 199struct acpi_processor {
200 acpi_handle handle; 200 acpi_handle handle;
201 u32 acpi_id; 201 u32 acpi_id;
202 u32 apic_id;
202 u32 id; 203 u32 id;
203 u32 pblk; 204 u32 pblk;
204 int performance_platform_limit; 205 int performance_platform_limit;
@@ -224,7 +225,6 @@ struct acpi_processor_errata {
224 } piix4; 225 } piix4;
225}; 226};
226 227
227extern void acpi_processor_load_module(struct acpi_processor *pr);
228extern int acpi_processor_preregister_performance(struct 228extern int acpi_processor_preregister_performance(struct
229 acpi_processor_performance 229 acpi_processor_performance
230 __percpu *performance); 230 __percpu *performance);
@@ -314,6 +314,8 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
314 314
315/* in processor_core.c */ 315/* in processor_core.c */
316void acpi_processor_set_pdc(acpi_handle handle); 316void acpi_processor_set_pdc(acpi_handle handle);
317int acpi_get_apicid(acpi_handle, int type, u32 acpi_id);
318int acpi_map_cpuid(int apic_id, u32 acpi_id);
317int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); 319int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
318 320
319/* in processor_throttling.c */ 321/* in processor_throttling.c */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index c30bac8503bc..74c5a8e467e8 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -116,7 +116,7 @@ void acpi_numa_arch_fixup(void);
116 116
117#ifdef CONFIG_ACPI_HOTPLUG_CPU 117#ifdef CONFIG_ACPI_HOTPLUG_CPU
118/* Arch dependent functions for cpu hotplug support */ 118/* Arch dependent functions for cpu hotplug support */
119int acpi_map_lsapic(acpi_handle handle, int *pcpu); 119int acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu);
120int acpi_unmap_lsapic(int cpu); 120int acpi_unmap_lsapic(int cpu);
121#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 121#endif /* CONFIG_ACPI_HOTPLUG_CPU */
122 122
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 53b77949c79d..5f9cd963213d 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -100,6 +100,9 @@ struct backlight_device {
100 /* The framebuffer notifier block */ 100 /* The framebuffer notifier block */
101 struct notifier_block fb_notif; 101 struct notifier_block fb_notif;
102 102
103 /* list entry of all registered backlight devices */
104 struct list_head entry;
105
103 struct device dev; 106 struct device dev;
104}; 107};
105 108
@@ -123,6 +126,7 @@ extern void devm_backlight_device_unregister(struct device *dev,
123 struct backlight_device *bd); 126 struct backlight_device *bd);
124extern void backlight_force_update(struct backlight_device *bd, 127extern void backlight_force_update(struct backlight_device *bd,
125 enum backlight_update_reason reason); 128 enum backlight_update_reason reason);
129extern bool backlight_device_registered(enum backlight_type type);
126 130
127#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev) 131#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
128 132
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index bd0c4598d03b..abc9ca778456 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -4,8 +4,11 @@
4 4
5#ifdef __KERNEL__ 5#ifdef __KERNEL__
6#define BIT(nr) (1UL << (nr)) 6#define BIT(nr) (1UL << (nr))
7#define BIT_ULL(nr) (1ULL << (nr))
7#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) 8#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
8#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) 9#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
10#define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG))
11#define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG)
9#define BITS_PER_BYTE 8 12#define BITS_PER_BYTE 8
10#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) 13#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
11#endif 14#endif
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index fbd25c3c2923..03e235ad1bba 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -188,19 +188,6 @@ extern void cpu_hotplug_enable(void);
188void clear_tasks_mm_cpumask(int cpu); 188void clear_tasks_mm_cpumask(int cpu);
189int cpu_down(unsigned int cpu); 189int cpu_down(unsigned int cpu);
190 190
191#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
192extern void cpu_hotplug_driver_lock(void);
193extern void cpu_hotplug_driver_unlock(void);
194#else
195static inline void cpu_hotplug_driver_lock(void)
196{
197}
198
199static inline void cpu_hotplug_driver_unlock(void)
200{
201}
202#endif
203
204#else /* CONFIG_HOTPLUG_CPU */ 191#else /* CONFIG_HOTPLUG_CPU */
205 192
206static inline void cpu_hotplug_begin(void) {} 193static inline void cpu_hotplug_begin(void) {}
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index fcabc42d66ab..5bd6ab9b0c27 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -85,6 +85,20 @@ struct cpufreq_policy {
85 struct list_head policy_list; 85 struct list_head policy_list;
86 struct kobject kobj; 86 struct kobject kobj;
87 struct completion kobj_unregister; 87 struct completion kobj_unregister;
88
89 /*
90 * The rules for this semaphore:
91 * - Any routine that wants to read from the policy structure will
92 * do a down_read on this semaphore.
93 * - Any routine that will write to the policy structure and/or may take away
94 * the policy altogether (eg. CPU hotplug), will hold this lock in write
95 * mode before doing so.
96 *
97 * Additional rules:
98 * - Lock should not be held across
99 * __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT);
100 */
101 struct rw_semaphore rwsem;
88}; 102};
89 103
90/* Only for ACPI */ 104/* Only for ACPI */
@@ -180,13 +194,6 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
180struct cpufreq_driver { 194struct cpufreq_driver {
181 char name[CPUFREQ_NAME_LEN]; 195 char name[CPUFREQ_NAME_LEN];
182 u8 flags; 196 u8 flags;
183 /*
184 * This should be set by platforms having multiple clock-domains, i.e.
185 * supporting multiple policies. With this sysfs directories of governor
186 * would be created in cpu/cpu<num>/cpufreq/ directory and so they can
187 * use the same governor with different tunables for different clusters.
188 */
189 bool have_governor_per_policy;
190 197
191 /* needed by all drivers */ 198 /* needed by all drivers */
192 int (*init) (struct cpufreq_policy *policy); 199 int (*init) (struct cpufreq_policy *policy);
@@ -194,9 +201,11 @@ struct cpufreq_driver {
194 201
195 /* define one out of two */ 202 /* define one out of two */
196 int (*setpolicy) (struct cpufreq_policy *policy); 203 int (*setpolicy) (struct cpufreq_policy *policy);
197 int (*target) (struct cpufreq_policy *policy, 204 int (*target) (struct cpufreq_policy *policy, /* Deprecated */
198 unsigned int target_freq, 205 unsigned int target_freq,
199 unsigned int relation); 206 unsigned int relation);
207 int (*target_index) (struct cpufreq_policy *policy,
208 unsigned int index);
200 209
201 /* should be defined, if possible */ 210 /* should be defined, if possible */
202 unsigned int (*get) (unsigned int cpu); 211 unsigned int (*get) (unsigned int cpu);
@@ -211,13 +220,29 @@ struct cpufreq_driver {
211}; 220};
212 221
213/* flags */ 222/* flags */
214#define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if 223#define CPUFREQ_STICKY (1 << 0) /* driver isn't removed even if
215 * all ->init() calls failed */ 224 all ->init() calls failed */
216#define CPUFREQ_CONST_LOOPS 0x02 /* loops_per_jiffy or other kernel 225#define CPUFREQ_CONST_LOOPS (1 << 1) /* loops_per_jiffy or other
217 * "constants" aren't affected by 226 kernel "constants" aren't
218 * frequency transitions */ 227 affected by frequency
219#define CPUFREQ_PM_NO_WARN 0x04 /* don't warn on suspend/resume speed 228 transitions */
220 * mismatches */ 229#define CPUFREQ_PM_NO_WARN (1 << 2) /* don't warn on suspend/resume
230 speed mismatches */
231
232/*
233 * This should be set by platforms having multiple clock-domains, i.e.
234 * supporting multiple policies. With this sysfs directories of governor would
235 * be created in cpu/cpu<num>/cpufreq/ directory and so they can use the same
236 * governor with different tunables for different clusters.
237 */
238#define CPUFREQ_HAVE_GOVERNOR_PER_POLICY (1 << 3)
239
240/*
241 * Driver will do POSTCHANGE notifications from outside of their ->target()
242 * routine and so must set cpufreq_driver->flags with this flag, so that core
243 * can handle them specially.
244 */
245#define CPUFREQ_ASYNC_NOTIFICATION (1 << 4)
221 246
222int cpufreq_register_driver(struct cpufreq_driver *driver_data); 247int cpufreq_register_driver(struct cpufreq_driver *driver_data);
223int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); 248int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
@@ -240,6 +265,13 @@ static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy,
240 return; 265 return;
241} 266}
242 267
268static inline void
269cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy)
270{
271 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
272 policy->cpuinfo.max_freq);
273}
274
243/********************************************************************* 275/*********************************************************************
244 * CPUFREQ NOTIFIER INTERFACE * 276 * CPUFREQ NOTIFIER INTERFACE *
245 *********************************************************************/ 277 *********************************************************************/
@@ -392,6 +424,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
392 424
393int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, 425int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
394 struct cpufreq_frequency_table *table); 426 struct cpufreq_frequency_table *table);
427int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy);
395 428
396int cpufreq_frequency_table_target(struct cpufreq_policy *policy, 429int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
397 struct cpufreq_frequency_table *table, 430 struct cpufreq_frequency_table *table,
@@ -407,8 +440,20 @@ struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu);
407 440
408/* the following are really really optional */ 441/* the following are really really optional */
409extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; 442extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
443extern struct freq_attr *cpufreq_generic_attr[];
410void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, 444void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
411 unsigned int cpu); 445 unsigned int cpu);
412void cpufreq_frequency_table_put_attr(unsigned int cpu); 446void cpufreq_frequency_table_put_attr(unsigned int cpu);
447int cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
448 struct cpufreq_frequency_table *table);
449
450int cpufreq_generic_init(struct cpufreq_policy *policy,
451 struct cpufreq_frequency_table *table,
452 unsigned int transition_latency);
453static inline int cpufreq_generic_exit(struct cpufreq_policy *policy)
454{
455 cpufreq_frequency_table_put_attr(policy->cpu);
456 return 0;
457}
413 458
414#endif /* _LINUX_CPUFREQ_H */ 459#endif /* _LINUX_CPUFREQ_H */
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 781addc66f03..50fcbb0ac4e7 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -114,7 +114,7 @@ struct cpuidle_driver {
114 int safe_state_index; 114 int safe_state_index;
115 115
116 /* the driver handles the cpus in cpumask */ 116 /* the driver handles the cpus in cpumask */
117 struct cpumask *cpumask; 117 struct cpumask *cpumask;
118}; 118};
119 119
120#ifdef CONFIG_CPU_IDLE 120#ifdef CONFIG_CPU_IDLE
@@ -195,16 +195,10 @@ struct cpuidle_governor {
195}; 195};
196 196
197#ifdef CONFIG_CPU_IDLE 197#ifdef CONFIG_CPU_IDLE
198
199extern int cpuidle_register_governor(struct cpuidle_governor *gov); 198extern int cpuidle_register_governor(struct cpuidle_governor *gov);
200extern void cpuidle_unregister_governor(struct cpuidle_governor *gov);
201
202#else 199#else
203
204static inline int cpuidle_register_governor(struct cpuidle_governor *gov) 200static inline int cpuidle_register_governor(struct cpuidle_governor *gov)
205{return 0;} 201{return 0;}
206static inline void cpuidle_unregister_governor(struct cpuidle_governor *gov) { }
207
208#endif 202#endif
209 203
210#ifdef CONFIG_ARCH_HAS_CPU_RELAX 204#ifdef CONFIG_ARCH_HAS_CPU_RELAX
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
index 5f1ab92107e6..7a7cc74d7f27 100644
--- a/include/linux/devfreq.h
+++ b/include/linux/devfreq.h
@@ -15,7 +15,7 @@
15 15
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/notifier.h> 17#include <linux/notifier.h>
18#include <linux/opp.h> 18#include <linux/pm_opp.h>
19 19
20#define DEVFREQ_NAME_LEN 16 20#define DEVFREQ_NAME_LEN 16
21 21
@@ -187,7 +187,7 @@ extern int devfreq_suspend_device(struct devfreq *devfreq);
187extern int devfreq_resume_device(struct devfreq *devfreq); 187extern int devfreq_resume_device(struct devfreq *devfreq);
188 188
189/* Helper functions for devfreq user device driver with OPP. */ 189/* Helper functions for devfreq user device driver with OPP. */
190extern struct opp *devfreq_recommended_opp(struct device *dev, 190extern struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
191 unsigned long *freq, u32 flags); 191 unsigned long *freq, u32 flags);
192extern int devfreq_register_opp_notifier(struct device *dev, 192extern int devfreq_register_opp_notifier(struct device *dev,
193 struct devfreq *devfreq); 193 struct devfreq *devfreq);
@@ -238,7 +238,7 @@ static inline int devfreq_resume_device(struct devfreq *devfreq)
238 return 0; 238 return 0;
239} 239}
240 240
241static inline struct opp *devfreq_recommended_opp(struct device *dev, 241static inline struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
242 unsigned long *freq, u32 flags) 242 unsigned long *freq, u32 flags)
243{ 243{
244 return ERR_PTR(-EINVAL); 244 return ERR_PTR(-EINVAL);
diff --git a/include/linux/opp.h b/include/linux/opp.h
deleted file mode 100644
index 3aca2b8def33..000000000000
--- a/include/linux/opp.h
+++ /dev/null
@@ -1,134 +0,0 @@
1/*
2 * Generic OPP Interface
3 *
4 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
5 * Nishanth Menon
6 * Romit Dasgupta
7 * Kevin Hilman
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef __LINUX_OPP_H__
15#define __LINUX_OPP_H__
16
17#include <linux/err.h>
18#include <linux/cpufreq.h>
19#include <linux/notifier.h>
20
21struct opp;
22struct device;
23
24enum opp_event {
25 OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
26};
27
28#if defined(CONFIG_PM_OPP)
29
30unsigned long opp_get_voltage(struct opp *opp);
31
32unsigned long opp_get_freq(struct opp *opp);
33
34int opp_get_opp_count(struct device *dev);
35
36struct opp *opp_find_freq_exact(struct device *dev, unsigned long freq,
37 bool available);
38
39struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq);
40
41struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq);
42
43int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt);
44
45int opp_enable(struct device *dev, unsigned long freq);
46
47int opp_disable(struct device *dev, unsigned long freq);
48
49struct srcu_notifier_head *opp_get_notifier(struct device *dev);
50#else
51static inline unsigned long opp_get_voltage(struct opp *opp)
52{
53 return 0;
54}
55
56static inline unsigned long opp_get_freq(struct opp *opp)
57{
58 return 0;
59}
60
61static inline int opp_get_opp_count(struct device *dev)
62{
63 return 0;
64}
65
66static inline struct opp *opp_find_freq_exact(struct device *dev,
67 unsigned long freq, bool available)
68{
69 return ERR_PTR(-EINVAL);
70}
71
72static inline struct opp *opp_find_freq_floor(struct device *dev,
73 unsigned long *freq)
74{
75 return ERR_PTR(-EINVAL);
76}
77
78static inline struct opp *opp_find_freq_ceil(struct device *dev,
79 unsigned long *freq)
80{
81 return ERR_PTR(-EINVAL);
82}
83
84static inline int opp_add(struct device *dev, unsigned long freq,
85 unsigned long u_volt)
86{
87 return -EINVAL;
88}
89
90static inline int opp_enable(struct device *dev, unsigned long freq)
91{
92 return 0;
93}
94
95static inline int opp_disable(struct device *dev, unsigned long freq)
96{
97 return 0;
98}
99
100static inline struct srcu_notifier_head *opp_get_notifier(struct device *dev)
101{
102 return ERR_PTR(-EINVAL);
103}
104#endif /* CONFIG_PM_OPP */
105
106#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
107int of_init_opp_table(struct device *dev);
108#else
109static inline int of_init_opp_table(struct device *dev)
110{
111 return -EINVAL;
112}
113#endif
114
115#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
116int opp_init_cpufreq_table(struct device *dev,
117 struct cpufreq_frequency_table **table);
118void opp_free_cpufreq_table(struct device *dev,
119 struct cpufreq_frequency_table **table);
120#else
121static inline int opp_init_cpufreq_table(struct device *dev,
122 struct cpufreq_frequency_table **table)
123{
124 return -EINVAL;
125}
126
127static inline
128void opp_free_cpufreq_table(struct device *dev,
129 struct cpufreq_frequency_table **table)
130{
131}
132#endif /* CONFIG_CPU_FREQ */
133
134#endif /* __LINUX_OPP_H__ */
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
new file mode 100644
index 000000000000..5151b0059585
--- /dev/null
+++ b/include/linux/pm_opp.h
@@ -0,0 +1,139 @@
1/*
2 * Generic OPP Interface
3 *
4 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
5 * Nishanth Menon
6 * Romit Dasgupta
7 * Kevin Hilman
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef __LINUX_OPP_H__
15#define __LINUX_OPP_H__
16
17#include <linux/err.h>
18#include <linux/cpufreq.h>
19#include <linux/notifier.h>
20
21struct dev_pm_opp;
22struct device;
23
24enum dev_pm_opp_event {
25 OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
26};
27
28#if defined(CONFIG_PM_OPP)
29
30unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
31
32unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
33
34int dev_pm_opp_get_opp_count(struct device *dev);
35
36struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
37 unsigned long freq,
38 bool available);
39
40struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
41 unsigned long *freq);
42
43struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
44 unsigned long *freq);
45
46int dev_pm_opp_add(struct device *dev, unsigned long freq,
47 unsigned long u_volt);
48
49int dev_pm_opp_enable(struct device *dev, unsigned long freq);
50
51int dev_pm_opp_disable(struct device *dev, unsigned long freq);
52
53struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
54#else
55static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
56{
57 return 0;
58}
59
60static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
61{
62 return 0;
63}
64
65static inline int dev_pm_opp_get_opp_count(struct device *dev)
66{
67 return 0;
68}
69
70static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
71 unsigned long freq, bool available)
72{
73 return ERR_PTR(-EINVAL);
74}
75
76static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
77 unsigned long *freq)
78{
79 return ERR_PTR(-EINVAL);
80}
81
82static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
83 unsigned long *freq)
84{
85 return ERR_PTR(-EINVAL);
86}
87
88static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
89 unsigned long u_volt)
90{
91 return -EINVAL;
92}
93
94static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
95{
96 return 0;
97}
98
99static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
100{
101 return 0;
102}
103
104static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
105 struct device *dev)
106{
107 return ERR_PTR(-EINVAL);
108}
109#endif /* CONFIG_PM_OPP */
110
111#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
112int of_init_opp_table(struct device *dev);
113#else
114static inline int of_init_opp_table(struct device *dev)
115{
116 return -EINVAL;
117}
118#endif
119
120#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
121int dev_pm_opp_init_cpufreq_table(struct device *dev,
122 struct cpufreq_frequency_table **table);
123void dev_pm_opp_free_cpufreq_table(struct device *dev,
124 struct cpufreq_frequency_table **table);
125#else
126static inline int dev_pm_opp_init_cpufreq_table(struct device *dev,
127 struct cpufreq_frequency_table **table)
128{
129 return -EINVAL;
130}
131
132static inline
133void dev_pm_opp_free_cpufreq_table(struct device *dev,
134 struct cpufreq_frequency_table **table)
135{
136}
137#endif /* CONFIG_CPU_FREQ */
138
139#endif /* __LINUX_OPP_H__ */
diff --git a/include/linux/powercap.h b/include/linux/powercap.h
new file mode 100644
index 000000000000..4e250417ee30
--- /dev/null
+++ b/include/linux/powercap.h
@@ -0,0 +1,325 @@
1/*
2 * powercap.h: Data types and headers for sysfs power capping interface
3 * Copyright (c) 2013, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.
16 *
17 */
18
19#ifndef __POWERCAP_H__
20#define __POWERCAP_H__
21
22#include <linux/device.h>
23#include <linux/idr.h>
24
25/*
26 * A power cap class device can contain multiple powercap control_types.
27 * Each control_type can have multiple power zones, which can be independently
28 * controlled. Each power zone can have one or more constraints.
29 */
30
31struct powercap_control_type;
32struct powercap_zone;
33struct powercap_zone_constraint;
34
35/**
36 * struct powercap_control_type_ops - Define control type callbacks
37 * @set_enable: Enable/Disable whole control type.
38 * Default is enabled. But this callback allows all zones
39 * to be in disable state and remove any applied power
40 * limits. If disabled power zone can only be monitored
41 * not controlled.
42 * @get_enable: get Enable/Disable status.
43 * @release: Callback to inform that last reference to this
44 * control type is closed. So it is safe to free data
45 * structure associated with this control type.
46 * This callback is mandatory if the client own memory
47 * for the control type.
48 *
49 * This structure defines control type callbacks to be implemented by client
50 * drivers
51 */
52struct powercap_control_type_ops {
53 int (*set_enable) (struct powercap_control_type *, bool mode);
54 int (*get_enable) (struct powercap_control_type *, bool *mode);
55 int (*release) (struct powercap_control_type *);
56};
57
58/**
59 * struct powercap_control_type- Defines a powercap control_type
60 * @name: name of control_type
61 * @dev: device for this control_type
62 * @idr: idr to have unique id for its child
63 * @root_node: Root holding power zones for this control_type
64 * @ops: Pointer to callback struct
65 * @node_lock: mutex for control type
66 * @allocated: This is possible that client owns the memory
67 * used by this structure. In this case
68 * this flag is set to false by framework to
69 * prevent deallocation during release process.
70 * Otherwise this flag is set to true.
71 * @ctrl_inst: link to the control_type list
72 *
73 * Defines powercap control_type. This acts as a container for power
74 * zones, which use same method to control power. E.g. RAPL, RAPL-PCI etc.
75 * All fields are private and should not be used by client drivers.
76 */
77struct powercap_control_type {
78 struct device dev;
79 struct idr idr;
80 int nr_zones;
81 const struct powercap_control_type_ops *ops;
82 struct mutex lock;
83 bool allocated;
84 struct list_head node;
85};
86
87/**
88 * struct powercap_zone_ops - Define power zone callbacks
89 * @get_max_energy_range_uj: Get maximum range of energy counter in
90 * micro-joules.
91 * @get_energy_uj: Get current energy counter in micro-joules.
92 * @reset_energy_uj: Reset micro-joules energy counter.
93 * @get_max_power_range_uw: Get maximum range of power counter in
94 * micro-watts.
95 * @get_power_uw: Get current power counter in micro-watts.
96 * @set_enable: Enable/Disable power zone controls.
97 * Default is enabled.
98 * @get_enable: get Enable/Disable status.
99 * @release: Callback to inform that last reference to this
100 * control type is closed. So it is safe to free
101 * data structure associated with this
102 * control type. Mandatory, if client driver owns
103 * the power_zone memory.
104 *
105 * This structure defines zone callbacks to be implemented by client drivers.
106 * Client drives can define both energy and power related callbacks. But at
107 * the least one type (either power or energy) is mandatory. Client drivers
108 * should handle mutual exclusion, if required in callbacks.
109 */
110struct powercap_zone_ops {
111 int (*get_max_energy_range_uj) (struct powercap_zone *, u64 *);
112 int (*get_energy_uj) (struct powercap_zone *, u64 *);
113 int (*reset_energy_uj) (struct powercap_zone *);
114 int (*get_max_power_range_uw) (struct powercap_zone *, u64 *);
115 int (*get_power_uw) (struct powercap_zone *, u64 *);
116 int (*set_enable) (struct powercap_zone *, bool mode);
117 int (*get_enable) (struct powercap_zone *, bool *mode);
118 int (*release) (struct powercap_zone *);
119};
120
121#define POWERCAP_ZONE_MAX_ATTRS 6
122#define POWERCAP_CONSTRAINTS_ATTRS 8
123#define MAX_CONSTRAINTS_PER_ZONE 10
124/**
125 * struct powercap_zone- Defines instance of a power cap zone
126 * @id: Unique id
127 * @name: Power zone name.
128 * @control_type_inst: Control type instance for this zone.
129 * @ops: Pointer to the zone operation structure.
130 * @dev: Instance of a device.
131 * @const_id_cnt: Number of constraint defined.
132 * @idr: Instance to an idr entry for children zones.
133 * @parent_idr: To remove reference from the parent idr.
134 * @private_data: Private data pointer if any for this zone.
135 * @zone_dev_attrs: Attributes associated with this device.
136 * @zone_attr_count: Attribute count.
137 * @dev_zone_attr_group: Attribute group for attributes.
138 * @dev_attr_groups: Attribute group store to register with device.
139 * @allocated: This is possible that client owns the memory
140 * used by this structure. In this case
141 * this flag is set to false by framework to
142 * prevent deallocation during release process.
143 * Otherwise this flag is set to true.
144 * @constraint_ptr: List of constraints for this zone.
145 *
146 * This defines a power zone instance. The fields of this structure are
147 * private, and should not be used by client drivers.
148 */
149struct powercap_zone {
150 int id;
151 char *name;
152 void *control_type_inst;
153 const struct powercap_zone_ops *ops;
154 struct device dev;
155 int const_id_cnt;
156 struct idr idr;
157 struct idr *parent_idr;
158 void *private_data;
159 struct attribute **zone_dev_attrs;
160 int zone_attr_count;
161 struct attribute_group dev_zone_attr_group;
162 const struct attribute_group *dev_attr_groups[2]; /* 1 group + NULL */
163 bool allocated;
164 struct powercap_zone_constraint *constraints;
165};
166
167/**
168 * struct powercap_zone_constraint_ops - Define constraint callbacks
169 * @set_power_limit_uw: Set power limit in micro-watts.
170 * @get_power_limit_uw: Get power limit in micro-watts.
171 * @set_time_window_us: Set time window in micro-seconds.
172 * @get_time_window_us: Get time window in micro-seconds.
173 * @get_max_power_uw: Get max power allowed in micro-watts.
174 * @get_min_power_uw: Get min power allowed in micro-watts.
175 * @get_max_time_window_us: Get max time window allowed in micro-seconds.
176 * @get_min_time_window_us: Get min time window allowed in micro-seconds.
177 * @get_name: Get the name of constraint
178 *
179 * This structure is used to define the constraint callbacks for the client
180 * drivers. The following callbacks are mandatory and can't be NULL:
181 * set_power_limit_uw
182 * get_power_limit_uw
183 * set_time_window_us
184 * get_time_window_us
185 * get_name
186 * Client drivers should handle mutual exclusion, if required in callbacks.
187 */
188struct powercap_zone_constraint_ops {
189 int (*set_power_limit_uw) (struct powercap_zone *, int, u64);
190 int (*get_power_limit_uw) (struct powercap_zone *, int, u64 *);
191 int (*set_time_window_us) (struct powercap_zone *, int, u64);
192 int (*get_time_window_us) (struct powercap_zone *, int, u64 *);
193 int (*get_max_power_uw) (struct powercap_zone *, int, u64 *);
194 int (*get_min_power_uw) (struct powercap_zone *, int, u64 *);
195 int (*get_max_time_window_us) (struct powercap_zone *, int, u64 *);
196 int (*get_min_time_window_us) (struct powercap_zone *, int, u64 *);
197 const char *(*get_name) (struct powercap_zone *, int);
198};
199
200/**
201 * struct powercap_zone_constraint- Defines instance of a constraint
202 * @id: Instance Id of this constraint.
203 * @power_zone: Pointer to the power zone for this constraint.
204 * @ops: Pointer to the constraint callbacks.
205 *
206 * This defines a constraint instance.
207 */
208struct powercap_zone_constraint {
209 int id;
210 struct powercap_zone *power_zone;
211 struct powercap_zone_constraint_ops *ops;
212};
213
214
215/* For clients to get their device pointer, may be used for dev_dbgs */
216#define POWERCAP_GET_DEV(power_zone) (&power_zone->dev)
217
218/**
219* powercap_set_zone_data() - Set private data for a zone
220* @power_zone: A pointer to the valid zone instance.
221* @pdata: A pointer to the user private data.
222*
223* Allows client drivers to associate some private data to zone instance.
224*/
225static inline void powercap_set_zone_data(struct powercap_zone *power_zone,
226 void *pdata)
227{
228 if (power_zone)
229 power_zone->private_data = pdata;
230}
231
232/**
233* powercap_get_zone_data() - Get private data for a zone
234* @power_zone: A pointer to the valid zone instance.
235*
236* Allows client drivers to get private data associate with a zone,
237* using call to powercap_set_zone_data.
238*/
239static inline void *powercap_get_zone_data(struct powercap_zone *power_zone)
240{
241 if (power_zone)
242 return power_zone->private_data;
243 return NULL;
244}
245
246/**
247* powercap_register_control_type() - Register a control_type with framework
248* @control_type: Pointer to client allocated memory for the control type
249* structure storage. If this is NULL, powercap framework
250* will allocate memory and own it.
251* Advantage of this parameter is that client can embed
252* this data in its data structures and allocate in a
253* single call, preventing multiple allocations.
254* @control_type_name: The Name of this control_type, which will be shown
255* in the sysfs Interface.
256* @ops: Callbacks for control type. This parameter is optional.
257*
258* Used to create a control_type with the power capping class. Here control_type
259* can represent a type of technology, which can control a range of power zones.
260* For example a control_type can be RAPL (Running Average Power Limit)
261* IntelĀ® 64 and IA-32 Processor Architectures. The name can be any string
262* which must be unique, otherwise this function returns NULL.
263* A pointer to the control_type instance is returned on success.
264*/
265struct powercap_control_type *powercap_register_control_type(
266 struct powercap_control_type *control_type,
267 const char *name,
268 const struct powercap_control_type_ops *ops);
269
270/**
271* powercap_unregister_control_type() - Unregister a control_type from framework
272* @instance: A pointer to the valid control_type instance.
273*
274* Used to unregister a control_type with the power capping class.
275* All power zones registered under this control type have to be unregistered
276* before calling this function, or it will fail with an error code.
277*/
278int powercap_unregister_control_type(struct powercap_control_type *instance);
279
280/* Zone register/unregister API */
281
282/**
283* powercap_register_zone() - Register a power zone
284* @power_zone: Pointer to client allocated memory for the power zone structure
285* storage. If this is NULL, powercap framework will allocate
286* memory and own it. Advantage of this parameter is that client
287* can embed this data in its data structures and allocate in a
288* single call, preventing multiple allocations.
289* @control_type: A control_type instance under which this zone operates.
290* @name: A name for this zone.
291* @parent: A pointer to the parent power zone instance if any or NULL
292* @ops: Pointer to zone operation callback structure.
293* @no_constraints: Number of constraints for this zone
294* @const_ops: Pointer to constraint callback structure
295*
296* Register a power zone under a given control type. A power zone must register
297* a pointer to a structure representing zone callbacks.
298* A power zone can be located under a parent power zone, in which case @parent
299* should point to it. Otherwise, if @parent is NULL, the new power zone will
300* be located directly under the given control type
301* For each power zone there may be a number of constraints that appear in the
302* sysfs under that zone as attributes with unique numeric IDs.
303* Returns pointer to the power_zone on success.
304*/
305struct powercap_zone *powercap_register_zone(
306 struct powercap_zone *power_zone,
307 struct powercap_control_type *control_type,
308 const char *name,
309 struct powercap_zone *parent,
310 const struct powercap_zone_ops *ops,
311 int nr_constraints,
312 struct powercap_zone_constraint_ops *const_ops);
313
314/**
315* powercap_unregister_zone() - Unregister a zone device
316* @control_type: A pointer to the valid instance of a control_type.
317* @power_zone: A pointer to the valid zone instance for a control_type
318*
319* Used to unregister a zone device for a control_type. Caller should
320* make sure that children for this zone are unregistered first.
321*/
322int powercap_unregister_zone(struct powercap_control_type *control_type,
323 struct powercap_zone *power_zone);
324
325#endif