blob: d315d86844e491f4a59a2ae30a0ecdc8109ff490 [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * acpi.h - ACPI Interface
4 *
5 * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7
8#ifndef _LINUX_ACPI_H
9#define _LINUX_ACPI_H
10
Rafael J. Wysocki51333752012-11-15 13:15:37 +010011#include <linux/errno.h>
Thomas Renninger443dea72008-02-04 23:31:23 -080012#include <linux/ioport.h> /* for struct resource */
Jiang Liu90e97822015-02-05 13:44:43 +080013#include <linux/resource_ext.h>
Mika Westerbergcf761af2012-10-31 22:44:41 +010014#include <linux/device.h>
Rafael J. Wysockib31384f2014-11-04 01:28:56 +010015#include <linux/property.h>
Christoph Hellwigbcbc2262017-06-08 09:02:20 +020016#include <linux/uuid.h>
David Mosberger3f5948f2005-06-06 15:50:09 -070017
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#ifndef _LINUX
19#define _LINUX
20#endif
Lv Zheng633adab2014-07-16 16:58:30 +080021#include <acpi/acpi.h>
22
23#ifdef CONFIG_ACPI
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25#include <linux/list.h>
Thomas Renninger29b71a12007-07-23 14:43:51 +020026#include <linux/mod_devicetable.h>
Bjørn Mork45fef5b2014-05-22 12:47:47 +020027#include <linux/dynamic_debug.h>
Lv Zheng836d083012015-12-03 10:43:14 +080028#include <linux/module.h>
29#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <acpi/acpi_bus.h>
32#include <acpi/acpi_drivers.h>
Yasunori Goto762834e2006-06-23 02:03:19 -070033#include <acpi/acpi_numa.h>
Lv Zheng27d50c82013-12-06 16:52:05 +080034#include <acpi/acpi_io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <asm/acpi.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Rafael J. Wysocki7b199812013-11-11 22:41:56 +010037static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
38{
39 return adev ? adev->handle : NULL;
40}
41
Rafael J. Wysocki3a7a2ab2015-08-27 04:40:05 +020042#define ACPI_COMPANION(dev) to_acpi_device_node((dev)->fwnode)
Rafael J. Wysocki97badf82015-04-03 23:23:37 +020043#define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \
44 acpi_fwnode_handle(adev) : NULL)
Rafael J. Wysocki7b199812013-11-11 22:41:56 +010045#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
Marcin Wojtas7c6c57f2018-01-18 13:31:40 +010046#define ACPI_HANDLE_FWNODE(fwnode) \
47 acpi_device_handle(to_acpi_device_node(fwnode))
Rafael J. Wysocki7b199812013-11-11 22:41:56 +010048
Lorenzo Pieralisi027b25b2016-11-21 10:01:33 +000049static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
50{
51 struct fwnode_handle *fwnode;
52
53 fwnode = kzalloc(sizeof(struct fwnode_handle), GFP_KERNEL);
54 if (!fwnode)
55 return NULL;
56
Sakari Ailusdb3e50f2017-07-21 14:39:31 +030057 fwnode->ops = &acpi_static_fwnode_ops;
Lorenzo Pieralisi027b25b2016-11-21 10:01:33 +000058
59 return fwnode;
60}
61
62static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode)
63{
Sakari Ailusdb3e50f2017-07-21 14:39:31 +030064 if (WARN_ON(!is_acpi_static_node(fwnode)))
Lorenzo Pieralisi027b25b2016-11-21 10:01:33 +000065 return;
66
67 kfree(fwnode);
68}
69
Suthikulpanit, Suravee26095a02015-07-07 01:55:20 +020070/**
71 * ACPI_DEVICE_CLASS - macro used to describe an ACPI device with
72 * the PCI-defined class-code information
73 *
74 * @_cls : the class, subclass, prog-if triple for this device
75 * @_msk : the class mask for this device
76 *
77 * This macro is used to create a struct acpi_device_id that matches a
78 * specific PCI class. The .id and .driver_data fields will be left
79 * initialized with the default value.
80 */
81#define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (_cls), .cls_msk = (_msk),
82
Rafael J. Wysockica5b74d2015-03-16 23:49:08 +010083static inline bool has_acpi_companion(struct device *dev)
84{
Rafael J. Wysocki3a7a2ab2015-08-27 04:40:05 +020085 return is_acpi_device_node(dev->fwnode);
Rafael J. Wysockica5b74d2015-03-16 23:49:08 +010086}
87
Rafael J. Wysocki9c5ad362013-11-28 23:58:28 +010088static inline void acpi_preset_companion(struct device *dev,
89 struct acpi_device *parent, u64 addr)
90{
Alexey Dobriyanf8c6d142018-11-23 23:07:14 +030091 ACPI_COMPANION_SET(dev, acpi_find_child_device(parent, addr, false));
Rafael J. Wysocki9c5ad362013-11-28 23:58:28 +010092}
93
Jarkko Nikula45c42a72013-11-14 14:03:51 +020094static inline const char *acpi_dev_name(struct acpi_device *adev)
95{
96 return dev_name(&adev->dev);
97}
98
Lukas Wunnerdaae45c2016-07-28 02:25:41 +020099struct device *acpi_get_first_physical_node(struct acpi_device *adev);
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101enum acpi_irq_model_id {
102 ACPI_IRQ_MODEL_PIC = 0,
103 ACPI_IRQ_MODEL_IOAPIC,
104 ACPI_IRQ_MODEL_IOSAPIC,
John Keller3948ec92006-12-22 11:50:04 -0600105 ACPI_IRQ_MODEL_PLATFORM,
Hanjun Guofbe61ec2015-03-24 14:02:48 +0000106 ACPI_IRQ_MODEL_GIC,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 ACPI_IRQ_MODEL_COUNT
108};
109
110extern enum acpi_irq_model_id acpi_irq_model;
111
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112enum acpi_interrupt_id {
113 ACPI_INTERRUPT_PMI = 1,
114 ACPI_INTERRUPT_INIT,
115 ACPI_INTERRUPT_CPEI,
116 ACPI_INTERRUPT_COUNT
117};
118
119#define ACPI_SPACE_MEM 0
120
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121enum acpi_address_range_id {
122 ACPI_ADDRESS_RANGE_MEMORY = 1,
123 ACPI_ADDRESS_RANGE_RESERVED = 2,
124 ACPI_ADDRESS_RANGE_ACPI = 3,
125 ACPI_ADDRESS_RANGE_NVS = 4,
126 ACPI_ADDRESS_RANGE_COUNT
127};
128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130/* Table Handlers */
Keith Busch60574d12019-03-11 14:55:57 -0600131union acpi_subtable_headers {
132 struct acpi_subtable_header common;
Keith Busch3bc0e8e2019-03-11 14:55:58 -0600133 struct acpi_hmat_structure hmat;
Keith Busch60574d12019-03-11 14:55:57 -0600134};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
Lv Zhengb43e1062013-01-12 15:29:38 +0000136typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
Keith Busch60574d12019-03-11 14:55:57 -0600138typedef int (*acpi_tbl_entry_handler)(union acpi_subtable_headers *header,
Lv Zhengb43e1062013-01-12 15:29:38 +0000139 const unsigned long end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
Lv Zheng836d083012015-12-03 10:43:14 +0800141/* Debugger support */
142
143struct acpi_debugger_ops {
144 int (*create_thread)(acpi_osd_exec_callback function, void *context);
145 ssize_t (*write_log)(const char *msg);
146 ssize_t (*read_cmd)(char *buffer, size_t length);
147 int (*wait_command_ready)(bool single_step, char *buffer, size_t length);
148 int (*notify_command_complete)(void);
149};
150
151struct acpi_debugger {
152 const struct acpi_debugger_ops *ops;
153 struct module *owner;
154 struct mutex lock;
155};
156
157#ifdef CONFIG_ACPI_DEBUGGER
158int __init acpi_debugger_init(void);
159int acpi_register_debugger(struct module *owner,
160 const struct acpi_debugger_ops *ops);
161void acpi_unregister_debugger(const struct acpi_debugger_ops *ops);
162int acpi_debugger_create_thread(acpi_osd_exec_callback function, void *context);
163ssize_t acpi_debugger_write_log(const char *msg);
164ssize_t acpi_debugger_read_cmd(char *buffer, size_t buffer_length);
165int acpi_debugger_wait_command_ready(void);
166int acpi_debugger_notify_command_complete(void);
167#else
168static inline int acpi_debugger_init(void)
169{
170 return -ENODEV;
171}
172
173static inline int acpi_register_debugger(struct module *owner,
174 const struct acpi_debugger_ops *ops)
175{
176 return -ENODEV;
177}
178
179static inline void acpi_unregister_debugger(const struct acpi_debugger_ops *ops)
180{
181}
182
183static inline int acpi_debugger_create_thread(acpi_osd_exec_callback function,
184 void *context)
185{
186 return -ENODEV;
187}
188
189static inline int acpi_debugger_write_log(const char *msg)
190{
191 return -ENODEV;
192}
193
194static inline int acpi_debugger_read_cmd(char *buffer, u32 buffer_length)
195{
196 return -ENODEV;
197}
198
199static inline int acpi_debugger_wait_command_ready(void)
200{
201 return -ENODEV;
202}
203
204static inline int acpi_debugger_notify_command_complete(void)
205{
206 return -ENODEV;
207}
208#endif
209
Hanjun Guo328281b2014-02-19 00:23:57 +0800210#define BAD_MADT_ENTRY(entry, end) ( \
211 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \
212 ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
213
Lukasz Anaczkowski9b3fedd2015-09-09 15:47:28 +0200214struct acpi_subtable_proc {
215 int id;
216 acpi_tbl_entry_handler handler;
217 int count;
218};
219
Andy Shevchenko6c9a58e2017-07-18 18:04:17 +0300220void __iomem *__acpi_map_table(unsigned long phys, unsigned long size);
221void __acpi_unmap_table(void __iomem *map, unsigned long size);
Yinghai Lucbf9bd62008-02-19 03:21:06 -0800222int early_acpi_boot_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223int acpi_boot_init (void);
Len Brown8558e392010-01-06 16:11:06 -0500224void acpi_boot_table_init (void);
Yinghai Lu3c999f12008-06-20 16:11:20 -0700225int acpi_mps_check (void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226int acpi_numa_init (void);
227
228int acpi_table_init (void);
Lv Zhengb43e1062013-01-12 15:29:38 +0000229int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
Len Brown6eb87fe2007-02-10 22:17:07 -0500230int __init acpi_table_parse_entries(char *id, unsigned long table_size,
Lukasz Anaczkowski9b3fedd2015-09-09 15:47:28 +0200231 int entry_id,
232 acpi_tbl_entry_handler handler,
233 unsigned int max_entries);
Lukasz Anaczkowski9b3fedd2015-09-09 15:47:28 +0200234int __init acpi_table_parse_entries_array(char *id, unsigned long table_size,
235 struct acpi_subtable_proc *proc, int proc_num,
236 unsigned int max_entries);
Lv Zhengb43e1062013-01-12 15:29:38 +0000237int acpi_table_parse_madt(enum acpi_madt_type id,
238 acpi_tbl_entry_handler handler,
239 unsigned int max_entries);
Alexey Starikovskiyceb6c462007-02-02 19:48:22 +0300240int acpi_parse_mcfg (struct acpi_table_header *header);
Alexey Starikovskiy5f3b1a82007-02-02 19:48:22 +0300241void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242
Hanjun Guo4bac6fa2016-06-17 11:53:02 +0800243/* the following numa functions are architecture-dependent */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244void acpi_numa_slit_init (struct acpi_table_slit *slit);
Hanjun Guo4bac6fa2016-06-17 11:53:02 +0800245
246#if defined(CONFIG_X86) || defined(CONFIG_IA64)
Alexey Starikovskiy15a58ed2007-02-02 19:48:22 +0300247void acpi_numa_processor_affinity_init (struct acpi_srat_cpu_affinity *pa);
Hanjun Guo4bac6fa2016-06-17 11:53:02 +0800248#else
249static inline void
250acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa) { }
251#endif
252
Suresh Siddha7237d3d2009-03-30 13:55:30 -0800253void acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa);
Hanjun Guo4bac6fa2016-06-17 11:53:02 +0800254
255#ifdef CONFIG_ARM64
256void acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa);
257#else
258static inline void
259acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa) { }
260#endif
261
Thomas Renninger095adbb2012-07-31 17:41:09 +0200262int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
Catalin Marinas828aef32015-03-24 14:02:46 +0000264#ifndef PHYS_CPUID_INVALID
265typedef u32 phys_cpuid_t;
266#define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
267#endif
268
Hanjun Guo25956b62015-05-11 12:17:13 +0800269static inline bool invalid_logical_cpuid(u32 cpuid)
270{
271 return (int)cpuid < 0;
272}
273
Hanjun Guoddcc18f2015-05-13 16:19:30 +0800274static inline bool invalid_phys_cpuid(phys_cpuid_t phys_id)
275{
276 return phys_id == PHYS_CPUID_INVALID;
277}
278
Dou Liyangfd74da22016-08-25 16:35:20 +0800279/* Validate the processor object's proc_id */
Dou Liyanga77d6cd2017-03-03 16:02:27 +0800280bool acpi_duplicate_processor_id(int proc_id);
Dou Liyangfd74da22016-08-25 16:35:20 +0800281
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282#ifdef CONFIG_ACPI_HOTPLUG_CPU
283/* Arch dependent functions for cpu hotplug support */
Vitaly Kuznetsovfebf2402017-02-06 18:01:51 +0100284int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id,
285 int *pcpu);
Hanjun Guod02dc272015-01-04 18:55:03 +0800286int acpi_unmap_cpu(int cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287#endif /* CONFIG_ACPI_HOTPLUG_CPU */
288
Yinghai Luecf56362015-02-05 13:44:48 +0800289#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
290int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
291#endif
292
Kenji Kaneshigeb1bb2482005-04-28 00:25:58 -0700293int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
294int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
Jiang Liue89900c2014-10-27 13:21:47 +0800295int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base);
Len Brown5229e872008-02-06 01:26:55 -0500296void acpi_irq_stats_init(void);
Len Brown5229e872008-02-06 01:26:55 -0500297extern u32 acpi_irq_handled;
Len Brown88bea182009-04-21 00:35:47 -0400298extern u32 acpi_irq_not_handled;
Chen Yu49e4b8432015-10-25 01:02:19 +0800299extern unsigned int acpi_sci_irq;
Chen Yu13737182016-03-22 08:51:10 +0800300extern bool acpi_no_s5;
Chen Yu49e4b8432015-10-25 01:02:19 +0800301#define INVALID_ACPI_IRQ ((unsigned)-1)
302static inline bool acpi_sci_irq_valid(void)
303{
304 return acpi_sci_irq != INVALID_ACPI_IRQ;
305}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
Pavel Machekc255d842006-02-20 18:27:58 -0800307extern int sbf_port;
Pavel Machek77afcf72007-07-19 01:47:41 -0700308extern unsigned long acpi_realmode_flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
Yinghai Lua2f809b2009-04-27 18:01:20 -0700310int acpi_register_gsi (struct device *dev, u32 gsi, int triggering, int polarity);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
Eric W. Biederman2c2df842010-03-30 01:07:02 -0700312int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
Marc Zyngier2bc6eba2015-10-13 12:51:38 +0100314void acpi_set_irq_model(enum acpi_irq_model_id model,
315 struct fwnode_handle *fwnode);
316
Shaohua Li61fd47e2007-11-17 01:05:28 -0500317#ifdef CONFIG_X86_IO_APIC
Eric W. Biederman9a0a91b2010-03-30 01:07:03 -0700318extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity);
Shaohua Li61fd47e2007-11-17 01:05:28 -0500319#else
Eric W. Biederman9a0a91b2010-03-30 01:07:03 -0700320#define acpi_get_override_irq(gsi, trigger, polarity) (-1)
Shaohua Li61fd47e2007-11-17 01:05:28 -0500321#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322/*
323 * This function undoes the effect of one call to acpi_register_gsi().
324 * If this matches the last registration, any IRQ resources for gsi
325 * are freed.
326 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327void acpi_unregister_gsi (u32 gsi);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329struct pci_dev;
330
331int acpi_pci_irq_enable (struct pci_dev *dev);
David Shaohua Lic9c3e452005-04-01 00:07:31 -0500332void acpi_penalize_isa_irq(int irq, int active);
Jiang Liu5ebc7602015-09-17 14:02:45 +0800333bool acpi_isa_irq_available(int irq);
Sinan Kaya5d32a662018-12-19 22:46:56 +0000334#ifdef CONFIG_PCI
Sinan Kayaf1caa612016-10-24 00:31:31 -0400335void acpi_penalize_sci_irq(int irq, int trigger, int polarity);
Sinan Kaya5d32a662018-12-19 22:46:56 +0000336#else
337static inline void acpi_penalize_sci_irq(int irq, int trigger,
338 int polarity)
339{
340}
341#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342void acpi_pci_irq_disable (struct pci_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344extern int ec_read(u8 addr, u8 *val);
345extern int ec_write(u8 addr, u8 val);
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400346extern int ec_transaction(u8 command,
347 const u8 *wdata, unsigned wdata_len,
Thomas Renninger1cb7b1e2011-03-31 13:36:38 +0200348 u8 *rdata, unsigned rdata_len);
Seth Forshee3e2abc52012-01-18 13:44:08 -0600349extern acpi_handle ec_get_handle(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350
Zhang Ruieec15ed2014-05-30 04:23:01 +0200351extern bool acpi_is_pnp_device(struct acpi_device *);
352
Carlos Corbachobff431e2008-02-05 02:17:04 +0000353#if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE)
354
355typedef void (*wmi_notify_handler) (u32 value, void *context);
356
357extern acpi_status wmi_evaluate_method(const char *guid, u8 instance,
358 u32 method_id,
359 const struct acpi_buffer *in,
360 struct acpi_buffer *out);
361extern acpi_status wmi_query_block(const char *guid, u8 instance,
362 struct acpi_buffer *out);
363extern acpi_status wmi_set_block(const char *guid, u8 instance,
364 const struct acpi_buffer *in);
365extern acpi_status wmi_install_notify_handler(const char *guid,
366 wmi_notify_handler handler, void *data);
367extern acpi_status wmi_remove_notify_handler(const char *guid);
368extern acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out);
369extern bool wmi_has_guid(const char *guid);
370
371#endif /* CONFIG_ACPI_WMI */
372
Thomas Renningerc3d6de62008-08-01 17:37:55 +0200373#define ACPI_VIDEO_OUTPUT_SWITCHING 0x0001
374#define ACPI_VIDEO_DEVICE_POSTING 0x0002
375#define ACPI_VIDEO_ROM_AVAILABLE 0x0004
376#define ACPI_VIDEO_BACKLIGHT 0x0008
377#define ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR 0x0010
378#define ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO 0x0020
379#define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR 0x0040
380#define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO 0x0080
381#define ACPI_VIDEO_BACKLIGHT_DMI_VENDOR 0x0100
382#define ACPI_VIDEO_BACKLIGHT_DMI_VIDEO 0x0200
383#define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR 0x0400
384#define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO 0x0800
385
Hans de Goede14ca7a472015-06-16 16:27:47 +0200386extern char acpi_video_backlight_string[];
Toshi Kanid4e1a692013-03-04 21:30:41 +0000387extern long acpi_is_video_device(acpi_handle handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388extern int acpi_blacklisted(void);
Lin Mingd90aa922010-12-09 16:50:52 +0800389extern void acpi_osi_setup(char *str);
Hans de Goedea87878b2015-06-16 16:27:46 +0200390extern bool acpi_osi_is_win8(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392#ifdef CONFIG_ACPI_NUMA
Toshi Kani99759862015-06-19 17:14:15 -0600393int acpi_map_pxm_to_online_node(int pxm);
Dan Williams8fc5c732018-11-09 12:43:07 -0800394int acpi_map_pxm_to_node(int pxm);
Bjorn Helgaas486c79b2014-01-24 15:25:10 -0700395int acpi_get_node(acpi_handle handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396#else
Toshi Kani99759862015-06-19 17:14:15 -0600397static inline int acpi_map_pxm_to_online_node(int pxm)
398{
399 return 0;
400}
Dan Williams8fc5c732018-11-09 12:43:07 -0800401static inline int acpi_map_pxm_to_node(int pxm)
402{
403 return 0;
404}
Bjorn Helgaas486c79b2014-01-24 15:25:10 -0700405static inline int acpi_get_node(acpi_handle handle)
Yasunori Goto1e3590e2006-06-27 02:53:31 -0700406{
407 return 0;
408}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409#endif
Yasunori Goto1e3590e2006-06-27 02:53:31 -0700410extern int acpi_paddr_to_node(u64 start_addr, u64 size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411
412extern int pnpacpi_disabled;
413
David Rientjes3484d792007-07-21 17:10:32 +0200414#define PXM_INVAL (-1)
David Rientjes3484d792007-07-21 17:10:32 +0200415
Rafael J. Wysocki046d9ce2012-11-15 00:30:01 +0100416bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res);
417bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res);
418bool acpi_dev_resource_address_space(struct acpi_resource *ares,
Jiang Liua49170b2015-02-02 10:42:58 +0800419 struct resource_win *win);
Rafael J. Wysocki046d9ce2012-11-15 00:30:01 +0100420bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
Jiang Liua49170b2015-02-02 10:42:58 +0800421 struct resource_win *win);
Rafael J. Wysocki046d9ce2012-11-15 00:30:01 +0100422unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable);
Christophe RICARD55a93412015-12-23 23:25:33 +0100423unsigned int acpi_dev_get_irq_type(int triggering, int polarity);
Rafael J. Wysocki046d9ce2012-11-15 00:30:01 +0100424bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
425 struct resource *res);
426
Rafael J. Wysocki8e345c92012-11-15 00:30:21 +0100427void acpi_dev_free_resource_list(struct list_head *list);
428int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
429 int (*preproc)(struct acpi_resource *, void *),
430 void *preproc_data);
Lorenzo Pieralisic04ac672017-08-07 11:29:48 +0100431int acpi_dev_get_dma_resources(struct acpi_device *adev,
432 struct list_head *list);
Jiang Liu62d11412015-02-02 10:43:01 +0800433int acpi_dev_filter_resource_type(struct acpi_resource *ares,
434 unsigned long types);
435
436static inline int acpi_dev_filter_resource_type_cb(struct acpi_resource *ares,
437 void *arg)
438{
439 return acpi_dev_filter_resource_type(ares, (unsigned long)arg);
440}
Rafael J. Wysocki8e345c92012-11-15 00:30:21 +0100441
Bjorn Helgaas00710982016-11-30 14:47:13 -0600442struct acpi_device *acpi_resource_consumer(struct resource *res);
443
Jean Delvare876fba42009-11-11 15:22:15 +0100444int acpi_check_resource_conflict(const struct resource *res);
Thomas Renninger443dea72008-02-04 23:31:23 -0800445
Thomas Renningerdf92e692008-02-04 23:31:22 -0800446int acpi_check_region(resource_size_t start, resource_size_t n,
447 const char *name);
Thomas Renningerdf92e692008-02-04 23:31:22 -0800448
Heikki Krogerusd2d2e3c2018-06-21 16:43:17 +0300449acpi_status acpi_release_memory(acpi_handle handle, struct resource *res,
450 u32 level);
451
Jean Delvare70dd6be2010-05-27 19:58:37 +0200452int acpi_resources_are_enforced(void);
453
Yuanhan Liu9743fde2012-10-26 13:39:24 +0200454#ifdef CONFIG_HIBERNATION
Shaohua Libdfe6b72008-07-23 21:28:41 -0700455void __init acpi_no_s4_hw_signature(void);
Yuanhan Liu9743fde2012-10-26 13:39:24 +0200456#endif
457
458#ifdef CONFIG_PM_SLEEP
Rafael J. Wysockid8f3de02008-06-12 23:24:06 +0200459void __init acpi_old_suspend_ordering(void);
Rafael J. Wysocki72ad5d72010-07-23 22:59:09 +0200460void __init acpi_nvs_nosave(void);
Kristen Carlson Accardi1bad2f12012-10-26 13:39:15 +0200461void __init acpi_nvs_nosave_s3(void);
Rafael J. Wysocki57044032017-11-15 02:16:55 +0100462void __init acpi_sleep_no_blacklist(void);
Rafael J. Wysockid8f3de02008-06-12 23:24:06 +0200463#endif /* CONFIG_PM_SLEEP */
Kenji Kaneshige9f5404d2009-02-09 16:00:04 +0900464
Shaohua Li70023de2009-10-29 11:04:28 +0800465struct acpi_osc_context {
Bjorn Helgaasc8678472013-09-05 15:05:55 -0600466 char *uuid_str; /* UUID string */
Shaohua Li70023de2009-10-29 11:04:28 +0800467 int rev;
Bjorn Helgaasc8678472013-09-05 15:05:55 -0600468 struct acpi_buffer cap; /* list of DWORD capabilities */
469 struct acpi_buffer ret; /* free by caller if success */
Shaohua Li70023de2009-10-29 11:04:28 +0800470};
471
Shaohua Li70023de2009-10-29 11:04:28 +0800472acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);
473
Bjorn Helgaasb938a222013-09-05 15:05:54 -0600474/* Indexes into _OSC Capabilities Buffer (DWORDs 2 & 3 are device-specific) */
475#define OSC_QUERY_DWORD 0 /* DWORD 1 */
476#define OSC_SUPPORT_DWORD 1 /* DWORD 2 */
477#define OSC_CONTROL_DWORD 2 /* DWORD 3 */
Kenji Kaneshige9f5404d2009-02-09 16:00:04 +0900478
Bjorn Helgaasdedf1e42013-09-05 15:05:53 -0600479/* _OSC Capabilities DWORD 1: Query/Control and Error Returns (generic) */
480#define OSC_QUERY_ENABLE 0x00000001 /* input */
481#define OSC_REQUEST_ERROR 0x00000002 /* return */
482#define OSC_INVALID_UUID_ERROR 0x00000004 /* return */
483#define OSC_INVALID_REVISION_ERROR 0x00000008 /* return */
484#define OSC_CAPABILITIES_MASK_ERROR 0x00000010 /* return */
Kenji Kaneshige9f5404d2009-02-09 16:00:04 +0900485
Bjorn Helgaasdedf1e42013-09-05 15:05:53 -0600486/* Platform-Wide Capabilities _OSC: Capabilities DWORD 2: Support Field */
487#define OSC_SB_PAD_SUPPORT 0x00000001
488#define OSC_SB_PPC_OST_SUPPORT 0x00000002
489#define OSC_SB_PR3_SUPPORT 0x00000004
490#define OSC_SB_HOTPLUG_OST_SUPPORT 0x00000008
491#define OSC_SB_APEI_SUPPORT 0x00000010
492#define OSC_SB_CPC_SUPPORT 0x00000020
Sudeep Hollaa36a7fe2016-07-21 17:18:07 +0100493#define OSC_SB_CPCV2_SUPPORT 0x00000040
494#define OSC_SB_PCLPI_SUPPORT 0x00000080
495#define OSC_SB_OSLPI_SUPPORT 0x00000100
Srinivas Pandruvada8b533a02016-11-22 12:23:59 -0800496#define OSC_SB_CPC_DIVERSE_HIGH_SUPPORT 0x00001000
Shaohua Li3563ff92009-10-29 11:05:05 +0800497
Huang Yingeccddd32011-07-13 13:14:20 +0800498extern bool osc_sb_apei_support_acked;
Sudeep Hollaa36a7fe2016-07-21 17:18:07 +0100499extern bool osc_pc_lpi_support_confirmed;
Huang Yingeccddd32011-07-13 13:14:20 +0800500
Bjorn Helgaasdedf1e42013-09-05 15:05:53 -0600501/* PCI Host Bridge _OSC: Capabilities DWORD 2: Support Field */
Bjorn Helgaas7dab9ef2013-09-05 15:07:39 -0600502#define OSC_PCI_EXT_CONFIG_SUPPORT 0x00000001
503#define OSC_PCI_ASPM_SUPPORT 0x00000002
504#define OSC_PCI_CLOCK_PM_SUPPORT 0x00000004
Bjorn Helgaasdedf1e42013-09-05 15:05:53 -0600505#define OSC_PCI_SEGMENT_GROUPS_SUPPORT 0x00000008
Bjorn Helgaas7dab9ef2013-09-05 15:07:39 -0600506#define OSC_PCI_MSI_SUPPORT 0x00000010
Alexandru Gagniucba11edc2019-03-15 14:29:40 -0500507#define OSC_PCI_HPX_TYPE_3_SUPPORT 0x00000100
508#define OSC_PCI_SUPPORT_MASKS 0x0000011f
Kenji Kaneshige9f5404d2009-02-09 16:00:04 +0900509
Bjorn Helgaasdedf1e42013-09-05 15:05:53 -0600510/* PCI Host Bridge _OSC: Capabilities DWORD 3: Control Field */
511#define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL 0x00000001
Bjorn Helgaas7dab9ef2013-09-05 15:07:39 -0600512#define OSC_PCI_SHPC_NATIVE_HP_CONTROL 0x00000002
Bjorn Helgaasdedf1e42013-09-05 15:05:53 -0600513#define OSC_PCI_EXPRESS_PME_CONTROL 0x00000004
514#define OSC_PCI_EXPRESS_AER_CONTROL 0x00000008
Bjorn Helgaas7dab9ef2013-09-05 15:07:39 -0600515#define OSC_PCI_EXPRESS_CAPABILITY_CONTROL 0x00000010
Bjorn Helgaasaf8bb9f2018-04-17 10:58:09 -0500516#define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020
517#define OSC_PCI_CONTROL_MASKS 0x0000003f
Rafael J. Wysockid90116e2011-11-06 23:11:28 +0100518
Lan Tianyu5d98e612014-05-20 20:59:23 +0800519#define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002
520#define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004
521#define ACPI_GSB_ACCESS_ATTRIB_BYTE 0x00000006
522#define ACPI_GSB_ACCESS_ATTRIB_WORD 0x00000008
523#define ACPI_GSB_ACCESS_ATTRIB_BLOCK 0x0000000A
524#define ACPI_GSB_ACCESS_ATTRIB_MULTIBYTE 0x0000000B
525#define ACPI_GSB_ACCESS_ATTRIB_WORD_CALL 0x0000000C
526#define ACPI_GSB_ACCESS_ATTRIB_BLOCK_CALL 0x0000000D
527#define ACPI_GSB_ACCESS_ATTRIB_RAW_BYTES 0x0000000E
528#define ACPI_GSB_ACCESS_ATTRIB_RAW_PROCESS 0x0000000F
529
Rafael J. Wysocki75fb60f2010-08-23 23:53:11 +0200530extern acpi_status acpi_pci_osc_control_set(acpi_handle handle,
531 u32 *mask, u32 req);
Toshi Kani275c58d2012-05-23 20:25:19 -0600532
533/* Enable _OST when all relevant hotplug operations are enabled */
534#if defined(CONFIG_ACPI_HOTPLUG_CPU) && \
Toshi Kani08f502c2013-06-18 15:06:45 -0600535 defined(CONFIG_ACPI_HOTPLUG_MEMORY) && \
Toshi Kani64fd7402013-02-11 22:33:20 +0000536 defined(CONFIG_ACPI_CONTAINER)
Toshi Kani275c58d2012-05-23 20:25:19 -0600537#define ACPI_HOTPLUG_OST
538#endif
539
540/* _OST Source Event Code (OSPM Action) */
541#define ACPI_OST_EC_OSPM_SHUTDOWN 0x100
542#define ACPI_OST_EC_OSPM_EJECT 0x103
543#define ACPI_OST_EC_OSPM_INSERTION 0x200
544
545/* _OST General Processing Status Code */
546#define ACPI_OST_SC_SUCCESS 0x0
547#define ACPI_OST_SC_NON_SPECIFIC_FAILURE 0x1
548#define ACPI_OST_SC_UNRECOGNIZED_NOTIFY 0x2
549
550/* _OST OS Shutdown Processing (0x100) Status Code */
551#define ACPI_OST_SC_OS_SHUTDOWN_DENIED 0x80
552#define ACPI_OST_SC_OS_SHUTDOWN_IN_PROGRESS 0x81
553#define ACPI_OST_SC_OS_SHUTDOWN_COMPLETED 0x82
554#define ACPI_OST_SC_OS_SHUTDOWN_NOT_SUPPORTED 0x83
555
556/* _OST Ejection Request (0x3, 0x103) Status Code */
557#define ACPI_OST_SC_EJECT_NOT_SUPPORTED 0x80
558#define ACPI_OST_SC_DEVICE_IN_USE 0x81
559#define ACPI_OST_SC_DEVICE_BUSY 0x82
560#define ACPI_OST_SC_EJECT_DEPENDENCY_BUSY 0x83
561#define ACPI_OST_SC_EJECT_IN_PROGRESS 0x84
562
563/* _OST Insertion Request (0x200) Status Code */
564#define ACPI_OST_SC_INSERT_IN_PROGRESS 0x80
565#define ACPI_OST_SC_DRIVER_LOAD_FAILURE 0x81
566#define ACPI_OST_SC_INSERT_NOT_SUPPORTED 0x82
567
Toshi Kani5aa59112017-08-23 16:54:43 -0600568enum acpi_predicate {
569 all_versions,
570 less_than_or_equal,
571 equal,
572 greater_than_or_equal,
573};
574
575/* Table must be terminted by a NULL entry */
576struct acpi_platform_list {
577 char oem_id[ACPI_OEM_ID_SIZE+1];
578 char oem_table_id[ACPI_OEM_TABLE_ID_SIZE+1];
579 u32 oem_revision;
580 char *table;
581 enum acpi_predicate pred;
582 char *reason;
583 u32 data;
584};
585int acpi_match_platform_list(const struct acpi_platform_list *plat);
586
Len Brown4a7a16d2009-06-12 20:42:08 -0400587extern void acpi_early_init(void);
Rafael J. Wysockib064a8f2015-06-10 01:33:36 +0200588extern void acpi_subsystem_init(void);
Mathieu Malaterre63fab692018-05-05 22:36:03 +0200589extern void arch_post_acpi_subsys_init(void);
Len Brown4a7a16d2009-06-12 20:42:08 -0400590
Huang Yingb54ac6d2011-12-08 11:25:49 +0800591extern int acpi_nvs_register(__u64 start, __u64 size);
592
593extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
594 void *data);
595
Mika Westerbergcf761af2012-10-31 22:44:41 +0100596const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
597 const struct device *dev);
598
Andy Shevchenko67dcc262018-02-09 17:38:36 +0200599const void *acpi_device_get_match_data(const struct device *dev);
Mika Westerberg733e6252014-10-21 13:33:56 +0200600extern bool acpi_driver_match_device(struct device *dev,
601 const struct device_driver *drv);
Zhang Rui6eb24512014-01-14 16:46:36 +0800602int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *);
603int acpi_device_modalias(struct device *, char *, int);
Lan Tianyu40e7fcb2014-11-23 21:22:54 +0800604void acpi_walk_dep_device_list(acpi_handle handle);
Zhang Rui6eb24512014-01-14 16:46:36 +0800605
Heikki Krogerus15718752016-11-03 16:21:26 +0200606struct platform_device *acpi_create_platform_device(struct acpi_device *,
607 struct property_entry *);
Mika Westerbergcf761af2012-10-31 22:44:41 +0100608#define ACPI_PTR(_ptr) (_ptr)
609
Octavian Purdila10c7e202016-07-08 19:13:08 +0300610static inline void acpi_device_set_enumerated(struct acpi_device *adev)
611{
612 adev->flags.visited = true;
613}
614
615static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
616{
617 adev->flags.visited = false;
618}
619
Octavian Purdila68bdb672016-07-08 19:13:09 +0300620enum acpi_reconfig_event {
621 ACPI_RECONFIG_DEVICE_ADD = 0,
622 ACPI_RECONFIG_DEVICE_REMOVE,
623};
624
625int acpi_reconfig_notifier_register(struct notifier_block *nb);
626int acpi_reconfig_notifier_unregister(struct notifier_block *nb);
627
Fu Wei5f1ae4e2017-04-01 01:51:01 +0800628#ifdef CONFIG_ACPI_GTDT
629int acpi_gtdt_init(struct acpi_table_header *table, int *platform_timer_count);
630int acpi_gtdt_map_ppi(int type);
631bool acpi_gtdt_c3stop(int type);
Fu Weia712c3e2017-04-01 01:51:03 +0800632int acpi_arch_timer_mem_init(struct arch_timer_mem *timer_mem, int *timer_count);
Fu Wei5f1ae4e2017-04-01 01:51:01 +0800633#endif
634
Juergen Grossdfc93272018-02-19 11:09:04 +0100635#ifndef ACPI_HAVE_ARCH_GET_ROOT_POINTER
636static inline u64 acpi_arch_get_root_pointer(void)
637{
638 return 0;
639}
640#endif
641
Feng Tange55a5992009-07-28 17:41:53 +0800642#else /* !CONFIG_ACPI */
643
644#define acpi_disabled 1
645
Rafael J. Wysocki7b199812013-11-11 22:41:56 +0100646#define ACPI_COMPANION(dev) (NULL)
647#define ACPI_COMPANION_SET(dev, adev) do { } while (0)
648#define ACPI_HANDLE(dev) (NULL)
Marcin Wojtas7c6c57f2018-01-18 13:31:40 +0100649#define ACPI_HANDLE_FWNODE(fwnode) (NULL)
Suthikulpanit, Suravee26095a02015-07-07 01:55:20 +0200650#define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (0), .cls_msk = (0),
Rafael J. Wysocki7b199812013-11-11 22:41:56 +0100651
Rafael J. Wysocki8a0662d2014-11-04 14:03:59 +0100652struct fwnode_handle;
653
Kejian Yan6eb17e02016-06-03 10:55:09 +0800654static inline bool acpi_dev_found(const char *hid)
655{
656 return false;
657}
658
Hans de Goede86614232017-04-19 14:02:08 +0200659static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
660{
661 return false;
662}
663
Andy Shevchenko817b4d62019-03-18 23:00:54 +0300664static inline struct acpi_device *
665acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
666{
667 return NULL;
668}
669
YueHaibingfe066622019-04-12 23:19:11 +0800670static inline void acpi_dev_put(struct acpi_device *adev) {}
671
Rafael J. Wysocki8a0662d2014-11-04 14:03:59 +0100672static inline bool is_acpi_node(struct fwnode_handle *fwnode)
673{
674 return false;
675}
676
Rafael J. Wysocki3a7a2ab2015-08-27 04:40:05 +0200677static inline bool is_acpi_device_node(struct fwnode_handle *fwnode)
678{
679 return false;
680}
681
682static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
683{
684 return NULL;
685}
686
687static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
688{
689 return false;
690}
691
692static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
Rafael J. Wysocki8a0662d2014-11-04 14:03:59 +0100693{
694 return NULL;
695}
696
Adam Thomson613e9722016-06-21 18:50:20 +0100697static inline bool acpi_data_node_match(struct fwnode_handle *fwnode,
698 const char *name)
699{
700 return false;
701}
702
Rafael J. Wysocki8a0662d2014-11-04 14:03:59 +0100703static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
704{
705 return NULL;
706}
707
Rafael J. Wysockica5b74d2015-03-16 23:49:08 +0100708static inline bool has_acpi_companion(struct device *dev)
709{
710 return false;
711}
712
Dustin Byfordc0e5c442015-10-23 12:27:06 -0700713static inline void acpi_preset_companion(struct device *dev,
714 struct acpi_device *parent, u64 addr)
715{
716}
717
Jarkko Nikula45c42a72013-11-14 14:03:51 +0200718static inline const char *acpi_dev_name(struct acpi_device *adev)
719{
720 return NULL;
721}
722
Lukas Wunnerdaae45c2016-07-28 02:25:41 +0200723static inline struct device *acpi_get_first_physical_node(struct acpi_device *adev)
724{
725 return NULL;
726}
727
Len Brown4a7a16d2009-06-12 20:42:08 -0400728static inline void acpi_early_init(void) { }
Rafael J. Wysockib064a8f2015-06-10 01:33:36 +0200729static inline void acpi_subsystem_init(void) { }
Andrew Morton53de49f2005-07-30 04:18:00 -0400730
Yinghai Lucbf9bd62008-02-19 03:21:06 -0800731static inline int early_acpi_boot_init(void)
732{
733 return 0;
734}
Andrew Morton53de49f2005-07-30 04:18:00 -0400735static inline int acpi_boot_init(void)
736{
737 return 0;
738}
739
Len Brown8558e392010-01-06 16:11:06 -0500740static inline void acpi_boot_table_init(void)
Andrew Morton53de49f2005-07-30 04:18:00 -0400741{
Len Brown8558e392010-01-06 16:11:06 -0500742 return;
Andrew Morton53de49f2005-07-30 04:18:00 -0400743}
744
Yinghai Lu3c999f12008-06-20 16:11:20 -0700745static inline int acpi_mps_check(void)
746{
747 return 0;
748}
749
Thomas Renninger443dea72008-02-04 23:31:23 -0800750static inline int acpi_check_resource_conflict(struct resource *res)
751{
752 return 0;
753}
754
Thomas Renningerdf92e692008-02-04 23:31:22 -0800755static inline int acpi_check_region(resource_size_t start, resource_size_t n,
756 const char *name)
757{
758 return 0;
759}
760
Feng Tange55a5992009-07-28 17:41:53 +0800761struct acpi_table_header;
762static inline int acpi_table_parse(char *id,
763 int (*handler)(struct acpi_table_header *))
764{
tangchenf8a571b2014-01-06 16:47:59 +0800765 return -ENODEV;
Feng Tange55a5992009-07-28 17:41:53 +0800766}
Rafael J. Wysocki6fed05c2011-01-12 22:03:20 +0100767
Huang Yingb54ac6d2011-12-08 11:25:49 +0800768static inline int acpi_nvs_register(__u64 start, __u64 size)
Rafael J. Wysocki6fed05c2011-01-12 22:03:20 +0100769{
770 return 0;
771}
Huang Yingb54ac6d2011-12-08 11:25:49 +0800772
773static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
774 void *data)
775{
776 return 0;
777}
778
Mika Westerbergcf761af2012-10-31 22:44:41 +0100779struct acpi_device_id;
780
781static inline const struct acpi_device_id *acpi_match_device(
782 const struct acpi_device_id *ids, const struct device *dev)
783{
784 return NULL;
785}
786
Andy Shevchenko67dcc262018-02-09 17:38:36 +0200787static inline const void *acpi_device_get_match_data(const struct device *dev)
Sinan Kaya80212a12017-12-13 02:20:48 -0500788{
789 return NULL;
790}
791
Mika Westerbergcf761af2012-10-31 22:44:41 +0100792static inline bool acpi_driver_match_device(struct device *dev,
793 const struct device_driver *drv)
794{
795 return false;
796}
797
Kejian Yan4ae39922016-06-03 10:55:10 +0800798static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,
Andy Shevchenko94116f82017-06-05 19:40:46 +0300799 const guid_t *guid,
Kejian Yan4ae39922016-06-03 10:55:10 +0800800 int rev, int func,
801 union acpi_object *argv4)
802{
803 return NULL;
804}
805
Zhang Rui6eb24512014-01-14 16:46:36 +0800806static inline int acpi_device_uevent_modalias(struct device *dev,
807 struct kobj_uevent_env *env)
808{
809 return -ENODEV;
810}
811
812static inline int acpi_device_modalias(struct device *dev,
813 char *buf, int size)
814{
815 return -ENODEV;
816}
817
Suthikulpanit, Suraveeb84f1962015-10-28 15:50:48 -0700818static inline bool acpi_dma_supported(struct acpi_device *adev)
Suthikulpanit, Suraveed0562672015-06-10 11:08:52 -0500819{
820 return false;
821}
822
Suthikulpanit, Suraveeb84f1962015-10-28 15:50:48 -0700823static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
824{
825 return DEV_DMA_NOT_SUPPORTED;
826}
827
Lorenzo Pieralisic04ac672017-08-07 11:29:48 +0100828static inline int acpi_dma_get_range(struct device *dev, u64 *dma_addr,
829 u64 *offset, u64 *size)
830{
831 return -ENODEV;
832}
833
Sricharan R5a1bb632017-04-10 16:51:03 +0530834static inline int acpi_dma_configure(struct device *dev,
835 enum dev_dma_attr attr)
836{
837 return 0;
838}
Lorenzo Pieralisid760a1b2016-11-21 10:01:39 +0000839
Mika Westerbergcf761af2012-10-31 22:44:41 +0100840#define ACPI_PTR(_ptr) (NULL)
841
Octavian Purdila10c7e202016-07-08 19:13:08 +0300842static inline void acpi_device_set_enumerated(struct acpi_device *adev)
843{
844}
845
846static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
847{
848}
849
Octavian Purdila68bdb672016-07-08 19:13:09 +0300850static inline int acpi_reconfig_notifier_register(struct notifier_block *nb)
851{
852 return -EINVAL;
853}
854
855static inline int acpi_reconfig_notifier_unregister(struct notifier_block *nb)
856{
857 return -EINVAL;
858}
859
Bjorn Helgaas00710982016-11-30 14:47:13 -0600860static inline struct acpi_device *acpi_resource_consumer(struct resource *res)
861{
862 return NULL;
863}
864
Huang Yingb54ac6d2011-12-08 11:25:49 +0800865#endif /* !CONFIG_ACPI */
Rafael J. Wysocki6fed05c2011-01-12 22:03:20 +0100866
Rui Wangfe7bd582016-08-17 16:00:33 +0800867#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
868int acpi_ioapic_add(acpi_handle root);
869#else
870static inline int acpi_ioapic_add(acpi_handle root) { return 0; }
871#endif
872
Tang Liang09f98a82011-12-09 10:05:54 +0800873#ifdef CONFIG_ACPI
874void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
875 u32 pm1a_ctrl, u32 pm1b_ctrl));
876
877acpi_status acpi_os_prepare_sleep(u8 sleep_state,
878 u32 pm1a_control, u32 pm1b_control);
Ben Guthrod6b47b12013-07-30 08:24:52 -0400879
880void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
881 u32 val_a, u32 val_b));
882
883acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state,
884 u32 val_a, u32 val_b);
885
Luck, Tony385ddea2012-10-05 15:05:34 -0700886#ifdef CONFIG_X86
Thomas Renninger8e305242012-10-01 00:23:53 +0200887void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
888#else
889static inline void arch_reserve_mem_area(acpi_physical_address addr,
890 size_t size)
891{
892}
893#endif /* CONFIG_X86 */
Tang Liang09f98a82011-12-09 10:05:54 +0800894#else
895#define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
896#endif
897
Rafael J. Wysocki5de21bb92014-11-27 22:38:23 +0100898#if defined(CONFIG_ACPI) && defined(CONFIG_PM)
Rafael J. Wysockicbe25ce2017-10-14 17:43:15 +0200899int acpi_dev_suspend(struct device *dev, bool wakeup);
Rafael J. Wysocki63705c42017-10-10 18:49:22 +0200900int acpi_dev_resume(struct device *dev);
Rafael J. Wysockie5cc8ef2012-11-02 01:41:01 +0100901int acpi_subsys_runtime_suspend(struct device *dev);
902int acpi_subsys_runtime_resume(struct device *dev);
Rafael J. Wysocki5de21bb92014-11-27 22:38:23 +0100903int acpi_dev_pm_attach(struct device *dev, bool power_on);
Rafael J. Wysockie5cc8ef2012-11-02 01:41:01 +0100904#else
905static inline int acpi_dev_runtime_suspend(struct device *dev) { return 0; }
906static inline int acpi_dev_runtime_resume(struct device *dev) { return 0; }
907static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; }
908static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; }
Rafael J. Wysocki5de21bb92014-11-27 22:38:23 +0100909static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
910{
Ulf Hansson919b7302018-05-09 12:17:52 +0200911 return 0;
Rafael J. Wysocki5de21bb92014-11-27 22:38:23 +0100912}
Rafael J. Wysockie5cc8ef2012-11-02 01:41:01 +0100913#endif
914
Rafael J. Wysockid79beb392013-01-19 14:29:31 +0100915#if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
Rafael J. Wysockie5cc8ef2012-11-02 01:41:01 +0100916int acpi_dev_suspend_late(struct device *dev);
Rafael J. Wysockie5cc8ef2012-11-02 01:41:01 +0100917int acpi_subsys_prepare(struct device *dev);
Heikki Krogerus4cf563c2014-05-15 16:40:23 +0300918void acpi_subsys_complete(struct device *dev);
Rafael J. Wysockie5cc8ef2012-11-02 01:41:01 +0100919int acpi_subsys_suspend_late(struct device *dev);
Rafael J. Wysocki05087362017-10-27 10:10:16 +0200920int acpi_subsys_suspend_noirq(struct device *dev);
921int acpi_subsys_resume_noirq(struct device *dev);
Rafael J. Wysockie5cc8ef2012-11-02 01:41:01 +0100922int acpi_subsys_resume_early(struct device *dev);
Heikki Krogerus4cf563c2014-05-15 16:40:23 +0300923int acpi_subsys_suspend(struct device *dev);
924int acpi_subsys_freeze(struct device *dev);
Rafael J. Wysocki05087362017-10-27 10:10:16 +0200925int acpi_subsys_freeze_late(struct device *dev);
926int acpi_subsys_freeze_noirq(struct device *dev);
927int acpi_subsys_thaw_noirq(struct device *dev);
Rafael J. Wysockie5cc8ef2012-11-02 01:41:01 +0100928#else
Rafael J. Wysockie5cc8ef2012-11-02 01:41:01 +0100929static inline int acpi_dev_resume_early(struct device *dev) { return 0; }
930static inline int acpi_subsys_prepare(struct device *dev) { return 0; }
Heikki Krogerus4cf563c2014-05-15 16:40:23 +0300931static inline void acpi_subsys_complete(struct device *dev) {}
Rafael J. Wysockie5cc8ef2012-11-02 01:41:01 +0100932static inline int acpi_subsys_suspend_late(struct device *dev) { return 0; }
Rafael J. Wysocki05087362017-10-27 10:10:16 +0200933static inline int acpi_subsys_suspend_noirq(struct device *dev) { return 0; }
934static inline int acpi_subsys_resume_noirq(struct device *dev) { return 0; }
Rafael J. Wysockie5cc8ef2012-11-02 01:41:01 +0100935static inline int acpi_subsys_resume_early(struct device *dev) { return 0; }
Heikki Krogerus4cf563c2014-05-15 16:40:23 +0300936static inline int acpi_subsys_suspend(struct device *dev) { return 0; }
937static inline int acpi_subsys_freeze(struct device *dev) { return 0; }
Rafael J. Wysocki05087362017-10-27 10:10:16 +0200938static inline int acpi_subsys_freeze_late(struct device *dev) { return 0; }
939static inline int acpi_subsys_freeze_noirq(struct device *dev) { return 0; }
940static inline int acpi_subsys_thaw_noirq(struct device *dev) { return 0; }
Rafael J. Wysockie5cc8ef2012-11-02 01:41:01 +0100941#endif
942
Toshi Kanifbfddae2012-11-21 01:36:28 +0000943#ifdef CONFIG_ACPI
944__printf(3, 4)
945void acpi_handle_printk(const char *level, acpi_handle handle,
946 const char *fmt, ...);
947#else /* !CONFIG_ACPI */
948static inline __printf(3, 4) void
949acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {}
950#endif /* !CONFIG_ACPI */
951
Bjørn Mork45fef5b2014-05-22 12:47:47 +0200952#if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
953__printf(3, 4)
954void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
Bjørn Mork45fef5b2014-05-22 12:47:47 +0200955#endif
956
Toshi Kanifbfddae2012-11-21 01:36:28 +0000957/*
958 * acpi_handle_<level>: Print message with ACPI prefix and object path
959 *
960 * These interfaces acquire the global namespace mutex to obtain an object
961 * path. In interrupt context, it shows the object path as <n/a>.
962 */
963#define acpi_handle_emerg(handle, fmt, ...) \
964 acpi_handle_printk(KERN_EMERG, handle, fmt, ##__VA_ARGS__)
965#define acpi_handle_alert(handle, fmt, ...) \
966 acpi_handle_printk(KERN_ALERT, handle, fmt, ##__VA_ARGS__)
967#define acpi_handle_crit(handle, fmt, ...) \
968 acpi_handle_printk(KERN_CRIT, handle, fmt, ##__VA_ARGS__)
969#define acpi_handle_err(handle, fmt, ...) \
970 acpi_handle_printk(KERN_ERR, handle, fmt, ##__VA_ARGS__)
971#define acpi_handle_warn(handle, fmt, ...) \
972 acpi_handle_printk(KERN_WARNING, handle, fmt, ##__VA_ARGS__)
973#define acpi_handle_notice(handle, fmt, ...) \
974 acpi_handle_printk(KERN_NOTICE, handle, fmt, ##__VA_ARGS__)
975#define acpi_handle_info(handle, fmt, ...) \
976 acpi_handle_printk(KERN_INFO, handle, fmt, ##__VA_ARGS__)
977
Bjørn Mork45fef5b2014-05-22 12:47:47 +0200978#if defined(DEBUG)
Toshi Kanifbfddae2012-11-21 01:36:28 +0000979#define acpi_handle_debug(handle, fmt, ...) \
980 acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__)
981#else
Bjørn Mork45fef5b2014-05-22 12:47:47 +0200982#if defined(CONFIG_DYNAMIC_DEBUG)
983#define acpi_handle_debug(handle, fmt, ...) \
Rasmus Villemoesf1ebe042019-03-07 16:28:10 -0800984 _dynamic_func_call(fmt, __acpi_handle_debug, \
985 handle, pr_fmt(fmt), ##__VA_ARGS__)
Bjørn Mork45fef5b2014-05-22 12:47:47 +0200986#else
Toshi Kanifbfddae2012-11-21 01:36:28 +0000987#define acpi_handle_debug(handle, fmt, ...) \
988({ \
989 if (0) \
990 acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__); \
991 0; \
992})
993#endif
Bjørn Mork45fef5b2014-05-22 12:47:47 +0200994#endif
Toshi Kanifbfddae2012-11-21 01:36:28 +0000995
Rafael J. Wysockif028d522014-11-03 23:39:41 +0100996struct acpi_gpio_params {
997 unsigned int crs_entry_index;
998 unsigned int line_index;
999 bool active_low;
1000};
1001
1002struct acpi_gpio_mapping {
1003 const char *name;
1004 const struct acpi_gpio_params *data;
1005 unsigned int size;
Andy Shevchenko1b2ca322017-11-10 15:40:33 +02001006
1007/* Ignore IoRestriction field */
1008#define ACPI_GPIO_QUIRK_NO_IO_RESTRICTION BIT(0)
Andy Shevchenko4d1f7a62019-02-06 22:49:46 +02001009/*
1010 * When ACPI GPIO mapping table is in use the index parameter inside it
1011 * refers to the GPIO resource in _CRS method. That index has no
1012 * distinction of actual type of the resource. When consumer wants to
1013 * get GpioIo type explicitly, this quirk may be used.
1014 */
1015#define ACPI_GPIO_QUIRK_ONLY_GPIOIO BIT(1)
Andy Shevchenko1b2ca322017-11-10 15:40:33 +02001016
Andy Shevchenkoce0929d2017-11-10 15:40:32 +02001017 unsigned int quirks;
Rafael J. Wysockif028d522014-11-03 23:39:41 +01001018};
1019
1020#if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB)
1021int acpi_dev_add_driver_gpios(struct acpi_device *adev,
1022 const struct acpi_gpio_mapping *gpios);
1023
1024static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev)
1025{
1026 if (adev)
1027 adev->driver_gpios = NULL;
1028}
Mika Westerbergc884fbd2015-05-06 13:29:06 +03001029
Andy Shevchenko85c73d52017-03-02 15:48:05 +02001030int devm_acpi_dev_add_driver_gpios(struct device *dev,
1031 const struct acpi_gpio_mapping *gpios);
1032void devm_acpi_dev_remove_driver_gpios(struct device *dev);
1033
Andy Shevchenko25e3ef82017-05-23 20:03:24 +03001034bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
1035 struct acpi_resource_gpio **agpio);
Mika Westerbergc884fbd2015-05-06 13:29:06 +03001036int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index);
Rafael J. Wysockif028d522014-11-03 23:39:41 +01001037#else
1038static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
1039 const struct acpi_gpio_mapping *gpios)
1040{
1041 return -ENXIO;
1042}
1043static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev) {}
Mika Westerbergc884fbd2015-05-06 13:29:06 +03001044
Andy Shevchenko85c73d52017-03-02 15:48:05 +02001045static inline int devm_acpi_dev_add_driver_gpios(struct device *dev,
1046 const struct acpi_gpio_mapping *gpios)
1047{
1048 return -ENXIO;
1049}
1050static inline void devm_acpi_dev_remove_driver_gpios(struct device *dev) {}
1051
Andy Shevchenko25e3ef82017-05-23 20:03:24 +03001052static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
1053 struct acpi_resource_gpio **agpio)
1054{
1055 return false;
1056}
Mika Westerbergc884fbd2015-05-06 13:29:06 +03001057static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
1058{
1059 return -ENXIO;
1060}
Rafael J. Wysockif028d522014-11-03 23:39:41 +01001061#endif
1062
Mika Westerbergffdcd952014-10-21 13:33:55 +02001063/* Device properties */
1064
Mika Westerbergffdcd952014-10-21 13:33:55 +02001065#ifdef CONFIG_ACPI
Sakari Ailus99a85462017-07-21 14:39:34 +03001066int acpi_dev_get_property(const struct acpi_device *adev, const char *name,
Mika Westerbergffdcd952014-10-21 13:33:55 +02001067 acpi_object_type type, const union acpi_object **obj);
Sakari Ailus99a85462017-07-21 14:39:34 +03001068int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
Mika Westerbergb60e4ea2016-09-29 16:39:41 +03001069 const char *name, size_t index, size_t num_args,
Sakari Ailus977d5ad2018-07-17 17:19:11 +03001070 struct fwnode_reference_args *args);
Mika Westerbergb60e4ea2016-09-29 16:39:41 +03001071
Sakari Ailus99a85462017-07-21 14:39:34 +03001072static inline int acpi_node_get_property_reference(
1073 const struct fwnode_handle *fwnode,
Mika Westerbergb60e4ea2016-09-29 16:39:41 +03001074 const char *name, size_t index,
Sakari Ailus977d5ad2018-07-17 17:19:11 +03001075 struct fwnode_reference_args *args)
Mika Westerbergb60e4ea2016-09-29 16:39:41 +03001076{
1077 return __acpi_node_get_property_reference(fwnode, name, index,
Sakari Ailus977d5ad2018-07-17 17:19:11 +03001078 NR_FWNODE_REFERENCE_ARGS, args);
Mika Westerbergb60e4ea2016-09-29 16:39:41 +03001079}
Rafael J. Wysockib31384f2014-11-04 01:28:56 +01001080
Mika Westerberg5f5e4892018-09-27 16:57:05 -05001081static inline bool acpi_dev_has_props(const struct acpi_device *adev)
1082{
1083 return !list_empty(&adev->data.properties);
1084}
1085
1086struct acpi_device_properties *
1087acpi_data_add_props(struct acpi_device_data *data, const guid_t *guid,
1088 const union acpi_object *properties);
1089
Sakari Ailus99a85462017-07-21 14:39:34 +03001090int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
Rafael J. Wysocki3a7a2ab2015-08-27 04:40:05 +02001091 void **valptr);
Sakari Ailus99a85462017-07-21 14:39:34 +03001092int acpi_dev_prop_read_single(struct acpi_device *adev,
1093 const char *propname, enum dev_prop_type proptype,
1094 void *val);
1095int acpi_node_prop_read(const struct fwnode_handle *fwnode,
1096 const char *propname, enum dev_prop_type proptype,
1097 void *val, size_t nval);
1098int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname,
Rafael J. Wysockib31384f2014-11-04 01:28:56 +01001099 enum dev_prop_type proptype, void *val, size_t nval);
Rafael J. Wysocki8a0662d2014-11-04 14:03:59 +01001100
Sakari Ailus37ba9832017-07-21 14:39:36 +03001101struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
Mika Westerberg34055192017-03-28 10:52:18 +03001102 struct fwnode_handle *child);
Sakari Ailus37ba9832017-07-21 14:39:36 +03001103struct fwnode_handle *acpi_node_get_parent(const struct fwnode_handle *fwnode);
Marc Zyngiere647b532015-09-28 15:49:12 +01001104
1105struct acpi_probe_entry;
1106typedef bool (*acpi_probe_entry_validate_subtbl)(struct acpi_subtable_header *,
1107 struct acpi_probe_entry *);
1108
1109#define ACPI_TABLE_ID_LEN 5
1110
1111/**
1112 * struct acpi_probe_entry - boot-time probing entry
1113 * @id: ACPI table name
1114 * @type: Optional subtable type to match
1115 * (if @id contains subtables)
1116 * @subtable_valid: Optional callback to check the validity of
1117 * the subtable
1118 * @probe_table: Callback to the driver being probed when table
1119 * match is successful
1120 * @probe_subtbl: Callback to the driver being probed when table and
1121 * subtable match (and optional callback is successful)
1122 * @driver_data: Sideband data provided back to the driver
1123 */
1124struct acpi_probe_entry {
1125 __u8 id[ACPI_TABLE_ID_LEN];
1126 __u8 type;
1127 acpi_probe_entry_validate_subtbl subtable_valid;
1128 union {
1129 acpi_tbl_table_handler probe_table;
1130 acpi_tbl_entry_handler probe_subtbl;
1131 };
1132 kernel_ulong_t driver_data;
1133};
1134
1135#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
1136 static const struct acpi_probe_entry __acpi_probe_##name \
1137 __used __section(__##table##_acpi_probe_table) \
1138 = { \
1139 .id = table_id, \
1140 .type = subtable, \
1141 .subtable_valid = valid, \
1142 .probe_table = (acpi_tbl_table_handler)fn, \
1143 .driver_data = data, \
1144 }
1145
1146#define ACPI_PROBE_TABLE(name) __##name##_acpi_probe_table
1147#define ACPI_PROBE_TABLE_END(name) __##name##_acpi_probe_table_end
1148
1149int __acpi_probe_device_table(struct acpi_probe_entry *start, int nr);
1150
1151#define acpi_probe_device_table(t) \
1152 ({ \
1153 extern struct acpi_probe_entry ACPI_PROBE_TABLE(t), \
1154 ACPI_PROBE_TABLE_END(t); \
1155 __acpi_probe_device_table(&ACPI_PROBE_TABLE(t), \
1156 (&ACPI_PROBE_TABLE_END(t) - \
1157 &ACPI_PROBE_TABLE(t))); \
1158 })
Mika Westerbergffdcd952014-10-21 13:33:55 +02001159#else
1160static inline int acpi_dev_get_property(struct acpi_device *adev,
1161 const char *name, acpi_object_type type,
1162 const union acpi_object **obj)
1163{
1164 return -ENXIO;
1165}
Rafael J. Wysocki3a7a2ab2015-08-27 04:40:05 +02001166
Mika Westerbergb60e4ea2016-09-29 16:39:41 +03001167static inline int
Sakari Ailus99a85462017-07-21 14:39:34 +03001168__acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
Mika Westerbergb60e4ea2016-09-29 16:39:41 +03001169 const char *name, size_t index, size_t num_args,
Sakari Ailus977d5ad2018-07-17 17:19:11 +03001170 struct fwnode_reference_args *args)
Mika Westerbergb60e4ea2016-09-29 16:39:41 +03001171{
1172 return -ENXIO;
1173}
1174
Sakari Ailus99a85462017-07-21 14:39:34 +03001175static inline int
1176acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
1177 const char *name, size_t index,
Sakari Ailus977d5ad2018-07-17 17:19:11 +03001178 struct fwnode_reference_args *args)
Mika Westerbergffdcd952014-10-21 13:33:55 +02001179{
1180 return -ENXIO;
1181}
Rafael J. Wysockib31384f2014-11-04 01:28:56 +01001182
Sakari Ailus99a85462017-07-21 14:39:34 +03001183static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,
Rafael J. Wysocki3a7a2ab2015-08-27 04:40:05 +02001184 const char *propname,
1185 void **valptr)
Mika Westerbergffdcd952014-10-21 13:33:55 +02001186{
1187 return -ENXIO;
1188}
Rafael J. Wysockib31384f2014-11-04 01:28:56 +01001189
Sakari Ailus99a85462017-07-21 14:39:34 +03001190static inline int acpi_dev_prop_get(const struct acpi_device *adev,
Rafael J. Wysockib31384f2014-11-04 01:28:56 +01001191 const char *propname,
1192 void **valptr)
1193{
1194 return -ENXIO;
1195}
1196
Sakari Ailus99a85462017-07-21 14:39:34 +03001197static inline int acpi_dev_prop_read_single(const struct acpi_device *adev,
Rafael J. Wysockib31384f2014-11-04 01:28:56 +01001198 const char *propname,
1199 enum dev_prop_type proptype,
1200 void *val)
1201{
1202 return -ENXIO;
1203}
1204
Sakari Ailus99a85462017-07-21 14:39:34 +03001205static inline int acpi_node_prop_read(const struct fwnode_handle *fwnode,
Rafael J. Wysocki3a7a2ab2015-08-27 04:40:05 +02001206 const char *propname,
1207 enum dev_prop_type proptype,
1208 void *val, size_t nval)
1209{
1210 return -ENXIO;
1211}
1212
Sakari Ailus99a85462017-07-21 14:39:34 +03001213static inline int acpi_dev_prop_read(const struct acpi_device *adev,
Rafael J. Wysockib31384f2014-11-04 01:28:56 +01001214 const char *propname,
1215 enum dev_prop_type proptype,
1216 void *val, size_t nval)
1217{
1218 return -ENXIO;
1219}
1220
Mika Westerberg34055192017-03-28 10:52:18 +03001221static inline struct fwnode_handle *
Sakari Ailus37ba9832017-07-21 14:39:36 +03001222acpi_get_next_subnode(const struct fwnode_handle *fwnode,
1223 struct fwnode_handle *child)
Rafael J. Wysocki8a0662d2014-11-04 14:03:59 +01001224{
1225 return NULL;
1226}
1227
Mika Westerbergdfa672f2017-03-28 10:52:16 +03001228static inline struct fwnode_handle *
Sakari Ailus37ba9832017-07-21 14:39:36 +03001229acpi_node_get_parent(const struct fwnode_handle *fwnode)
Mika Westerbergdfa672f2017-03-28 10:52:16 +03001230{
1231 return NULL;
1232}
1233
Mika Westerberg79389a82017-03-28 10:52:20 +03001234static inline struct fwnode_handle *
Sakari Ailus37ba9832017-07-21 14:39:36 +03001235acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
Mika Westerberg79389a82017-03-28 10:52:20 +03001236 struct fwnode_handle *prev)
1237{
1238 return ERR_PTR(-ENXIO);
1239}
1240
1241static inline int
Sakari Ailus37ba9832017-07-21 14:39:36 +03001242acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode,
Mika Westerberg79389a82017-03-28 10:52:20 +03001243 struct fwnode_handle **remote,
1244 struct fwnode_handle **port,
1245 struct fwnode_handle **endpoint)
1246{
1247 return -ENXIO;
1248}
1249
Lorenzo Pieralisi3feab132016-08-16 16:59:52 +01001250#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
Marc Zyngiere647b532015-09-28 15:49:12 +01001251 static const void * __acpi_table_##name[] \
1252 __attribute__((unused)) \
1253 = { (void *) table_id, \
1254 (void *) subtable, \
1255 (void *) valid, \
1256 (void *) fn, \
1257 (void *) data }
1258
1259#define acpi_probe_device_table(t) ({ int __r = 0; __r;})
Mika Westerbergffdcd952014-10-21 13:33:55 +02001260#endif
1261
Aleksey Makarovda3d3f92016-06-20 13:56:10 +03001262#ifdef CONFIG_ACPI_TABLE_UPGRADE
1263void acpi_table_upgrade(void);
1264#else
1265static inline void acpi_table_upgrade(void) { }
1266#endif
1267
Mika Westerberg058dfc72016-09-20 15:30:51 +03001268#if defined(CONFIG_ACPI) && defined(CONFIG_ACPI_WATCHDOG)
1269extern bool acpi_has_watchdog(void);
1270#else
1271static inline bool acpi_has_watchdog(void) { return false; }
1272#endif
1273
Aleksey Makarovad1696f2016-09-27 23:54:13 +03001274#ifdef CONFIG_ACPI_SPCR_TABLE
Timur Tabi37ef38f2017-07-27 16:15:52 -05001275extern bool qdf2400_e44_present;
Prarit Bhargava0231d002018-01-18 10:09:51 -05001276int acpi_parse_spcr(bool enable_earlycon, bool enable_console);
Aleksey Makarovad1696f2016-09-27 23:54:13 +03001277#else
Prarit Bhargava0231d002018-01-18 10:09:51 -05001278static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console)
1279{
1280 return 0;
1281}
Aleksey Makarovad1696f2016-09-27 23:54:13 +03001282#endif
1283
Agustin Vega-Friasd44fa3d2017-02-02 18:23:58 -05001284#if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI)
1285int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res);
1286#else
1287static inline
1288int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res)
1289{
1290 return -EINVAL;
1291}
1292#endif
1293
Srinivas Pandruvadaeeb2d802017-10-05 16:24:03 -07001294#ifdef CONFIG_ACPI_LPIT
1295int lpit_read_residency_count_address(u64 *address);
1296#else
1297static inline int lpit_read_residency_count_address(u64 *address)
1298{
1299 return -EINVAL;
1300}
1301#endif
1302
Sudeep Holla2520e6272018-06-05 15:35:03 +01001303#ifdef CONFIG_ACPI_PPTT
Jeremy Linton2bd00bc2018-05-11 18:58:00 -05001304int find_acpi_cpu_topology(unsigned int cpu, int level);
1305int find_acpi_cpu_topology_package(unsigned int cpu);
1306int find_acpi_cpu_cache_topology(unsigned int cpu, int level);
Sudeep Holla2520e6272018-06-05 15:35:03 +01001307#else
1308static inline int find_acpi_cpu_topology(unsigned int cpu, int level)
1309{
1310 return -EINVAL;
1311}
1312static inline int find_acpi_cpu_topology_package(unsigned int cpu)
1313{
1314 return -EINVAL;
1315}
1316static inline int find_acpi_cpu_cache_topology(unsigned int cpu, int level)
1317{
1318 return -EINVAL;
1319}
1320#endif
Jeremy Linton2bd00bc2018-05-11 18:58:00 -05001321
Heikki Krogerus7847a142018-11-09 17:21:35 +03001322#ifdef CONFIG_ACPI
1323extern int acpi_platform_notify(struct device *dev, enum kobject_action action);
1324#else
1325static inline int
1326acpi_platform_notify(struct device *dev, enum kobject_action action)
1327{
1328 return 0;
1329}
1330#endif
1331
Len Brown25be5e62005-05-27 04:21:50 -04001332#endif /*_LINUX_ACPI_H*/