acpi.h 37 KB

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