• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * acpi.h - ACPI Interface
4  *
5  * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6  */
7 
8 #ifndef _LINUX_ACPI_H
9 #define _LINUX_ACPI_H
10 
11 #include <linux/errno.h>
12 #include <linux/ioport.h>	/* for struct resource */
13 #include <linux/irqdomain.h>
14 #include <linux/resource_ext.h>
15 #include <linux/device.h>
16 #include <linux/property.h>
17 #include <linux/uuid.h>
18 
19 #ifndef _LINUX
20 #define _LINUX
21 #endif
22 #include <acpi/acpi.h>
23 
24 #ifdef	CONFIG_ACPI
25 
26 #include <linux/list.h>
27 #include <linux/mod_devicetable.h>
28 #include <linux/dynamic_debug.h>
29 #include <linux/module.h>
30 #include <linux/mutex.h>
31 
32 #include <acpi/acpi_bus.h>
33 #include <acpi/acpi_drivers.h>
34 #include <acpi/acpi_numa.h>
35 #include <acpi/acpi_io.h>
36 #include <asm/acpi.h>
37 
acpi_device_handle(struct acpi_device * adev)38 static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
39 {
40 	return adev ? adev->handle : NULL;
41 }
42 
43 #define ACPI_COMPANION(dev)		to_acpi_device_node((dev)->fwnode)
44 #define ACPI_COMPANION_SET(dev, adev)	set_primary_fwnode(dev, (adev) ? \
45 	acpi_fwnode_handle(adev) : NULL)
46 #define ACPI_HANDLE(dev)		acpi_device_handle(ACPI_COMPANION(dev))
47 #define ACPI_HANDLE_FWNODE(fwnode)	\
48 				acpi_device_handle(to_acpi_device_node(fwnode))
49 
acpi_alloc_fwnode_static(void)50 static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
51 {
52 	struct fwnode_handle *fwnode;
53 
54 	fwnode = kzalloc(sizeof(struct fwnode_handle), GFP_KERNEL);
55 	if (!fwnode)
56 		return NULL;
57 
58 	fwnode->ops = &acpi_static_fwnode_ops;
59 
60 	return fwnode;
61 }
62 
acpi_free_fwnode_static(struct fwnode_handle * fwnode)63 static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode)
64 {
65 	if (WARN_ON(!is_acpi_static_node(fwnode)))
66 		return;
67 
68 	kfree(fwnode);
69 }
70 
71 /**
72  * ACPI_DEVICE_CLASS - macro used to describe an ACPI device with
73  * the PCI-defined class-code information
74  *
75  * @_cls : the class, subclass, prog-if triple for this device
76  * @_msk : the class mask for this device
77  *
78  * This macro is used to create a struct acpi_device_id that matches a
79  * specific PCI class. The .id and .driver_data fields will be left
80  * initialized with the default value.
81  */
82 #define ACPI_DEVICE_CLASS(_cls, _msk)	.cls = (_cls), .cls_msk = (_msk),
83 
has_acpi_companion(struct device * dev)84 static inline bool has_acpi_companion(struct device *dev)
85 {
86 	return is_acpi_device_node(dev->fwnode);
87 }
88 
acpi_preset_companion(struct device * dev,struct acpi_device * parent,u64 addr)89 static inline void acpi_preset_companion(struct device *dev,
90 					 struct acpi_device *parent, u64 addr)
91 {
92 	ACPI_COMPANION_SET(dev, acpi_find_child_device(parent, addr, false));
93 }
94 
acpi_dev_name(struct acpi_device * adev)95 static inline const char *acpi_dev_name(struct acpi_device *adev)
96 {
97 	return dev_name(&adev->dev);
98 }
99 
100 struct device *acpi_get_first_physical_node(struct acpi_device *adev);
101 
102 enum acpi_irq_model_id {
103 	ACPI_IRQ_MODEL_PIC = 0,
104 	ACPI_IRQ_MODEL_IOAPIC,
105 	ACPI_IRQ_MODEL_IOSAPIC,
106 	ACPI_IRQ_MODEL_PLATFORM,
107 	ACPI_IRQ_MODEL_GIC,
108 	ACPI_IRQ_MODEL_LPIC,
109 	ACPI_IRQ_MODEL_COUNT
110 };
111 
112 extern enum acpi_irq_model_id	acpi_irq_model;
113 
114 enum acpi_interrupt_id {
115 	ACPI_INTERRUPT_PMI	= 1,
116 	ACPI_INTERRUPT_INIT,
117 	ACPI_INTERRUPT_CPEI,
118 	ACPI_INTERRUPT_COUNT
119 };
120 
121 #define	ACPI_SPACE_MEM		0
122 
123 enum acpi_address_range_id {
124 	ACPI_ADDRESS_RANGE_MEMORY = 1,
125 	ACPI_ADDRESS_RANGE_RESERVED = 2,
126 	ACPI_ADDRESS_RANGE_ACPI = 3,
127 	ACPI_ADDRESS_RANGE_NVS	= 4,
128 	ACPI_ADDRESS_RANGE_COUNT
129 };
130 
131 
132 /* Table Handlers */
133 union acpi_subtable_headers {
134 	struct acpi_subtable_header common;
135 	struct acpi_hmat_structure hmat;
136 };
137 
138 typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table);
139 
140 typedef int (*acpi_tbl_entry_handler)(union acpi_subtable_headers *header,
141 				      const unsigned long end);
142 
143 /* Debugger support */
144 
145 struct acpi_debugger_ops {
146 	int (*create_thread)(acpi_osd_exec_callback function, void *context);
147 	ssize_t (*write_log)(const char *msg);
148 	ssize_t (*read_cmd)(char *buffer, size_t length);
149 	int (*wait_command_ready)(bool single_step, char *buffer, size_t length);
150 	int (*notify_command_complete)(void);
151 };
152 
153 struct acpi_debugger {
154 	const struct acpi_debugger_ops *ops;
155 	struct module *owner;
156 	struct mutex lock;
157 };
158 
159 #ifdef CONFIG_ACPI_DEBUGGER
160 int __init acpi_debugger_init(void);
161 int acpi_register_debugger(struct module *owner,
162 			   const struct acpi_debugger_ops *ops);
163 void acpi_unregister_debugger(const struct acpi_debugger_ops *ops);
164 int acpi_debugger_create_thread(acpi_osd_exec_callback function, void *context);
165 ssize_t acpi_debugger_write_log(const char *msg);
166 ssize_t acpi_debugger_read_cmd(char *buffer, size_t buffer_length);
167 int acpi_debugger_wait_command_ready(void);
168 int acpi_debugger_notify_command_complete(void);
169 #else
acpi_debugger_init(void)170 static inline int acpi_debugger_init(void)
171 {
172 	return -ENODEV;
173 }
174 
acpi_register_debugger(struct module * owner,const struct acpi_debugger_ops * ops)175 static inline int acpi_register_debugger(struct module *owner,
176 					 const struct acpi_debugger_ops *ops)
177 {
178 	return -ENODEV;
179 }
180 
acpi_unregister_debugger(const struct acpi_debugger_ops * ops)181 static inline void acpi_unregister_debugger(const struct acpi_debugger_ops *ops)
182 {
183 }
184 
acpi_debugger_create_thread(acpi_osd_exec_callback function,void * context)185 static inline int acpi_debugger_create_thread(acpi_osd_exec_callback function,
186 					      void *context)
187 {
188 	return -ENODEV;
189 }
190 
acpi_debugger_write_log(const char * msg)191 static inline int acpi_debugger_write_log(const char *msg)
192 {
193 	return -ENODEV;
194 }
195 
acpi_debugger_read_cmd(char * buffer,u32 buffer_length)196 static inline int acpi_debugger_read_cmd(char *buffer, u32 buffer_length)
197 {
198 	return -ENODEV;
199 }
200 
acpi_debugger_wait_command_ready(void)201 static inline int acpi_debugger_wait_command_ready(void)
202 {
203 	return -ENODEV;
204 }
205 
acpi_debugger_notify_command_complete(void)206 static inline int acpi_debugger_notify_command_complete(void)
207 {
208 	return -ENODEV;
209 }
210 #endif
211 
212 #define BAD_MADT_ENTRY(entry, end) (					    \
213 		(!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
214 		((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
215 
216 struct acpi_subtable_proc {
217 	int id;
218 	acpi_tbl_entry_handler handler;
219 	int count;
220 };
221 
222 void __iomem *__acpi_map_table(unsigned long phys, unsigned long size);
223 void __acpi_unmap_table(void __iomem *map, unsigned long size);
224 int early_acpi_boot_init(void);
225 int acpi_boot_init (void);
226 void acpi_boot_table_prepare (void);
227 void acpi_boot_table_init (void);
228 int acpi_mps_check (void);
229 int acpi_numa_init (void);
230 
231 int acpi_locate_initial_tables (void);
232 void acpi_reserve_initial_tables (void);
233 void acpi_table_init_complete (void);
234 int acpi_table_init (void);
235 int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
236 int __init acpi_table_parse_entries(char *id, unsigned long table_size,
237 			      int entry_id,
238 			      acpi_tbl_entry_handler handler,
239 			      unsigned int max_entries);
240 int __init acpi_table_parse_entries_array(char *id, unsigned long table_size,
241 			      struct acpi_subtable_proc *proc, int proc_num,
242 			      unsigned int max_entries);
243 int acpi_table_parse_madt(enum acpi_madt_type id,
244 			  acpi_tbl_entry_handler handler,
245 			  unsigned int max_entries);
246 int acpi_parse_mcfg (struct acpi_table_header *header);
247 void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
248 
249 /* the following numa functions are architecture-dependent */
250 void acpi_numa_slit_init (struct acpi_table_slit *slit);
251 
252 #if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_LOONGARCH)
253 void acpi_numa_processor_affinity_init (struct acpi_srat_cpu_affinity *pa);
254 #else
255 static inline void
acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity * pa)256 acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa) { }
257 #endif
258 
259 void acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa);
260 
261 #if defined(CONFIG_ARM64) || defined(CONFIG_LOONGARCH)
262 void acpi_arch_dma_setup(struct device *dev);
263 #else
acpi_arch_dma_setup(struct device * dev)264 static inline void acpi_arch_dma_setup(struct device *dev) { }
265 #endif
266 
267 #ifdef CONFIG_ARM64
268 void acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa);
269 #else
270 static inline void
acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity * pa)271 acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa) { }
272 #endif
273 
274 int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma);
275 
276 #ifndef PHYS_CPUID_INVALID
277 typedef u32 phys_cpuid_t;
278 #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
279 #endif
280 
invalid_logical_cpuid(u32 cpuid)281 static inline bool invalid_logical_cpuid(u32 cpuid)
282 {
283 	return (int)cpuid < 0;
284 }
285 
invalid_phys_cpuid(phys_cpuid_t phys_id)286 static inline bool invalid_phys_cpuid(phys_cpuid_t phys_id)
287 {
288 	return phys_id == PHYS_CPUID_INVALID;
289 }
290 
291 /* Validate the processor object's proc_id */
292 bool acpi_duplicate_processor_id(int proc_id);
293 /* Processor _CTS control */
294 struct acpi_processor_power;
295 
296 #ifdef CONFIG_ACPI_PROCESSOR_CSTATE
297 bool acpi_processor_claim_cst_control(void);
298 int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
299 				struct acpi_processor_power *info);
300 #else
acpi_processor_claim_cst_control(void)301 static inline bool acpi_processor_claim_cst_control(void) { return false; }
acpi_processor_evaluate_cst(acpi_handle handle,u32 cpu,struct acpi_processor_power * info)302 static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
303 					      struct acpi_processor_power *info)
304 {
305 	return -ENODEV;
306 }
307 #endif
308 
309 #ifdef CONFIG_ACPI_HOTPLUG_CPU
310 /* Arch dependent functions for cpu hotplug support */
311 int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id,
312 		 int *pcpu);
313 int acpi_unmap_cpu(int cpu);
314 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
315 
316 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
317 int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
318 #endif
319 
320 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
321 int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
322 int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base);
323 void acpi_irq_stats_init(void);
324 extern u32 acpi_irq_handled;
325 extern u32 acpi_irq_not_handled;
326 extern unsigned int acpi_sci_irq;
327 extern bool acpi_no_s5;
328 #define INVALID_ACPI_IRQ	((unsigned)-1)
acpi_sci_irq_valid(void)329 static inline bool acpi_sci_irq_valid(void)
330 {
331 	return acpi_sci_irq != INVALID_ACPI_IRQ;
332 }
333 
334 extern int sbf_port;
335 extern unsigned long acpi_realmode_flags;
336 
337 int acpi_register_gsi (struct device *dev, u32 gsi, int triggering, int polarity);
338 int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
339 int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi);
340 
341 void acpi_set_irq_model(enum acpi_irq_model_id model,
342 			struct fwnode_handle *fwnode);
343 
344 struct irq_domain *acpi_irq_create_hierarchy(unsigned int flags,
345 					     unsigned int size,
346 					     struct fwnode_handle *fwnode,
347 					     const struct irq_domain_ops *ops,
348 					     void *host_data);
349 
350 #ifdef CONFIG_X86_IO_APIC
351 extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity);
352 #else
acpi_get_override_irq(u32 gsi,int * trigger,int * polarity)353 static inline int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity)
354 {
355 	return -1;
356 }
357 #endif
358 /*
359  * This function undoes the effect of one call to acpi_register_gsi().
360  * If this matches the last registration, any IRQ resources for gsi
361  * are freed.
362  */
363 void acpi_unregister_gsi (u32 gsi);
364 
365 struct pci_dev;
366 
367 int acpi_pci_irq_enable (struct pci_dev *dev);
368 void acpi_penalize_isa_irq(int irq, int active);
369 bool acpi_isa_irq_available(int irq);
370 #ifdef CONFIG_PCI
371 void acpi_penalize_sci_irq(int irq, int trigger, int polarity);
372 #else
acpi_penalize_sci_irq(int irq,int trigger,int polarity)373 static inline void acpi_penalize_sci_irq(int irq, int trigger,
374 					int polarity)
375 {
376 }
377 #endif
378 void acpi_pci_irq_disable (struct pci_dev *dev);
379 
380 extern int ec_read(u8 addr, u8 *val);
381 extern int ec_write(u8 addr, u8 val);
382 extern int ec_transaction(u8 command,
383                           const u8 *wdata, unsigned wdata_len,
384                           u8 *rdata, unsigned rdata_len);
385 extern acpi_handle ec_get_handle(void);
386 
387 extern bool acpi_is_pnp_device(struct acpi_device *);
388 
389 #if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE)
390 
391 typedef void (*wmi_notify_handler) (u32 value, void *context);
392 
393 extern acpi_status wmi_evaluate_method(const char *guid, u8 instance,
394 					u32 method_id,
395 					const struct acpi_buffer *in,
396 					struct acpi_buffer *out);
397 extern acpi_status wmi_query_block(const char *guid, u8 instance,
398 					struct acpi_buffer *out);
399 extern acpi_status wmi_set_block(const char *guid, u8 instance,
400 					const struct acpi_buffer *in);
401 extern acpi_status wmi_install_notify_handler(const char *guid,
402 					wmi_notify_handler handler, void *data);
403 extern acpi_status wmi_remove_notify_handler(const char *guid);
404 extern acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out);
405 extern bool wmi_has_guid(const char *guid);
406 extern char *wmi_get_acpi_device_uid(const char *guid);
407 
408 #endif	/* CONFIG_ACPI_WMI */
409 
410 #define ACPI_VIDEO_OUTPUT_SWITCHING			0x0001
411 #define ACPI_VIDEO_DEVICE_POSTING			0x0002
412 #define ACPI_VIDEO_ROM_AVAILABLE			0x0004
413 #define ACPI_VIDEO_BACKLIGHT				0x0008
414 #define ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR		0x0010
415 #define ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO		0x0020
416 #define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR	0x0040
417 #define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO		0x0080
418 #define ACPI_VIDEO_BACKLIGHT_DMI_VENDOR			0x0100
419 #define ACPI_VIDEO_BACKLIGHT_DMI_VIDEO			0x0200
420 #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR		0x0400
421 #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO		0x0800
422 
423 extern char acpi_video_backlight_string[];
424 extern long acpi_is_video_device(acpi_handle handle);
425 extern int acpi_blacklisted(void);
426 extern void acpi_osi_setup(char *str);
427 extern bool acpi_osi_is_win8(void);
428 
429 #ifdef CONFIG_ACPI_NUMA
430 int acpi_map_pxm_to_node(int pxm);
431 int acpi_get_node(acpi_handle handle);
432 
433 /**
434  * pxm_to_online_node - Map proximity ID to online node
435  * @pxm: ACPI proximity ID
436  *
437  * This is similar to pxm_to_node(), but always returns an online
438  * node.  When the mapped node from a given proximity ID is offline, it
439  * looks up the node distance table and returns the nearest online node.
440  *
441  * ACPI device drivers, which are called after the NUMA initialization has
442  * completed in the kernel, can call this interface to obtain their device
443  * NUMA topology from ACPI tables.  Such drivers do not have to deal with
444  * offline nodes.  A node may be offline when SRAT memory entry does not exist,
445  * or NUMA is disabled, ex. "numa=off" on x86.
446  */
pxm_to_online_node(int pxm)447 static inline int pxm_to_online_node(int pxm)
448 {
449 	int node = pxm_to_node(pxm);
450 
451 	return numa_map_to_online_node(node);
452 }
453 #else
pxm_to_online_node(int pxm)454 static inline int pxm_to_online_node(int pxm)
455 {
456 	return 0;
457 }
acpi_map_pxm_to_node(int pxm)458 static inline int acpi_map_pxm_to_node(int pxm)
459 {
460 	return 0;
461 }
acpi_get_node(acpi_handle handle)462 static inline int acpi_get_node(acpi_handle handle)
463 {
464 	return 0;
465 }
466 #endif
467 extern int acpi_paddr_to_node(u64 start_addr, u64 size);
468 
469 extern int pnpacpi_disabled;
470 
471 #define PXM_INVAL	(-1)
472 
473 bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res);
474 bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res);
475 bool acpi_dev_resource_address_space(struct acpi_resource *ares,
476 				     struct resource_win *win);
477 bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
478 					 struct resource_win *win);
479 unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable);
480 unsigned int acpi_dev_get_irq_type(int triggering, int polarity);
481 bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
482 				 struct resource *res);
483 
484 void acpi_dev_free_resource_list(struct list_head *list);
485 int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
486 			   int (*preproc)(struct acpi_resource *, void *),
487 			   void *preproc_data);
488 int acpi_dev_get_dma_resources(struct acpi_device *adev,
489 			       struct list_head *list);
490 int acpi_dev_filter_resource_type(struct acpi_resource *ares,
491 				  unsigned long types);
492 
acpi_dev_filter_resource_type_cb(struct acpi_resource * ares,void * arg)493 static inline int acpi_dev_filter_resource_type_cb(struct acpi_resource *ares,
494 						   void *arg)
495 {
496 	return acpi_dev_filter_resource_type(ares, (unsigned long)arg);
497 }
498 
499 struct acpi_device *acpi_resource_consumer(struct resource *res);
500 
501 int acpi_check_resource_conflict(const struct resource *res);
502 
503 int acpi_check_region(resource_size_t start, resource_size_t n,
504 		      const char *name);
505 
506 acpi_status acpi_release_memory(acpi_handle handle, struct resource *res,
507 				u32 level);
508 
509 int acpi_resources_are_enforced(void);
510 
511 #ifdef CONFIG_HIBERNATION
512 void __init acpi_no_s4_hw_signature(void);
513 #endif
514 
515 #ifdef CONFIG_PM_SLEEP
516 void __init acpi_old_suspend_ordering(void);
517 void __init acpi_nvs_nosave(void);
518 void __init acpi_nvs_nosave_s3(void);
519 void __init acpi_sleep_no_blacklist(void);
520 #endif /* CONFIG_PM_SLEEP */
521 
522 int acpi_register_wakeup_handler(
523 	int wake_irq, bool (*wakeup)(void *context), void *context);
524 void acpi_unregister_wakeup_handler(
525 	bool (*wakeup)(void *context), void *context);
526 
527 struct acpi_osc_context {
528 	char *uuid_str;			/* UUID string */
529 	int rev;
530 	struct acpi_buffer cap;		/* list of DWORD capabilities */
531 	struct acpi_buffer ret;		/* free by caller if success */
532 };
533 
534 acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);
535 
536 /* Indexes into _OSC Capabilities Buffer (DWORDs 2 & 3 are device-specific) */
537 #define OSC_QUERY_DWORD				0	/* DWORD 1 */
538 #define OSC_SUPPORT_DWORD			1	/* DWORD 2 */
539 #define OSC_CONTROL_DWORD			2	/* DWORD 3 */
540 
541 /* _OSC Capabilities DWORD 1: Query/Control and Error Returns (generic) */
542 #define OSC_QUERY_ENABLE			0x00000001  /* input */
543 #define OSC_REQUEST_ERROR			0x00000002  /* return */
544 #define OSC_INVALID_UUID_ERROR			0x00000004  /* return */
545 #define OSC_INVALID_REVISION_ERROR		0x00000008  /* return */
546 #define OSC_CAPABILITIES_MASK_ERROR		0x00000010  /* return */
547 
548 /* Platform-Wide Capabilities _OSC: Capabilities DWORD 2: Support Field */
549 #define OSC_SB_PAD_SUPPORT			0x00000001
550 #define OSC_SB_PPC_OST_SUPPORT			0x00000002
551 #define OSC_SB_PR3_SUPPORT			0x00000004
552 #define OSC_SB_HOTPLUG_OST_SUPPORT		0x00000008
553 #define OSC_SB_APEI_SUPPORT			0x00000010
554 #define OSC_SB_CPC_SUPPORT			0x00000020
555 #define OSC_SB_CPCV2_SUPPORT			0x00000040
556 #define OSC_SB_PCLPI_SUPPORT			0x00000080
557 #define OSC_SB_OSLPI_SUPPORT			0x00000100
558 #define OSC_SB_CPC_DIVERSE_HIGH_SUPPORT		0x00001000
559 #define OSC_SB_GENERIC_INITIATOR_SUPPORT	0x00002000
560 
561 extern bool osc_sb_apei_support_acked;
562 extern bool osc_pc_lpi_support_confirmed;
563 
564 /* PCI Host Bridge _OSC: Capabilities DWORD 2: Support Field */
565 #define OSC_PCI_EXT_CONFIG_SUPPORT		0x00000001
566 #define OSC_PCI_ASPM_SUPPORT			0x00000002
567 #define OSC_PCI_CLOCK_PM_SUPPORT		0x00000004
568 #define OSC_PCI_SEGMENT_GROUPS_SUPPORT		0x00000008
569 #define OSC_PCI_MSI_SUPPORT			0x00000010
570 #define OSC_PCI_EDR_SUPPORT			0x00000080
571 #define OSC_PCI_HPX_TYPE_3_SUPPORT		0x00000100
572 #define OSC_PCI_SUPPORT_MASKS			0x0000019f
573 
574 /* PCI Host Bridge _OSC: Capabilities DWORD 3: Control Field */
575 #define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL	0x00000001
576 #define OSC_PCI_SHPC_NATIVE_HP_CONTROL		0x00000002
577 #define OSC_PCI_EXPRESS_PME_CONTROL		0x00000004
578 #define OSC_PCI_EXPRESS_AER_CONTROL		0x00000008
579 #define OSC_PCI_EXPRESS_CAPABILITY_CONTROL	0x00000010
580 #define OSC_PCI_EXPRESS_LTR_CONTROL		0x00000020
581 #define OSC_PCI_EXPRESS_DPC_CONTROL		0x00000080
582 #define OSC_PCI_CONTROL_MASKS			0x000000bf
583 
584 #define ACPI_GSB_ACCESS_ATTRIB_QUICK		0x00000002
585 #define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV         0x00000004
586 #define ACPI_GSB_ACCESS_ATTRIB_BYTE		0x00000006
587 #define ACPI_GSB_ACCESS_ATTRIB_WORD		0x00000008
588 #define ACPI_GSB_ACCESS_ATTRIB_BLOCK		0x0000000A
589 #define ACPI_GSB_ACCESS_ATTRIB_MULTIBYTE	0x0000000B
590 #define ACPI_GSB_ACCESS_ATTRIB_WORD_CALL	0x0000000C
591 #define ACPI_GSB_ACCESS_ATTRIB_BLOCK_CALL	0x0000000D
592 #define ACPI_GSB_ACCESS_ATTRIB_RAW_BYTES	0x0000000E
593 #define ACPI_GSB_ACCESS_ATTRIB_RAW_PROCESS	0x0000000F
594 
595 extern acpi_status acpi_pci_osc_control_set(acpi_handle handle,
596 					     u32 *mask, u32 req);
597 
598 /* Enable _OST when all relevant hotplug operations are enabled */
599 #if defined(CONFIG_ACPI_HOTPLUG_CPU) &&			\
600 	defined(CONFIG_ACPI_HOTPLUG_MEMORY) &&		\
601 	defined(CONFIG_ACPI_CONTAINER)
602 #define ACPI_HOTPLUG_OST
603 #endif
604 
605 /* _OST Source Event Code (OSPM Action) */
606 #define ACPI_OST_EC_OSPM_SHUTDOWN		0x100
607 #define ACPI_OST_EC_OSPM_EJECT			0x103
608 #define ACPI_OST_EC_OSPM_INSERTION		0x200
609 
610 /* _OST General Processing Status Code */
611 #define ACPI_OST_SC_SUCCESS			0x0
612 #define ACPI_OST_SC_NON_SPECIFIC_FAILURE	0x1
613 #define ACPI_OST_SC_UNRECOGNIZED_NOTIFY		0x2
614 
615 /* _OST OS Shutdown Processing (0x100) Status Code */
616 #define ACPI_OST_SC_OS_SHUTDOWN_DENIED		0x80
617 #define ACPI_OST_SC_OS_SHUTDOWN_IN_PROGRESS	0x81
618 #define ACPI_OST_SC_OS_SHUTDOWN_COMPLETED	0x82
619 #define ACPI_OST_SC_OS_SHUTDOWN_NOT_SUPPORTED	0x83
620 
621 /* _OST Ejection Request (0x3, 0x103) Status Code */
622 #define ACPI_OST_SC_EJECT_NOT_SUPPORTED		0x80
623 #define ACPI_OST_SC_DEVICE_IN_USE		0x81
624 #define ACPI_OST_SC_DEVICE_BUSY			0x82
625 #define ACPI_OST_SC_EJECT_DEPENDENCY_BUSY	0x83
626 #define ACPI_OST_SC_EJECT_IN_PROGRESS		0x84
627 
628 /* _OST Insertion Request (0x200) Status Code */
629 #define ACPI_OST_SC_INSERT_IN_PROGRESS		0x80
630 #define ACPI_OST_SC_DRIVER_LOAD_FAILURE		0x81
631 #define ACPI_OST_SC_INSERT_NOT_SUPPORTED	0x82
632 
633 enum acpi_predicate {
634 	all_versions,
635 	less_than_or_equal,
636 	equal,
637 	greater_than_or_equal,
638 };
639 
640 /* Table must be terminted by a NULL entry */
641 struct acpi_platform_list {
642 	char	oem_id[ACPI_OEM_ID_SIZE+1];
643 	char	oem_table_id[ACPI_OEM_TABLE_ID_SIZE+1];
644 	u32	oem_revision;
645 	char	*table;
646 	enum acpi_predicate pred;
647 	char	*reason;
648 	u32	data;
649 };
650 int acpi_match_platform_list(const struct acpi_platform_list *plat);
651 
652 extern void acpi_early_init(void);
653 extern void acpi_subsystem_init(void);
654 extern void arch_post_acpi_subsys_init(void);
655 
656 extern int acpi_nvs_register(__u64 start, __u64 size);
657 
658 extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
659 				    void *data);
660 
661 const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
662 					       const struct device *dev);
663 
664 const void *acpi_device_get_match_data(const struct device *dev);
665 extern bool acpi_driver_match_device(struct device *dev,
666 				     const struct device_driver *drv);
667 int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *);
668 int acpi_device_modalias(struct device *, char *, int);
669 void acpi_walk_dep_device_list(acpi_handle handle);
670 
671 struct platform_device *acpi_create_platform_device(struct acpi_device *,
672 						    struct property_entry *);
673 #define ACPI_PTR(_ptr)	(_ptr)
674 
acpi_device_set_enumerated(struct acpi_device * adev)675 static inline void acpi_device_set_enumerated(struct acpi_device *adev)
676 {
677 	adev->flags.visited = true;
678 }
679 
acpi_device_clear_enumerated(struct acpi_device * adev)680 static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
681 {
682 	adev->flags.visited = false;
683 }
684 
685 enum acpi_reconfig_event  {
686 	ACPI_RECONFIG_DEVICE_ADD = 0,
687 	ACPI_RECONFIG_DEVICE_REMOVE,
688 };
689 
690 int acpi_reconfig_notifier_register(struct notifier_block *nb);
691 int acpi_reconfig_notifier_unregister(struct notifier_block *nb);
692 
693 #ifdef CONFIG_ACPI_GTDT
694 int acpi_gtdt_init(struct acpi_table_header *table, int *platform_timer_count);
695 int acpi_gtdt_map_ppi(int type);
696 bool acpi_gtdt_c3stop(int type);
697 int acpi_arch_timer_mem_init(struct arch_timer_mem *timer_mem, int *timer_count);
698 #endif
699 
700 #ifndef ACPI_HAVE_ARCH_SET_ROOT_POINTER
acpi_arch_set_root_pointer(u64 addr)701 static inline void acpi_arch_set_root_pointer(u64 addr)
702 {
703 }
704 #endif
705 
706 #ifndef ACPI_HAVE_ARCH_GET_ROOT_POINTER
acpi_arch_get_root_pointer(void)707 static inline u64 acpi_arch_get_root_pointer(void)
708 {
709 	return 0;
710 }
711 #endif
712 
713 #else	/* !CONFIG_ACPI */
714 
715 #define acpi_disabled 1
716 
717 #define ACPI_COMPANION(dev)		(NULL)
718 #define ACPI_COMPANION_SET(dev, adev)	do { } while (0)
719 #define ACPI_HANDLE(dev)		(NULL)
720 #define ACPI_HANDLE_FWNODE(fwnode)	(NULL)
721 #define ACPI_DEVICE_CLASS(_cls, _msk)	.cls = (0), .cls_msk = (0),
722 
723 #include <acpi/acpi_numa.h>
724 
725 struct fwnode_handle;
726 
acpi_dev_found(const char * hid)727 static inline bool acpi_dev_found(const char *hid)
728 {
729 	return false;
730 }
731 
acpi_dev_present(const char * hid,const char * uid,s64 hrv)732 static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
733 {
734 	return false;
735 }
736 
737 struct acpi_device;
738 
739 static inline bool
acpi_dev_hid_uid_match(struct acpi_device * adev,const char * hid2,const char * uid2)740 acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2)
741 {
742 	return false;
743 }
744 
745 static inline struct acpi_device *
acpi_dev_get_first_match_dev(const char * hid,const char * uid,s64 hrv)746 acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
747 {
748 	return NULL;
749 }
750 
acpi_dev_put(struct acpi_device * adev)751 static inline void acpi_dev_put(struct acpi_device *adev) {}
752 
is_acpi_node(struct fwnode_handle * fwnode)753 static inline bool is_acpi_node(struct fwnode_handle *fwnode)
754 {
755 	return false;
756 }
757 
is_acpi_device_node(struct fwnode_handle * fwnode)758 static inline bool is_acpi_device_node(struct fwnode_handle *fwnode)
759 {
760 	return false;
761 }
762 
to_acpi_device_node(struct fwnode_handle * fwnode)763 static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
764 {
765 	return NULL;
766 }
767 
is_acpi_data_node(struct fwnode_handle * fwnode)768 static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
769 {
770 	return false;
771 }
772 
to_acpi_data_node(struct fwnode_handle * fwnode)773 static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
774 {
775 	return NULL;
776 }
777 
acpi_data_node_match(struct fwnode_handle * fwnode,const char * name)778 static inline bool acpi_data_node_match(struct fwnode_handle *fwnode,
779 					const char *name)
780 {
781 	return false;
782 }
783 
acpi_fwnode_handle(struct acpi_device * adev)784 static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
785 {
786 	return NULL;
787 }
788 
has_acpi_companion(struct device * dev)789 static inline bool has_acpi_companion(struct device *dev)
790 {
791 	return false;
792 }
793 
acpi_preset_companion(struct device * dev,struct acpi_device * parent,u64 addr)794 static inline void acpi_preset_companion(struct device *dev,
795 					 struct acpi_device *parent, u64 addr)
796 {
797 }
798 
acpi_dev_name(struct acpi_device * adev)799 static inline const char *acpi_dev_name(struct acpi_device *adev)
800 {
801 	return NULL;
802 }
803 
acpi_get_first_physical_node(struct acpi_device * adev)804 static inline struct device *acpi_get_first_physical_node(struct acpi_device *adev)
805 {
806 	return NULL;
807 }
808 
acpi_early_init(void)809 static inline void acpi_early_init(void) { }
acpi_subsystem_init(void)810 static inline void acpi_subsystem_init(void) { }
811 
early_acpi_boot_init(void)812 static inline int early_acpi_boot_init(void)
813 {
814 	return 0;
815 }
acpi_boot_init(void)816 static inline int acpi_boot_init(void)
817 {
818 	return 0;
819 }
820 
acpi_boot_table_prepare(void)821 static inline void acpi_boot_table_prepare(void)
822 {
823 }
824 
acpi_boot_table_init(void)825 static inline void acpi_boot_table_init(void)
826 {
827 }
828 
acpi_mps_check(void)829 static inline int acpi_mps_check(void)
830 {
831 	return 0;
832 }
833 
acpi_check_resource_conflict(struct resource * res)834 static inline int acpi_check_resource_conflict(struct resource *res)
835 {
836 	return 0;
837 }
838 
acpi_check_region(resource_size_t start,resource_size_t n,const char * name)839 static inline int acpi_check_region(resource_size_t start, resource_size_t n,
840 				    const char *name)
841 {
842 	return 0;
843 }
844 
845 struct acpi_table_header;
acpi_table_parse(char * id,int (* handler)(struct acpi_table_header *))846 static inline int acpi_table_parse(char *id,
847 				int (*handler)(struct acpi_table_header *))
848 {
849 	return -ENODEV;
850 }
851 
acpi_nvs_register(__u64 start,__u64 size)852 static inline int acpi_nvs_register(__u64 start, __u64 size)
853 {
854 	return 0;
855 }
856 
acpi_nvs_for_each_region(int (* func)(__u64,__u64,void *),void * data)857 static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
858 					   void *data)
859 {
860 	return 0;
861 }
862 
863 struct acpi_device_id;
864 
acpi_match_device(const struct acpi_device_id * ids,const struct device * dev)865 static inline const struct acpi_device_id *acpi_match_device(
866 	const struct acpi_device_id *ids, const struct device *dev)
867 {
868 	return NULL;
869 }
870 
acpi_device_get_match_data(const struct device * dev)871 static inline const void *acpi_device_get_match_data(const struct device *dev)
872 {
873 	return NULL;
874 }
875 
acpi_driver_match_device(struct device * dev,const struct device_driver * drv)876 static inline bool acpi_driver_match_device(struct device *dev,
877 					    const struct device_driver *drv)
878 {
879 	return false;
880 }
881 
acpi_evaluate_dsm(acpi_handle handle,const guid_t * guid,u64 rev,u64 func,union acpi_object * argv4)882 static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,
883 						   const guid_t *guid,
884 						   u64 rev, u64 func,
885 						   union acpi_object *argv4)
886 {
887 	return NULL;
888 }
889 
acpi_device_uevent_modalias(struct device * dev,struct kobj_uevent_env * env)890 static inline int acpi_device_uevent_modalias(struct device *dev,
891 				struct kobj_uevent_env *env)
892 {
893 	return -ENODEV;
894 }
895 
acpi_device_modalias(struct device * dev,char * buf,int size)896 static inline int acpi_device_modalias(struct device *dev,
897 				char *buf, int size)
898 {
899 	return -ENODEV;
900 }
901 
902 static inline struct platform_device *
acpi_create_platform_device(struct acpi_device * adev,struct property_entry * properties)903 acpi_create_platform_device(struct acpi_device *adev,
904 			    struct property_entry *properties)
905 {
906 	return NULL;
907 }
908 
acpi_dma_supported(struct acpi_device * adev)909 static inline bool acpi_dma_supported(struct acpi_device *adev)
910 {
911 	return false;
912 }
913 
acpi_get_dma_attr(struct acpi_device * adev)914 static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
915 {
916 	return DEV_DMA_NOT_SUPPORTED;
917 }
918 
acpi_dma_get_range(struct device * dev,const struct bus_dma_region ** map)919 static inline int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map)
920 {
921 	return -ENODEV;
922 }
923 
acpi_dma_configure(struct device * dev,enum dev_dma_attr attr)924 static inline int acpi_dma_configure(struct device *dev,
925 				     enum dev_dma_attr attr)
926 {
927 	return 0;
928 }
929 
acpi_dma_configure_id(struct device * dev,enum dev_dma_attr attr,const u32 * input_id)930 static inline int acpi_dma_configure_id(struct device *dev,
931 					enum dev_dma_attr attr,
932 					const u32 *input_id)
933 {
934 	return 0;
935 }
936 
937 #define ACPI_PTR(_ptr)	(NULL)
938 
acpi_device_set_enumerated(struct acpi_device * adev)939 static inline void acpi_device_set_enumerated(struct acpi_device *adev)
940 {
941 }
942 
acpi_device_clear_enumerated(struct acpi_device * adev)943 static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
944 {
945 }
946 
acpi_reconfig_notifier_register(struct notifier_block * nb)947 static inline int acpi_reconfig_notifier_register(struct notifier_block *nb)
948 {
949 	return -EINVAL;
950 }
951 
acpi_reconfig_notifier_unregister(struct notifier_block * nb)952 static inline int acpi_reconfig_notifier_unregister(struct notifier_block *nb)
953 {
954 	return -EINVAL;
955 }
956 
acpi_resource_consumer(struct resource * res)957 static inline struct acpi_device *acpi_resource_consumer(struct resource *res)
958 {
959 	return NULL;
960 }
961 
acpi_register_wakeup_handler(int wake_irq,bool (* wakeup)(void * context),void * context)962 static inline int acpi_register_wakeup_handler(int wake_irq,
963 	bool (*wakeup)(void *context), void *context)
964 {
965 	return -ENXIO;
966 }
967 
acpi_unregister_wakeup_handler(bool (* wakeup)(void * context),void * context)968 static inline void acpi_unregister_wakeup_handler(
969 	bool (*wakeup)(void *context), void *context) { }
970 
971 #endif	/* !CONFIG_ACPI */
972 
973 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
974 int acpi_ioapic_add(acpi_handle root);
975 #else
acpi_ioapic_add(acpi_handle root)976 static inline int acpi_ioapic_add(acpi_handle root) { return 0; }
977 #endif
978 
979 #ifdef CONFIG_ACPI
980 void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
981 			       u32 pm1a_ctrl,  u32 pm1b_ctrl));
982 
983 acpi_status acpi_os_prepare_sleep(u8 sleep_state,
984 				  u32 pm1a_control, u32 pm1b_control);
985 
986 void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
987 				        u32 val_a,  u32 val_b));
988 
989 acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state,
990 					   u32 val_a, u32 val_b);
991 
992 #ifndef CONFIG_IA64
993 void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
994 #else
arch_reserve_mem_area(acpi_physical_address addr,size_t size)995 static inline void arch_reserve_mem_area(acpi_physical_address addr,
996 					  size_t size)
997 {
998 }
999 #endif /* CONFIG_X86 */
1000 #else
1001 #define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
1002 #endif
1003 
1004 #if defined(CONFIG_ACPI) && defined(CONFIG_PM)
1005 int acpi_dev_suspend(struct device *dev, bool wakeup);
1006 int acpi_dev_resume(struct device *dev);
1007 int acpi_subsys_runtime_suspend(struct device *dev);
1008 int acpi_subsys_runtime_resume(struct device *dev);
1009 int acpi_dev_pm_attach(struct device *dev, bool power_on);
1010 bool acpi_storage_d3(struct device *dev);
1011 #else
acpi_subsys_runtime_suspend(struct device * dev)1012 static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; }
acpi_subsys_runtime_resume(struct device * dev)1013 static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; }
acpi_dev_pm_attach(struct device * dev,bool power_on)1014 static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
1015 {
1016 	return 0;
1017 }
acpi_storage_d3(struct device * dev)1018 static inline bool acpi_storage_d3(struct device *dev)
1019 {
1020 	return false;
1021 }
1022 #endif
1023 
1024 #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
1025 int acpi_subsys_prepare(struct device *dev);
1026 void acpi_subsys_complete(struct device *dev);
1027 int acpi_subsys_suspend_late(struct device *dev);
1028 int acpi_subsys_suspend_noirq(struct device *dev);
1029 int acpi_subsys_suspend(struct device *dev);
1030 int acpi_subsys_freeze(struct device *dev);
1031 int acpi_subsys_poweroff(struct device *dev);
1032 void acpi_ec_mark_gpe_for_wake(void);
1033 void acpi_ec_set_gpe_wake_mask(u8 action);
1034 #else
acpi_subsys_prepare(struct device * dev)1035 static inline int acpi_subsys_prepare(struct device *dev) { return 0; }
acpi_subsys_complete(struct device * dev)1036 static inline void acpi_subsys_complete(struct device *dev) {}
acpi_subsys_suspend_late(struct device * dev)1037 static inline int acpi_subsys_suspend_late(struct device *dev) { return 0; }
acpi_subsys_suspend_noirq(struct device * dev)1038 static inline int acpi_subsys_suspend_noirq(struct device *dev) { return 0; }
acpi_subsys_suspend(struct device * dev)1039 static inline int acpi_subsys_suspend(struct device *dev) { return 0; }
acpi_subsys_freeze(struct device * dev)1040 static inline int acpi_subsys_freeze(struct device *dev) { return 0; }
acpi_subsys_poweroff(struct device * dev)1041 static inline int acpi_subsys_poweroff(struct device *dev) { return 0; }
acpi_ec_mark_gpe_for_wake(void)1042 static inline void acpi_ec_mark_gpe_for_wake(void) {}
acpi_ec_set_gpe_wake_mask(u8 action)1043 static inline void acpi_ec_set_gpe_wake_mask(u8 action) {}
1044 #endif
1045 
1046 #ifdef CONFIG_ACPI
1047 __printf(3, 4)
1048 void acpi_handle_printk(const char *level, acpi_handle handle,
1049 			const char *fmt, ...);
1050 #else	/* !CONFIG_ACPI */
1051 static inline __printf(3, 4) void
acpi_handle_printk(const char * level,void * handle,const char * fmt,...)1052 acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {}
1053 #endif	/* !CONFIG_ACPI */
1054 
1055 #if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
1056 __printf(3, 4)
1057 void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
1058 #endif
1059 
1060 /*
1061  * acpi_handle_<level>: Print message with ACPI prefix and object path
1062  *
1063  * These interfaces acquire the global namespace mutex to obtain an object
1064  * path.  In interrupt context, it shows the object path as <n/a>.
1065  */
1066 #define acpi_handle_emerg(handle, fmt, ...)				\
1067 	acpi_handle_printk(KERN_EMERG, handle, fmt, ##__VA_ARGS__)
1068 #define acpi_handle_alert(handle, fmt, ...)				\
1069 	acpi_handle_printk(KERN_ALERT, handle, fmt, ##__VA_ARGS__)
1070 #define acpi_handle_crit(handle, fmt, ...)				\
1071 	acpi_handle_printk(KERN_CRIT, handle, fmt, ##__VA_ARGS__)
1072 #define acpi_handle_err(handle, fmt, ...)				\
1073 	acpi_handle_printk(KERN_ERR, handle, fmt, ##__VA_ARGS__)
1074 #define acpi_handle_warn(handle, fmt, ...)				\
1075 	acpi_handle_printk(KERN_WARNING, handle, fmt, ##__VA_ARGS__)
1076 #define acpi_handle_notice(handle, fmt, ...)				\
1077 	acpi_handle_printk(KERN_NOTICE, handle, fmt, ##__VA_ARGS__)
1078 #define acpi_handle_info(handle, fmt, ...)				\
1079 	acpi_handle_printk(KERN_INFO, handle, fmt, ##__VA_ARGS__)
1080 
1081 #if defined(DEBUG)
1082 #define acpi_handle_debug(handle, fmt, ...)				\
1083 	acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__)
1084 #else
1085 #if defined(CONFIG_DYNAMIC_DEBUG)
1086 #define acpi_handle_debug(handle, fmt, ...)				\
1087 	_dynamic_func_call(fmt, __acpi_handle_debug,			\
1088 			   handle, pr_fmt(fmt), ##__VA_ARGS__)
1089 #else
1090 #define acpi_handle_debug(handle, fmt, ...)				\
1091 ({									\
1092 	if (0)								\
1093 		acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__); \
1094 	0;								\
1095 })
1096 #endif
1097 #endif
1098 
1099 #if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB)
1100 bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
1101 				struct acpi_resource_gpio **agpio);
1102 int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index);
1103 #else
acpi_gpio_get_irq_resource(struct acpi_resource * ares,struct acpi_resource_gpio ** agpio)1104 static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
1105 					      struct acpi_resource_gpio **agpio)
1106 {
1107 	return false;
1108 }
acpi_dev_gpio_irq_get_by(struct acpi_device * adev,const char * name,int index)1109 static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev,
1110 					   const char *name, int index)
1111 {
1112 	return -ENXIO;
1113 }
1114 #endif
1115 
acpi_dev_gpio_irq_get(struct acpi_device * adev,int index)1116 static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
1117 {
1118 	return acpi_dev_gpio_irq_get_by(adev, NULL, index);
1119 }
1120 
1121 /* Device properties */
1122 
1123 #ifdef CONFIG_ACPI
1124 int acpi_dev_get_property(const struct acpi_device *adev, const char *name,
1125 			  acpi_object_type type, const union acpi_object **obj);
1126 int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
1127 				const char *name, size_t index, size_t num_args,
1128 				struct fwnode_reference_args *args);
1129 
acpi_node_get_property_reference(const struct fwnode_handle * fwnode,const char * name,size_t index,struct fwnode_reference_args * args)1130 static inline int acpi_node_get_property_reference(
1131 				const struct fwnode_handle *fwnode,
1132 				const char *name, size_t index,
1133 				struct fwnode_reference_args *args)
1134 {
1135 	return __acpi_node_get_property_reference(fwnode, name, index,
1136 		NR_FWNODE_REFERENCE_ARGS, args);
1137 }
1138 
acpi_dev_has_props(const struct acpi_device * adev)1139 static inline bool acpi_dev_has_props(const struct acpi_device *adev)
1140 {
1141 	return !list_empty(&adev->data.properties);
1142 }
1143 
1144 struct acpi_device_properties *
1145 acpi_data_add_props(struct acpi_device_data *data, const guid_t *guid,
1146 		    const union acpi_object *properties);
1147 
1148 int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
1149 		       void **valptr);
1150 int acpi_dev_prop_read_single(struct acpi_device *adev,
1151 			      const char *propname, enum dev_prop_type proptype,
1152 			      void *val);
1153 int acpi_node_prop_read(const struct fwnode_handle *fwnode,
1154 			const char *propname, enum dev_prop_type proptype,
1155 			void *val, size_t nval);
1156 int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname,
1157 		       enum dev_prop_type proptype, void *val, size_t nval);
1158 
1159 struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
1160 					    struct fwnode_handle *child);
1161 struct fwnode_handle *acpi_node_get_parent(const struct fwnode_handle *fwnode);
1162 
1163 struct acpi_probe_entry;
1164 typedef bool (*acpi_probe_entry_validate_subtbl)(struct acpi_subtable_header *,
1165 						 struct acpi_probe_entry *);
1166 
1167 #define ACPI_TABLE_ID_LEN	5
1168 
1169 /**
1170  * struct acpi_probe_entry - boot-time probing entry
1171  * @id:			ACPI table name
1172  * @type:		Optional subtable type to match
1173  *			(if @id contains subtables)
1174  * @subtable_valid:	Optional callback to check the validity of
1175  *			the subtable
1176  * @probe_table:	Callback to the driver being probed when table
1177  *			match is successful
1178  * @probe_subtbl:	Callback to the driver being probed when table and
1179  *			subtable match (and optional callback is successful)
1180  * @driver_data:	Sideband data provided back to the driver
1181  */
1182 struct acpi_probe_entry {
1183 	__u8 id[ACPI_TABLE_ID_LEN];
1184 	__u8 type;
1185 	acpi_probe_entry_validate_subtbl subtable_valid;
1186 	union {
1187 		acpi_tbl_table_handler probe_table;
1188 		acpi_tbl_entry_handler probe_subtbl;
1189 	};
1190 	kernel_ulong_t driver_data;
1191 };
1192 
1193 #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable,	\
1194 				 valid, data, fn)			\
1195 	static const struct acpi_probe_entry __acpi_probe_##name	\
1196 		__used __section("__" #table "_acpi_probe_table") = {	\
1197 			.id = table_id,					\
1198 			.type = subtable,				\
1199 			.subtable_valid = valid,			\
1200 			.probe_table = fn,				\
1201 			.driver_data = data,				\
1202 		}
1203 
1204 #define ACPI_DECLARE_SUBTABLE_PROBE_ENTRY(table, name, table_id,	\
1205 					  subtable, valid, data, fn)	\
1206 	static const struct acpi_probe_entry __acpi_probe_##name	\
1207 		__used __section("__" #table "_acpi_probe_table") = {	\
1208 			.id = table_id,					\
1209 			.type = subtable,				\
1210 			.subtable_valid = valid,			\
1211 			.probe_subtbl = fn,				\
1212 			.driver_data = data,				\
1213 		}
1214 
1215 #define ACPI_PROBE_TABLE(name)		__##name##_acpi_probe_table
1216 #define ACPI_PROBE_TABLE_END(name)	__##name##_acpi_probe_table_end
1217 
1218 int __acpi_probe_device_table(struct acpi_probe_entry *start, int nr);
1219 
1220 #define acpi_probe_device_table(t)					\
1221 	({ 								\
1222 		extern struct acpi_probe_entry ACPI_PROBE_TABLE(t),	\
1223 			                       ACPI_PROBE_TABLE_END(t);	\
1224 		__acpi_probe_device_table(&ACPI_PROBE_TABLE(t),		\
1225 					  (&ACPI_PROBE_TABLE_END(t) -	\
1226 					   &ACPI_PROBE_TABLE(t)));	\
1227 	})
1228 #else
acpi_dev_get_property(struct acpi_device * adev,const char * name,acpi_object_type type,const union acpi_object ** obj)1229 static inline int acpi_dev_get_property(struct acpi_device *adev,
1230 					const char *name, acpi_object_type type,
1231 					const union acpi_object **obj)
1232 {
1233 	return -ENXIO;
1234 }
1235 
1236 static inline int
__acpi_node_get_property_reference(const struct fwnode_handle * fwnode,const char * name,size_t index,size_t num_args,struct fwnode_reference_args * args)1237 __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
1238 				const char *name, size_t index, size_t num_args,
1239 				struct fwnode_reference_args *args)
1240 {
1241 	return -ENXIO;
1242 }
1243 
1244 static inline int
acpi_node_get_property_reference(const struct fwnode_handle * fwnode,const char * name,size_t index,struct fwnode_reference_args * args)1245 acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
1246 				 const char *name, size_t index,
1247 				 struct fwnode_reference_args *args)
1248 {
1249 	return -ENXIO;
1250 }
1251 
acpi_node_prop_get(const struct fwnode_handle * fwnode,const char * propname,void ** valptr)1252 static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,
1253 				     const char *propname,
1254 				     void **valptr)
1255 {
1256 	return -ENXIO;
1257 }
1258 
acpi_dev_prop_read_single(const struct acpi_device * adev,const char * propname,enum dev_prop_type proptype,void * val)1259 static inline int acpi_dev_prop_read_single(const struct acpi_device *adev,
1260 					    const char *propname,
1261 					    enum dev_prop_type proptype,
1262 					    void *val)
1263 {
1264 	return -ENXIO;
1265 }
1266 
acpi_node_prop_read(const struct fwnode_handle * fwnode,const char * propname,enum dev_prop_type proptype,void * val,size_t nval)1267 static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode,
1268 				      const char *propname,
1269 				      enum dev_prop_type proptype,
1270 				      void *val, size_t nval)
1271 {
1272 	return -ENXIO;
1273 }
1274 
acpi_dev_prop_read(const struct acpi_device * adev,const char * propname,enum dev_prop_type proptype,void * val,size_t nval)1275 static inline int acpi_dev_prop_read(const struct acpi_device *adev,
1276 				     const char *propname,
1277 				     enum dev_prop_type proptype,
1278 				     void *val, size_t nval)
1279 {
1280 	return -ENXIO;
1281 }
1282 
1283 static inline struct fwnode_handle *
acpi_get_next_subnode(const struct fwnode_handle * fwnode,struct fwnode_handle * child)1284 acpi_get_next_subnode(const struct fwnode_handle *fwnode,
1285 		      struct fwnode_handle *child)
1286 {
1287 	return NULL;
1288 }
1289 
1290 static inline struct fwnode_handle *
acpi_node_get_parent(const struct fwnode_handle * fwnode)1291 acpi_node_get_parent(const struct fwnode_handle *fwnode)
1292 {
1293 	return NULL;
1294 }
1295 
1296 static inline struct fwnode_handle *
acpi_graph_get_next_endpoint(const struct fwnode_handle * fwnode,struct fwnode_handle * prev)1297 acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
1298 			     struct fwnode_handle *prev)
1299 {
1300 	return ERR_PTR(-ENXIO);
1301 }
1302 
1303 static inline int
acpi_graph_get_remote_endpoint(const struct fwnode_handle * fwnode,struct fwnode_handle ** remote,struct fwnode_handle ** port,struct fwnode_handle ** endpoint)1304 acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode,
1305 			       struct fwnode_handle **remote,
1306 			       struct fwnode_handle **port,
1307 			       struct fwnode_handle **endpoint)
1308 {
1309 	return -ENXIO;
1310 }
1311 
1312 #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
1313 	static const void * __acpi_table_##name[]			\
1314 		__attribute__((unused))					\
1315 		 = { (void *) table_id,					\
1316 		     (void *) subtable,					\
1317 		     (void *) valid,					\
1318 		     (void *) fn,					\
1319 		     (void *) data }
1320 
1321 #define acpi_probe_device_table(t)	({ int __r = 0; __r;})
1322 #endif
1323 
1324 #ifdef CONFIG_ACPI_TABLE_UPGRADE
1325 void acpi_table_upgrade(void);
1326 #else
acpi_table_upgrade(void)1327 static inline void acpi_table_upgrade(void) { }
1328 #endif
1329 
1330 #if defined(CONFIG_ACPI) && defined(CONFIG_ACPI_WATCHDOG)
1331 extern bool acpi_has_watchdog(void);
1332 #else
acpi_has_watchdog(void)1333 static inline bool acpi_has_watchdog(void) { return false; }
1334 #endif
1335 
1336 #ifdef CONFIG_ACPI_SPCR_TABLE
1337 extern bool qdf2400_e44_present;
1338 int acpi_parse_spcr(bool enable_earlycon, bool enable_console);
1339 #else
acpi_parse_spcr(bool enable_earlycon,bool enable_console)1340 static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console)
1341 {
1342 	return 0;
1343 }
1344 #endif
1345 
1346 #if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI)
1347 int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res);
1348 #else
1349 static inline
acpi_irq_get(acpi_handle handle,unsigned int index,struct resource * res)1350 int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res)
1351 {
1352 	return -EINVAL;
1353 }
1354 #endif
1355 
1356 #ifdef CONFIG_ACPI_LPIT
1357 int lpit_read_residency_count_address(u64 *address);
1358 #else
lpit_read_residency_count_address(u64 * address)1359 static inline int lpit_read_residency_count_address(u64 *address)
1360 {
1361 	return -EINVAL;
1362 }
1363 #endif
1364 
1365 #ifdef CONFIG_ACPI_PPTT
1366 int acpi_pptt_cpu_is_thread(unsigned int cpu);
1367 int find_acpi_cpu_topology(unsigned int cpu, int level);
1368 int find_acpi_cpu_topology_package(unsigned int cpu);
1369 int find_acpi_cpu_topology_hetero_id(unsigned int cpu);
1370 int find_acpi_cpu_cache_topology(unsigned int cpu, int level);
1371 #else
acpi_pptt_cpu_is_thread(unsigned int cpu)1372 static inline int acpi_pptt_cpu_is_thread(unsigned int cpu)
1373 {
1374 	return -EINVAL;
1375 }
find_acpi_cpu_topology(unsigned int cpu,int level)1376 static inline int find_acpi_cpu_topology(unsigned int cpu, int level)
1377 {
1378 	return -EINVAL;
1379 }
find_acpi_cpu_topology_package(unsigned int cpu)1380 static inline int find_acpi_cpu_topology_package(unsigned int cpu)
1381 {
1382 	return -EINVAL;
1383 }
find_acpi_cpu_topology_hetero_id(unsigned int cpu)1384 static inline int find_acpi_cpu_topology_hetero_id(unsigned int cpu)
1385 {
1386 	return -EINVAL;
1387 }
find_acpi_cpu_cache_topology(unsigned int cpu,int level)1388 static inline int find_acpi_cpu_cache_topology(unsigned int cpu, int level)
1389 {
1390 	return -EINVAL;
1391 }
1392 #endif
1393 
1394 #ifdef CONFIG_ACPI
1395 extern int acpi_platform_notify(struct device *dev, enum kobject_action action);
1396 #else
1397 static inline int
acpi_platform_notify(struct device * dev,enum kobject_action action)1398 acpi_platform_notify(struct device *dev, enum kobject_action action)
1399 {
1400 	return 0;
1401 }
1402 #endif
1403 
1404 #endif	/*_LINUX_ACPI_H*/
1405