acpi.h 37 KB

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