acpi.h 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * acpi.h - ACPI Interface
  4. *
  5. * Copyright (C) 2001 Paul Diefenbaugh <[email protected]>
  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_init(fwnode, &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_LPIC,
  89. ACPI_IRQ_MODEL_COUNT
  90. };
  91. extern enum acpi_irq_model_id acpi_irq_model;
  92. enum acpi_interrupt_id {
  93. ACPI_INTERRUPT_PMI = 1,
  94. ACPI_INTERRUPT_INIT,
  95. ACPI_INTERRUPT_CPEI,
  96. ACPI_INTERRUPT_COUNT
  97. };
  98. #define ACPI_SPACE_MEM 0
  99. enum acpi_address_range_id {
  100. ACPI_ADDRESS_RANGE_MEMORY = 1,
  101. ACPI_ADDRESS_RANGE_RESERVED = 2,
  102. ACPI_ADDRESS_RANGE_ACPI = 3,
  103. ACPI_ADDRESS_RANGE_NVS = 4,
  104. ACPI_ADDRESS_RANGE_COUNT
  105. };
  106. /* Table Handlers */
  107. union acpi_subtable_headers {
  108. struct acpi_subtable_header common;
  109. struct acpi_hmat_structure hmat;
  110. struct acpi_prmt_module_header prmt;
  111. struct acpi_cedt_header cedt;
  112. };
  113. typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table);
  114. typedef int (*acpi_tbl_entry_handler)(union acpi_subtable_headers *header,
  115. const unsigned long end);
  116. typedef int (*acpi_tbl_entry_handler_arg)(union acpi_subtable_headers *header,
  117. void *arg, const unsigned long end);
  118. /* Debugger support */
  119. struct acpi_debugger_ops {
  120. int (*create_thread)(acpi_osd_exec_callback function, void *context);
  121. ssize_t (*write_log)(const char *msg);
  122. ssize_t (*read_cmd)(char *buffer, size_t length);
  123. int (*wait_command_ready)(bool single_step, char *buffer, size_t length);
  124. int (*notify_command_complete)(void);
  125. };
  126. struct acpi_debugger {
  127. const struct acpi_debugger_ops *ops;
  128. struct module *owner;
  129. struct mutex lock;
  130. };
  131. #ifdef CONFIG_ACPI_DEBUGGER
  132. int __init acpi_debugger_init(void);
  133. int acpi_register_debugger(struct module *owner,
  134. const struct acpi_debugger_ops *ops);
  135. void acpi_unregister_debugger(const struct acpi_debugger_ops *ops);
  136. int acpi_debugger_create_thread(acpi_osd_exec_callback function, void *context);
  137. ssize_t acpi_debugger_write_log(const char *msg);
  138. ssize_t acpi_debugger_read_cmd(char *buffer, size_t buffer_length);
  139. int acpi_debugger_wait_command_ready(void);
  140. int acpi_debugger_notify_command_complete(void);
  141. #else
  142. static inline int acpi_debugger_init(void)
  143. {
  144. return -ENODEV;
  145. }
  146. static inline int acpi_register_debugger(struct module *owner,
  147. const struct acpi_debugger_ops *ops)
  148. {
  149. return -ENODEV;
  150. }
  151. static inline void acpi_unregister_debugger(const struct acpi_debugger_ops *ops)
  152. {
  153. }
  154. static inline int acpi_debugger_create_thread(acpi_osd_exec_callback function,
  155. void *context)
  156. {
  157. return -ENODEV;
  158. }
  159. static inline int acpi_debugger_write_log(const char *msg)
  160. {
  161. return -ENODEV;
  162. }
  163. static inline int acpi_debugger_read_cmd(char *buffer, u32 buffer_length)
  164. {
  165. return -ENODEV;
  166. }
  167. static inline int acpi_debugger_wait_command_ready(void)
  168. {
  169. return -ENODEV;
  170. }
  171. static inline int acpi_debugger_notify_command_complete(void)
  172. {
  173. return -ENODEV;
  174. }
  175. #endif
  176. #define BAD_MADT_ENTRY(entry, end) ( \
  177. (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
  178. ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
  179. struct acpi_subtable_proc {
  180. int id;
  181. acpi_tbl_entry_handler handler;
  182. acpi_tbl_entry_handler_arg handler_arg;
  183. void *arg;
  184. int count;
  185. };
  186. void __iomem *__acpi_map_table(unsigned long phys, unsigned long size);
  187. void __acpi_unmap_table(void __iomem *map, unsigned long size);
  188. int early_acpi_boot_init(void);
  189. int acpi_boot_init (void);
  190. void acpi_boot_table_prepare (void);
  191. void acpi_boot_table_init (void);
  192. int acpi_mps_check (void);
  193. int acpi_numa_init (void);
  194. int acpi_locate_initial_tables (void);
  195. void acpi_reserve_initial_tables (void);
  196. void acpi_table_init_complete (void);
  197. int acpi_table_init (void);
  198. #ifdef CONFIG_ACPI_TABLE_LIB
  199. #define EXPORT_SYMBOL_ACPI_LIB(x) EXPORT_SYMBOL_NS_GPL(x, ACPI)
  200. #define __init_or_acpilib
  201. #define __initdata_or_acpilib
  202. #else
  203. #define EXPORT_SYMBOL_ACPI_LIB(x)
  204. #define __init_or_acpilib __init
  205. #define __initdata_or_acpilib __initdata
  206. #endif
  207. int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
  208. int __init_or_acpilib acpi_table_parse_entries(char *id,
  209. unsigned long table_size, int entry_id,
  210. acpi_tbl_entry_handler handler, unsigned int max_entries);
  211. int __init_or_acpilib acpi_table_parse_entries_array(char *id,
  212. unsigned long table_size, struct acpi_subtable_proc *proc,
  213. int proc_num, unsigned int max_entries);
  214. int acpi_table_parse_madt(enum acpi_madt_type id,
  215. acpi_tbl_entry_handler handler,
  216. unsigned int max_entries);
  217. int __init_or_acpilib
  218. acpi_table_parse_cedt(enum acpi_cedt_type id,
  219. acpi_tbl_entry_handler_arg handler_arg, void *arg);
  220. int acpi_parse_mcfg (struct acpi_table_header *header);
  221. void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
  222. /* the following numa functions are architecture-dependent */
  223. void acpi_numa_slit_init (struct acpi_table_slit *slit);
  224. #if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_LOONGARCH)
  225. void acpi_numa_processor_affinity_init (struct acpi_srat_cpu_affinity *pa);
  226. #else
  227. static inline void
  228. acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa) { }
  229. #endif
  230. void acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa);
  231. #if defined(CONFIG_ARM64) || defined(CONFIG_LOONGARCH)
  232. void acpi_arch_dma_setup(struct device *dev);
  233. #else
  234. static inline void acpi_arch_dma_setup(struct device *dev) { }
  235. #endif
  236. #ifdef CONFIG_ARM64
  237. void acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa);
  238. #else
  239. static inline void
  240. acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa) { }
  241. #endif
  242. int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma);
  243. #ifndef PHYS_CPUID_INVALID
  244. typedef u32 phys_cpuid_t;
  245. #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
  246. #endif
  247. static inline bool invalid_logical_cpuid(u32 cpuid)
  248. {
  249. return (int)cpuid < 0;
  250. }
  251. static inline bool invalid_phys_cpuid(phys_cpuid_t phys_id)
  252. {
  253. return phys_id == PHYS_CPUID_INVALID;
  254. }
  255. /* Validate the processor object's proc_id */
  256. bool acpi_duplicate_processor_id(int proc_id);
  257. /* Processor _CTS control */
  258. struct acpi_processor_power;
  259. #ifdef CONFIG_ACPI_PROCESSOR_CSTATE
  260. bool acpi_processor_claim_cst_control(void);
  261. int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
  262. struct acpi_processor_power *info);
  263. #else
  264. static inline bool acpi_processor_claim_cst_control(void) { return false; }
  265. static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
  266. struct acpi_processor_power *info)
  267. {
  268. return -ENODEV;
  269. }
  270. #endif
  271. #ifdef CONFIG_ACPI_HOTPLUG_CPU
  272. /* Arch dependent functions for cpu hotplug support */
  273. int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id,
  274. int *pcpu);
  275. int acpi_unmap_cpu(int cpu);
  276. #endif /* CONFIG_ACPI_HOTPLUG_CPU */
  277. #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
  278. int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
  279. #endif
  280. int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
  281. int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
  282. int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base);
  283. void acpi_irq_stats_init(void);
  284. extern u32 acpi_irq_handled;
  285. extern u32 acpi_irq_not_handled;
  286. extern unsigned int acpi_sci_irq;
  287. extern bool acpi_no_s5;
  288. #define INVALID_ACPI_IRQ ((unsigned)-1)
  289. static inline bool acpi_sci_irq_valid(void)
  290. {
  291. return acpi_sci_irq != INVALID_ACPI_IRQ;
  292. }
  293. extern int sbf_port;
  294. extern unsigned long acpi_realmode_flags;
  295. int acpi_register_gsi (struct device *dev, u32 gsi, int triggering, int polarity);
  296. int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
  297. int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi);
  298. void acpi_set_irq_model(enum acpi_irq_model_id model,
  299. struct fwnode_handle *(*)(u32));
  300. void acpi_set_gsi_to_irq_fallback(u32 (*)(u32));
  301. struct irq_domain *acpi_irq_create_hierarchy(unsigned int flags,
  302. unsigned int size,
  303. struct fwnode_handle *fwnode,
  304. const struct irq_domain_ops *ops,
  305. void *host_data);
  306. #ifdef CONFIG_X86_IO_APIC
  307. extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity);
  308. #else
  309. static inline int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity)
  310. {
  311. return -1;
  312. }
  313. #endif
  314. /*
  315. * This function undoes the effect of one call to acpi_register_gsi().
  316. * If this matches the last registration, any IRQ resources for gsi
  317. * are freed.
  318. */
  319. void acpi_unregister_gsi (u32 gsi);
  320. struct pci_dev;
  321. int acpi_pci_irq_enable (struct pci_dev *dev);
  322. void acpi_penalize_isa_irq(int irq, int active);
  323. bool acpi_isa_irq_available(int irq);
  324. #ifdef CONFIG_PCI
  325. void acpi_penalize_sci_irq(int irq, int trigger, int polarity);
  326. #else
  327. static inline void acpi_penalize_sci_irq(int irq, int trigger,
  328. int polarity)
  329. {
  330. }
  331. #endif
  332. void acpi_pci_irq_disable (struct pci_dev *dev);
  333. extern int ec_read(u8 addr, u8 *val);
  334. extern int ec_write(u8 addr, u8 val);
  335. extern int ec_transaction(u8 command,
  336. const u8 *wdata, unsigned wdata_len,
  337. u8 *rdata, unsigned rdata_len);
  338. extern acpi_handle ec_get_handle(void);
  339. extern bool acpi_is_pnp_device(struct acpi_device *);
  340. #if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE)
  341. typedef void (*wmi_notify_handler) (u32 value, void *context);
  342. extern acpi_status wmi_evaluate_method(const char *guid, u8 instance,
  343. u32 method_id,
  344. const struct acpi_buffer *in,
  345. struct acpi_buffer *out);
  346. extern acpi_status wmi_query_block(const char *guid, u8 instance,
  347. struct acpi_buffer *out);
  348. extern acpi_status wmi_set_block(const char *guid, u8 instance,
  349. const struct acpi_buffer *in);
  350. extern acpi_status wmi_install_notify_handler(const char *guid,
  351. wmi_notify_handler handler, void *data);
  352. extern acpi_status wmi_remove_notify_handler(const char *guid);
  353. extern acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out);
  354. extern bool wmi_has_guid(const char *guid);
  355. extern char *wmi_get_acpi_device_uid(const char *guid);
  356. #endif /* CONFIG_ACPI_WMI */
  357. #define ACPI_VIDEO_OUTPUT_SWITCHING 0x0001
  358. #define ACPI_VIDEO_DEVICE_POSTING 0x0002
  359. #define ACPI_VIDEO_ROM_AVAILABLE 0x0004
  360. #define ACPI_VIDEO_BACKLIGHT 0x0008
  361. #define ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR 0x0010
  362. #define ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO 0x0020
  363. #define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR 0x0040
  364. #define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO 0x0080
  365. #define ACPI_VIDEO_BACKLIGHT_DMI_VENDOR 0x0100
  366. #define ACPI_VIDEO_BACKLIGHT_DMI_VIDEO 0x0200
  367. #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR 0x0400
  368. #define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO 0x0800
  369. extern char acpi_video_backlight_string[];
  370. extern long acpi_is_video_device(acpi_handle handle);
  371. extern int acpi_blacklisted(void);
  372. extern void acpi_osi_setup(char *str);
  373. extern bool acpi_osi_is_win8(void);
  374. #ifdef CONFIG_ACPI_NUMA
  375. int acpi_map_pxm_to_node(int pxm);
  376. int acpi_get_node(acpi_handle handle);
  377. /**
  378. * pxm_to_online_node - Map proximity ID to online node
  379. * @pxm: ACPI proximity ID
  380. *
  381. * This is similar to pxm_to_node(), but always returns an online
  382. * node. When the mapped node from a given proximity ID is offline, it
  383. * looks up the node distance table and returns the nearest online node.
  384. *
  385. * ACPI device drivers, which are called after the NUMA initialization has
  386. * completed in the kernel, can call this interface to obtain their device
  387. * NUMA topology from ACPI tables. Such drivers do not have to deal with
  388. * offline nodes. A node may be offline when SRAT memory entry does not exist,
  389. * or NUMA is disabled, ex. "numa=off" on x86.
  390. */
  391. static inline int pxm_to_online_node(int pxm)
  392. {
  393. int node = pxm_to_node(pxm);
  394. return numa_map_to_online_node(node);
  395. }
  396. #else
  397. static inline int pxm_to_online_node(int pxm)
  398. {
  399. return 0;
  400. }
  401. static inline int acpi_map_pxm_to_node(int pxm)
  402. {
  403. return 0;
  404. }
  405. static inline int acpi_get_node(acpi_handle handle)
  406. {
  407. return 0;
  408. }
  409. #endif
  410. extern int acpi_paddr_to_node(u64 start_addr, u64 size);
  411. extern int pnpacpi_disabled;
  412. #define PXM_INVAL (-1)
  413. bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res);
  414. bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res);
  415. bool acpi_dev_resource_address_space(struct acpi_resource *ares,
  416. struct resource_win *win);
  417. bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
  418. struct resource_win *win);
  419. unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable, u8 wake_capable);
  420. unsigned int acpi_dev_get_irq_type(int triggering, int polarity);
  421. bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
  422. struct resource *res);
  423. void acpi_dev_free_resource_list(struct list_head *list);
  424. int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
  425. int (*preproc)(struct acpi_resource *, void *),
  426. void *preproc_data);
  427. int acpi_dev_get_dma_resources(struct acpi_device *adev,
  428. struct list_head *list);
  429. int acpi_dev_get_memory_resources(struct acpi_device *adev, struct list_head *list);
  430. int acpi_dev_filter_resource_type(struct acpi_resource *ares,
  431. unsigned long types);
  432. static inline int acpi_dev_filter_resource_type_cb(struct acpi_resource *ares,
  433. void *arg)
  434. {
  435. return acpi_dev_filter_resource_type(ares, (unsigned long)arg);
  436. }
  437. struct acpi_device *acpi_resource_consumer(struct resource *res);
  438. int acpi_check_resource_conflict(const struct resource *res);
  439. int acpi_check_region(resource_size_t start, resource_size_t n,
  440. const char *name);
  441. int acpi_resources_are_enforced(void);
  442. #ifdef CONFIG_HIBERNATION
  443. extern int acpi_check_s4_hw_signature;
  444. #endif
  445. #ifdef CONFIG_PM_SLEEP
  446. void __init acpi_old_suspend_ordering(void);
  447. void __init acpi_nvs_nosave(void);
  448. void __init acpi_nvs_nosave_s3(void);
  449. void __init acpi_sleep_no_blacklist(void);
  450. #endif /* CONFIG_PM_SLEEP */
  451. int acpi_register_wakeup_handler(
  452. int wake_irq, bool (*wakeup)(void *context), void *context);
  453. void acpi_unregister_wakeup_handler(
  454. bool (*wakeup)(void *context), void *context);
  455. struct acpi_osc_context {
  456. char *uuid_str; /* UUID string */
  457. int rev;
  458. struct acpi_buffer cap; /* list of DWORD capabilities */
  459. struct acpi_buffer ret; /* free by caller if success */
  460. };
  461. acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);
  462. /* Number of _OSC capability DWORDS depends on bridge type */
  463. #define OSC_PCI_CAPABILITY_DWORDS 3
  464. #define OSC_CXL_CAPABILITY_DWORDS 5
  465. /* Indexes into _OSC Capabilities Buffer (DWORDs 2 to 5 are device-specific) */
  466. #define OSC_QUERY_DWORD 0 /* DWORD 1 */
  467. #define OSC_SUPPORT_DWORD 1 /* DWORD 2 */
  468. #define OSC_CONTROL_DWORD 2 /* DWORD 3 */
  469. #define OSC_EXT_SUPPORT_DWORD 3 /* DWORD 4 */
  470. #define OSC_EXT_CONTROL_DWORD 4 /* DWORD 5 */
  471. /* _OSC Capabilities DWORD 1: Query/Control and Error Returns (generic) */
  472. #define OSC_QUERY_ENABLE 0x00000001 /* input */
  473. #define OSC_REQUEST_ERROR 0x00000002 /* return */
  474. #define OSC_INVALID_UUID_ERROR 0x00000004 /* return */
  475. #define OSC_INVALID_REVISION_ERROR 0x00000008 /* return */
  476. #define OSC_CAPABILITIES_MASK_ERROR 0x00000010 /* return */
  477. /* Platform-Wide Capabilities _OSC: Capabilities DWORD 2: Support Field */
  478. #define OSC_SB_PAD_SUPPORT 0x00000001
  479. #define OSC_SB_PPC_OST_SUPPORT 0x00000002
  480. #define OSC_SB_PR3_SUPPORT 0x00000004
  481. #define OSC_SB_HOTPLUG_OST_SUPPORT 0x00000008
  482. #define OSC_SB_APEI_SUPPORT 0x00000010
  483. #define OSC_SB_CPC_SUPPORT 0x00000020
  484. #define OSC_SB_CPCV2_SUPPORT 0x00000040
  485. #define OSC_SB_PCLPI_SUPPORT 0x00000080
  486. #define OSC_SB_OSLPI_SUPPORT 0x00000100
  487. #define OSC_SB_CPC_DIVERSE_HIGH_SUPPORT 0x00001000
  488. #define OSC_SB_GENERIC_INITIATOR_SUPPORT 0x00002000
  489. #define OSC_SB_CPC_FLEXIBLE_ADR_SPACE 0x00004000
  490. #define OSC_SB_NATIVE_USB4_SUPPORT 0x00040000
  491. #define OSC_SB_PRM_SUPPORT 0x00200000
  492. extern bool osc_sb_apei_support_acked;
  493. extern bool osc_pc_lpi_support_confirmed;
  494. extern bool osc_sb_native_usb4_support_confirmed;
  495. extern bool osc_sb_cppc2_support_acked;
  496. extern bool osc_cpc_flexible_adr_space_confirmed;
  497. /* USB4 Capabilities */
  498. #define OSC_USB_USB3_TUNNELING 0x00000001
  499. #define OSC_USB_DP_TUNNELING 0x00000002
  500. #define OSC_USB_PCIE_TUNNELING 0x00000004
  501. #define OSC_USB_XDOMAIN 0x00000008
  502. extern u32 osc_sb_native_usb4_control;
  503. /* PCI Host Bridge _OSC: Capabilities DWORD 2: Support Field */
  504. #define OSC_PCI_EXT_CONFIG_SUPPORT 0x00000001
  505. #define OSC_PCI_ASPM_SUPPORT 0x00000002
  506. #define OSC_PCI_CLOCK_PM_SUPPORT 0x00000004
  507. #define OSC_PCI_SEGMENT_GROUPS_SUPPORT 0x00000008
  508. #define OSC_PCI_MSI_SUPPORT 0x00000010
  509. #define OSC_PCI_EDR_SUPPORT 0x00000080
  510. #define OSC_PCI_HPX_TYPE_3_SUPPORT 0x00000100
  511. /* PCI Host Bridge _OSC: Capabilities DWORD 3: Control Field */
  512. #define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL 0x00000001
  513. #define OSC_PCI_SHPC_NATIVE_HP_CONTROL 0x00000002
  514. #define OSC_PCI_EXPRESS_PME_CONTROL 0x00000004
  515. #define OSC_PCI_EXPRESS_AER_CONTROL 0x00000008
  516. #define OSC_PCI_EXPRESS_CAPABILITY_CONTROL 0x00000010
  517. #define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020
  518. #define OSC_PCI_EXPRESS_DPC_CONTROL 0x00000080
  519. /* CXL _OSC: Capabilities DWORD 4: Support Field */
  520. #define OSC_CXL_1_1_PORT_REG_ACCESS_SUPPORT 0x00000001
  521. #define OSC_CXL_2_0_PORT_DEV_REG_ACCESS_SUPPORT 0x00000002
  522. #define OSC_CXL_PROTOCOL_ERR_REPORTING_SUPPORT 0x00000004
  523. #define OSC_CXL_NATIVE_HP_SUPPORT 0x00000008
  524. /* CXL _OSC: Capabilities DWORD 5: Control Field */
  525. #define OSC_CXL_ERROR_REPORTING_CONTROL 0x00000001
  526. static inline u32 acpi_osc_ctx_get_pci_control(struct acpi_osc_context *context)
  527. {
  528. u32 *ret = context->ret.pointer;
  529. return ret[OSC_CONTROL_DWORD];
  530. }
  531. static inline u32 acpi_osc_ctx_get_cxl_control(struct acpi_osc_context *context)
  532. {
  533. u32 *ret = context->ret.pointer;
  534. return ret[OSC_EXT_CONTROL_DWORD];
  535. }
  536. #define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002
  537. #define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004
  538. #define ACPI_GSB_ACCESS_ATTRIB_BYTE 0x00000006
  539. #define ACPI_GSB_ACCESS_ATTRIB_WORD 0x00000008
  540. #define ACPI_GSB_ACCESS_ATTRIB_BLOCK 0x0000000A
  541. #define ACPI_GSB_ACCESS_ATTRIB_MULTIBYTE 0x0000000B
  542. #define ACPI_GSB_ACCESS_ATTRIB_WORD_CALL 0x0000000C
  543. #define ACPI_GSB_ACCESS_ATTRIB_BLOCK_CALL 0x0000000D
  544. #define ACPI_GSB_ACCESS_ATTRIB_RAW_BYTES 0x0000000E
  545. #define ACPI_GSB_ACCESS_ATTRIB_RAW_PROCESS 0x0000000F
  546. /* Enable _OST when all relevant hotplug operations are enabled */
  547. #if defined(CONFIG_ACPI_HOTPLUG_CPU) && \
  548. defined(CONFIG_ACPI_HOTPLUG_MEMORY) && \
  549. defined(CONFIG_ACPI_CONTAINER)
  550. #define ACPI_HOTPLUG_OST
  551. #endif
  552. /* _OST Source Event Code (OSPM Action) */
  553. #define ACPI_OST_EC_OSPM_SHUTDOWN 0x100
  554. #define ACPI_OST_EC_OSPM_EJECT 0x103
  555. #define ACPI_OST_EC_OSPM_INSERTION 0x200
  556. /* _OST General Processing Status Code */
  557. #define ACPI_OST_SC_SUCCESS 0x0
  558. #define ACPI_OST_SC_NON_SPECIFIC_FAILURE 0x1
  559. #define ACPI_OST_SC_UNRECOGNIZED_NOTIFY 0x2
  560. /* _OST OS Shutdown Processing (0x100) Status Code */
  561. #define ACPI_OST_SC_OS_SHUTDOWN_DENIED 0x80
  562. #define ACPI_OST_SC_OS_SHUTDOWN_IN_PROGRESS 0x81
  563. #define ACPI_OST_SC_OS_SHUTDOWN_COMPLETED 0x82
  564. #define ACPI_OST_SC_OS_SHUTDOWN_NOT_SUPPORTED 0x83
  565. /* _OST Ejection Request (0x3, 0x103) Status Code */
  566. #define ACPI_OST_SC_EJECT_NOT_SUPPORTED 0x80
  567. #define ACPI_OST_SC_DEVICE_IN_USE 0x81
  568. #define ACPI_OST_SC_DEVICE_BUSY 0x82
  569. #define ACPI_OST_SC_EJECT_DEPENDENCY_BUSY 0x83
  570. #define ACPI_OST_SC_EJECT_IN_PROGRESS 0x84
  571. /* _OST Insertion Request (0x200) Status Code */
  572. #define ACPI_OST_SC_INSERT_IN_PROGRESS 0x80
  573. #define ACPI_OST_SC_DRIVER_LOAD_FAILURE 0x81
  574. #define ACPI_OST_SC_INSERT_NOT_SUPPORTED 0x82
  575. enum acpi_predicate {
  576. all_versions,
  577. less_than_or_equal,
  578. equal,
  579. greater_than_or_equal,
  580. };
  581. /* Table must be terminted by a NULL entry */
  582. struct acpi_platform_list {
  583. char oem_id[ACPI_OEM_ID_SIZE+1];
  584. char oem_table_id[ACPI_OEM_TABLE_ID_SIZE+1];
  585. u32 oem_revision;
  586. char *table;
  587. enum acpi_predicate pred;
  588. char *reason;
  589. u32 data;
  590. };
  591. int acpi_match_platform_list(const struct acpi_platform_list *plat);
  592. extern void acpi_early_init(void);
  593. extern void acpi_subsystem_init(void);
  594. extern void arch_post_acpi_subsys_init(void);
  595. extern int acpi_nvs_register(__u64 start, __u64 size);
  596. extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
  597. void *data);
  598. const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
  599. const struct device *dev);
  600. const void *acpi_device_get_match_data(const struct device *dev);
  601. extern bool acpi_driver_match_device(struct device *dev,
  602. const struct device_driver *drv);
  603. int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *);
  604. int acpi_device_modalias(struct device *, char *, int);
  605. struct platform_device *acpi_create_platform_device(struct acpi_device *,
  606. const struct property_entry *);
  607. #define ACPI_PTR(_ptr) (_ptr)
  608. static inline void acpi_device_set_enumerated(struct acpi_device *adev)
  609. {
  610. adev->flags.visited = true;
  611. }
  612. static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
  613. {
  614. adev->flags.visited = false;
  615. }
  616. enum acpi_reconfig_event {
  617. ACPI_RECONFIG_DEVICE_ADD = 0,
  618. ACPI_RECONFIG_DEVICE_REMOVE,
  619. };
  620. int acpi_reconfig_notifier_register(struct notifier_block *nb);
  621. int acpi_reconfig_notifier_unregister(struct notifier_block *nb);
  622. #ifdef CONFIG_ACPI_GTDT
  623. int acpi_gtdt_init(struct acpi_table_header *table, int *platform_timer_count);
  624. int acpi_gtdt_map_ppi(int type);
  625. bool acpi_gtdt_c3stop(int type);
  626. int acpi_arch_timer_mem_init(struct arch_timer_mem *timer_mem, int *timer_count);
  627. #endif
  628. #ifndef ACPI_HAVE_ARCH_SET_ROOT_POINTER
  629. static inline void acpi_arch_set_root_pointer(u64 addr)
  630. {
  631. }
  632. #endif
  633. #ifndef ACPI_HAVE_ARCH_GET_ROOT_POINTER
  634. static inline u64 acpi_arch_get_root_pointer(void)
  635. {
  636. return 0;
  637. }
  638. #endif
  639. int acpi_get_local_address(acpi_handle handle, u32 *addr);
  640. const char *acpi_get_subsystem_id(acpi_handle handle);
  641. #else /* !CONFIG_ACPI */
  642. #define acpi_disabled 1
  643. #define ACPI_COMPANION(dev) (NULL)
  644. #define ACPI_COMPANION_SET(dev, adev) do { } while (0)
  645. #define ACPI_HANDLE(dev) (NULL)
  646. #define ACPI_HANDLE_FWNODE(fwnode) (NULL)
  647. #define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (0), .cls_msk = (0),
  648. #include <acpi/acpi_numa.h>
  649. struct fwnode_handle;
  650. static inline bool acpi_dev_found(const char *hid)
  651. {
  652. return false;
  653. }
  654. static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
  655. {
  656. return false;
  657. }
  658. struct acpi_device;
  659. static inline bool
  660. acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2)
  661. {
  662. return false;
  663. }
  664. static inline int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer)
  665. {
  666. return -ENODEV;
  667. }
  668. static inline struct acpi_device *
  669. acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
  670. {
  671. return NULL;
  672. }
  673. static inline bool acpi_reduced_hardware(void)
  674. {
  675. return false;
  676. }
  677. static inline void acpi_dev_put(struct acpi_device *adev) {}
  678. static inline bool is_acpi_node(const struct fwnode_handle *fwnode)
  679. {
  680. return false;
  681. }
  682. static inline bool is_acpi_device_node(const struct fwnode_handle *fwnode)
  683. {
  684. return false;
  685. }
  686. static inline struct acpi_device *to_acpi_device_node(const struct fwnode_handle *fwnode)
  687. {
  688. return NULL;
  689. }
  690. static inline bool is_acpi_data_node(const struct fwnode_handle *fwnode)
  691. {
  692. return false;
  693. }
  694. static inline struct acpi_data_node *to_acpi_data_node(const struct fwnode_handle *fwnode)
  695. {
  696. return NULL;
  697. }
  698. static inline bool acpi_data_node_match(const struct fwnode_handle *fwnode,
  699. const char *name)
  700. {
  701. return false;
  702. }
  703. static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
  704. {
  705. return NULL;
  706. }
  707. static inline bool has_acpi_companion(struct device *dev)
  708. {
  709. return false;
  710. }
  711. static inline void acpi_preset_companion(struct device *dev,
  712. struct acpi_device *parent, u64 addr)
  713. {
  714. }
  715. static inline const char *acpi_dev_name(struct acpi_device *adev)
  716. {
  717. return NULL;
  718. }
  719. static inline struct device *acpi_get_first_physical_node(struct acpi_device *adev)
  720. {
  721. return NULL;
  722. }
  723. static inline void acpi_early_init(void) { }
  724. static inline void acpi_subsystem_init(void) { }
  725. static inline int early_acpi_boot_init(void)
  726. {
  727. return 0;
  728. }
  729. static inline int acpi_boot_init(void)
  730. {
  731. return 0;
  732. }
  733. static inline void acpi_boot_table_prepare(void)
  734. {
  735. }
  736. static inline void acpi_boot_table_init(void)
  737. {
  738. }
  739. static inline int acpi_mps_check(void)
  740. {
  741. return 0;
  742. }
  743. static inline int acpi_check_resource_conflict(struct resource *res)
  744. {
  745. return 0;
  746. }
  747. static inline int acpi_check_region(resource_size_t start, resource_size_t n,
  748. const char *name)
  749. {
  750. return 0;
  751. }
  752. struct acpi_table_header;
  753. static inline int acpi_table_parse(char *id,
  754. int (*handler)(struct acpi_table_header *))
  755. {
  756. return -ENODEV;
  757. }
  758. static inline int acpi_nvs_register(__u64 start, __u64 size)
  759. {
  760. return 0;
  761. }
  762. static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
  763. void *data)
  764. {
  765. return 0;
  766. }
  767. struct acpi_device_id;
  768. static inline const struct acpi_device_id *acpi_match_device(
  769. const struct acpi_device_id *ids, const struct device *dev)
  770. {
  771. return NULL;
  772. }
  773. static inline const void *acpi_device_get_match_data(const struct device *dev)
  774. {
  775. return NULL;
  776. }
  777. static inline bool acpi_driver_match_device(struct device *dev,
  778. const struct device_driver *drv)
  779. {
  780. return false;
  781. }
  782. static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,
  783. const guid_t *guid,
  784. u64 rev, u64 func,
  785. union acpi_object *argv4)
  786. {
  787. return NULL;
  788. }
  789. static inline int acpi_device_uevent_modalias(struct device *dev,
  790. struct kobj_uevent_env *env)
  791. {
  792. return -ENODEV;
  793. }
  794. static inline int acpi_device_modalias(struct device *dev,
  795. char *buf, int size)
  796. {
  797. return -ENODEV;
  798. }
  799. static inline struct platform_device *
  800. acpi_create_platform_device(struct acpi_device *adev,
  801. const struct property_entry *properties)
  802. {
  803. return NULL;
  804. }
  805. static inline bool acpi_dma_supported(const struct acpi_device *adev)
  806. {
  807. return false;
  808. }
  809. static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
  810. {
  811. return DEV_DMA_NOT_SUPPORTED;
  812. }
  813. static inline int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map)
  814. {
  815. return -ENODEV;
  816. }
  817. static inline int acpi_dma_configure(struct device *dev,
  818. enum dev_dma_attr attr)
  819. {
  820. return 0;
  821. }
  822. static inline int acpi_dma_configure_id(struct device *dev,
  823. enum dev_dma_attr attr,
  824. const u32 *input_id)
  825. {
  826. return 0;
  827. }
  828. #define ACPI_PTR(_ptr) (NULL)
  829. static inline void acpi_device_set_enumerated(struct acpi_device *adev)
  830. {
  831. }
  832. static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
  833. {
  834. }
  835. static inline int acpi_reconfig_notifier_register(struct notifier_block *nb)
  836. {
  837. return -EINVAL;
  838. }
  839. static inline int acpi_reconfig_notifier_unregister(struct notifier_block *nb)
  840. {
  841. return -EINVAL;
  842. }
  843. static inline struct acpi_device *acpi_resource_consumer(struct resource *res)
  844. {
  845. return NULL;
  846. }
  847. static inline int acpi_get_local_address(acpi_handle handle, u32 *addr)
  848. {
  849. return -ENODEV;
  850. }
  851. static inline const char *acpi_get_subsystem_id(acpi_handle handle)
  852. {
  853. return ERR_PTR(-ENODEV);
  854. }
  855. static inline int acpi_register_wakeup_handler(int wake_irq,
  856. bool (*wakeup)(void *context), void *context)
  857. {
  858. return -ENXIO;
  859. }
  860. static inline void acpi_unregister_wakeup_handler(
  861. bool (*wakeup)(void *context), void *context) { }
  862. struct acpi_osc_context;
  863. static inline u32 acpi_osc_ctx_get_pci_control(struct acpi_osc_context *context)
  864. {
  865. return 0;
  866. }
  867. static inline u32 acpi_osc_ctx_get_cxl_control(struct acpi_osc_context *context)
  868. {
  869. return 0;
  870. }
  871. #endif /* !CONFIG_ACPI */
  872. #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
  873. int acpi_ioapic_add(acpi_handle root);
  874. #else
  875. static inline int acpi_ioapic_add(acpi_handle root) { return 0; }
  876. #endif
  877. #ifdef CONFIG_ACPI
  878. void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
  879. u32 pm1a_ctrl, u32 pm1b_ctrl));
  880. acpi_status acpi_os_prepare_sleep(u8 sleep_state,
  881. u32 pm1a_control, u32 pm1b_control);
  882. void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
  883. u32 val_a, u32 val_b));
  884. acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state,
  885. u32 val_a, u32 val_b);
  886. #ifdef CONFIG_X86
  887. struct acpi_s2idle_dev_ops {
  888. struct list_head list_node;
  889. void (*prepare)(void);
  890. void (*check)(void);
  891. void (*restore)(void);
  892. };
  893. int acpi_register_lps0_dev(struct acpi_s2idle_dev_ops *arg);
  894. void acpi_unregister_lps0_dev(struct acpi_s2idle_dev_ops *arg);
  895. #endif /* CONFIG_X86 */
  896. #ifndef CONFIG_IA64
  897. void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
  898. #else
  899. static inline void arch_reserve_mem_area(acpi_physical_address addr,
  900. size_t size)
  901. {
  902. }
  903. #endif /* CONFIG_X86 */
  904. #else
  905. #define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
  906. #endif
  907. #if defined(CONFIG_ACPI) && defined(CONFIG_PM)
  908. int acpi_dev_suspend(struct device *dev, bool wakeup);
  909. int acpi_dev_resume(struct device *dev);
  910. int acpi_subsys_runtime_suspend(struct device *dev);
  911. int acpi_subsys_runtime_resume(struct device *dev);
  912. int acpi_dev_pm_attach(struct device *dev, bool power_on);
  913. bool acpi_storage_d3(struct device *dev);
  914. bool acpi_dev_state_d0(struct device *dev);
  915. #else
  916. static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; }
  917. static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; }
  918. static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
  919. {
  920. return 0;
  921. }
  922. static inline bool acpi_storage_d3(struct device *dev)
  923. {
  924. return false;
  925. }
  926. static inline bool acpi_dev_state_d0(struct device *dev)
  927. {
  928. return true;
  929. }
  930. #endif
  931. #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
  932. int acpi_subsys_prepare(struct device *dev);
  933. void acpi_subsys_complete(struct device *dev);
  934. int acpi_subsys_suspend_late(struct device *dev);
  935. int acpi_subsys_suspend_noirq(struct device *dev);
  936. int acpi_subsys_suspend(struct device *dev);
  937. int acpi_subsys_freeze(struct device *dev);
  938. int acpi_subsys_poweroff(struct device *dev);
  939. void acpi_ec_mark_gpe_for_wake(void);
  940. void acpi_ec_set_gpe_wake_mask(u8 action);
  941. #else
  942. static inline int acpi_subsys_prepare(struct device *dev) { return 0; }
  943. static inline void acpi_subsys_complete(struct device *dev) {}
  944. static inline int acpi_subsys_suspend_late(struct device *dev) { return 0; }
  945. static inline int acpi_subsys_suspend_noirq(struct device *dev) { return 0; }
  946. static inline int acpi_subsys_suspend(struct device *dev) { return 0; }
  947. static inline int acpi_subsys_freeze(struct device *dev) { return 0; }
  948. static inline int acpi_subsys_poweroff(struct device *dev) { return 0; }
  949. static inline void acpi_ec_mark_gpe_for_wake(void) {}
  950. static inline void acpi_ec_set_gpe_wake_mask(u8 action) {}
  951. #endif
  952. #ifdef CONFIG_ACPI
  953. __printf(3, 4)
  954. void acpi_handle_printk(const char *level, acpi_handle handle,
  955. const char *fmt, ...);
  956. void acpi_evaluation_failure_warn(acpi_handle handle, const char *name,
  957. acpi_status status);
  958. #else /* !CONFIG_ACPI */
  959. static inline __printf(3, 4) void
  960. acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {}
  961. static inline void acpi_evaluation_failure_warn(acpi_handle handle,
  962. const char *name,
  963. acpi_status status) {}
  964. #endif /* !CONFIG_ACPI */
  965. #if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
  966. __printf(3, 4)
  967. void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
  968. #endif
  969. /*
  970. * acpi_handle_<level>: Print message with ACPI prefix and object path
  971. *
  972. * These interfaces acquire the global namespace mutex to obtain an object
  973. * path. In interrupt context, it shows the object path as <n/a>.
  974. */
  975. #define acpi_handle_emerg(handle, fmt, ...) \
  976. acpi_handle_printk(KERN_EMERG, handle, fmt, ##__VA_ARGS__)
  977. #define acpi_handle_alert(handle, fmt, ...) \
  978. acpi_handle_printk(KERN_ALERT, handle, fmt, ##__VA_ARGS__)
  979. #define acpi_handle_crit(handle, fmt, ...) \
  980. acpi_handle_printk(KERN_CRIT, handle, fmt, ##__VA_ARGS__)
  981. #define acpi_handle_err(handle, fmt, ...) \
  982. acpi_handle_printk(KERN_ERR, handle, fmt, ##__VA_ARGS__)
  983. #define acpi_handle_warn(handle, fmt, ...) \
  984. acpi_handle_printk(KERN_WARNING, handle, fmt, ##__VA_ARGS__)
  985. #define acpi_handle_notice(handle, fmt, ...) \
  986. acpi_handle_printk(KERN_NOTICE, handle, fmt, ##__VA_ARGS__)
  987. #define acpi_handle_info(handle, fmt, ...) \
  988. acpi_handle_printk(KERN_INFO, handle, fmt, ##__VA_ARGS__)
  989. #if defined(DEBUG)
  990. #define acpi_handle_debug(handle, fmt, ...) \
  991. acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__)
  992. #else
  993. #if defined(CONFIG_DYNAMIC_DEBUG)
  994. #define acpi_handle_debug(handle, fmt, ...) \
  995. _dynamic_func_call(fmt, __acpi_handle_debug, \
  996. handle, pr_fmt(fmt), ##__VA_ARGS__)
  997. #else
  998. #define acpi_handle_debug(handle, fmt, ...) \
  999. ({ \
  1000. if (0) \
  1001. acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__); \
  1002. 0; \
  1003. })
  1004. #endif
  1005. #endif
  1006. #if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB)
  1007. bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
  1008. struct acpi_resource_gpio **agpio);
  1009. bool acpi_gpio_get_io_resource(struct acpi_resource *ares,
  1010. struct acpi_resource_gpio **agpio);
  1011. int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, int index,
  1012. bool *wake_capable);
  1013. #else
  1014. static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
  1015. struct acpi_resource_gpio **agpio)
  1016. {
  1017. return false;
  1018. }
  1019. static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares,
  1020. struct acpi_resource_gpio **agpio)
  1021. {
  1022. return false;
  1023. }
  1024. static inline int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name,
  1025. int index, bool *wake_capable)
  1026. {
  1027. return -ENXIO;
  1028. }
  1029. #endif
  1030. static inline int acpi_dev_gpio_irq_wake_get(struct acpi_device *adev, int index,
  1031. bool *wake_capable)
  1032. {
  1033. return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, wake_capable);
  1034. }
  1035. static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name,
  1036. int index)
  1037. {
  1038. return acpi_dev_gpio_irq_wake_get_by(adev, name, index, NULL);
  1039. }
  1040. static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
  1041. {
  1042. return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, NULL);
  1043. }
  1044. /* Device properties */
  1045. #ifdef CONFIG_ACPI
  1046. int acpi_dev_get_property(const struct acpi_device *adev, const char *name,
  1047. acpi_object_type type, const union acpi_object **obj);
  1048. int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
  1049. const char *name, size_t index, size_t num_args,
  1050. struct fwnode_reference_args *args);
  1051. static inline int acpi_node_get_property_reference(
  1052. const struct fwnode_handle *fwnode,
  1053. const char *name, size_t index,
  1054. struct fwnode_reference_args *args)
  1055. {
  1056. return __acpi_node_get_property_reference(fwnode, name, index,
  1057. NR_FWNODE_REFERENCE_ARGS, args);
  1058. }
  1059. static inline bool acpi_dev_has_props(const struct acpi_device *adev)
  1060. {
  1061. return !list_empty(&adev->data.properties);
  1062. }
  1063. struct acpi_device_properties *
  1064. acpi_data_add_props(struct acpi_device_data *data, const guid_t *guid,
  1065. union acpi_object *properties);
  1066. int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
  1067. void **valptr);
  1068. struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
  1069. struct fwnode_handle *child);
  1070. struct acpi_probe_entry;
  1071. typedef bool (*acpi_probe_entry_validate_subtbl)(struct acpi_subtable_header *,
  1072. struct acpi_probe_entry *);
  1073. #define ACPI_TABLE_ID_LEN 5
  1074. /**
  1075. * struct acpi_probe_entry - boot-time probing entry
  1076. * @id: ACPI table name
  1077. * @type: Optional subtable type to match
  1078. * (if @id contains subtables)
  1079. * @subtable_valid: Optional callback to check the validity of
  1080. * the subtable
  1081. * @probe_table: Callback to the driver being probed when table
  1082. * match is successful
  1083. * @probe_subtbl: Callback to the driver being probed when table and
  1084. * subtable match (and optional callback is successful)
  1085. * @driver_data: Sideband data provided back to the driver
  1086. */
  1087. struct acpi_probe_entry {
  1088. __u8 id[ACPI_TABLE_ID_LEN];
  1089. __u8 type;
  1090. acpi_probe_entry_validate_subtbl subtable_valid;
  1091. union {
  1092. acpi_tbl_table_handler probe_table;
  1093. acpi_tbl_entry_handler probe_subtbl;
  1094. };
  1095. kernel_ulong_t driver_data;
  1096. };
  1097. #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, \
  1098. valid, data, fn) \
  1099. static const struct acpi_probe_entry __acpi_probe_##name \
  1100. __used __section("__" #table "_acpi_probe_table") = { \
  1101. .id = table_id, \
  1102. .type = subtable, \
  1103. .subtable_valid = valid, \
  1104. .probe_table = fn, \
  1105. .driver_data = data, \
  1106. }
  1107. #define ACPI_DECLARE_SUBTABLE_PROBE_ENTRY(table, name, table_id, \
  1108. subtable, valid, data, fn) \
  1109. static const struct acpi_probe_entry __acpi_probe_##name \
  1110. __used __section("__" #table "_acpi_probe_table") = { \
  1111. .id = table_id, \
  1112. .type = subtable, \
  1113. .subtable_valid = valid, \
  1114. .probe_subtbl = fn, \
  1115. .driver_data = data, \
  1116. }
  1117. #define ACPI_PROBE_TABLE(name) __##name##_acpi_probe_table
  1118. #define ACPI_PROBE_TABLE_END(name) __##name##_acpi_probe_table_end
  1119. int __acpi_probe_device_table(struct acpi_probe_entry *start, int nr);
  1120. #define acpi_probe_device_table(t) \
  1121. ({ \
  1122. extern struct acpi_probe_entry ACPI_PROBE_TABLE(t), \
  1123. ACPI_PROBE_TABLE_END(t); \
  1124. __acpi_probe_device_table(&ACPI_PROBE_TABLE(t), \
  1125. (&ACPI_PROBE_TABLE_END(t) - \
  1126. &ACPI_PROBE_TABLE(t))); \
  1127. })
  1128. #else
  1129. static inline int acpi_dev_get_property(struct acpi_device *adev,
  1130. const char *name, acpi_object_type type,
  1131. const union acpi_object **obj)
  1132. {
  1133. return -ENXIO;
  1134. }
  1135. static inline int
  1136. __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
  1137. const char *name, size_t index, size_t num_args,
  1138. struct fwnode_reference_args *args)
  1139. {
  1140. return -ENXIO;
  1141. }
  1142. static inline int
  1143. acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
  1144. const char *name, size_t index,
  1145. struct fwnode_reference_args *args)
  1146. {
  1147. return -ENXIO;
  1148. }
  1149. static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,
  1150. const char *propname,
  1151. void **valptr)
  1152. {
  1153. return -ENXIO;
  1154. }
  1155. static inline struct fwnode_handle *
  1156. acpi_get_next_subnode(const struct fwnode_handle *fwnode,
  1157. struct fwnode_handle *child)
  1158. {
  1159. return NULL;
  1160. }
  1161. static inline struct fwnode_handle *
  1162. acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
  1163. struct fwnode_handle *prev)
  1164. {
  1165. return ERR_PTR(-ENXIO);
  1166. }
  1167. static inline int
  1168. acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode,
  1169. struct fwnode_handle **remote,
  1170. struct fwnode_handle **port,
  1171. struct fwnode_handle **endpoint)
  1172. {
  1173. return -ENXIO;
  1174. }
  1175. #define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
  1176. static const void * __acpi_table_##name[] \
  1177. __attribute__((unused)) \
  1178. = { (void *) table_id, \
  1179. (void *) subtable, \
  1180. (void *) valid, \
  1181. (void *) fn, \
  1182. (void *) data }
  1183. #define acpi_probe_device_table(t) ({ int __r = 0; __r;})
  1184. #endif
  1185. #ifdef CONFIG_ACPI_TABLE_UPGRADE
  1186. void acpi_table_upgrade(void);
  1187. #else
  1188. static inline void acpi_table_upgrade(void) { }
  1189. #endif
  1190. #if defined(CONFIG_ACPI) && defined(CONFIG_ACPI_WATCHDOG)
  1191. extern bool acpi_has_watchdog(void);
  1192. #else
  1193. static inline bool acpi_has_watchdog(void) { return false; }
  1194. #endif
  1195. #ifdef CONFIG_ACPI_SPCR_TABLE
  1196. extern bool qdf2400_e44_present;
  1197. int acpi_parse_spcr(bool enable_earlycon, bool enable_console);
  1198. #else
  1199. static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console)
  1200. {
  1201. return 0;
  1202. }
  1203. #endif
  1204. #if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI)
  1205. int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res);
  1206. #else
  1207. static inline
  1208. int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res)
  1209. {
  1210. return -EINVAL;
  1211. }
  1212. #endif
  1213. #ifdef CONFIG_ACPI_LPIT
  1214. int lpit_read_residency_count_address(u64 *address);
  1215. #else
  1216. static inline int lpit_read_residency_count_address(u64 *address)
  1217. {
  1218. return -EINVAL;
  1219. }
  1220. #endif
  1221. #ifdef CONFIG_ACPI_PPTT
  1222. int acpi_pptt_cpu_is_thread(unsigned int cpu);
  1223. int find_acpi_cpu_topology(unsigned int cpu, int level);
  1224. int find_acpi_cpu_topology_cluster(unsigned int cpu);
  1225. int find_acpi_cpu_topology_package(unsigned int cpu);
  1226. int find_acpi_cpu_topology_hetero_id(unsigned int cpu);
  1227. #else
  1228. static inline int acpi_pptt_cpu_is_thread(unsigned int cpu)
  1229. {
  1230. return -EINVAL;
  1231. }
  1232. static inline int find_acpi_cpu_topology(unsigned int cpu, int level)
  1233. {
  1234. return -EINVAL;
  1235. }
  1236. static inline int find_acpi_cpu_topology_cluster(unsigned int cpu)
  1237. {
  1238. return -EINVAL;
  1239. }
  1240. static inline int find_acpi_cpu_topology_package(unsigned int cpu)
  1241. {
  1242. return -EINVAL;
  1243. }
  1244. static inline int find_acpi_cpu_topology_hetero_id(unsigned int cpu)
  1245. {
  1246. return -EINVAL;
  1247. }
  1248. #endif
  1249. #ifdef CONFIG_ACPI_PCC
  1250. void acpi_init_pcc(void);
  1251. #else
  1252. static inline void acpi_init_pcc(void) { }
  1253. #endif
  1254. #ifdef CONFIG_ACPI
  1255. extern void acpi_device_notify(struct device *dev);
  1256. extern void acpi_device_notify_remove(struct device *dev);
  1257. #else
  1258. static inline void acpi_device_notify(struct device *dev) { }
  1259. static inline void acpi_device_notify_remove(struct device *dev) { }
  1260. #endif
  1261. #endif /*_LINUX_ACPI_H*/