xref: /openbmc/linux/include/acpi/acpixf.h (revision b34e08d5)
1 /******************************************************************************
2  *
3  * Name: acpixf.h - External interfaces to the ACPI subsystem
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2014, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43 
44 #ifndef __ACXFACE_H__
45 #define __ACXFACE_H__
46 
47 /* Current ACPICA subsystem version in YYYYMMDD format */
48 
49 #define ACPI_CA_VERSION                 0x20140214
50 
51 #include <acpi/acconfig.h>
52 #include <acpi/actypes.h>
53 #include <acpi/actbl.h>
54 #include <acpi/acbuffer.h>
55 
56 extern u8 acpi_gbl_permanent_mmap;
57 
58 /*
59  * Globals that are publically available
60  */
61 extern u32 acpi_current_gpe_count;
62 extern struct acpi_table_fadt acpi_gbl_FADT;
63 extern u8 acpi_gbl_system_awake_and_running;
64 extern u8 acpi_gbl_reduced_hardware;	/* ACPI 5.0 */
65 extern u8 acpi_gbl_osi_data;
66 
67 /* Runtime configuration of debug print levels */
68 
69 extern u32 acpi_dbg_level;
70 extern u32 acpi_dbg_layer;
71 
72 /* ACPICA runtime options */
73 
74 extern u8 acpi_gbl_auto_serialize_methods;
75 extern u8 acpi_gbl_copy_dsdt_locally;
76 extern u8 acpi_gbl_create_osi_method;
77 extern u8 acpi_gbl_disable_auto_repair;
78 extern u8 acpi_gbl_disable_ssdt_table_load;
79 extern u8 acpi_gbl_do_not_use_xsdt;
80 extern u8 acpi_gbl_enable_aml_debug_object;
81 extern u8 acpi_gbl_enable_interpreter_slack;
82 extern u32 acpi_gbl_trace_flags;
83 extern acpi_name acpi_gbl_trace_method_name;
84 extern u8 acpi_gbl_truncate_io_addresses;
85 extern u8 acpi_gbl_use32_bit_fadt_addresses;
86 extern u8 acpi_gbl_use_default_register_widths;
87 
88 /*
89  * Hardware-reduced prototypes. All interfaces that use these macros will
90  * be configured out of the ACPICA build if the ACPI_REDUCED_HARDWARE flag
91  * is set to TRUE.
92  */
93 #if (!ACPI_REDUCED_HARDWARE)
94 #define ACPI_HW_DEPENDENT_RETURN_STATUS(prototype) \
95 	prototype;
96 
97 #define ACPI_HW_DEPENDENT_RETURN_OK(prototype) \
98 	prototype;
99 
100 #define ACPI_HW_DEPENDENT_RETURN_VOID(prototype) \
101 	prototype;
102 
103 #else
104 #define ACPI_HW_DEPENDENT_RETURN_STATUS(prototype) \
105 	static ACPI_INLINE prototype {return(AE_NOT_CONFIGURED);}
106 
107 #define ACPI_HW_DEPENDENT_RETURN_OK(prototype) \
108 	static ACPI_INLINE prototype {return(AE_OK);}
109 
110 #define ACPI_HW_DEPENDENT_RETURN_VOID(prototype) \
111 	static ACPI_INLINE prototype {return;}
112 
113 #endif				/* !ACPI_REDUCED_HARDWARE */
114 
115 /*
116  * Initialization
117  */
118 acpi_status __init
119 acpi_initialize_tables(struct acpi_table_desc *initial_storage,
120 		       u32 initial_table_count, u8 allow_resize);
121 
122 acpi_status __init acpi_initialize_subsystem(void);
123 
124 acpi_status __init acpi_enable_subsystem(u32 flags);
125 
126 acpi_status __init acpi_initialize_objects(u32 flags);
127 
128 acpi_status __init acpi_terminate(void);
129 
130 /*
131  * Miscellaneous global interfaces
132  */
133 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable(void))
134 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable(void))
135 #ifdef ACPI_FUTURE_USAGE
136 acpi_status acpi_subsystem_status(void);
137 #endif
138 
139 #ifdef ACPI_FUTURE_USAGE
140 acpi_status acpi_get_system_info(struct acpi_buffer *ret_buffer);
141 #endif
142 
143 acpi_status acpi_get_statistics(struct acpi_statistics *stats);
144 
145 const char *acpi_format_exception(acpi_status exception);
146 
147 acpi_status acpi_purge_cached_objects(void);
148 
149 acpi_status acpi_install_interface(acpi_string interface_name);
150 
151 acpi_status acpi_remove_interface(acpi_string interface_name);
152 
153 acpi_status acpi_update_interfaces(u8 action);
154 
155 u32
156 acpi_check_address_range(acpi_adr_space_type space_id,
157 			 acpi_physical_address address,
158 			 acpi_size length, u8 warn);
159 
160 acpi_status
161 acpi_decode_pld_buffer(u8 *in_buffer,
162 		       acpi_size length, struct acpi_pld_info **return_buffer);
163 
164 /*
165  * ACPI table load/unload interfaces
166  */
167 acpi_status acpi_load_table(struct acpi_table_header *table);
168 
169 acpi_status acpi_unload_parent_table(acpi_handle object);
170 
171 acpi_status __init acpi_load_tables(void);
172 
173 /*
174  * ACPI table manipulation interfaces
175  */
176 acpi_status __init acpi_reallocate_root_table(void);
177 
178 acpi_status __init acpi_find_root_pointer(acpi_size *rsdp_address);
179 
180 acpi_status acpi_unload_table_id(acpi_owner_id id);
181 
182 acpi_status
183 acpi_get_table_header(acpi_string signature,
184 		      u32 instance, struct acpi_table_header *out_table_header);
185 
186 acpi_status
187 acpi_get_table_with_size(acpi_string signature,
188 	       u32 instance, struct acpi_table_header **out_table,
189 	       acpi_size *tbl_size);
190 
191 acpi_status
192 acpi_get_table(acpi_string signature,
193 	       u32 instance, struct acpi_table_header **out_table);
194 
195 acpi_status
196 acpi_get_table_by_index(u32 table_index, struct acpi_table_header **out_table);
197 
198 acpi_status
199 acpi_install_table_handler(acpi_table_handler handler, void *context);
200 
201 acpi_status acpi_remove_table_handler(acpi_table_handler handler);
202 
203 /*
204  * Namespace and name interfaces
205  */
206 acpi_status
207 acpi_walk_namespace(acpi_object_type type,
208 		    acpi_handle start_object,
209 		    u32 max_depth,
210 		    acpi_walk_callback descending_callback,
211 		    acpi_walk_callback ascending_callback,
212 		    void *context, void **return_value);
213 
214 acpi_status
215 acpi_get_devices(const char *HID,
216 		 acpi_walk_callback user_function,
217 		 void *context, void **return_value);
218 
219 acpi_status
220 acpi_get_name(acpi_handle object,
221 	      u32 name_type, struct acpi_buffer *ret_path_ptr);
222 
223 acpi_status
224 acpi_get_handle(acpi_handle parent,
225 		acpi_string pathname, acpi_handle * ret_handle);
226 
227 acpi_status
228 acpi_attach_data(acpi_handle object, acpi_object_handler handler, void *data);
229 
230 acpi_status acpi_detach_data(acpi_handle object, acpi_object_handler handler);
231 
232 acpi_status
233 acpi_get_data_full(acpi_handle object, acpi_object_handler handler, void **data,
234 		   void (*callback)(void *));
235 
236 acpi_status
237 acpi_get_data(acpi_handle object, acpi_object_handler handler, void **data);
238 
239 acpi_status
240 acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags);
241 
242 /*
243  * Object manipulation and enumeration
244  */
245 acpi_status
246 acpi_evaluate_object(acpi_handle object,
247 		     acpi_string pathname,
248 		     struct acpi_object_list *parameter_objects,
249 		     struct acpi_buffer *return_object_buffer);
250 
251 acpi_status
252 acpi_evaluate_object_typed(acpi_handle object,
253 			   acpi_string pathname,
254 			   struct acpi_object_list *external_params,
255 			   struct acpi_buffer *return_buffer,
256 			   acpi_object_type return_type);
257 
258 acpi_status
259 acpi_get_object_info(acpi_handle object,
260 		     struct acpi_device_info **return_buffer);
261 
262 acpi_status acpi_install_method(u8 *buffer);
263 
264 acpi_status
265 acpi_get_next_object(acpi_object_type type,
266 		     acpi_handle parent,
267 		     acpi_handle child, acpi_handle * out_handle);
268 
269 acpi_status acpi_get_type(acpi_handle object, acpi_object_type * out_type);
270 
271 acpi_status acpi_get_id(acpi_handle object, acpi_owner_id * out_type);
272 
273 acpi_status acpi_get_parent(acpi_handle object, acpi_handle * out_handle);
274 
275 /*
276  * Handler interfaces
277  */
278 acpi_status
279 acpi_install_initialization_handler(acpi_init_handler handler, u32 function);
280 
281 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
282 				acpi_install_sci_handler(acpi_sci_handler
283 							 address,
284 							 void *context))
285 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
286 				 acpi_remove_sci_handler(acpi_sci_handler
287 							 address))
288 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
289 				 acpi_install_global_event_handler
290 				 (acpi_gbl_event_handler handler,
291 				  void *context))
292 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
293 				 acpi_install_fixed_event_handler(u32
294 								  acpi_event,
295 								  acpi_event_handler
296 								  handler,
297 								  void
298 								  *context))
299 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
300 				 acpi_remove_fixed_event_handler(u32 acpi_event,
301 								 acpi_event_handler
302 								 handler))
303 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
304 				 acpi_install_gpe_handler(acpi_handle
305 							  gpe_device,
306 							  u32 gpe_number,
307 							  u32 type,
308 							  acpi_gpe_handler
309 							  address,
310 							  void *context))
311 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
312 				 acpi_remove_gpe_handler(acpi_handle gpe_device,
313 							 u32 gpe_number,
314 							 acpi_gpe_handler
315 							 address))
316 acpi_status acpi_install_notify_handler(acpi_handle device, u32 handler_type,
317 					 acpi_notify_handler handler,
318 					 void *context);
319 
320 acpi_status
321 acpi_remove_notify_handler(acpi_handle device,
322 			   u32 handler_type, acpi_notify_handler handler);
323 
324 acpi_status
325 acpi_install_address_space_handler(acpi_handle device,
326 				   acpi_adr_space_type space_id,
327 				   acpi_adr_space_handler handler,
328 				   acpi_adr_space_setup setup, void *context);
329 
330 acpi_status
331 acpi_remove_address_space_handler(acpi_handle device,
332 				  acpi_adr_space_type space_id,
333 				  acpi_adr_space_handler handler);
334 
335 #ifdef ACPI_FUTURE_USAGE
336 acpi_status acpi_install_exception_handler(acpi_exception_handler handler);
337 #endif
338 
339 acpi_status acpi_install_interface_handler(acpi_interface_handler handler);
340 
341 /*
342  * Global Lock interfaces
343  */
344 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
345 				acpi_acquire_global_lock(u16 timeout,
346 							 u32 *handle))
347 
348 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
349 				acpi_release_global_lock(u32 handle))
350 
351 /*
352  * Interfaces to AML mutex objects
353  */
354 acpi_status
355 acpi_acquire_mutex(acpi_handle handle, acpi_string pathname, u16 timeout);
356 
357 acpi_status acpi_release_mutex(acpi_handle handle, acpi_string pathname);
358 
359 /*
360  * Fixed Event interfaces
361  */
362 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
363 				acpi_enable_event(u32 event, u32 flags))
364 
365 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
366 				acpi_disable_event(u32 event, u32 flags))
367 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_clear_event(u32 event))
368 
369 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
370 				acpi_get_event_status(u32 event,
371 						      acpi_event_status
372 						      *event_status))
373 
374 /*
375  * General Purpose Event (GPE) Interfaces
376  */
377 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_update_all_gpes(void))
378 
379 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
380 				acpi_enable_gpe(acpi_handle gpe_device,
381 						u32 gpe_number))
382 
383 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
384 				acpi_disable_gpe(acpi_handle gpe_device,
385 						 u32 gpe_number))
386 
387 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
388 				acpi_clear_gpe(acpi_handle gpe_device,
389 					       u32 gpe_number))
390 
391 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
392 				acpi_set_gpe(acpi_handle gpe_device,
393 					     u32 gpe_number, u8 action))
394 
395 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
396 				acpi_finish_gpe(acpi_handle gpe_device,
397 						u32 gpe_number))
398 
399 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
400 				acpi_setup_gpe_for_wake(acpi_handle
401 							parent_device,
402 							acpi_handle gpe_device,
403 							u32 gpe_number))
404 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
405 				 acpi_set_gpe_wake_mask(acpi_handle gpe_device,
406 							u32 gpe_number,
407 							u8 action))
408 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
409 				 acpi_get_gpe_status(acpi_handle gpe_device,
410 						     u32 gpe_number,
411 						     acpi_event_status
412 						     *event_status))
413 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable_all_gpes(void))
414 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_runtime_gpes(void))
415 
416 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
417 				acpi_get_gpe_device(u32 gpe_index,
418 						    acpi_handle * gpe_device))
419 
420 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
421 				acpi_install_gpe_block(acpi_handle gpe_device,
422 						       struct
423 						       acpi_generic_address
424 						       *gpe_block_address,
425 						       u32 register_count,
426 						       u32 interrupt_number))
427 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
428 				 acpi_remove_gpe_block(acpi_handle gpe_device))
429 
430 /*
431  * Resource interfaces
432  */
433 typedef
434 acpi_status(*acpi_walk_resource_callback) (struct acpi_resource * resource,
435 					   void *context);
436 
437 acpi_status
438 acpi_get_vendor_resource(acpi_handle device,
439 			 char *name,
440 			 struct acpi_vendor_uuid *uuid,
441 			 struct acpi_buffer *ret_buffer);
442 
443 acpi_status
444 acpi_get_current_resources(acpi_handle device, struct acpi_buffer *ret_buffer);
445 
446 #ifdef ACPI_FUTURE_USAGE
447 acpi_status
448 acpi_get_possible_resources(acpi_handle device, struct acpi_buffer *ret_buffer);
449 #endif
450 
451 acpi_status
452 acpi_get_event_resources(acpi_handle device_handle,
453 			 struct acpi_buffer *ret_buffer);
454 
455 acpi_status
456 acpi_walk_resource_buffer(struct acpi_buffer *buffer,
457 			  acpi_walk_resource_callback user_function,
458 			  void *context);
459 
460 acpi_status
461 acpi_walk_resources(acpi_handle device,
462 		    char *name,
463 		    acpi_walk_resource_callback user_function, void *context);
464 
465 acpi_status
466 acpi_set_current_resources(acpi_handle device, struct acpi_buffer *in_buffer);
467 
468 acpi_status
469 acpi_get_irq_routing_table(acpi_handle device, struct acpi_buffer *ret_buffer);
470 
471 acpi_status
472 acpi_resource_to_address64(struct acpi_resource *resource,
473 			   struct acpi_resource_address64 *out);
474 
475 acpi_status
476 acpi_buffer_to_resource(u8 *aml_buffer,
477 			u16 aml_buffer_length,
478 			struct acpi_resource **resource_ptr);
479 
480 /*
481  * Hardware (ACPI device) interfaces
482  */
483 acpi_status acpi_reset(void);
484 
485 acpi_status acpi_read(u64 *value, struct acpi_generic_address *reg);
486 
487 acpi_status acpi_write(u64 value, struct acpi_generic_address *reg);
488 
489 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
490 				acpi_read_bit_register(u32 register_id,
491 						       u32 *return_value))
492 
493 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
494 				acpi_write_bit_register(u32 register_id,
495 							u32 value))
496 
497 /*
498  * Sleep/Wake interfaces
499  */
500 acpi_status
501 acpi_get_sleep_type_data(u8 sleep_state, u8 *slp_typ_a, u8 *slp_typ_b);
502 
503 acpi_status acpi_enter_sleep_state_prep(u8 sleep_state);
504 
505 acpi_status acpi_enter_sleep_state(u8 sleep_state);
506 
507 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enter_sleep_state_s4bios(void))
508 
509 acpi_status acpi_leave_sleep_state_prep(u8 sleep_state);
510 
511 acpi_status acpi_leave_sleep_state(u8 sleep_state);
512 
513 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
514 				acpi_set_firmware_waking_vector(u32
515 								physical_address))
516 #if ACPI_MACHINE_WIDTH == 64
517 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
518 				acpi_set_firmware_waking_vector64(u64
519 								  physical_address))
520 #endif
521 /*
522  * ACPI Timer interfaces
523  */
524 #ifdef ACPI_FUTURE_USAGE
525 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
526 				acpi_get_timer_resolution(u32 *resolution))
527 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_get_timer(u32 *ticks))
528 
529 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
530 				acpi_get_timer_duration(u32 start_ticks,
531 							u32 end_ticks,
532 							u32 *time_elapsed))
533 #endif				/* ACPI_FUTURE_USAGE */
534 
535 /*
536  * Error/Warning output
537  */
538 ACPI_PRINTF_LIKE(3)
539 void ACPI_INTERNAL_VAR_XFACE
540 acpi_error(const char *module_name, u32 line_number, const char *format, ...);
541 
542 ACPI_PRINTF_LIKE(4)
543 void ACPI_INTERNAL_VAR_XFACE
544 acpi_exception(const char *module_name,
545 	       u32 line_number, acpi_status status, const char *format, ...);
546 
547 ACPI_PRINTF_LIKE(3)
548 void ACPI_INTERNAL_VAR_XFACE
549 acpi_warning(const char *module_name, u32 line_number, const char *format, ...);
550 
551 ACPI_PRINTF_LIKE(3)
552 void ACPI_INTERNAL_VAR_XFACE
553 acpi_info(const char *module_name, u32 line_number, const char *format, ...);
554 
555 ACPI_PRINTF_LIKE(3)
556 void ACPI_INTERNAL_VAR_XFACE
557 acpi_bios_error(const char *module_name,
558 		u32 line_number, const char *format, ...);
559 
560 ACPI_PRINTF_LIKE(3)
561 void ACPI_INTERNAL_VAR_XFACE
562 acpi_bios_warning(const char *module_name,
563 		  u32 line_number, const char *format, ...);
564 
565 /*
566  * Debug output
567  */
568 #ifdef ACPI_DEBUG_OUTPUT
569 
570 ACPI_PRINTF_LIKE(6)
571 void ACPI_INTERNAL_VAR_XFACE
572 acpi_debug_print(u32 requested_debug_level,
573 		 u32 line_number,
574 		 const char *function_name,
575 		 const char *module_name,
576 		 u32 component_id, const char *format, ...);
577 
578 ACPI_PRINTF_LIKE(6)
579 void ACPI_INTERNAL_VAR_XFACE
580 acpi_debug_print_raw(u32 requested_debug_level,
581 		     u32 line_number,
582 		     const char *function_name,
583 		     const char *module_name,
584 		     u32 component_id, const char *format, ...);
585 #endif
586 
587 #endif				/* __ACXFACE_H__ */
588