acpi.h 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  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 int acpi_nvs_register(__u64 start, __u64 size);
  482. extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
  483. void *data);
  484. const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
  485. const struct device *dev);
  486. const void *acpi_device_get_match_data(const struct device *dev);
  487. extern bool acpi_driver_match_device(struct device *dev,
  488. const struct device_driver *drv);
  489. int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *);
  490. int acpi_device_modalias(struct device *, char *, int);
  491. void acpi_walk_dep_device_list(acpi_handle handle);
  492. struct platform_device *acpi_create_platform_device(struct acpi_device *,
  493. struct property_entry *);
  494. #define ACPI_PTR(_ptr) (_ptr)
  495. static inline void acpi_device_set_enumerated(struct acpi_device *adev)
  496. {
  497. adev->flags.visited = true;
  498. }
  499. static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
  500. {
  501. adev->flags.visited = false;
  502. }
  503. enum acpi_reconfig_event {
  504. ACPI_RECONFIG_DEVICE_ADD = 0,
  505. ACPI_RECONFIG_DEVICE_REMOVE,
  506. };
  507. int acpi_reconfig_notifier_register(struct notifier_block *nb);
  508. int acpi_reconfig_notifier_unregister(struct notifier_block *nb);
  509. #ifdef CONFIG_ACPI_GTDT
  510. int acpi_gtdt_init(struct acpi_table_header *table, int *platform_timer_count);
  511. int acpi_gtdt_map_ppi(int type);
  512. bool acpi_gtdt_c3stop(int type);
  513. int acpi_arch_timer_mem_init(struct arch_timer_mem *timer_mem, int *timer_count);
  514. #endif
  515. #ifndef ACPI_HAVE_ARCH_GET_ROOT_POINTER
  516. static inline u64 acpi_arch_get_root_pointer(void)
  517. {
  518. return 0;
  519. }
  520. #endif
  521. #else /* !CONFIG_ACPI */
  522. #define acpi_disabled 1
  523. #define ACPI_COMPANION(dev) (NULL)
  524. #define ACPI_COMPANION_SET(dev, adev) do { } while (0)
  525. #define ACPI_HANDLE(dev) (NULL)
  526. #define ACPI_HANDLE_FWNODE(fwnode) (NULL)
  527. #define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (0), .cls_msk = (0),
  528. struct fwnode_handle;
  529. static inline bool acpi_dev_found(const char *hid)
  530. {
  531. return false;
  532. }
  533. static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
  534. {
  535. return false;
  536. }
  537. static inline const char *
  538. acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
  539. {
  540. return NULL;
  541. }
  542. static inline bool is_acpi_node(struct fwnode_handle *fwnode)
  543. {
  544. return false;
  545. }
  546. static inline bool is_acpi_device_node(struct fwnode_handle *fwnode)
  547. {
  548. return false;
  549. }
  550. static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
  551. {
  552. return NULL;
  553. }
  554. static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
  555. {
  556. return false;
  557. }
  558. static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
  559. {
  560. return NULL;
  561. }
  562. static inline bool acpi_data_node_match(struct fwnode_handle *fwnode,
  563. const char *name)
  564. {
  565. return false;
  566. }
  567. static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
  568. {
  569. return NULL;
  570. }
  571. static inline bool has_acpi_companion(struct device *dev)
  572. {
  573. return false;
  574. }
  575. static inline void acpi_preset_companion(struct device *dev,
  576. struct acpi_device *parent, u64 addr)
  577. {
  578. }
  579. static inline const char *acpi_dev_name(struct acpi_device *adev)
  580. {
  581. return NULL;
  582. }
  583. static inline struct device *acpi_get_first_physical_node(struct acpi_device *adev)
  584. {
  585. return NULL;
  586. }
  587. static inline void acpi_early_init(void) { }
  588. static inline void acpi_subsystem_init(void) { }
  589. static inline int early_acpi_boot_init(void)
  590. {
  591. return 0;
  592. }
  593. static inline int acpi_boot_init(void)
  594. {
  595. return 0;
  596. }
  597. static inline void acpi_boot_table_init(void)
  598. {
  599. return;
  600. }
  601. static inline int acpi_mps_check(void)
  602. {
  603. return 0;
  604. }
  605. static inline int acpi_check_resource_conflict(struct resource *res)
  606. {
  607. return 0;
  608. }
  609. static inline int acpi_check_region(resource_size_t start, resource_size_t n,
  610. const char *name)
  611. {
  612. return 0;
  613. }
  614. struct acpi_table_header;
  615. static inline int acpi_table_parse(char *id,
  616. int (*handler)(struct acpi_table_header *))
  617. {
  618. return -ENODEV;
  619. }
  620. static inline int acpi_nvs_register(__u64 start, __u64 size)
  621. {
  622. return 0;
  623. }
  624. static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
  625. void *data)
  626. {
  627. return 0;
  628. }
  629. struct acpi_device_id;
  630. static inline const struct acpi_device_id *acpi_match_device(
  631. const struct acpi_device_id *ids, const struct device *dev)
  632. {
  633. return NULL;
  634. }
  635. static inline const void *acpi_device_get_match_data(const struct device *dev)
  636. {
  637. return NULL;
  638. }
  639. static inline bool acpi_driver_match_device(struct device *dev,
  640. const struct device_driver *drv)
  641. {
  642. return false;
  643. }
  644. static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,
  645. const guid_t *guid,
  646. int rev, int func,
  647. union acpi_object *argv4)
  648. {
  649. return NULL;
  650. }
  651. static inline int acpi_device_uevent_modalias(struct device *dev,
  652. struct kobj_uevent_env *env)
  653. {
  654. return -ENODEV;
  655. }
  656. static inline int acpi_device_modalias(struct device *dev,
  657. char *buf, int size)
  658. {
  659. return -ENODEV;
  660. }
  661. static inline bool acpi_dma_supported(struct acpi_device *adev)
  662. {
  663. return false;
  664. }
  665. static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
  666. {
  667. return DEV_DMA_NOT_SUPPORTED;
  668. }
  669. static inline int acpi_dma_get_range(struct device *dev, u64 *dma_addr,
  670. u64 *offset, u64 *size)
  671. {
  672. return -ENODEV;
  673. }
  674. static inline int acpi_dma_configure(struct device *dev,
  675. enum dev_dma_attr attr)
  676. {
  677. return 0;
  678. }
  679. static inline void acpi_dma_deconfigure(struct device *dev) { }
  680. #define ACPI_PTR(_ptr) (NULL)
  681. static inline void acpi_device_set_enumerated(struct acpi_device *adev)
  682. {
  683. }
  684. static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
  685. {
  686. }
  687. static inline int acpi_reconfig_notifier_register(struct notifier_block *nb)
  688. {
  689. return -EINVAL;
  690. }
  691. static inline int acpi_reconfig_notifier_unregister(struct notifier_block *nb)
  692. {
  693. return -EINVAL;
  694. }
  695. static inline struct acpi_device *acpi_resource_consumer(struct resource *res)
  696. {
  697. return NULL;
  698. }
  699. #endif /* !CONFIG_ACPI */
  700. #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
  701. int acpi_ioapic_add(acpi_handle root);
  702. #else
  703. static inline int acpi_ioapic_add(acpi_handle root) { return 0; }
  704. #endif
  705. #ifdef CONFIG_ACPI
  706. void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
  707. u32 pm1a_ctrl, u32 pm1b_ctrl));
  708. acpi_status acpi_os_prepare_sleep(u8 sleep_state,
  709. u32 pm1a_control, u32 pm1b_control);
  710. void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
  711. u32 val_a, u32 val_b));
  712. acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state,
  713. u32 val_a, u32 val_b);
  714. #ifdef CONFIG_X86
  715. void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
  716. #else
  717. static inline void arch_reserve_mem_area(acpi_physical_address addr,
  718. size_t size)
  719. {
  720. }
  721. #endif /* CONFIG_X86 */
  722. #else
  723. #define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
  724. #endif
  725. #if defined(CONFIG_ACPI) && defined(CONFIG_PM)
  726. int acpi_dev_suspend(struct device *dev, bool wakeup);
  727. int acpi_dev_resume(struct device *dev);
  728. int acpi_subsys_runtime_suspend(struct device *dev);
  729. int acpi_subsys_runtime_resume(struct device *dev);
  730. int acpi_dev_pm_attach(struct device *dev, bool power_on);
  731. #else
  732. static inline int acpi_dev_runtime_suspend(struct device *dev) { return 0; }
  733. static inline int acpi_dev_runtime_resume(struct device *dev) { return 0; }
  734. static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; }
  735. static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; }
  736. static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
  737. {
  738. return -ENODEV;
  739. }
  740. #endif
  741. #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
  742. int acpi_dev_suspend_late(struct device *dev);
  743. int acpi_subsys_prepare(struct device *dev);
  744. void acpi_subsys_complete(struct device *dev);
  745. int acpi_subsys_suspend_late(struct device *dev);
  746. int acpi_subsys_suspend_noirq(struct device *dev);
  747. int acpi_subsys_resume_noirq(struct device *dev);
  748. int acpi_subsys_resume_early(struct device *dev);
  749. int acpi_subsys_suspend(struct device *dev);
  750. int acpi_subsys_freeze(struct device *dev);
  751. int acpi_subsys_freeze_late(struct device *dev);
  752. int acpi_subsys_freeze_noirq(struct device *dev);
  753. int acpi_subsys_thaw_noirq(struct device *dev);
  754. #else
  755. static inline int acpi_dev_resume_early(struct device *dev) { return 0; }
  756. static inline int acpi_subsys_prepare(struct device *dev) { return 0; }
  757. static inline void acpi_subsys_complete(struct device *dev) {}
  758. static inline int acpi_subsys_suspend_late(struct device *dev) { return 0; }
  759. static inline int acpi_subsys_suspend_noirq(struct device *dev) { return 0; }
  760. static inline int acpi_subsys_resume_noirq(struct device *dev) { return 0; }
  761. static inline int acpi_subsys_resume_early(struct device *dev) { return 0; }
  762. static inline int acpi_subsys_suspend(struct device *dev) { return 0; }
  763. static inline int acpi_subsys_freeze(struct device *dev) { return 0; }
  764. static inline int acpi_subsys_freeze_late(struct device *dev) { return 0; }
  765. static inline int acpi_subsys_freeze_noirq(struct device *dev) { return 0; }
  766. static inline int acpi_subsys_thaw_noirq(struct device *dev) { return 0; }
  767. #endif
  768. #ifdef CONFIG_ACPI
  769. __printf(3, 4)
  770. void acpi_handle_printk(const char *level, acpi_handle handle,
  771. const char *fmt, ...);
  772. #else /* !CONFIG_ACPI */
  773. static inline __printf(3, 4) void
  774. acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {}
  775. #endif /* !CONFIG_ACPI */
  776. #if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
  777. __printf(3, 4)
  778. void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
  779. #else
  780. #define __acpi_handle_debug(descriptor, handle, fmt, ...) \
  781. acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__);
  782. #endif
  783. /*
  784. * acpi_handle_<level>: Print message with ACPI prefix and object path
  785. *
  786. * These interfaces acquire the global namespace mutex to obtain an object
  787. * path. In interrupt context, it shows the object path as <n/a>.
  788. */
  789. #define acpi_handle_emerg(handle, fmt, ...) \
  790. acpi_handle_printk(KERN_EMERG, handle, fmt, ##__VA_ARGS__)
  791. #define acpi_handle_alert(handle, fmt, ...) \
  792. acpi_handle_printk(KERN_ALERT, handle, fmt, ##__VA_ARGS__)
  793. #define acpi_handle_crit(handle, fmt, ...) \
  794. acpi_handle_printk(KERN_CRIT, handle, fmt, ##__VA_ARGS__)
  795. #define acpi_handle_err(handle, fmt, ...) \
  796. acpi_handle_printk(KERN_ERR, handle, fmt, ##__VA_ARGS__)
  797. #define acpi_handle_warn(handle, fmt, ...) \
  798. acpi_handle_printk(KERN_WARNING, handle, fmt, ##__VA_ARGS__)
  799. #define acpi_handle_notice(handle, fmt, ...) \
  800. acpi_handle_printk(KERN_NOTICE, handle, fmt, ##__VA_ARGS__)
  801. #define acpi_handle_info(handle, fmt, ...) \
  802. acpi_handle_printk(KERN_INFO, handle, fmt, ##__VA_ARGS__)
  803. #if defined(DEBUG)
  804. #define acpi_handle_debug(handle, fmt, ...) \
  805. acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__)
  806. #else
  807. #if defined(CONFIG_DYNAMIC_DEBUG)
  808. #define acpi_handle_debug(handle, fmt, ...) \
  809. do { \
  810. DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
  811. if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \
  812. __acpi_handle_debug(&descriptor, handle, pr_fmt(fmt), \
  813. ##__VA_ARGS__); \
  814. } while (0)
  815. #else
  816. #define acpi_handle_debug(handle, fmt, ...) \
  817. ({ \
  818. if (0) \
  819. acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__); \
  820. 0; \
  821. })
  822. #endif
  823. #endif
  824. struct acpi_gpio_params {
  825. unsigned int crs_entry_index;
  826. unsigned int line_index;
  827. bool active_low;
  828. };
  829. struct acpi_gpio_mapping {
  830. const char *name;
  831. const struct acpi_gpio_params *data;
  832. unsigned int size;
  833. /* Ignore IoRestriction field */
  834. #define ACPI_GPIO_QUIRK_NO_IO_RESTRICTION BIT(0)
  835. unsigned int quirks;
  836. };
  837. #if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB)
  838. int acpi_dev_add_driver_gpios(struct acpi_device *adev,
  839. const struct acpi_gpio_mapping *gpios);
  840. static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev)
  841. {
  842. if (adev)
  843. adev->driver_gpios = NULL;
  844. }
  845. int devm_acpi_dev_add_driver_gpios(struct device *dev,
  846. const struct acpi_gpio_mapping *gpios);
  847. void devm_acpi_dev_remove_driver_gpios(struct device *dev);
  848. bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
  849. struct acpi_resource_gpio **agpio);
  850. int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index);
  851. #else
  852. static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
  853. const struct acpi_gpio_mapping *gpios)
  854. {
  855. return -ENXIO;
  856. }
  857. static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev) {}
  858. static inline int devm_acpi_dev_add_driver_gpios(struct device *dev,
  859. const struct acpi_gpio_mapping *gpios)
  860. {
  861. return -ENXIO;
  862. }
  863. static inline void devm_acpi_dev_remove_driver_gpios(struct device *dev) {}
  864. static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
  865. struct acpi_resource_gpio **agpio)
  866. {
  867. return false;
  868. }
  869. static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
  870. {
  871. return -ENXIO;
  872. }
  873. #endif
  874. /* Device properties */
  875. #define MAX_ACPI_REFERENCE_ARGS 8
  876. struct acpi_reference_args {
  877. struct acpi_device *adev;
  878. size_t nargs;
  879. u64 args[MAX_ACPI_REFERENCE_ARGS];
  880. };
  881. #ifdef CONFIG_ACPI
  882. int acpi_dev_get_property(const struct acpi_device *adev, const char *name,
  883. acpi_object_type type, const union acpi_object **obj);
  884. int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
  885. const char *name, size_t index, size_t num_args,
  886. struct acpi_reference_args *args);
  887. static inline int acpi_node_get_property_reference(
  888. const struct fwnode_handle *fwnode,
  889. const char *name, size_t index,
  890. struct acpi_reference_args *args)
  891. {
  892. return __acpi_node_get_property_reference(fwnode, name, index,
  893. MAX_ACPI_REFERENCE_ARGS, args);
  894. }
  895. int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
  896. void **valptr);
  897. int acpi_dev_prop_read_single(struct acpi_device *adev,
  898. const char *propname, enum dev_prop_type proptype,
  899. void *val);
  900. int acpi_node_prop_read(const struct fwnode_handle *fwnode,
  901. const char *propname, enum dev_prop_type proptype,
  902. void *val, size_t nval);
  903. int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname,
  904. enum dev_prop_type proptype, void *val, size_t nval);
  905. struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
  906. struct fwnode_handle *child);
  907. struct fwnode_handle *acpi_node_get_parent(const struct fwnode_handle *fwnode);
  908. struct fwnode_handle *
  909. acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
  910. struct fwnode_handle *prev);
  911. int acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode,
  912. struct fwnode_handle **remote,
  913. struct fwnode_handle **port,
  914. struct fwnode_handle **endpoint);
  915. struct acpi_probe_entry;
  916. typedef bool (*acpi_probe_entry_validate_subtbl)(struct acpi_subtable_header *,
  917. struct acpi_probe_entry *);
  918. #define ACPI_TABLE_ID_LEN 5
  919. /**
  920. * struct acpi_probe_entry - boot-time probing entry
  921. * @id: ACPI table name
  922. * @type: Optional subtable type to match
  923. * (if @id contains subtables)
  924. * @subtable_valid: Optional callback to check the validity of
  925. * the subtable
  926. * @probe_table: Callback to the driver being probed when table
  927. * match is successful
  928. * @probe_subtbl: Callback to the driver being probed when table and
  929. * subtable match (and optional callback is successful)
  930. * @driver_data: Sideband data provided back to the driver
  931. */
  932. struct acpi_probe_entry {
  933. __u8 id[ACPI_TABLE_ID_LEN];
  934. __u8 type;
  935. acpi_probe_entry_validate_subtbl subtable_valid;
  936. union {
  937. acpi_tbl_table_handler probe_table;
  938. acpi_tbl_entry_handler probe_subtbl;
  939. };
  940. kernel_ulong_t driver_data;
  941. };
  942. #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
  943. static const struct acpi_probe_entry __acpi_probe_##name \
  944. __used __section(__##table##_acpi_probe_table) \
  945. = { \
  946. .id = table_id, \
  947. .type = subtable, \
  948. .subtable_valid = valid, \
  949. .probe_table = (acpi_tbl_table_handler)fn, \
  950. .driver_data = data, \
  951. }
  952. #define ACPI_PROBE_TABLE(name) __##name##_acpi_probe_table
  953. #define ACPI_PROBE_TABLE_END(name) __##name##_acpi_probe_table_end
  954. int __acpi_probe_device_table(struct acpi_probe_entry *start, int nr);
  955. #define acpi_probe_device_table(t) \
  956. ({ \
  957. extern struct acpi_probe_entry ACPI_PROBE_TABLE(t), \
  958. ACPI_PROBE_TABLE_END(t); \
  959. __acpi_probe_device_table(&ACPI_PROBE_TABLE(t), \
  960. (&ACPI_PROBE_TABLE_END(t) - \
  961. &ACPI_PROBE_TABLE(t))); \
  962. })
  963. #else
  964. static inline int acpi_dev_get_property(struct acpi_device *adev,
  965. const char *name, acpi_object_type type,
  966. const union acpi_object **obj)
  967. {
  968. return -ENXIO;
  969. }
  970. static inline int
  971. __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
  972. const char *name, size_t index, size_t num_args,
  973. struct acpi_reference_args *args)
  974. {
  975. return -ENXIO;
  976. }
  977. static inline int
  978. acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
  979. const char *name, size_t index,
  980. struct acpi_reference_args *args)
  981. {
  982. return -ENXIO;
  983. }
  984. static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,
  985. const char *propname,
  986. void **valptr)
  987. {
  988. return -ENXIO;
  989. }
  990. static inline int acpi_dev_prop_get(const struct acpi_device *adev,
  991. const char *propname,
  992. void **valptr)
  993. {
  994. return -ENXIO;
  995. }
  996. static inline int acpi_dev_prop_read_single(const struct acpi_device *adev,
  997. const char *propname,
  998. enum dev_prop_type proptype,
  999. void *val)
  1000. {
  1001. return -ENXIO;
  1002. }
  1003. static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode,
  1004. const char *propname,
  1005. enum dev_prop_type proptype,
  1006. void *val, size_t nval)
  1007. {
  1008. return -ENXIO;
  1009. }
  1010. static inline int acpi_dev_prop_read(const struct acpi_device *adev,
  1011. const char *propname,
  1012. enum dev_prop_type proptype,
  1013. void *val, size_t nval)
  1014. {
  1015. return -ENXIO;
  1016. }
  1017. static inline struct fwnode_handle *
  1018. acpi_get_next_subnode(const struct fwnode_handle *fwnode,
  1019. struct fwnode_handle *child)
  1020. {
  1021. return NULL;
  1022. }
  1023. static inline struct fwnode_handle *
  1024. acpi_node_get_parent(const struct fwnode_handle *fwnode)
  1025. {
  1026. return NULL;
  1027. }
  1028. static inline struct fwnode_handle *
  1029. acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
  1030. struct fwnode_handle *prev)
  1031. {
  1032. return ERR_PTR(-ENXIO);
  1033. }
  1034. static inline int
  1035. acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode,
  1036. struct fwnode_handle **remote,
  1037. struct fwnode_handle **port,
  1038. struct fwnode_handle **endpoint)
  1039. {
  1040. return -ENXIO;
  1041. }
  1042. #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
  1043. static const void * __acpi_table_##name[] \
  1044. __attribute__((unused)) \
  1045. = { (void *) table_id, \
  1046. (void *) subtable, \
  1047. (void *) valid, \
  1048. (void *) fn, \
  1049. (void *) data }
  1050. #define acpi_probe_device_table(t) ({ int __r = 0; __r;})
  1051. #endif
  1052. #ifdef CONFIG_ACPI_TABLE_UPGRADE
  1053. void acpi_table_upgrade(void);
  1054. #else
  1055. static inline void acpi_table_upgrade(void) { }
  1056. #endif
  1057. #if defined(CONFIG_ACPI) && defined(CONFIG_ACPI_WATCHDOG)
  1058. extern bool acpi_has_watchdog(void);
  1059. #else
  1060. static inline bool acpi_has_watchdog(void) { return false; }
  1061. #endif
  1062. #ifdef CONFIG_ACPI_SPCR_TABLE
  1063. extern bool qdf2400_e44_present;
  1064. int acpi_parse_spcr(bool enable_earlycon, bool enable_console);
  1065. #else
  1066. static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console)
  1067. {
  1068. return 0;
  1069. }
  1070. #endif
  1071. #if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI)
  1072. int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res);
  1073. #else
  1074. static inline
  1075. int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res)
  1076. {
  1077. return -EINVAL;
  1078. }
  1079. #endif
  1080. #ifdef CONFIG_ACPI_LPIT
  1081. int lpit_read_residency_count_address(u64 *address);
  1082. #else
  1083. static inline int lpit_read_residency_count_address(u64 *address)
  1084. {
  1085. return -EINVAL;
  1086. }
  1087. #endif
  1088. int find_acpi_cpu_topology(unsigned int cpu, int level);
  1089. int find_acpi_cpu_topology_package(unsigned int cpu);
  1090. int find_acpi_cpu_cache_topology(unsigned int cpu, int level);
  1091. #endif /*_LINUX_ACPI_H*/