acpi.h 36 KB

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