acpi.h 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301
  1. /*
  2. * acpi.h - ACPI Interface
  3. *
  4. * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  5. *
  6. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  19. */
  20. #ifndef _LINUX_ACPI_H
  21. #define _LINUX_ACPI_H
  22. #include <linux/errno.h>
  23. #include <linux/ioport.h> /* for struct resource */
  24. #include <linux/resource_ext.h>
  25. #include <linux/device.h>
  26. #include <linux/property.h>
  27. #include <linux/uuid.h>
  28. #ifndef _LINUX
  29. #define _LINUX
  30. #endif
  31. #include <acpi/acpi.h>
  32. #ifdef CONFIG_ACPI
  33. #include <linux/list.h>
  34. #include <linux/mod_devicetable.h>
  35. #include <linux/dynamic_debug.h>
  36. #include <linux/module.h>
  37. #include <linux/mutex.h>
  38. #include <acpi/acpi_bus.h>
  39. #include <acpi/acpi_drivers.h>
  40. #include <acpi/acpi_numa.h>
  41. #include <acpi/acpi_io.h>
  42. #include <asm/acpi.h>
  43. static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
  44. {
  45. return adev ? adev->handle : NULL;
  46. }
  47. #define ACPI_COMPANION(dev) to_acpi_device_node((dev)->fwnode)
  48. #define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \
  49. acpi_fwnode_handle(adev) : NULL)
  50. #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
  51. #define ACPI_HANDLE_FWNODE(fwnode) \
  52. acpi_device_handle(to_acpi_device_node(fwnode))
  53. static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
  54. {
  55. struct fwnode_handle *fwnode;
  56. fwnode = kzalloc(sizeof(struct fwnode_handle), GFP_KERNEL);
  57. if (!fwnode)
  58. return NULL;
  59. fwnode->ops = &acpi_static_fwnode_ops;
  60. return fwnode;
  61. }
  62. static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode)
  63. {
  64. if (WARN_ON(!is_acpi_static_node(fwnode)))
  65. return;
  66. kfree(fwnode);
  67. }
  68. /**
  69. * ACPI_DEVICE_CLASS - macro used to describe an ACPI device with
  70. * the PCI-defined class-code information
  71. *
  72. * @_cls : the class, subclass, prog-if triple for this device
  73. * @_msk : the class mask for this device
  74. *
  75. * This macro is used to create a struct acpi_device_id that matches a
  76. * specific PCI class. The .id and .driver_data fields will be left
  77. * initialized with the default value.
  78. */
  79. #define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (_cls), .cls_msk = (_msk),
  80. static inline bool has_acpi_companion(struct device *dev)
  81. {
  82. return is_acpi_device_node(dev->fwnode);
  83. }
  84. static inline void acpi_preset_companion(struct device *dev,
  85. struct acpi_device *parent, u64 addr)
  86. {
  87. ACPI_COMPANION_SET(dev, acpi_find_child_device(parent, addr, NULL));
  88. }
  89. static inline const char *acpi_dev_name(struct acpi_device *adev)
  90. {
  91. return dev_name(&adev->dev);
  92. }
  93. struct device *acpi_get_first_physical_node(struct acpi_device *adev);
  94. enum acpi_irq_model_id {
  95. ACPI_IRQ_MODEL_PIC = 0,
  96. ACPI_IRQ_MODEL_IOAPIC,
  97. ACPI_IRQ_MODEL_IOSAPIC,
  98. ACPI_IRQ_MODEL_PLATFORM,
  99. ACPI_IRQ_MODEL_GIC,
  100. ACPI_IRQ_MODEL_COUNT
  101. };
  102. extern enum acpi_irq_model_id acpi_irq_model;
  103. enum acpi_interrupt_id {
  104. ACPI_INTERRUPT_PMI = 1,
  105. ACPI_INTERRUPT_INIT,
  106. ACPI_INTERRUPT_CPEI,
  107. ACPI_INTERRUPT_COUNT
  108. };
  109. #define ACPI_SPACE_MEM 0
  110. enum acpi_address_range_id {
  111. ACPI_ADDRESS_RANGE_MEMORY = 1,
  112. ACPI_ADDRESS_RANGE_RESERVED = 2,
  113. ACPI_ADDRESS_RANGE_ACPI = 3,
  114. ACPI_ADDRESS_RANGE_NVS = 4,
  115. ACPI_ADDRESS_RANGE_COUNT
  116. };
  117. /* Table Handlers */
  118. typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table);
  119. typedef int (*acpi_tbl_entry_handler)(struct acpi_subtable_header *header,
  120. const unsigned long end);
  121. /* Debugger support */
  122. struct acpi_debugger_ops {
  123. int (*create_thread)(acpi_osd_exec_callback function, void *context);
  124. ssize_t (*write_log)(const char *msg);
  125. ssize_t (*read_cmd)(char *buffer, size_t length);
  126. int (*wait_command_ready)(bool single_step, char *buffer, size_t length);
  127. int (*notify_command_complete)(void);
  128. };
  129. struct acpi_debugger {
  130. const struct acpi_debugger_ops *ops;
  131. struct module *owner;
  132. struct mutex lock;
  133. };
  134. #ifdef CONFIG_ACPI_DEBUGGER
  135. int __init acpi_debugger_init(void);
  136. int acpi_register_debugger(struct module *owner,
  137. const struct acpi_debugger_ops *ops);
  138. void acpi_unregister_debugger(const struct acpi_debugger_ops *ops);
  139. int acpi_debugger_create_thread(acpi_osd_exec_callback function, void *context);
  140. ssize_t acpi_debugger_write_log(const char *msg);
  141. ssize_t acpi_debugger_read_cmd(char *buffer, size_t buffer_length);
  142. int acpi_debugger_wait_command_ready(void);
  143. int acpi_debugger_notify_command_complete(void);
  144. #else
  145. static inline int acpi_debugger_init(void)
  146. {
  147. return -ENODEV;
  148. }
  149. static inline int acpi_register_debugger(struct module *owner,
  150. const struct acpi_debugger_ops *ops)
  151. {
  152. return -ENODEV;
  153. }
  154. static inline void acpi_unregister_debugger(const struct acpi_debugger_ops *ops)
  155. {
  156. }
  157. static inline int acpi_debugger_create_thread(acpi_osd_exec_callback function,
  158. void *context)
  159. {
  160. return -ENODEV;
  161. }
  162. static inline int acpi_debugger_write_log(const char *msg)
  163. {
  164. return -ENODEV;
  165. }
  166. static inline int acpi_debugger_read_cmd(char *buffer, u32 buffer_length)
  167. {
  168. return -ENODEV;
  169. }
  170. static inline int acpi_debugger_wait_command_ready(void)
  171. {
  172. return -ENODEV;
  173. }
  174. static inline int acpi_debugger_notify_command_complete(void)
  175. {
  176. return -ENODEV;
  177. }
  178. #endif
  179. #define BAD_MADT_ENTRY(entry, end) ( \
  180. (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
  181. ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
  182. struct acpi_subtable_proc {
  183. int id;
  184. acpi_tbl_entry_handler handler;
  185. int count;
  186. };
  187. void __iomem *__acpi_map_table(unsigned long phys, unsigned long size);
  188. void __acpi_unmap_table(void __iomem *map, unsigned long size);
  189. int early_acpi_boot_init(void);
  190. int acpi_boot_init (void);
  191. void acpi_boot_table_init (void);
  192. int acpi_mps_check (void);
  193. int acpi_numa_init (void);
  194. int acpi_table_init (void);
  195. int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
  196. int __init acpi_table_parse_entries(char *id, unsigned long table_size,
  197. int entry_id,
  198. acpi_tbl_entry_handler handler,
  199. unsigned int max_entries);
  200. int __init acpi_table_parse_entries_array(char *id, unsigned long table_size,
  201. struct acpi_subtable_proc *proc, int proc_num,
  202. unsigned int max_entries);
  203. int acpi_table_parse_madt(enum acpi_madt_type id,
  204. acpi_tbl_entry_handler handler,
  205. unsigned int max_entries);
  206. int acpi_parse_mcfg (struct acpi_table_header *header);
  207. void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
  208. /* the following numa functions are architecture-dependent */
  209. void acpi_numa_slit_init (struct acpi_table_slit *slit);
  210. #if defined(CONFIG_X86) || defined(CONFIG_IA64)
  211. void acpi_numa_processor_affinity_init (struct acpi_srat_cpu_affinity *pa);
  212. #else
  213. static inline void
  214. acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa) { }
  215. #endif
  216. void acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa);
  217. #ifdef CONFIG_ARM64
  218. void acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa);
  219. #else
  220. static inline void
  221. acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa) { }
  222. #endif
  223. int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma);
  224. #ifndef PHYS_CPUID_INVALID
  225. typedef u32 phys_cpuid_t;
  226. #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
  227. #endif
  228. static inline bool invalid_logical_cpuid(u32 cpuid)
  229. {
  230. return (int)cpuid < 0;
  231. }
  232. static inline bool invalid_phys_cpuid(phys_cpuid_t phys_id)
  233. {
  234. return phys_id == PHYS_CPUID_INVALID;
  235. }
  236. /* Validate the processor object's proc_id */
  237. bool acpi_duplicate_processor_id(int proc_id);
  238. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  239. /* Arch dependent functions for cpu hotplug support */
  240. int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id,
  241. int *pcpu);
  242. int acpi_unmap_cpu(int cpu);
  243. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  244. #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
  245. int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
  246. #endif
  247. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
  248. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
  249. int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base);
  250. void acpi_irq_stats_init(void);
  251. extern u32 acpi_irq_handled;
  252. extern u32 acpi_irq_not_handled;
  253. extern unsigned int acpi_sci_irq;
  254. extern bool acpi_no_s5;
  255. #define INVALID_ACPI_IRQ ((unsigned)-1)
  256. static inline bool acpi_sci_irq_valid(void)
  257. {
  258. return acpi_sci_irq != INVALID_ACPI_IRQ;
  259. }
  260. extern int sbf_port;
  261. extern unsigned long acpi_realmode_flags;
  262. int acpi_register_gsi (struct device *dev, u32 gsi, int triggering, int polarity);
  263. int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
  264. int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi);
  265. void acpi_set_irq_model(enum acpi_irq_model_id model,
  266. struct fwnode_handle *fwnode);
  267. #ifdef CONFIG_X86_IO_APIC
  268. extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity);
  269. #else
  270. #define acpi_get_override_irq(gsi, trigger, polarity) (-1)
  271. #endif
  272. /*
  273. * This function undoes the effect of one call to acpi_register_gsi().
  274. * If this matches the last registration, any IRQ resources for gsi
  275. * are freed.
  276. */
  277. void acpi_unregister_gsi (u32 gsi);
  278. struct pci_dev;
  279. int acpi_pci_irq_enable (struct pci_dev *dev);
  280. void acpi_penalize_isa_irq(int irq, int active);
  281. bool acpi_isa_irq_available(int irq);
  282. void acpi_penalize_sci_irq(int irq, int trigger, int polarity);
  283. void acpi_pci_irq_disable (struct pci_dev *dev);
  284. extern int ec_read(u8 addr, u8 *val);
  285. extern int ec_write(u8 addr, u8 val);
  286. extern int ec_transaction(u8 command,
  287. const u8 *wdata, unsigned wdata_len,
  288. u8 *rdata, unsigned rdata_len);
  289. extern acpi_handle ec_get_handle(void);
  290. extern bool acpi_is_pnp_device(struct acpi_device *);
  291. #if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE)
  292. typedef void (*wmi_notify_handler) (u32 value, void *context);
  293. extern acpi_status wmi_evaluate_method(const char *guid, u8 instance,
  294. u32 method_id,
  295. const struct acpi_buffer *in,
  296. struct acpi_buffer *out);
  297. extern acpi_status wmi_query_block(const char *guid, u8 instance,
  298. struct acpi_buffer *out);
  299. extern acpi_status wmi_set_block(const char *guid, u8 instance,
  300. const struct acpi_buffer *in);
  301. extern acpi_status wmi_install_notify_handler(const char *guid,
  302. wmi_notify_handler handler, void *data);
  303. extern acpi_status wmi_remove_notify_handler(const char *guid);
  304. extern acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out);
  305. extern bool wmi_has_guid(const char *guid);
  306. #endif /* CONFIG_ACPI_WMI */
  307. #define ACPI_VIDEO_OUTPUT_SWITCHING 0x0001
  308. #define ACPI_VIDEO_DEVICE_POSTING 0x0002
  309. #define ACPI_VIDEO_ROM_AVAILABLE 0x0004
  310. #define ACPI_VIDEO_BACKLIGHT 0x0008
  311. #define ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR 0x0010
  312. #define ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO 0x0020
  313. #define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR 0x0040
  314. #define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO 0x0080
  315. #define ACPI_VIDEO_BACKLIGHT_DMI_VENDOR 0x0100
  316. #define ACPI_VIDEO_BACKLIGHT_DMI_VIDEO 0x0200
  317. #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR 0x0400
  318. #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO 0x0800
  319. extern char acpi_video_backlight_string[];
  320. extern long acpi_is_video_device(acpi_handle handle);
  321. extern int acpi_blacklisted(void);
  322. extern void acpi_osi_setup(char *str);
  323. extern bool acpi_osi_is_win8(void);
  324. #ifdef CONFIG_ACPI_NUMA
  325. int acpi_map_pxm_to_online_node(int pxm);
  326. int acpi_get_node(acpi_handle handle);
  327. #else
  328. static inline int acpi_map_pxm_to_online_node(int pxm)
  329. {
  330. return 0;
  331. }
  332. static inline int acpi_get_node(acpi_handle handle)
  333. {
  334. return 0;
  335. }
  336. #endif
  337. extern int acpi_paddr_to_node(u64 start_addr, u64 size);
  338. extern int pnpacpi_disabled;
  339. #define PXM_INVAL (-1)
  340. bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res);
  341. bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res);
  342. bool acpi_dev_resource_address_space(struct acpi_resource *ares,
  343. struct resource_win *win);
  344. bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
  345. struct resource_win *win);
  346. unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable);
  347. unsigned int acpi_dev_get_irq_type(int triggering, int polarity);
  348. bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
  349. struct resource *res);
  350. void acpi_dev_free_resource_list(struct list_head *list);
  351. int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
  352. int (*preproc)(struct acpi_resource *, void *),
  353. void *preproc_data);
  354. int acpi_dev_get_dma_resources(struct acpi_device *adev,
  355. struct list_head *list);
  356. int acpi_dev_filter_resource_type(struct acpi_resource *ares,
  357. unsigned long types);
  358. static inline int acpi_dev_filter_resource_type_cb(struct acpi_resource *ares,
  359. void *arg)
  360. {
  361. return acpi_dev_filter_resource_type(ares, (unsigned long)arg);
  362. }
  363. struct acpi_device *acpi_resource_consumer(struct resource *res);
  364. int acpi_check_resource_conflict(const struct resource *res);
  365. int acpi_check_region(resource_size_t start, resource_size_t n,
  366. const char *name);
  367. int acpi_resources_are_enforced(void);
  368. #ifdef CONFIG_HIBERNATION
  369. void __init acpi_no_s4_hw_signature(void);
  370. #endif
  371. #ifdef CONFIG_PM_SLEEP
  372. void __init acpi_old_suspend_ordering(void);
  373. void __init acpi_nvs_nosave(void);
  374. void __init acpi_nvs_nosave_s3(void);
  375. void __init acpi_sleep_no_blacklist(void);
  376. #endif /* CONFIG_PM_SLEEP */
  377. struct acpi_osc_context {
  378. char *uuid_str; /* UUID string */
  379. int rev;
  380. struct acpi_buffer cap; /* list of DWORD capabilities */
  381. struct acpi_buffer ret; /* free by caller if success */
  382. };
  383. acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);
  384. /* Indexes into _OSC Capabilities Buffer (DWORDs 2 & 3 are device-specific) */
  385. #define OSC_QUERY_DWORD 0 /* DWORD 1 */
  386. #define OSC_SUPPORT_DWORD 1 /* DWORD 2 */
  387. #define OSC_CONTROL_DWORD 2 /* DWORD 3 */
  388. /* _OSC Capabilities DWORD 1: Query/Control and Error Returns (generic) */
  389. #define OSC_QUERY_ENABLE 0x00000001 /* input */
  390. #define OSC_REQUEST_ERROR 0x00000002 /* return */
  391. #define OSC_INVALID_UUID_ERROR 0x00000004 /* return */
  392. #define OSC_INVALID_REVISION_ERROR 0x00000008 /* return */
  393. #define OSC_CAPABILITIES_MASK_ERROR 0x00000010 /* return */
  394. /* Platform-Wide Capabilities _OSC: Capabilities DWORD 2: Support Field */
  395. #define OSC_SB_PAD_SUPPORT 0x00000001
  396. #define OSC_SB_PPC_OST_SUPPORT 0x00000002
  397. #define OSC_SB_PR3_SUPPORT 0x00000004
  398. #define OSC_SB_HOTPLUG_OST_SUPPORT 0x00000008
  399. #define OSC_SB_APEI_SUPPORT 0x00000010
  400. #define OSC_SB_CPC_SUPPORT 0x00000020
  401. #define OSC_SB_CPCV2_SUPPORT 0x00000040
  402. #define OSC_SB_PCLPI_SUPPORT 0x00000080
  403. #define OSC_SB_OSLPI_SUPPORT 0x00000100
  404. #define OSC_SB_CPC_DIVERSE_HIGH_SUPPORT 0x00001000
  405. extern bool osc_sb_apei_support_acked;
  406. extern bool osc_pc_lpi_support_confirmed;
  407. /* PCI Host Bridge _OSC: Capabilities DWORD 2: Support Field */
  408. #define OSC_PCI_EXT_CONFIG_SUPPORT 0x00000001
  409. #define OSC_PCI_ASPM_SUPPORT 0x00000002
  410. #define OSC_PCI_CLOCK_PM_SUPPORT 0x00000004
  411. #define OSC_PCI_SEGMENT_GROUPS_SUPPORT 0x00000008
  412. #define OSC_PCI_MSI_SUPPORT 0x00000010
  413. #define OSC_PCI_SUPPORT_MASKS 0x0000001f
  414. /* PCI Host Bridge _OSC: Capabilities DWORD 3: Control Field */
  415. #define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL 0x00000001
  416. #define OSC_PCI_SHPC_NATIVE_HP_CONTROL 0x00000002
  417. #define OSC_PCI_EXPRESS_PME_CONTROL 0x00000004
  418. #define OSC_PCI_EXPRESS_AER_CONTROL 0x00000008
  419. #define OSC_PCI_EXPRESS_CAPABILITY_CONTROL 0x00000010
  420. #define OSC_PCI_CONTROL_MASKS 0x0000001f
  421. #define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002
  422. #define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004
  423. #define ACPI_GSB_ACCESS_ATTRIB_BYTE 0x00000006
  424. #define ACPI_GSB_ACCESS_ATTRIB_WORD 0x00000008
  425. #define ACPI_GSB_ACCESS_ATTRIB_BLOCK 0x0000000A
  426. #define ACPI_GSB_ACCESS_ATTRIB_MULTIBYTE 0x0000000B
  427. #define ACPI_GSB_ACCESS_ATTRIB_WORD_CALL 0x0000000C
  428. #define ACPI_GSB_ACCESS_ATTRIB_BLOCK_CALL 0x0000000D
  429. #define ACPI_GSB_ACCESS_ATTRIB_RAW_BYTES 0x0000000E
  430. #define ACPI_GSB_ACCESS_ATTRIB_RAW_PROCESS 0x0000000F
  431. extern acpi_status acpi_pci_osc_control_set(acpi_handle handle,
  432. u32 *mask, u32 req);
  433. /* Enable _OST when all relevant hotplug operations are enabled */
  434. #if defined(CONFIG_ACPI_HOTPLUG_CPU) && \
  435. defined(CONFIG_ACPI_HOTPLUG_MEMORY) && \
  436. defined(CONFIG_ACPI_CONTAINER)
  437. #define ACPI_HOTPLUG_OST
  438. #endif
  439. /* _OST Source Event Code (OSPM Action) */
  440. #define ACPI_OST_EC_OSPM_SHUTDOWN 0x100
  441. #define ACPI_OST_EC_OSPM_EJECT 0x103
  442. #define ACPI_OST_EC_OSPM_INSERTION 0x200
  443. /* _OST General Processing Status Code */
  444. #define ACPI_OST_SC_SUCCESS 0x0
  445. #define ACPI_OST_SC_NON_SPECIFIC_FAILURE 0x1
  446. #define ACPI_OST_SC_UNRECOGNIZED_NOTIFY 0x2
  447. /* _OST OS Shutdown Processing (0x100) Status Code */
  448. #define ACPI_OST_SC_OS_SHUTDOWN_DENIED 0x80
  449. #define ACPI_OST_SC_OS_SHUTDOWN_IN_PROGRESS 0x81
  450. #define ACPI_OST_SC_OS_SHUTDOWN_COMPLETED 0x82
  451. #define ACPI_OST_SC_OS_SHUTDOWN_NOT_SUPPORTED 0x83
  452. /* _OST Ejection Request (0x3, 0x103) Status Code */
  453. #define ACPI_OST_SC_EJECT_NOT_SUPPORTED 0x80
  454. #define ACPI_OST_SC_DEVICE_IN_USE 0x81
  455. #define ACPI_OST_SC_DEVICE_BUSY 0x82
  456. #define ACPI_OST_SC_EJECT_DEPENDENCY_BUSY 0x83
  457. #define ACPI_OST_SC_EJECT_IN_PROGRESS 0x84
  458. /* _OST Insertion Request (0x200) Status Code */
  459. #define ACPI_OST_SC_INSERT_IN_PROGRESS 0x80
  460. #define ACPI_OST_SC_DRIVER_LOAD_FAILURE 0x81
  461. #define ACPI_OST_SC_INSERT_NOT_SUPPORTED 0x82
  462. enum acpi_predicate {
  463. all_versions,
  464. less_than_or_equal,
  465. equal,
  466. greater_than_or_equal,
  467. };
  468. /* Table must be terminted by a NULL entry */
  469. struct acpi_platform_list {
  470. char oem_id[ACPI_OEM_ID_SIZE+1];
  471. char oem_table_id[ACPI_OEM_TABLE_ID_SIZE+1];
  472. u32 oem_revision;
  473. char *table;
  474. enum acpi_predicate pred;
  475. char *reason;
  476. u32 data;
  477. };
  478. int acpi_match_platform_list(const struct acpi_platform_list *plat);
  479. extern void acpi_early_init(void);
  480. extern void acpi_subsystem_init(void);
  481. extern void arch_post_acpi_subsys_init(void);
  482. extern int acpi_nvs_register(__u64 start, __u64 size);
  483. extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
  484. void *data);
  485. const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
  486. const struct device *dev);
  487. const void *acpi_device_get_match_data(const struct device *dev);
  488. extern bool acpi_driver_match_device(struct device *dev,
  489. const struct device_driver *drv);
  490. int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *);
  491. int acpi_device_modalias(struct device *, char *, int);
  492. void acpi_walk_dep_device_list(acpi_handle handle);
  493. struct platform_device *acpi_create_platform_device(struct acpi_device *,
  494. struct property_entry *);
  495. #define ACPI_PTR(_ptr) (_ptr)
  496. static inline void acpi_device_set_enumerated(struct acpi_device *adev)
  497. {
  498. adev->flags.visited = true;
  499. }
  500. static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
  501. {
  502. adev->flags.visited = false;
  503. }
  504. enum acpi_reconfig_event {
  505. ACPI_RECONFIG_DEVICE_ADD = 0,
  506. ACPI_RECONFIG_DEVICE_REMOVE,
  507. };
  508. int acpi_reconfig_notifier_register(struct notifier_block *nb);
  509. int acpi_reconfig_notifier_unregister(struct notifier_block *nb);
  510. #ifdef CONFIG_ACPI_GTDT
  511. int acpi_gtdt_init(struct acpi_table_header *table, int *platform_timer_count);
  512. int acpi_gtdt_map_ppi(int type);
  513. bool acpi_gtdt_c3stop(int type);
  514. int acpi_arch_timer_mem_init(struct arch_timer_mem *timer_mem, int *timer_count);
  515. #endif
  516. #ifndef ACPI_HAVE_ARCH_GET_ROOT_POINTER
  517. static inline u64 acpi_arch_get_root_pointer(void)
  518. {
  519. return 0;
  520. }
  521. #endif
  522. #else /* !CONFIG_ACPI */
  523. #define acpi_disabled 1
  524. #define ACPI_COMPANION(dev) (NULL)
  525. #define ACPI_COMPANION_SET(dev, adev) do { } while (0)
  526. #define ACPI_HANDLE(dev) (NULL)
  527. #define ACPI_HANDLE_FWNODE(fwnode) (NULL)
  528. #define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (0), .cls_msk = (0),
  529. struct fwnode_handle;
  530. static inline bool acpi_dev_found(const char *hid)
  531. {
  532. return false;
  533. }
  534. static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
  535. {
  536. return false;
  537. }
  538. static inline const char *
  539. acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
  540. {
  541. return NULL;
  542. }
  543. static inline bool is_acpi_node(struct fwnode_handle *fwnode)
  544. {
  545. return false;
  546. }
  547. static inline bool is_acpi_device_node(struct fwnode_handle *fwnode)
  548. {
  549. return false;
  550. }
  551. static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
  552. {
  553. return NULL;
  554. }
  555. static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
  556. {
  557. return false;
  558. }
  559. static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
  560. {
  561. return NULL;
  562. }
  563. static inline bool acpi_data_node_match(struct fwnode_handle *fwnode,
  564. const char *name)
  565. {
  566. return false;
  567. }
  568. static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
  569. {
  570. return NULL;
  571. }
  572. static inline bool has_acpi_companion(struct device *dev)
  573. {
  574. return false;
  575. }
  576. static inline void acpi_preset_companion(struct device *dev,
  577. struct acpi_device *parent, u64 addr)
  578. {
  579. }
  580. static inline const char *acpi_dev_name(struct acpi_device *adev)
  581. {
  582. return NULL;
  583. }
  584. static inline struct device *acpi_get_first_physical_node(struct acpi_device *adev)
  585. {
  586. return NULL;
  587. }
  588. static inline void acpi_early_init(void) { }
  589. static inline void acpi_subsystem_init(void) { }
  590. static inline int early_acpi_boot_init(void)
  591. {
  592. return 0;
  593. }
  594. static inline int acpi_boot_init(void)
  595. {
  596. return 0;
  597. }
  598. static inline void acpi_boot_table_init(void)
  599. {
  600. return;
  601. }
  602. static inline int acpi_mps_check(void)
  603. {
  604. return 0;
  605. }
  606. static inline int acpi_check_resource_conflict(struct resource *res)
  607. {
  608. return 0;
  609. }
  610. static inline int acpi_check_region(resource_size_t start, resource_size_t n,
  611. const char *name)
  612. {
  613. return 0;
  614. }
  615. struct acpi_table_header;
  616. static inline int acpi_table_parse(char *id,
  617. int (*handler)(struct acpi_table_header *))
  618. {
  619. return -ENODEV;
  620. }
  621. static inline int acpi_nvs_register(__u64 start, __u64 size)
  622. {
  623. return 0;
  624. }
  625. static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
  626. void *data)
  627. {
  628. return 0;
  629. }
  630. struct acpi_device_id;
  631. static inline const struct acpi_device_id *acpi_match_device(
  632. const struct acpi_device_id *ids, const struct device *dev)
  633. {
  634. return NULL;
  635. }
  636. static inline const void *acpi_device_get_match_data(const struct device *dev)
  637. {
  638. return NULL;
  639. }
  640. static inline bool acpi_driver_match_device(struct device *dev,
  641. const struct device_driver *drv)
  642. {
  643. return false;
  644. }
  645. static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,
  646. const guid_t *guid,
  647. int rev, int func,
  648. union acpi_object *argv4)
  649. {
  650. return NULL;
  651. }
  652. static inline int acpi_device_uevent_modalias(struct device *dev,
  653. struct kobj_uevent_env *env)
  654. {
  655. return -ENODEV;
  656. }
  657. static inline int acpi_device_modalias(struct device *dev,
  658. char *buf, int size)
  659. {
  660. return -ENODEV;
  661. }
  662. static inline bool acpi_dma_supported(struct acpi_device *adev)
  663. {
  664. return false;
  665. }
  666. static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
  667. {
  668. return DEV_DMA_NOT_SUPPORTED;
  669. }
  670. static inline int acpi_dma_get_range(struct device *dev, u64 *dma_addr,
  671. u64 *offset, u64 *size)
  672. {
  673. return -ENODEV;
  674. }
  675. static inline int acpi_dma_configure(struct device *dev,
  676. enum dev_dma_attr attr)
  677. {
  678. return 0;
  679. }
  680. static inline void acpi_dma_deconfigure(struct device *dev) { }
  681. #define ACPI_PTR(_ptr) (NULL)
  682. static inline void acpi_device_set_enumerated(struct acpi_device *adev)
  683. {
  684. }
  685. static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
  686. {
  687. }
  688. static inline int acpi_reconfig_notifier_register(struct notifier_block *nb)
  689. {
  690. return -EINVAL;
  691. }
  692. static inline int acpi_reconfig_notifier_unregister(struct notifier_block *nb)
  693. {
  694. return -EINVAL;
  695. }
  696. static inline struct acpi_device *acpi_resource_consumer(struct resource *res)
  697. {
  698. return NULL;
  699. }
  700. #endif /* !CONFIG_ACPI */
  701. #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
  702. int acpi_ioapic_add(acpi_handle root);
  703. #else
  704. static inline int acpi_ioapic_add(acpi_handle root) { return 0; }
  705. #endif
  706. #ifdef CONFIG_ACPI
  707. void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
  708. u32 pm1a_ctrl, u32 pm1b_ctrl));
  709. acpi_status acpi_os_prepare_sleep(u8 sleep_state,
  710. u32 pm1a_control, u32 pm1b_control);
  711. void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
  712. u32 val_a, u32 val_b));
  713. acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state,
  714. u32 val_a, u32 val_b);
  715. #ifdef CONFIG_X86
  716. void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
  717. #else
  718. static inline void arch_reserve_mem_area(acpi_physical_address addr,
  719. size_t size)
  720. {
  721. }
  722. #endif /* CONFIG_X86 */
  723. #else
  724. #define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
  725. #endif
  726. #if defined(CONFIG_ACPI) && defined(CONFIG_PM)
  727. int acpi_dev_suspend(struct device *dev, bool wakeup);
  728. int acpi_dev_resume(struct device *dev);
  729. int acpi_subsys_runtime_suspend(struct device *dev);
  730. int acpi_subsys_runtime_resume(struct device *dev);
  731. int acpi_dev_pm_attach(struct device *dev, bool power_on);
  732. #else
  733. static inline int acpi_dev_runtime_suspend(struct device *dev) { return 0; }
  734. static inline int acpi_dev_runtime_resume(struct device *dev) { return 0; }
  735. static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; }
  736. static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; }
  737. static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
  738. {
  739. return 0;
  740. }
  741. #endif
  742. #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
  743. int acpi_dev_suspend_late(struct device *dev);
  744. int acpi_subsys_prepare(struct device *dev);
  745. void acpi_subsys_complete(struct device *dev);
  746. int acpi_subsys_suspend_late(struct device *dev);
  747. int acpi_subsys_suspend_noirq(struct device *dev);
  748. int acpi_subsys_resume_noirq(struct device *dev);
  749. int acpi_subsys_resume_early(struct device *dev);
  750. int acpi_subsys_suspend(struct device *dev);
  751. int acpi_subsys_freeze(struct device *dev);
  752. int acpi_subsys_freeze_late(struct device *dev);
  753. int acpi_subsys_freeze_noirq(struct device *dev);
  754. int acpi_subsys_thaw_noirq(struct device *dev);
  755. #else
  756. static inline int acpi_dev_resume_early(struct device *dev) { return 0; }
  757. static inline int acpi_subsys_prepare(struct device *dev) { return 0; }
  758. static inline void acpi_subsys_complete(struct device *dev) {}
  759. static inline int acpi_subsys_suspend_late(struct device *dev) { return 0; }
  760. static inline int acpi_subsys_suspend_noirq(struct device *dev) { return 0; }
  761. static inline int acpi_subsys_resume_noirq(struct device *dev) { return 0; }
  762. static inline int acpi_subsys_resume_early(struct device *dev) { return 0; }
  763. static inline int acpi_subsys_suspend(struct device *dev) { return 0; }
  764. static inline int acpi_subsys_freeze(struct device *dev) { return 0; }
  765. static inline int acpi_subsys_freeze_late(struct device *dev) { return 0; }
  766. static inline int acpi_subsys_freeze_noirq(struct device *dev) { return 0; }
  767. static inline int acpi_subsys_thaw_noirq(struct device *dev) { return 0; }
  768. #endif
  769. #ifdef CONFIG_ACPI
  770. __printf(3, 4)
  771. void acpi_handle_printk(const char *level, acpi_handle handle,
  772. const char *fmt, ...);
  773. #else /* !CONFIG_ACPI */
  774. static inline __printf(3, 4) void
  775. acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {}
  776. #endif /* !CONFIG_ACPI */
  777. #if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
  778. __printf(3, 4)
  779. void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
  780. #else
  781. #define __acpi_handle_debug(descriptor, handle, fmt, ...) \
  782. acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__);
  783. #endif
  784. /*
  785. * acpi_handle_<level>: Print message with ACPI prefix and object path
  786. *
  787. * These interfaces acquire the global namespace mutex to obtain an object
  788. * path. In interrupt context, it shows the object path as <n/a>.
  789. */
  790. #define acpi_handle_emerg(handle, fmt, ...) \
  791. acpi_handle_printk(KERN_EMERG, handle, fmt, ##__VA_ARGS__)
  792. #define acpi_handle_alert(handle, fmt, ...) \
  793. acpi_handle_printk(KERN_ALERT, handle, fmt, ##__VA_ARGS__)
  794. #define acpi_handle_crit(handle, fmt, ...) \
  795. acpi_handle_printk(KERN_CRIT, handle, fmt, ##__VA_ARGS__)
  796. #define acpi_handle_err(handle, fmt, ...) \
  797. acpi_handle_printk(KERN_ERR, handle, fmt, ##__VA_ARGS__)
  798. #define acpi_handle_warn(handle, fmt, ...) \
  799. acpi_handle_printk(KERN_WARNING, handle, fmt, ##__VA_ARGS__)
  800. #define acpi_handle_notice(handle, fmt, ...) \
  801. acpi_handle_printk(KERN_NOTICE, handle, fmt, ##__VA_ARGS__)
  802. #define acpi_handle_info(handle, fmt, ...) \
  803. acpi_handle_printk(KERN_INFO, handle, fmt, ##__VA_ARGS__)
  804. #if defined(DEBUG)
  805. #define acpi_handle_debug(handle, fmt, ...) \
  806. acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__)
  807. #else
  808. #if defined(CONFIG_DYNAMIC_DEBUG)
  809. #define acpi_handle_debug(handle, fmt, ...) \
  810. do { \
  811. DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
  812. if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \
  813. __acpi_handle_debug(&descriptor, handle, pr_fmt(fmt), \
  814. ##__VA_ARGS__); \
  815. } while (0)
  816. #else
  817. #define acpi_handle_debug(handle, fmt, ...) \
  818. ({ \
  819. if (0) \
  820. acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__); \
  821. 0; \
  822. })
  823. #endif
  824. #endif
  825. struct acpi_gpio_params {
  826. unsigned int crs_entry_index;
  827. unsigned int line_index;
  828. bool active_low;
  829. };
  830. struct acpi_gpio_mapping {
  831. const char *name;
  832. const struct acpi_gpio_params *data;
  833. unsigned int size;
  834. /* Ignore IoRestriction field */
  835. #define ACPI_GPIO_QUIRK_NO_IO_RESTRICTION BIT(0)
  836. unsigned int quirks;
  837. };
  838. #if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB)
  839. int acpi_dev_add_driver_gpios(struct acpi_device *adev,
  840. const struct acpi_gpio_mapping *gpios);
  841. static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev)
  842. {
  843. if (adev)
  844. adev->driver_gpios = NULL;
  845. }
  846. int devm_acpi_dev_add_driver_gpios(struct device *dev,
  847. const struct acpi_gpio_mapping *gpios);
  848. void devm_acpi_dev_remove_driver_gpios(struct device *dev);
  849. bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
  850. struct acpi_resource_gpio **agpio);
  851. int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index);
  852. #else
  853. static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
  854. const struct acpi_gpio_mapping *gpios)
  855. {
  856. return -ENXIO;
  857. }
  858. static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev) {}
  859. static inline int devm_acpi_dev_add_driver_gpios(struct device *dev,
  860. const struct acpi_gpio_mapping *gpios)
  861. {
  862. return -ENXIO;
  863. }
  864. static inline void devm_acpi_dev_remove_driver_gpios(struct device *dev) {}
  865. static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
  866. struct acpi_resource_gpio **agpio)
  867. {
  868. return false;
  869. }
  870. static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
  871. {
  872. return -ENXIO;
  873. }
  874. #endif
  875. /* Device properties */
  876. #define MAX_ACPI_REFERENCE_ARGS 8
  877. struct acpi_reference_args {
  878. struct acpi_device *adev;
  879. size_t nargs;
  880. u64 args[MAX_ACPI_REFERENCE_ARGS];
  881. };
  882. #ifdef CONFIG_ACPI
  883. int acpi_dev_get_property(const struct acpi_device *adev, const char *name,
  884. acpi_object_type type, const union acpi_object **obj);
  885. int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
  886. const char *name, size_t index, size_t num_args,
  887. struct acpi_reference_args *args);
  888. static inline int acpi_node_get_property_reference(
  889. const struct fwnode_handle *fwnode,
  890. const char *name, size_t index,
  891. struct acpi_reference_args *args)
  892. {
  893. return __acpi_node_get_property_reference(fwnode, name, index,
  894. MAX_ACPI_REFERENCE_ARGS, args);
  895. }
  896. int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
  897. void **valptr);
  898. int acpi_dev_prop_read_single(struct acpi_device *adev,
  899. const char *propname, enum dev_prop_type proptype,
  900. void *val);
  901. int acpi_node_prop_read(const struct fwnode_handle *fwnode,
  902. const char *propname, enum dev_prop_type proptype,
  903. void *val, size_t nval);
  904. int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname,
  905. enum dev_prop_type proptype, void *val, size_t nval);
  906. struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
  907. struct fwnode_handle *child);
  908. struct fwnode_handle *acpi_node_get_parent(const struct fwnode_handle *fwnode);
  909. struct fwnode_handle *
  910. acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
  911. struct fwnode_handle *prev);
  912. int acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode,
  913. struct fwnode_handle **remote,
  914. struct fwnode_handle **port,
  915. struct fwnode_handle **endpoint);
  916. struct acpi_probe_entry;
  917. typedef bool (*acpi_probe_entry_validate_subtbl)(struct acpi_subtable_header *,
  918. struct acpi_probe_entry *);
  919. #define ACPI_TABLE_ID_LEN 5
  920. /**
  921. * struct acpi_probe_entry - boot-time probing entry
  922. * @id: ACPI table name
  923. * @type: Optional subtable type to match
  924. * (if @id contains subtables)
  925. * @subtable_valid: Optional callback to check the validity of
  926. * the subtable
  927. * @probe_table: Callback to the driver being probed when table
  928. * match is successful
  929. * @probe_subtbl: Callback to the driver being probed when table and
  930. * subtable match (and optional callback is successful)
  931. * @driver_data: Sideband data provided back to the driver
  932. */
  933. struct acpi_probe_entry {
  934. __u8 id[ACPI_TABLE_ID_LEN];
  935. __u8 type;
  936. acpi_probe_entry_validate_subtbl subtable_valid;
  937. union {
  938. acpi_tbl_table_handler probe_table;
  939. acpi_tbl_entry_handler probe_subtbl;
  940. };
  941. kernel_ulong_t driver_data;
  942. };
  943. #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
  944. static const struct acpi_probe_entry __acpi_probe_##name \
  945. __used __section(__##table##_acpi_probe_table) \
  946. = { \
  947. .id = table_id, \
  948. .type = subtable, \
  949. .subtable_valid = valid, \
  950. .probe_table = (acpi_tbl_table_handler)fn, \
  951. .driver_data = data, \
  952. }
  953. #define ACPI_PROBE_TABLE(name) __##name##_acpi_probe_table
  954. #define ACPI_PROBE_TABLE_END(name) __##name##_acpi_probe_table_end
  955. int __acpi_probe_device_table(struct acpi_probe_entry *start, int nr);
  956. #define acpi_probe_device_table(t) \
  957. ({ \
  958. extern struct acpi_probe_entry ACPI_PROBE_TABLE(t), \
  959. ACPI_PROBE_TABLE_END(t); \
  960. __acpi_probe_device_table(&ACPI_PROBE_TABLE(t), \
  961. (&ACPI_PROBE_TABLE_END(t) - \
  962. &ACPI_PROBE_TABLE(t))); \
  963. })
  964. #else
  965. static inline int acpi_dev_get_property(struct acpi_device *adev,
  966. const char *name, acpi_object_type type,
  967. const union acpi_object **obj)
  968. {
  969. return -ENXIO;
  970. }
  971. static inline int
  972. __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
  973. const char *name, size_t index, size_t num_args,
  974. struct acpi_reference_args *args)
  975. {
  976. return -ENXIO;
  977. }
  978. static inline int
  979. acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
  980. const char *name, size_t index,
  981. struct acpi_reference_args *args)
  982. {
  983. return -ENXIO;
  984. }
  985. static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,
  986. const char *propname,
  987. void **valptr)
  988. {
  989. return -ENXIO;
  990. }
  991. static inline int acpi_dev_prop_get(const struct acpi_device *adev,
  992. const char *propname,
  993. void **valptr)
  994. {
  995. return -ENXIO;
  996. }
  997. static inline int acpi_dev_prop_read_single(const struct acpi_device *adev,
  998. const char *propname,
  999. enum dev_prop_type proptype,
  1000. void *val)
  1001. {
  1002. return -ENXIO;
  1003. }
  1004. static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode,
  1005. const char *propname,
  1006. enum dev_prop_type proptype,
  1007. void *val, size_t nval)
  1008. {
  1009. return -ENXIO;
  1010. }
  1011. static inline int acpi_dev_prop_read(const struct acpi_device *adev,
  1012. const char *propname,
  1013. enum dev_prop_type proptype,
  1014. void *val, size_t nval)
  1015. {
  1016. return -ENXIO;
  1017. }
  1018. static inline struct fwnode_handle *
  1019. acpi_get_next_subnode(const struct fwnode_handle *fwnode,
  1020. struct fwnode_handle *child)
  1021. {
  1022. return NULL;
  1023. }
  1024. static inline struct fwnode_handle *
  1025. acpi_node_get_parent(const struct fwnode_handle *fwnode)
  1026. {
  1027. return NULL;
  1028. }
  1029. static inline struct fwnode_handle *
  1030. acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
  1031. struct fwnode_handle *prev)
  1032. {
  1033. return ERR_PTR(-ENXIO);
  1034. }
  1035. static inline int
  1036. acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode,
  1037. struct fwnode_handle **remote,
  1038. struct fwnode_handle **port,
  1039. struct fwnode_handle **endpoint)
  1040. {
  1041. return -ENXIO;
  1042. }
  1043. #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
  1044. static const void * __acpi_table_##name[] \
  1045. __attribute__((unused)) \
  1046. = { (void *) table_id, \
  1047. (void *) subtable, \
  1048. (void *) valid, \
  1049. (void *) fn, \
  1050. (void *) data }
  1051. #define acpi_probe_device_table(t) ({ int __r = 0; __r;})
  1052. #endif
  1053. #ifdef CONFIG_ACPI_TABLE_UPGRADE
  1054. void acpi_table_upgrade(void);
  1055. #else
  1056. static inline void acpi_table_upgrade(void) { }
  1057. #endif
  1058. #if defined(CONFIG_ACPI) && defined(CONFIG_ACPI_WATCHDOG)
  1059. extern bool acpi_has_watchdog(void);
  1060. #else
  1061. static inline bool acpi_has_watchdog(void) { return false; }
  1062. #endif
  1063. #ifdef CONFIG_ACPI_SPCR_TABLE
  1064. extern bool qdf2400_e44_present;
  1065. int acpi_parse_spcr(bool enable_earlycon, bool enable_console);
  1066. #else
  1067. static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console)
  1068. {
  1069. return 0;
  1070. }
  1071. #endif
  1072. #if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI)
  1073. int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res);
  1074. #else
  1075. static inline
  1076. int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res)
  1077. {
  1078. return -EINVAL;
  1079. }
  1080. #endif
  1081. #ifdef CONFIG_ACPI_LPIT
  1082. int lpit_read_residency_count_address(u64 *address);
  1083. #else
  1084. static inline int lpit_read_residency_count_address(u64 *address)
  1085. {
  1086. return -EINVAL;
  1087. }
  1088. #endif
  1089. #endif /*_LINUX_ACPI_H*/