acpi.h 37 KB

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