acpi.h 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  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. acpi_status acpi_release_memory(acpi_handle handle, struct resource *res,
  368. u32 level);
  369. int acpi_resources_are_enforced(void);
  370. #ifdef CONFIG_HIBERNATION
  371. void __init acpi_no_s4_hw_signature(void);
  372. #endif
  373. #ifdef CONFIG_PM_SLEEP
  374. void __init acpi_old_suspend_ordering(void);
  375. void __init acpi_nvs_nosave(void);
  376. void __init acpi_nvs_nosave_s3(void);
  377. void __init acpi_sleep_no_blacklist(void);
  378. #endif /* CONFIG_PM_SLEEP */
  379. struct acpi_osc_context {
  380. char *uuid_str; /* UUID string */
  381. int rev;
  382. struct acpi_buffer cap; /* list of DWORD capabilities */
  383. struct acpi_buffer ret; /* free by caller if success */
  384. };
  385. acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);
  386. /* Indexes into _OSC Capabilities Buffer (DWORDs 2 & 3 are device-specific) */
  387. #define OSC_QUERY_DWORD 0 /* DWORD 1 */
  388. #define OSC_SUPPORT_DWORD 1 /* DWORD 2 */
  389. #define OSC_CONTROL_DWORD 2 /* DWORD 3 */
  390. /* _OSC Capabilities DWORD 1: Query/Control and Error Returns (generic) */
  391. #define OSC_QUERY_ENABLE 0x00000001 /* input */
  392. #define OSC_REQUEST_ERROR 0x00000002 /* return */
  393. #define OSC_INVALID_UUID_ERROR 0x00000004 /* return */
  394. #define OSC_INVALID_REVISION_ERROR 0x00000008 /* return */
  395. #define OSC_CAPABILITIES_MASK_ERROR 0x00000010 /* return */
  396. /* Platform-Wide Capabilities _OSC: Capabilities DWORD 2: Support Field */
  397. #define OSC_SB_PAD_SUPPORT 0x00000001
  398. #define OSC_SB_PPC_OST_SUPPORT 0x00000002
  399. #define OSC_SB_PR3_SUPPORT 0x00000004
  400. #define OSC_SB_HOTPLUG_OST_SUPPORT 0x00000008
  401. #define OSC_SB_APEI_SUPPORT 0x00000010
  402. #define OSC_SB_CPC_SUPPORT 0x00000020
  403. #define OSC_SB_CPCV2_SUPPORT 0x00000040
  404. #define OSC_SB_PCLPI_SUPPORT 0x00000080
  405. #define OSC_SB_OSLPI_SUPPORT 0x00000100
  406. #define OSC_SB_CPC_DIVERSE_HIGH_SUPPORT 0x00001000
  407. extern bool osc_sb_apei_support_acked;
  408. extern bool osc_pc_lpi_support_confirmed;
  409. /* PCI Host Bridge _OSC: Capabilities DWORD 2: Support Field */
  410. #define OSC_PCI_EXT_CONFIG_SUPPORT 0x00000001
  411. #define OSC_PCI_ASPM_SUPPORT 0x00000002
  412. #define OSC_PCI_CLOCK_PM_SUPPORT 0x00000004
  413. #define OSC_PCI_SEGMENT_GROUPS_SUPPORT 0x00000008
  414. #define OSC_PCI_MSI_SUPPORT 0x00000010
  415. #define OSC_PCI_SUPPORT_MASKS 0x0000001f
  416. /* PCI Host Bridge _OSC: Capabilities DWORD 3: Control Field */
  417. #define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL 0x00000001
  418. #define OSC_PCI_SHPC_NATIVE_HP_CONTROL 0x00000002
  419. #define OSC_PCI_EXPRESS_PME_CONTROL 0x00000004
  420. #define OSC_PCI_EXPRESS_AER_CONTROL 0x00000008
  421. #define OSC_PCI_EXPRESS_CAPABILITY_CONTROL 0x00000010
  422. #define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020
  423. #define OSC_PCI_CONTROL_MASKS 0x0000003f
  424. #define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002
  425. #define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004
  426. #define ACPI_GSB_ACCESS_ATTRIB_BYTE 0x00000006
  427. #define ACPI_GSB_ACCESS_ATTRIB_WORD 0x00000008
  428. #define ACPI_GSB_ACCESS_ATTRIB_BLOCK 0x0000000A
  429. #define ACPI_GSB_ACCESS_ATTRIB_MULTIBYTE 0x0000000B
  430. #define ACPI_GSB_ACCESS_ATTRIB_WORD_CALL 0x0000000C
  431. #define ACPI_GSB_ACCESS_ATTRIB_BLOCK_CALL 0x0000000D
  432. #define ACPI_GSB_ACCESS_ATTRIB_RAW_BYTES 0x0000000E
  433. #define ACPI_GSB_ACCESS_ATTRIB_RAW_PROCESS 0x0000000F
  434. extern acpi_status acpi_pci_osc_control_set(acpi_handle handle,
  435. u32 *mask, u32 req);
  436. /* Enable _OST when all relevant hotplug operations are enabled */
  437. #if defined(CONFIG_ACPI_HOTPLUG_CPU) && \
  438. defined(CONFIG_ACPI_HOTPLUG_MEMORY) && \
  439. defined(CONFIG_ACPI_CONTAINER)
  440. #define ACPI_HOTPLUG_OST
  441. #endif
  442. /* _OST Source Event Code (OSPM Action) */
  443. #define ACPI_OST_EC_OSPM_SHUTDOWN 0x100
  444. #define ACPI_OST_EC_OSPM_EJECT 0x103
  445. #define ACPI_OST_EC_OSPM_INSERTION 0x200
  446. /* _OST General Processing Status Code */
  447. #define ACPI_OST_SC_SUCCESS 0x0
  448. #define ACPI_OST_SC_NON_SPECIFIC_FAILURE 0x1
  449. #define ACPI_OST_SC_UNRECOGNIZED_NOTIFY 0x2
  450. /* _OST OS Shutdown Processing (0x100) Status Code */
  451. #define ACPI_OST_SC_OS_SHUTDOWN_DENIED 0x80
  452. #define ACPI_OST_SC_OS_SHUTDOWN_IN_PROGRESS 0x81
  453. #define ACPI_OST_SC_OS_SHUTDOWN_COMPLETED 0x82
  454. #define ACPI_OST_SC_OS_SHUTDOWN_NOT_SUPPORTED 0x83
  455. /* _OST Ejection Request (0x3, 0x103) Status Code */
  456. #define ACPI_OST_SC_EJECT_NOT_SUPPORTED 0x80
  457. #define ACPI_OST_SC_DEVICE_IN_USE 0x81
  458. #define ACPI_OST_SC_DEVICE_BUSY 0x82
  459. #define ACPI_OST_SC_EJECT_DEPENDENCY_BUSY 0x83
  460. #define ACPI_OST_SC_EJECT_IN_PROGRESS 0x84
  461. /* _OST Insertion Request (0x200) Status Code */
  462. #define ACPI_OST_SC_INSERT_IN_PROGRESS 0x80
  463. #define ACPI_OST_SC_DRIVER_LOAD_FAILURE 0x81
  464. #define ACPI_OST_SC_INSERT_NOT_SUPPORTED 0x82
  465. enum acpi_predicate {
  466. all_versions,
  467. less_than_or_equal,
  468. equal,
  469. greater_than_or_equal,
  470. };
  471. /* Table must be terminted by a NULL entry */
  472. struct acpi_platform_list {
  473. char oem_id[ACPI_OEM_ID_SIZE+1];
  474. char oem_table_id[ACPI_OEM_TABLE_ID_SIZE+1];
  475. u32 oem_revision;
  476. char *table;
  477. enum acpi_predicate pred;
  478. char *reason;
  479. u32 data;
  480. };
  481. int acpi_match_platform_list(const struct acpi_platform_list *plat);
  482. extern void acpi_early_init(void);
  483. extern void acpi_subsystem_init(void);
  484. extern void arch_post_acpi_subsys_init(void);
  485. extern int acpi_nvs_register(__u64 start, __u64 size);
  486. extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
  487. void *data);
  488. const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
  489. const struct device *dev);
  490. const void *acpi_device_get_match_data(const struct device *dev);
  491. extern bool acpi_driver_match_device(struct device *dev,
  492. const struct device_driver *drv);
  493. int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *);
  494. int acpi_device_modalias(struct device *, char *, int);
  495. void acpi_walk_dep_device_list(acpi_handle handle);
  496. struct platform_device *acpi_create_platform_device(struct acpi_device *,
  497. struct property_entry *);
  498. #define ACPI_PTR(_ptr) (_ptr)
  499. static inline void acpi_device_set_enumerated(struct acpi_device *adev)
  500. {
  501. adev->flags.visited = true;
  502. }
  503. static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
  504. {
  505. adev->flags.visited = false;
  506. }
  507. enum acpi_reconfig_event {
  508. ACPI_RECONFIG_DEVICE_ADD = 0,
  509. ACPI_RECONFIG_DEVICE_REMOVE,
  510. };
  511. int acpi_reconfig_notifier_register(struct notifier_block *nb);
  512. int acpi_reconfig_notifier_unregister(struct notifier_block *nb);
  513. #ifdef CONFIG_ACPI_GTDT
  514. int acpi_gtdt_init(struct acpi_table_header *table, int *platform_timer_count);
  515. int acpi_gtdt_map_ppi(int type);
  516. bool acpi_gtdt_c3stop(int type);
  517. int acpi_arch_timer_mem_init(struct arch_timer_mem *timer_mem, int *timer_count);
  518. #endif
  519. #ifndef ACPI_HAVE_ARCH_GET_ROOT_POINTER
  520. static inline u64 acpi_arch_get_root_pointer(void)
  521. {
  522. return 0;
  523. }
  524. #endif
  525. #else /* !CONFIG_ACPI */
  526. #define acpi_disabled 1
  527. #define ACPI_COMPANION(dev) (NULL)
  528. #define ACPI_COMPANION_SET(dev, adev) do { } while (0)
  529. #define ACPI_HANDLE(dev) (NULL)
  530. #define ACPI_HANDLE_FWNODE(fwnode) (NULL)
  531. #define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (0), .cls_msk = (0),
  532. struct fwnode_handle;
  533. static inline bool acpi_dev_found(const char *hid)
  534. {
  535. return false;
  536. }
  537. static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
  538. {
  539. return false;
  540. }
  541. static inline const char *
  542. acpi_dev_get_first_match_name(const char *hid, const char *uid, s64 hrv)
  543. {
  544. return NULL;
  545. }
  546. static inline bool is_acpi_node(struct fwnode_handle *fwnode)
  547. {
  548. return false;
  549. }
  550. static inline bool is_acpi_device_node(struct fwnode_handle *fwnode)
  551. {
  552. return false;
  553. }
  554. static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
  555. {
  556. return NULL;
  557. }
  558. static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
  559. {
  560. return false;
  561. }
  562. static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
  563. {
  564. return NULL;
  565. }
  566. static inline bool acpi_data_node_match(struct fwnode_handle *fwnode,
  567. const char *name)
  568. {
  569. return false;
  570. }
  571. static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
  572. {
  573. return NULL;
  574. }
  575. static inline bool has_acpi_companion(struct device *dev)
  576. {
  577. return false;
  578. }
  579. static inline void acpi_preset_companion(struct device *dev,
  580. struct acpi_device *parent, u64 addr)
  581. {
  582. }
  583. static inline const char *acpi_dev_name(struct acpi_device *adev)
  584. {
  585. return NULL;
  586. }
  587. static inline struct device *acpi_get_first_physical_node(struct acpi_device *adev)
  588. {
  589. return NULL;
  590. }
  591. static inline void acpi_early_init(void) { }
  592. static inline void acpi_subsystem_init(void) { }
  593. static inline int early_acpi_boot_init(void)
  594. {
  595. return 0;
  596. }
  597. static inline int acpi_boot_init(void)
  598. {
  599. return 0;
  600. }
  601. static inline void acpi_boot_table_init(void)
  602. {
  603. return;
  604. }
  605. static inline int acpi_mps_check(void)
  606. {
  607. return 0;
  608. }
  609. static inline int acpi_check_resource_conflict(struct resource *res)
  610. {
  611. return 0;
  612. }
  613. static inline int acpi_check_region(resource_size_t start, resource_size_t n,
  614. const char *name)
  615. {
  616. return 0;
  617. }
  618. struct acpi_table_header;
  619. static inline int acpi_table_parse(char *id,
  620. int (*handler)(struct acpi_table_header *))
  621. {
  622. return -ENODEV;
  623. }
  624. static inline int acpi_nvs_register(__u64 start, __u64 size)
  625. {
  626. return 0;
  627. }
  628. static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
  629. void *data)
  630. {
  631. return 0;
  632. }
  633. struct acpi_device_id;
  634. static inline const struct acpi_device_id *acpi_match_device(
  635. const struct acpi_device_id *ids, const struct device *dev)
  636. {
  637. return NULL;
  638. }
  639. static inline const void *acpi_device_get_match_data(const struct device *dev)
  640. {
  641. return NULL;
  642. }
  643. static inline bool acpi_driver_match_device(struct device *dev,
  644. const struct device_driver *drv)
  645. {
  646. return false;
  647. }
  648. static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,
  649. const guid_t *guid,
  650. int rev, int func,
  651. union acpi_object *argv4)
  652. {
  653. return NULL;
  654. }
  655. static inline int acpi_device_uevent_modalias(struct device *dev,
  656. struct kobj_uevent_env *env)
  657. {
  658. return -ENODEV;
  659. }
  660. static inline int acpi_device_modalias(struct device *dev,
  661. char *buf, int size)
  662. {
  663. return -ENODEV;
  664. }
  665. static inline bool acpi_dma_supported(struct acpi_device *adev)
  666. {
  667. return false;
  668. }
  669. static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
  670. {
  671. return DEV_DMA_NOT_SUPPORTED;
  672. }
  673. static inline int acpi_dma_get_range(struct device *dev, u64 *dma_addr,
  674. u64 *offset, u64 *size)
  675. {
  676. return -ENODEV;
  677. }
  678. static inline int acpi_dma_configure(struct device *dev,
  679. enum dev_dma_attr attr)
  680. {
  681. return 0;
  682. }
  683. static inline void acpi_dma_deconfigure(struct device *dev) { }
  684. #define ACPI_PTR(_ptr) (NULL)
  685. static inline void acpi_device_set_enumerated(struct acpi_device *adev)
  686. {
  687. }
  688. static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
  689. {
  690. }
  691. static inline int acpi_reconfig_notifier_register(struct notifier_block *nb)
  692. {
  693. return -EINVAL;
  694. }
  695. static inline int acpi_reconfig_notifier_unregister(struct notifier_block *nb)
  696. {
  697. return -EINVAL;
  698. }
  699. static inline struct acpi_device *acpi_resource_consumer(struct resource *res)
  700. {
  701. return NULL;
  702. }
  703. #endif /* !CONFIG_ACPI */
  704. #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
  705. int acpi_ioapic_add(acpi_handle root);
  706. #else
  707. static inline int acpi_ioapic_add(acpi_handle root) { return 0; }
  708. #endif
  709. #ifdef CONFIG_ACPI
  710. void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
  711. u32 pm1a_ctrl, u32 pm1b_ctrl));
  712. acpi_status acpi_os_prepare_sleep(u8 sleep_state,
  713. u32 pm1a_control, u32 pm1b_control);
  714. void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
  715. u32 val_a, u32 val_b));
  716. acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state,
  717. u32 val_a, u32 val_b);
  718. #ifdef CONFIG_X86
  719. void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
  720. #else
  721. static inline void arch_reserve_mem_area(acpi_physical_address addr,
  722. size_t size)
  723. {
  724. }
  725. #endif /* CONFIG_X86 */
  726. #else
  727. #define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
  728. #endif
  729. #if defined(CONFIG_ACPI) && defined(CONFIG_PM)
  730. int acpi_dev_suspend(struct device *dev, bool wakeup);
  731. int acpi_dev_resume(struct device *dev);
  732. int acpi_subsys_runtime_suspend(struct device *dev);
  733. int acpi_subsys_runtime_resume(struct device *dev);
  734. int acpi_dev_pm_attach(struct device *dev, bool power_on);
  735. #else
  736. static inline int acpi_dev_runtime_suspend(struct device *dev) { return 0; }
  737. static inline int acpi_dev_runtime_resume(struct device *dev) { return 0; }
  738. static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; }
  739. static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; }
  740. static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
  741. {
  742. return 0;
  743. }
  744. #endif
  745. #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
  746. int acpi_dev_suspend_late(struct device *dev);
  747. int acpi_subsys_prepare(struct device *dev);
  748. void acpi_subsys_complete(struct device *dev);
  749. int acpi_subsys_suspend_late(struct device *dev);
  750. int acpi_subsys_suspend_noirq(struct device *dev);
  751. int acpi_subsys_resume_noirq(struct device *dev);
  752. int acpi_subsys_resume_early(struct device *dev);
  753. int acpi_subsys_suspend(struct device *dev);
  754. int acpi_subsys_freeze(struct device *dev);
  755. int acpi_subsys_freeze_late(struct device *dev);
  756. int acpi_subsys_freeze_noirq(struct device *dev);
  757. int acpi_subsys_thaw_noirq(struct device *dev);
  758. #else
  759. static inline int acpi_dev_resume_early(struct device *dev) { return 0; }
  760. static inline int acpi_subsys_prepare(struct device *dev) { return 0; }
  761. static inline void acpi_subsys_complete(struct device *dev) {}
  762. static inline int acpi_subsys_suspend_late(struct device *dev) { return 0; }
  763. static inline int acpi_subsys_suspend_noirq(struct device *dev) { return 0; }
  764. static inline int acpi_subsys_resume_noirq(struct device *dev) { return 0; }
  765. static inline int acpi_subsys_resume_early(struct device *dev) { return 0; }
  766. static inline int acpi_subsys_suspend(struct device *dev) { return 0; }
  767. static inline int acpi_subsys_freeze(struct device *dev) { return 0; }
  768. static inline int acpi_subsys_freeze_late(struct device *dev) { return 0; }
  769. static inline int acpi_subsys_freeze_noirq(struct device *dev) { return 0; }
  770. static inline int acpi_subsys_thaw_noirq(struct device *dev) { return 0; }
  771. #endif
  772. #ifdef CONFIG_ACPI
  773. __printf(3, 4)
  774. void acpi_handle_printk(const char *level, acpi_handle handle,
  775. const char *fmt, ...);
  776. #else /* !CONFIG_ACPI */
  777. static inline __printf(3, 4) void
  778. acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {}
  779. #endif /* !CONFIG_ACPI */
  780. #if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
  781. __printf(3, 4)
  782. void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
  783. #else
  784. #define __acpi_handle_debug(descriptor, handle, fmt, ...) \
  785. acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__);
  786. #endif
  787. /*
  788. * acpi_handle_<level>: Print message with ACPI prefix and object path
  789. *
  790. * These interfaces acquire the global namespace mutex to obtain an object
  791. * path. In interrupt context, it shows the object path as <n/a>.
  792. */
  793. #define acpi_handle_emerg(handle, fmt, ...) \
  794. acpi_handle_printk(KERN_EMERG, handle, fmt, ##__VA_ARGS__)
  795. #define acpi_handle_alert(handle, fmt, ...) \
  796. acpi_handle_printk(KERN_ALERT, handle, fmt, ##__VA_ARGS__)
  797. #define acpi_handle_crit(handle, fmt, ...) \
  798. acpi_handle_printk(KERN_CRIT, handle, fmt, ##__VA_ARGS__)
  799. #define acpi_handle_err(handle, fmt, ...) \
  800. acpi_handle_printk(KERN_ERR, handle, fmt, ##__VA_ARGS__)
  801. #define acpi_handle_warn(handle, fmt, ...) \
  802. acpi_handle_printk(KERN_WARNING, handle, fmt, ##__VA_ARGS__)
  803. #define acpi_handle_notice(handle, fmt, ...) \
  804. acpi_handle_printk(KERN_NOTICE, handle, fmt, ##__VA_ARGS__)
  805. #define acpi_handle_info(handle, fmt, ...) \
  806. acpi_handle_printk(KERN_INFO, handle, fmt, ##__VA_ARGS__)
  807. #if defined(DEBUG)
  808. #define acpi_handle_debug(handle, fmt, ...) \
  809. acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__)
  810. #else
  811. #if defined(CONFIG_DYNAMIC_DEBUG)
  812. #define acpi_handle_debug(handle, fmt, ...) \
  813. do { \
  814. DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
  815. if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \
  816. __acpi_handle_debug(&descriptor, handle, pr_fmt(fmt), \
  817. ##__VA_ARGS__); \
  818. } while (0)
  819. #else
  820. #define acpi_handle_debug(handle, fmt, ...) \
  821. ({ \
  822. if (0) \
  823. acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__); \
  824. 0; \
  825. })
  826. #endif
  827. #endif
  828. struct acpi_gpio_params {
  829. unsigned int crs_entry_index;
  830. unsigned int line_index;
  831. bool active_low;
  832. };
  833. struct acpi_gpio_mapping {
  834. const char *name;
  835. const struct acpi_gpio_params *data;
  836. unsigned int size;
  837. /* Ignore IoRestriction field */
  838. #define ACPI_GPIO_QUIRK_NO_IO_RESTRICTION BIT(0)
  839. unsigned int quirks;
  840. };
  841. #if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB)
  842. int acpi_dev_add_driver_gpios(struct acpi_device *adev,
  843. const struct acpi_gpio_mapping *gpios);
  844. static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev)
  845. {
  846. if (adev)
  847. adev->driver_gpios = NULL;
  848. }
  849. int devm_acpi_dev_add_driver_gpios(struct device *dev,
  850. const struct acpi_gpio_mapping *gpios);
  851. void devm_acpi_dev_remove_driver_gpios(struct device *dev);
  852. bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
  853. struct acpi_resource_gpio **agpio);
  854. int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index);
  855. #else
  856. static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
  857. const struct acpi_gpio_mapping *gpios)
  858. {
  859. return -ENXIO;
  860. }
  861. static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev) {}
  862. static inline int devm_acpi_dev_add_driver_gpios(struct device *dev,
  863. const struct acpi_gpio_mapping *gpios)
  864. {
  865. return -ENXIO;
  866. }
  867. static inline void devm_acpi_dev_remove_driver_gpios(struct device *dev) {}
  868. static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
  869. struct acpi_resource_gpio **agpio)
  870. {
  871. return false;
  872. }
  873. static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
  874. {
  875. return -ENXIO;
  876. }
  877. #endif
  878. /* Device properties */
  879. #ifdef CONFIG_ACPI
  880. int acpi_dev_get_property(const struct acpi_device *adev, const char *name,
  881. acpi_object_type type, const union acpi_object **obj);
  882. int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
  883. const char *name, size_t index, size_t num_args,
  884. struct fwnode_reference_args *args);
  885. static inline int acpi_node_get_property_reference(
  886. const struct fwnode_handle *fwnode,
  887. const char *name, size_t index,
  888. struct fwnode_reference_args *args)
  889. {
  890. return __acpi_node_get_property_reference(fwnode, name, index,
  891. NR_FWNODE_REFERENCE_ARGS, args);
  892. }
  893. int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
  894. void **valptr);
  895. int acpi_dev_prop_read_single(struct acpi_device *adev,
  896. const char *propname, enum dev_prop_type proptype,
  897. void *val);
  898. int acpi_node_prop_read(const struct fwnode_handle *fwnode,
  899. const char *propname, enum dev_prop_type proptype,
  900. void *val, size_t nval);
  901. int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname,
  902. enum dev_prop_type proptype, void *val, size_t nval);
  903. struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
  904. struct fwnode_handle *child);
  905. struct fwnode_handle *acpi_node_get_parent(const struct fwnode_handle *fwnode);
  906. struct acpi_probe_entry;
  907. typedef bool (*acpi_probe_entry_validate_subtbl)(struct acpi_subtable_header *,
  908. struct acpi_probe_entry *);
  909. #define ACPI_TABLE_ID_LEN 5
  910. /**
  911. * struct acpi_probe_entry - boot-time probing entry
  912. * @id: ACPI table name
  913. * @type: Optional subtable type to match
  914. * (if @id contains subtables)
  915. * @subtable_valid: Optional callback to check the validity of
  916. * the subtable
  917. * @probe_table: Callback to the driver being probed when table
  918. * match is successful
  919. * @probe_subtbl: Callback to the driver being probed when table and
  920. * subtable match (and optional callback is successful)
  921. * @driver_data: Sideband data provided back to the driver
  922. */
  923. struct acpi_probe_entry {
  924. __u8 id[ACPI_TABLE_ID_LEN];
  925. __u8 type;
  926. acpi_probe_entry_validate_subtbl subtable_valid;
  927. union {
  928. acpi_tbl_table_handler probe_table;
  929. acpi_tbl_entry_handler probe_subtbl;
  930. };
  931. kernel_ulong_t driver_data;
  932. };
  933. #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
  934. static const struct acpi_probe_entry __acpi_probe_##name \
  935. __used __section(__##table##_acpi_probe_table) \
  936. = { \
  937. .id = table_id, \
  938. .type = subtable, \
  939. .subtable_valid = valid, \
  940. .probe_table = (acpi_tbl_table_handler)fn, \
  941. .driver_data = data, \
  942. }
  943. #define ACPI_PROBE_TABLE(name) __##name##_acpi_probe_table
  944. #define ACPI_PROBE_TABLE_END(name) __##name##_acpi_probe_table_end
  945. int __acpi_probe_device_table(struct acpi_probe_entry *start, int nr);
  946. #define acpi_probe_device_table(t) \
  947. ({ \
  948. extern struct acpi_probe_entry ACPI_PROBE_TABLE(t), \
  949. ACPI_PROBE_TABLE_END(t); \
  950. __acpi_probe_device_table(&ACPI_PROBE_TABLE(t), \
  951. (&ACPI_PROBE_TABLE_END(t) - \
  952. &ACPI_PROBE_TABLE(t))); \
  953. })
  954. #else
  955. static inline int acpi_dev_get_property(struct acpi_device *adev,
  956. const char *name, acpi_object_type type,
  957. const union acpi_object **obj)
  958. {
  959. return -ENXIO;
  960. }
  961. static inline int
  962. __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
  963. const char *name, size_t index, size_t num_args,
  964. struct fwnode_reference_args *args)
  965. {
  966. return -ENXIO;
  967. }
  968. static inline int
  969. acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
  970. const char *name, size_t index,
  971. struct fwnode_reference_args *args)
  972. {
  973. return -ENXIO;
  974. }
  975. static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,
  976. const char *propname,
  977. void **valptr)
  978. {
  979. return -ENXIO;
  980. }
  981. static inline int acpi_dev_prop_get(const struct acpi_device *adev,
  982. const char *propname,
  983. void **valptr)
  984. {
  985. return -ENXIO;
  986. }
  987. static inline int acpi_dev_prop_read_single(const struct acpi_device *adev,
  988. const char *propname,
  989. enum dev_prop_type proptype,
  990. void *val)
  991. {
  992. return -ENXIO;
  993. }
  994. static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode,
  995. const char *propname,
  996. enum dev_prop_type proptype,
  997. void *val, size_t nval)
  998. {
  999. return -ENXIO;
  1000. }
  1001. static inline int acpi_dev_prop_read(const struct acpi_device *adev,
  1002. const char *propname,
  1003. enum dev_prop_type proptype,
  1004. void *val, size_t nval)
  1005. {
  1006. return -ENXIO;
  1007. }
  1008. static inline struct fwnode_handle *
  1009. acpi_get_next_subnode(const struct fwnode_handle *fwnode,
  1010. struct fwnode_handle *child)
  1011. {
  1012. return NULL;
  1013. }
  1014. static inline struct fwnode_handle *
  1015. acpi_node_get_parent(const struct fwnode_handle *fwnode)
  1016. {
  1017. return NULL;
  1018. }
  1019. static inline struct fwnode_handle *
  1020. acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
  1021. struct fwnode_handle *prev)
  1022. {
  1023. return ERR_PTR(-ENXIO);
  1024. }
  1025. static inline int
  1026. acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode,
  1027. struct fwnode_handle **remote,
  1028. struct fwnode_handle **port,
  1029. struct fwnode_handle **endpoint)
  1030. {
  1031. return -ENXIO;
  1032. }
  1033. #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
  1034. static const void * __acpi_table_##name[] \
  1035. __attribute__((unused)) \
  1036. = { (void *) table_id, \
  1037. (void *) subtable, \
  1038. (void *) valid, \
  1039. (void *) fn, \
  1040. (void *) data }
  1041. #define acpi_probe_device_table(t) ({ int __r = 0; __r;})
  1042. #endif
  1043. #ifdef CONFIG_ACPI_TABLE_UPGRADE
  1044. void acpi_table_upgrade(void);
  1045. #else
  1046. static inline void acpi_table_upgrade(void) { }
  1047. #endif
  1048. #if defined(CONFIG_ACPI) && defined(CONFIG_ACPI_WATCHDOG)
  1049. extern bool acpi_has_watchdog(void);
  1050. #else
  1051. static inline bool acpi_has_watchdog(void) { return false; }
  1052. #endif
  1053. #ifdef CONFIG_ACPI_SPCR_TABLE
  1054. extern bool qdf2400_e44_present;
  1055. int acpi_parse_spcr(bool enable_earlycon, bool enable_console);
  1056. #else
  1057. static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console)
  1058. {
  1059. return 0;
  1060. }
  1061. #endif
  1062. #if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI)
  1063. int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res);
  1064. #else
  1065. static inline
  1066. int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res)
  1067. {
  1068. return -EINVAL;
  1069. }
  1070. #endif
  1071. #ifdef CONFIG_ACPI_LPIT
  1072. int lpit_read_residency_count_address(u64 *address);
  1073. #else
  1074. static inline int lpit_read_residency_count_address(u64 *address)
  1075. {
  1076. return -EINVAL;
  1077. }
  1078. #endif
  1079. #ifdef CONFIG_ACPI_PPTT
  1080. int find_acpi_cpu_topology(unsigned int cpu, int level);
  1081. int find_acpi_cpu_topology_package(unsigned int cpu);
  1082. int find_acpi_cpu_cache_topology(unsigned int cpu, int level);
  1083. #else
  1084. static inline int find_acpi_cpu_topology(unsigned int cpu, int level)
  1085. {
  1086. return -EINVAL;
  1087. }
  1088. static inline int find_acpi_cpu_topology_package(unsigned int cpu)
  1089. {
  1090. return -EINVAL;
  1091. }
  1092. static inline int find_acpi_cpu_cache_topology(unsigned int cpu, int level)
  1093. {
  1094. return -EINVAL;
  1095. }
  1096. #endif
  1097. #endif /*_LINUX_ACPI_H*/