at master 47 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2/* 3 * acpi.h - ACPI Interface 4 * 5 * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 6 */ 7 8#ifndef _LINUX_ACPI_H 9#define _LINUX_ACPI_H 10 11#include <linux/cleanup.h> 12#include <linux/errno.h> 13#include <linux/ioport.h> /* for struct resource */ 14#include <linux/resource_ext.h> 15#include <linux/device.h> 16#include <linux/mod_devicetable.h> 17#include <linux/property.h> 18#include <linux/uuid.h> 19#include <linux/node.h> 20 21struct irq_domain; 22struct irq_domain_ops; 23 24#ifndef _LINUX 25#define _LINUX 26#endif 27#include <acpi/acpi.h> 28#include <acpi/acpi_numa.h> 29 30#ifdef CONFIG_ACPI 31 32#include <linux/list.h> 33#include <linux/dynamic_debug.h> 34#include <linux/module.h> 35#include <linux/mutex.h> 36#include <linux/fw_table.h> 37 38#include <acpi/acpi_bus.h> 39#include <acpi/acpi_drivers.h> 40#include <acpi/acpi_io.h> 41#include <asm/acpi.h> 42 43#ifdef CONFIG_ACPI_TABLE_LIB 44#define EXPORT_SYMBOL_ACPI_LIB(x) EXPORT_SYMBOL_NS_GPL(x, "ACPI") 45#define __init_or_acpilib 46#define __initdata_or_acpilib 47#else 48#define EXPORT_SYMBOL_ACPI_LIB(x) 49#define __init_or_acpilib __init 50#define __initdata_or_acpilib __initdata 51#endif 52 53static inline acpi_handle acpi_device_handle(struct acpi_device *adev) 54{ 55 return adev ? adev->handle : NULL; 56} 57 58#define ACPI_COMPANION(dev) to_acpi_device_node((dev)->fwnode) 59#define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \ 60 acpi_fwnode_handle(adev) : NULL) 61#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) 62#define ACPI_HANDLE_FWNODE(fwnode) \ 63 acpi_device_handle(to_acpi_device_node(fwnode)) 64 65static inline struct fwnode_handle *acpi_alloc_fwnode_static(void) 66{ 67 struct fwnode_handle *fwnode; 68 69 fwnode = kzalloc(sizeof(struct fwnode_handle), GFP_KERNEL); 70 if (!fwnode) 71 return NULL; 72 73 fwnode_init(fwnode, &acpi_static_fwnode_ops); 74 75 return fwnode; 76} 77 78static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode) 79{ 80 if (WARN_ON(!is_acpi_static_node(fwnode))) 81 return; 82 83 kfree(fwnode); 84} 85 86static inline bool has_acpi_companion(struct device *dev) 87{ 88 return is_acpi_device_node(dev->fwnode); 89} 90 91static inline void acpi_preset_companion(struct device *dev, 92 struct acpi_device *parent, u64 addr) 93{ 94 ACPI_COMPANION_SET(dev, acpi_find_child_device(parent, addr, false)); 95} 96 97static inline const char *acpi_dev_name(struct acpi_device *adev) 98{ 99 return dev_name(&adev->dev); 100} 101 102struct device *acpi_get_first_physical_node(struct acpi_device *adev); 103 104enum acpi_irq_model_id { 105 ACPI_IRQ_MODEL_PIC = 0, 106 ACPI_IRQ_MODEL_IOAPIC, 107 ACPI_IRQ_MODEL_IOSAPIC, 108 ACPI_IRQ_MODEL_PLATFORM, 109 ACPI_IRQ_MODEL_GIC, 110 ACPI_IRQ_MODEL_LPIC, 111 ACPI_IRQ_MODEL_RINTC, 112 ACPI_IRQ_MODEL_COUNT 113}; 114 115extern enum acpi_irq_model_id acpi_irq_model; 116 117enum acpi_interrupt_id { 118 ACPI_INTERRUPT_PMI = 1, 119 ACPI_INTERRUPT_INIT, 120 ACPI_INTERRUPT_CPEI, 121 ACPI_INTERRUPT_COUNT 122}; 123 124#define ACPI_SPACE_MEM 0 125 126enum acpi_address_range_id { 127 ACPI_ADDRESS_RANGE_MEMORY = 1, 128 ACPI_ADDRESS_RANGE_RESERVED = 2, 129 ACPI_ADDRESS_RANGE_ACPI = 3, 130 ACPI_ADDRESS_RANGE_NVS = 4, 131 ACPI_ADDRESS_RANGE_COUNT 132}; 133 134 135/* Table Handlers */ 136typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table); 137 138/* Debugger support */ 139 140struct acpi_debugger_ops { 141 int (*create_thread)(acpi_osd_exec_callback function, void *context); 142 ssize_t (*write_log)(const char *msg); 143 ssize_t (*read_cmd)(char *buffer, size_t length); 144 int (*wait_command_ready)(bool single_step, char *buffer, size_t length); 145 int (*notify_command_complete)(void); 146}; 147 148struct acpi_debugger { 149 const struct acpi_debugger_ops *ops; 150 struct module *owner; 151 struct mutex lock; 152}; 153 154#ifdef CONFIG_ACPI_DEBUGGER 155int __init acpi_debugger_init(void); 156int acpi_register_debugger(struct module *owner, 157 const struct acpi_debugger_ops *ops); 158void acpi_unregister_debugger(const struct acpi_debugger_ops *ops); 159int acpi_debugger_create_thread(acpi_osd_exec_callback function, void *context); 160ssize_t acpi_debugger_write_log(const char *msg); 161ssize_t acpi_debugger_read_cmd(char *buffer, size_t buffer_length); 162int acpi_debugger_wait_command_ready(void); 163int acpi_debugger_notify_command_complete(void); 164#else 165static inline int acpi_debugger_init(void) 166{ 167 return -ENODEV; 168} 169 170static inline int acpi_register_debugger(struct module *owner, 171 const struct acpi_debugger_ops *ops) 172{ 173 return -ENODEV; 174} 175 176static inline void acpi_unregister_debugger(const struct acpi_debugger_ops *ops) 177{ 178} 179 180static inline int acpi_debugger_create_thread(acpi_osd_exec_callback function, 181 void *context) 182{ 183 return -ENODEV; 184} 185 186static inline int acpi_debugger_write_log(const char *msg) 187{ 188 return -ENODEV; 189} 190 191static inline int acpi_debugger_read_cmd(char *buffer, u32 buffer_length) 192{ 193 return -ENODEV; 194} 195 196static inline int acpi_debugger_wait_command_ready(void) 197{ 198 return -ENODEV; 199} 200 201static inline int acpi_debugger_notify_command_complete(void) 202{ 203 return -ENODEV; 204} 205#endif 206 207#define BAD_MADT_ENTRY(entry, end) ( \ 208 (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ 209 ((struct acpi_subtable_header *)entry)->length < sizeof(*entry)) 210 211void __iomem *__acpi_map_table(unsigned long phys, unsigned long size); 212void __acpi_unmap_table(void __iomem *map, unsigned long size); 213int early_acpi_boot_init(void); 214int acpi_boot_init (void); 215void acpi_boot_table_prepare (void); 216void acpi_boot_table_init (void); 217int acpi_mps_check (void); 218int acpi_numa_init (void); 219 220int acpi_locate_initial_tables (void); 221void acpi_reserve_initial_tables (void); 222void acpi_table_init_complete (void); 223int acpi_table_init (void); 224 225static inline struct acpi_table_header *acpi_get_table_pointer(char *signature, u32 instance) 226{ 227 struct acpi_table_header *table; 228 int status = acpi_get_table(signature, instance, &table); 229 230 if (ACPI_FAILURE(status)) 231 return ERR_PTR(-ENOENT); 232 return table; 233} 234DEFINE_FREE(acpi_put_table, struct acpi_table_header *, if (!IS_ERR_OR_NULL(_T)) acpi_put_table(_T)) 235 236int acpi_table_parse(char *id, acpi_tbl_table_handler handler); 237int __init_or_acpilib acpi_table_parse_entries(char *id, 238 unsigned long table_size, int entry_id, 239 acpi_tbl_entry_handler handler, unsigned int max_entries); 240int __init_or_acpilib acpi_table_parse_entries_array(char *id, 241 unsigned long table_size, struct acpi_subtable_proc *proc, 242 int proc_num, unsigned int max_entries); 243int acpi_table_parse_madt(enum acpi_madt_type id, 244 acpi_tbl_entry_handler handler, 245 unsigned int max_entries); 246int __init_or_acpilib 247acpi_table_parse_cedt(enum acpi_cedt_type id, 248 acpi_tbl_entry_handler_arg handler_arg, void *arg); 249 250int acpi_parse_mcfg (struct acpi_table_header *header); 251void acpi_table_print_madt_entry (struct acpi_subtable_header *madt); 252 253#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) 254void acpi_numa_processor_affinity_init (struct acpi_srat_cpu_affinity *pa); 255#else 256static inline void 257acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa) { } 258#endif 259 260void acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa); 261 262#if defined(CONFIG_ARM64) || defined(CONFIG_LOONGARCH) 263void acpi_arch_dma_setup(struct device *dev); 264#else 265static inline void acpi_arch_dma_setup(struct device *dev) { } 266#endif 267 268#ifdef CONFIG_ARM64 269void acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa); 270#else 271static inline void 272acpi_numa_gicc_affinity_init(struct acpi_srat_gicc_affinity *pa) { } 273#endif 274 275#ifdef CONFIG_RISCV 276void acpi_numa_rintc_affinity_init(struct acpi_srat_rintc_affinity *pa); 277#else 278static inline void acpi_numa_rintc_affinity_init(struct acpi_srat_rintc_affinity *pa) { } 279#endif 280 281#ifndef PHYS_CPUID_INVALID 282typedef u32 phys_cpuid_t; 283#define PHYS_CPUID_INVALID (phys_cpuid_t)(-1) 284#endif 285 286static inline bool invalid_logical_cpuid(u32 cpuid) 287{ 288 return (int)cpuid < 0; 289} 290 291static inline bool invalid_phys_cpuid(phys_cpuid_t phys_id) 292{ 293 return phys_id == PHYS_CPUID_INVALID; 294} 295 296 297int __init acpi_get_madt_revision(void); 298 299/* Validate the processor object's proc_id */ 300bool acpi_duplicate_processor_id(int proc_id); 301/* Processor _CTS control */ 302struct acpi_processor_power; 303 304#ifdef CONFIG_ACPI_PROCESSOR_CSTATE 305bool acpi_processor_claim_cst_control(void); 306int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, 307 struct acpi_processor_power *info); 308#else 309static inline bool acpi_processor_claim_cst_control(void) { return false; } 310static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, 311 struct acpi_processor_power *info) 312{ 313 return -ENODEV; 314} 315#endif 316 317#ifdef CONFIG_ACPI_HOTPLUG_CPU 318/* Arch dependent functions for cpu hotplug support */ 319int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, 320 int *pcpu); 321int acpi_unmap_cpu(int cpu); 322#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 323 324acpi_handle acpi_get_processor_handle(int cpu); 325 326#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC 327int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr); 328#endif 329 330int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base); 331int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base); 332int acpi_ioapic_registered(acpi_handle handle, u32 gsi_base); 333void acpi_irq_stats_init(void); 334extern u32 acpi_irq_handled; 335extern u32 acpi_irq_not_handled; 336extern unsigned int acpi_sci_irq; 337extern bool acpi_no_s5; 338#define INVALID_ACPI_IRQ ((unsigned)-1) 339static inline bool acpi_sci_irq_valid(void) 340{ 341 return acpi_sci_irq != INVALID_ACPI_IRQ; 342} 343 344extern int sbf_port; 345 346int acpi_register_gsi (struct device *dev, u32 gsi, int triggering, int polarity); 347int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); 348int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi); 349 350typedef struct fwnode_handle *(*acpi_gsi_domain_disp_fn)(u32); 351 352void acpi_set_irq_model(enum acpi_irq_model_id model, 353 acpi_gsi_domain_disp_fn fn); 354acpi_gsi_domain_disp_fn acpi_get_gsi_dispatcher(void); 355void acpi_set_gsi_to_irq_fallback(u32 (*)(u32)); 356 357struct irq_domain *acpi_irq_create_hierarchy(unsigned int flags, 358 unsigned int size, 359 struct fwnode_handle *fwnode, 360 const struct irq_domain_ops *ops, 361 void *host_data); 362 363#ifdef CONFIG_X86_IO_APIC 364extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity); 365#else 366static inline int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity) 367{ 368 return -1; 369} 370#endif 371/* 372 * This function undoes the effect of one call to acpi_register_gsi(). 373 * If this matches the last registration, any IRQ resources for gsi 374 * are freed. 375 */ 376void acpi_unregister_gsi (u32 gsi); 377 378struct pci_dev; 379 380struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin); 381int acpi_pci_irq_enable (struct pci_dev *dev); 382void acpi_penalize_isa_irq(int irq, int active); 383bool acpi_isa_irq_available(int irq); 384#ifdef CONFIG_PCI 385void acpi_penalize_sci_irq(int irq, int trigger, int polarity); 386#else 387static inline void acpi_penalize_sci_irq(int irq, int trigger, 388 int polarity) 389{ 390} 391#endif 392void acpi_pci_irq_disable (struct pci_dev *dev); 393 394extern int ec_read(u8 addr, u8 *val); 395extern int ec_write(u8 addr, u8 val); 396extern int ec_transaction(u8 command, 397 const u8 *wdata, unsigned wdata_len, 398 u8 *rdata, unsigned rdata_len); 399extern acpi_handle ec_get_handle(void); 400 401extern bool acpi_is_pnp_device(struct acpi_device *); 402 403#if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE) 404 405typedef void (*wmi_notify_handler) (union acpi_object *data, void *context); 406 407int wmi_instance_count(const char *guid); 408 409extern acpi_status wmi_evaluate_method(const char *guid, u8 instance, 410 u32 method_id, 411 const struct acpi_buffer *in, 412 struct acpi_buffer *out); 413extern acpi_status wmi_query_block(const char *guid, u8 instance, 414 struct acpi_buffer *out); 415extern acpi_status wmi_set_block(const char *guid, u8 instance, 416 const struct acpi_buffer *in); 417extern acpi_status wmi_install_notify_handler(const char *guid, 418 wmi_notify_handler handler, void *data); 419extern acpi_status wmi_remove_notify_handler(const char *guid); 420extern bool wmi_has_guid(const char *guid); 421extern char *wmi_get_acpi_device_uid(const char *guid); 422 423#endif /* CONFIG_ACPI_WMI */ 424 425#define ACPI_VIDEO_OUTPUT_SWITCHING 0x0001 426#define ACPI_VIDEO_DEVICE_POSTING 0x0002 427#define ACPI_VIDEO_ROM_AVAILABLE 0x0004 428#define ACPI_VIDEO_BACKLIGHT 0x0008 429#define ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR 0x0010 430#define ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO 0x0020 431#define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR 0x0040 432#define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO 0x0080 433#define ACPI_VIDEO_BACKLIGHT_DMI_VENDOR 0x0100 434#define ACPI_VIDEO_BACKLIGHT_DMI_VIDEO 0x0200 435#define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR 0x0400 436#define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO 0x0800 437 438extern char acpi_video_backlight_string[]; 439extern long acpi_is_video_device(acpi_handle handle); 440 441extern void acpi_osi_setup(char *str); 442extern bool acpi_osi_is_win8(void); 443 444#ifdef CONFIG_ACPI_THERMAL_LIB 445int thermal_acpi_active_trip_temp(struct acpi_device *adev, int id, int *ret_temp); 446int thermal_acpi_passive_trip_temp(struct acpi_device *adev, int *ret_temp); 447int thermal_acpi_hot_trip_temp(struct acpi_device *adev, int *ret_temp); 448int thermal_acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp); 449#endif 450 451#ifdef CONFIG_ACPI_HMAT 452int acpi_get_genport_coordinates(u32 uid, struct access_coordinate *coord); 453#else 454static inline int acpi_get_genport_coordinates(u32 uid, 455 struct access_coordinate *coord) 456{ 457 return -EOPNOTSUPP; 458} 459#endif 460 461#ifdef CONFIG_ACPI_NUMA 462int acpi_map_pxm_to_node(int pxm); 463int acpi_get_node(acpi_handle handle); 464 465/** 466 * pxm_to_online_node - Map proximity ID to online node 467 * @pxm: ACPI proximity ID 468 * 469 * This is similar to pxm_to_node(), but always returns an online 470 * node. When the mapped node from a given proximity ID is offline, it 471 * looks up the node distance table and returns the nearest online node. 472 * 473 * ACPI device drivers, which are called after the NUMA initialization has 474 * completed in the kernel, can call this interface to obtain their device 475 * NUMA topology from ACPI tables. Such drivers do not have to deal with 476 * offline nodes. A node may be offline when SRAT memory entry does not exist, 477 * or NUMA is disabled, ex. "numa=off" on x86. 478 */ 479static inline int pxm_to_online_node(int pxm) 480{ 481 int node = pxm_to_node(pxm); 482 483 return numa_map_to_online_node(node); 484} 485#else 486static inline int pxm_to_online_node(int pxm) 487{ 488 return 0; 489} 490static inline int acpi_map_pxm_to_node(int pxm) 491{ 492 return 0; 493} 494static inline int acpi_get_node(acpi_handle handle) 495{ 496 return 0; 497} 498#endif 499extern int pnpacpi_disabled; 500 501#define PXM_INVAL (-1) 502 503bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res); 504bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res); 505bool acpi_dev_resource_address_space(struct acpi_resource *ares, 506 struct resource_win *win); 507bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, 508 struct resource_win *win); 509unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable, u8 wake_capable); 510unsigned int acpi_dev_get_irq_type(int triggering, int polarity); 511bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, 512 struct resource *res); 513 514void acpi_dev_free_resource_list(struct list_head *list); 515int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, 516 int (*preproc)(struct acpi_resource *, void *), 517 void *preproc_data); 518int acpi_dev_get_dma_resources(struct acpi_device *adev, 519 struct list_head *list); 520int acpi_dev_get_memory_resources(struct acpi_device *adev, struct list_head *list); 521int acpi_dev_filter_resource_type(struct acpi_resource *ares, 522 unsigned long types); 523 524static inline int acpi_dev_filter_resource_type_cb(struct acpi_resource *ares, 525 void *arg) 526{ 527 return acpi_dev_filter_resource_type(ares, (unsigned long)arg); 528} 529 530struct acpi_device *acpi_resource_consumer(struct resource *res); 531 532int acpi_check_resource_conflict(const struct resource *res); 533 534int acpi_check_region(resource_size_t start, resource_size_t n, 535 const char *name); 536 537int acpi_resources_are_enforced(void); 538 539#ifdef CONFIG_HIBERNATION 540extern int acpi_check_s4_hw_signature; 541#endif 542 543#ifdef CONFIG_PM_SLEEP 544void __init acpi_old_suspend_ordering(void); 545void __init acpi_nvs_nosave(void); 546void __init acpi_nvs_nosave_s3(void); 547void __init acpi_sleep_no_blacklist(void); 548#endif /* CONFIG_PM_SLEEP */ 549 550int acpi_register_wakeup_handler( 551 int wake_irq, bool (*wakeup)(void *context), void *context); 552void acpi_unregister_wakeup_handler( 553 bool (*wakeup)(void *context), void *context); 554 555struct acpi_osc_context { 556 char *uuid_str; /* UUID string */ 557 int rev; 558 struct acpi_buffer cap; /* list of DWORD capabilities */ 559 struct acpi_buffer ret; /* free by caller if success */ 560}; 561 562acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context); 563 564/* Number of _OSC capability DWORDS depends on bridge type */ 565#define OSC_PCI_CAPABILITY_DWORDS 3 566#define OSC_CXL_CAPABILITY_DWORDS 5 567 568/* Indexes into _OSC Capabilities Buffer (DWORDs 2 to 5 are device-specific) */ 569#define OSC_QUERY_DWORD 0 /* DWORD 1 */ 570#define OSC_SUPPORT_DWORD 1 /* DWORD 2 */ 571#define OSC_CONTROL_DWORD 2 /* DWORD 3 */ 572#define OSC_EXT_SUPPORT_DWORD 3 /* DWORD 4 */ 573#define OSC_EXT_CONTROL_DWORD 4 /* DWORD 5 */ 574 575/* _OSC Capabilities DWORD 1: Query/Control and Error Returns (generic) */ 576#define OSC_QUERY_ENABLE 0x00000001 /* input */ 577#define OSC_REQUEST_ERROR 0x00000002 /* return */ 578#define OSC_INVALID_UUID_ERROR 0x00000004 /* return */ 579#define OSC_INVALID_REVISION_ERROR 0x00000008 /* return */ 580#define OSC_CAPABILITIES_MASK_ERROR 0x00000010 /* return */ 581 582/* Platform-Wide Capabilities _OSC: Capabilities DWORD 2: Support Field */ 583#define OSC_SB_PAD_SUPPORT 0x00000001 584#define OSC_SB_PPC_OST_SUPPORT 0x00000002 585#define OSC_SB_PR3_SUPPORT 0x00000004 586#define OSC_SB_HOTPLUG_OST_SUPPORT 0x00000008 587#define OSC_SB_APEI_SUPPORT 0x00000010 588#define OSC_SB_CPC_SUPPORT 0x00000020 589#define OSC_SB_CPCV2_SUPPORT 0x00000040 590#define OSC_SB_PCLPI_SUPPORT 0x00000080 591#define OSC_SB_OSLPI_SUPPORT 0x00000100 592#define OSC_SB_FAST_THERMAL_SAMPLING_SUPPORT 0x00000200 593#define OSC_SB_OVER_16_PSTATES_SUPPORT 0x00000400 594#define OSC_SB_GED_SUPPORT 0x00000800 595#define OSC_SB_CPC_DIVERSE_HIGH_SUPPORT 0x00001000 596#define OSC_SB_IRQ_RESOURCE_SOURCE_SUPPORT 0x00002000 597#define OSC_SB_CPC_FLEXIBLE_ADR_SPACE 0x00004000 598#define OSC_SB_GENERIC_INITIATOR_SUPPORT 0x00020000 599#define OSC_SB_NATIVE_USB4_SUPPORT 0x00040000 600#define OSC_SB_BATTERY_CHARGE_LIMITING_SUPPORT 0x00080000 601#define OSC_SB_PRM_SUPPORT 0x00200000 602#define OSC_SB_FFH_OPR_SUPPORT 0x00400000 603 604extern bool osc_sb_apei_support_acked; 605extern bool osc_pc_lpi_support_confirmed; 606extern bool osc_sb_native_usb4_support_confirmed; 607extern bool osc_sb_cppc2_support_acked; 608extern bool osc_cpc_flexible_adr_space_confirmed; 609 610/* USB4 Capabilities */ 611#define OSC_USB_USB3_TUNNELING 0x00000001 612#define OSC_USB_DP_TUNNELING 0x00000002 613#define OSC_USB_PCIE_TUNNELING 0x00000004 614#define OSC_USB_XDOMAIN 0x00000008 615 616extern u32 osc_sb_native_usb4_control; 617 618/* PCI Host Bridge _OSC: Capabilities DWORD 2: Support Field */ 619#define OSC_PCI_EXT_CONFIG_SUPPORT 0x00000001 620#define OSC_PCI_ASPM_SUPPORT 0x00000002 621#define OSC_PCI_CLOCK_PM_SUPPORT 0x00000004 622#define OSC_PCI_SEGMENT_GROUPS_SUPPORT 0x00000008 623#define OSC_PCI_MSI_SUPPORT 0x00000010 624#define OSC_PCI_EDR_SUPPORT 0x00000080 625#define OSC_PCI_HPX_TYPE_3_SUPPORT 0x00000100 626 627/* PCI Host Bridge _OSC: Capabilities DWORD 3: Control Field */ 628#define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL 0x00000001 629#define OSC_PCI_SHPC_NATIVE_HP_CONTROL 0x00000002 630#define OSC_PCI_EXPRESS_PME_CONTROL 0x00000004 631#define OSC_PCI_EXPRESS_AER_CONTROL 0x00000008 632#define OSC_PCI_EXPRESS_CAPABILITY_CONTROL 0x00000010 633#define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020 634#define OSC_PCI_EXPRESS_DPC_CONTROL 0x00000080 635 636/* CXL _OSC: Capabilities DWORD 4: Support Field */ 637#define OSC_CXL_1_1_PORT_REG_ACCESS_SUPPORT 0x00000001 638#define OSC_CXL_2_0_PORT_DEV_REG_ACCESS_SUPPORT 0x00000002 639#define OSC_CXL_PROTOCOL_ERR_REPORTING_SUPPORT 0x00000004 640#define OSC_CXL_NATIVE_HP_SUPPORT 0x00000008 641 642/* CXL _OSC: Capabilities DWORD 5: Control Field */ 643#define OSC_CXL_ERROR_REPORTING_CONTROL 0x00000001 644 645static inline u32 acpi_osc_ctx_get_pci_control(struct acpi_osc_context *context) 646{ 647 u32 *ret = context->ret.pointer; 648 649 return ret[OSC_CONTROL_DWORD]; 650} 651 652static inline u32 acpi_osc_ctx_get_cxl_control(struct acpi_osc_context *context) 653{ 654 u32 *ret = context->ret.pointer; 655 656 return ret[OSC_EXT_CONTROL_DWORD]; 657} 658 659#define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002 660#define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004 661#define ACPI_GSB_ACCESS_ATTRIB_BYTE 0x00000006 662#define ACPI_GSB_ACCESS_ATTRIB_WORD 0x00000008 663#define ACPI_GSB_ACCESS_ATTRIB_BLOCK 0x0000000A 664#define ACPI_GSB_ACCESS_ATTRIB_MULTIBYTE 0x0000000B 665#define ACPI_GSB_ACCESS_ATTRIB_WORD_CALL 0x0000000C 666#define ACPI_GSB_ACCESS_ATTRIB_BLOCK_CALL 0x0000000D 667#define ACPI_GSB_ACCESS_ATTRIB_RAW_BYTES 0x0000000E 668#define ACPI_GSB_ACCESS_ATTRIB_RAW_PROCESS 0x0000000F 669 670/* Enable _OST when all relevant hotplug operations are enabled */ 671#if defined(CONFIG_ACPI_HOTPLUG_CPU) && \ 672 defined(CONFIG_ACPI_HOTPLUG_MEMORY) && \ 673 defined(CONFIG_ACPI_CONTAINER) 674#define ACPI_HOTPLUG_OST 675#endif 676 677/* _OST Source Event Code (OSPM Action) */ 678#define ACPI_OST_EC_OSPM_SHUTDOWN 0x100 679#define ACPI_OST_EC_OSPM_EJECT 0x103 680#define ACPI_OST_EC_OSPM_INSERTION 0x200 681 682/* _OST General Processing Status Code */ 683#define ACPI_OST_SC_SUCCESS 0x0 684#define ACPI_OST_SC_NON_SPECIFIC_FAILURE 0x1 685#define ACPI_OST_SC_UNRECOGNIZED_NOTIFY 0x2 686 687/* _OST OS Shutdown Processing (0x100) Status Code */ 688#define ACPI_OST_SC_OS_SHUTDOWN_DENIED 0x80 689#define ACPI_OST_SC_OS_SHUTDOWN_IN_PROGRESS 0x81 690#define ACPI_OST_SC_OS_SHUTDOWN_COMPLETED 0x82 691#define ACPI_OST_SC_OS_SHUTDOWN_NOT_SUPPORTED 0x83 692 693/* _OST Ejection Request (0x3, 0x103) Status Code */ 694#define ACPI_OST_SC_EJECT_NOT_SUPPORTED 0x80 695#define ACPI_OST_SC_DEVICE_IN_USE 0x81 696#define ACPI_OST_SC_DEVICE_BUSY 0x82 697#define ACPI_OST_SC_EJECT_DEPENDENCY_BUSY 0x83 698#define ACPI_OST_SC_EJECT_IN_PROGRESS 0x84 699 700/* _OST Insertion Request (0x200) Status Code */ 701#define ACPI_OST_SC_INSERT_IN_PROGRESS 0x80 702#define ACPI_OST_SC_DRIVER_LOAD_FAILURE 0x81 703#define ACPI_OST_SC_INSERT_NOT_SUPPORTED 0x82 704 705enum acpi_predicate { 706 all_versions, 707 less_than_or_equal, 708 equal, 709 greater_than_or_equal, 710}; 711 712/* Table must be terminted by a NULL entry */ 713struct acpi_platform_list { 714 char oem_id[ACPI_OEM_ID_SIZE+1]; 715 char oem_table_id[ACPI_OEM_TABLE_ID_SIZE+1]; 716 u32 oem_revision; 717 char *table; 718 enum acpi_predicate pred; 719 char *reason; 720 u32 data; 721}; 722int acpi_match_platform_list(const struct acpi_platform_list *plat); 723 724extern void acpi_early_init(void); 725extern void acpi_subsystem_init(void); 726 727extern int acpi_nvs_register(__u64 start, __u64 size); 728 729extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *), 730 void *data); 731 732const struct acpi_device_id *acpi_match_acpi_device(const struct acpi_device_id *ids, 733 const struct acpi_device *adev); 734 735const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, 736 const struct device *dev); 737 738const void *acpi_device_get_match_data(const struct device *dev); 739extern bool acpi_driver_match_device(struct device *dev, 740 const struct device_driver *drv); 741int acpi_device_uevent_modalias(const struct device *, struct kobj_uevent_env *); 742int acpi_device_modalias(struct device *, char *, int); 743 744struct platform_device *acpi_create_platform_device(struct acpi_device *, 745 const struct property_entry *); 746#define ACPI_PTR(_ptr) (_ptr) 747 748static inline void acpi_device_set_enumerated(struct acpi_device *adev) 749{ 750 adev->flags.visited = true; 751} 752 753static inline void acpi_device_clear_enumerated(struct acpi_device *adev) 754{ 755 adev->flags.visited = false; 756} 757 758enum acpi_reconfig_event { 759 ACPI_RECONFIG_DEVICE_ADD = 0, 760 ACPI_RECONFIG_DEVICE_REMOVE, 761}; 762 763int acpi_reconfig_notifier_register(struct notifier_block *nb); 764int acpi_reconfig_notifier_unregister(struct notifier_block *nb); 765 766#ifdef CONFIG_ACPI_GTDT 767int acpi_gtdt_init(struct acpi_table_header *table, int *platform_timer_count); 768int acpi_gtdt_map_ppi(int type); 769bool acpi_gtdt_c3stop(int type); 770#endif 771 772#ifndef ACPI_HAVE_ARCH_SET_ROOT_POINTER 773static __always_inline void acpi_arch_set_root_pointer(u64 addr) 774{ 775} 776#endif 777 778#ifndef ACPI_HAVE_ARCH_GET_ROOT_POINTER 779static __always_inline u64 acpi_arch_get_root_pointer(void) 780{ 781 return 0; 782} 783#endif 784 785int acpi_get_local_u64_address(acpi_handle handle, u64 *addr); 786int acpi_get_local_address(acpi_handle handle, u32 *addr); 787const char *acpi_get_subsystem_id(acpi_handle handle); 788 789#ifdef CONFIG_ACPI_MRRM 790int acpi_mrrm_max_mem_region(void); 791#endif 792 793#else /* !CONFIG_ACPI */ 794 795#define acpi_disabled 1 796 797#define ACPI_COMPANION(dev) (NULL) 798#define ACPI_COMPANION_SET(dev, adev) do { } while (0) 799#define ACPI_HANDLE(dev) (NULL) 800#define ACPI_HANDLE_FWNODE(fwnode) (NULL) 801 802/* Get rid of the -Wunused-variable for adev */ 803#define acpi_dev_uid_match(adev, uid2) (adev && false) 804#define acpi_dev_hid_uid_match(adev, hid2, uid2) (adev && false) 805 806struct fwnode_handle; 807 808static inline bool acpi_dev_found(const char *hid) 809{ 810 return false; 811} 812 813static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv) 814{ 815 return false; 816} 817 818struct acpi_device; 819 820static inline int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer) 821{ 822 return -ENODEV; 823} 824 825static inline struct acpi_device * 826acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) 827{ 828 return NULL; 829} 830 831static inline bool acpi_reduced_hardware(void) 832{ 833 return false; 834} 835 836static inline void acpi_dev_put(struct acpi_device *adev) {} 837 838static inline bool is_acpi_node(const struct fwnode_handle *fwnode) 839{ 840 return false; 841} 842 843static inline bool is_acpi_device_node(const struct fwnode_handle *fwnode) 844{ 845 return false; 846} 847 848static inline struct acpi_device *to_acpi_device_node(const struct fwnode_handle *fwnode) 849{ 850 return NULL; 851} 852 853static inline bool is_acpi_data_node(const struct fwnode_handle *fwnode) 854{ 855 return false; 856} 857 858static inline struct acpi_data_node *to_acpi_data_node(const struct fwnode_handle *fwnode) 859{ 860 return NULL; 861} 862 863static inline bool acpi_data_node_match(const struct fwnode_handle *fwnode, 864 const char *name) 865{ 866 return false; 867} 868 869static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev) 870{ 871 return NULL; 872} 873 874static inline acpi_handle acpi_device_handle(struct acpi_device *adev) 875{ 876 return NULL; 877} 878 879static inline bool has_acpi_companion(struct device *dev) 880{ 881 return false; 882} 883 884static inline void acpi_preset_companion(struct device *dev, 885 struct acpi_device *parent, u64 addr) 886{ 887} 888 889static inline const char *acpi_dev_name(struct acpi_device *adev) 890{ 891 return NULL; 892} 893 894static inline struct device *acpi_get_first_physical_node(struct acpi_device *adev) 895{ 896 return NULL; 897} 898 899static inline void acpi_early_init(void) { } 900static inline void acpi_subsystem_init(void) { } 901 902static inline int early_acpi_boot_init(void) 903{ 904 return 0; 905} 906static inline int acpi_boot_init(void) 907{ 908 return 0; 909} 910 911static inline void acpi_boot_table_prepare(void) 912{ 913} 914 915static inline void acpi_boot_table_init(void) 916{ 917} 918 919static inline int acpi_mps_check(void) 920{ 921 return 0; 922} 923 924static inline int acpi_check_resource_conflict(struct resource *res) 925{ 926 return 0; 927} 928 929static inline int acpi_check_region(resource_size_t start, resource_size_t n, 930 const char *name) 931{ 932 return 0; 933} 934 935struct acpi_table_header; 936static inline int acpi_table_parse(char *id, 937 int (*handler)(struct acpi_table_header *)) 938{ 939 return -ENODEV; 940} 941 942static inline int acpi_nvs_register(__u64 start, __u64 size) 943{ 944 return 0; 945} 946 947static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *), 948 void *data) 949{ 950 return 0; 951} 952 953struct acpi_device_id; 954 955static inline const struct acpi_device_id *acpi_match_acpi_device( 956 const struct acpi_device_id *ids, const struct acpi_device *adev) 957{ 958 return NULL; 959} 960 961static inline const struct acpi_device_id *acpi_match_device( 962 const struct acpi_device_id *ids, const struct device *dev) 963{ 964 return NULL; 965} 966 967static inline const void *acpi_device_get_match_data(const struct device *dev) 968{ 969 return NULL; 970} 971 972static inline bool acpi_driver_match_device(struct device *dev, 973 const struct device_driver *drv) 974{ 975 return false; 976} 977 978static inline bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, 979 u64 rev, u64 funcs) 980{ 981 return false; 982} 983 984static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle, 985 const guid_t *guid, 986 u64 rev, u64 func, 987 union acpi_object *argv4) 988{ 989 return NULL; 990} 991 992static inline union acpi_object *acpi_evaluate_dsm_typed(acpi_handle handle, 993 const guid_t *guid, 994 u64 rev, u64 func, 995 union acpi_object *argv4, 996 acpi_object_type type) 997{ 998 return NULL; 999} 1000 1001static inline int acpi_device_uevent_modalias(const struct device *dev, 1002 struct kobj_uevent_env *env) 1003{ 1004 return -ENODEV; 1005} 1006 1007static inline int acpi_device_modalias(struct device *dev, 1008 char *buf, int size) 1009{ 1010 return -ENODEV; 1011} 1012 1013static inline struct platform_device * 1014acpi_create_platform_device(struct acpi_device *adev, 1015 const struct property_entry *properties) 1016{ 1017 return NULL; 1018} 1019 1020static inline bool acpi_dma_supported(const struct acpi_device *adev) 1021{ 1022 return false; 1023} 1024 1025static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev) 1026{ 1027 return DEV_DMA_NOT_SUPPORTED; 1028} 1029 1030static inline int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map) 1031{ 1032 return -ENODEV; 1033} 1034 1035static inline int acpi_dma_configure(struct device *dev, 1036 enum dev_dma_attr attr) 1037{ 1038 return 0; 1039} 1040 1041static inline int acpi_dma_configure_id(struct device *dev, 1042 enum dev_dma_attr attr, 1043 const u32 *input_id) 1044{ 1045 return 0; 1046} 1047 1048#define ACPI_PTR(_ptr) (NULL) 1049 1050static inline void acpi_device_set_enumerated(struct acpi_device *adev) 1051{ 1052} 1053 1054static inline void acpi_device_clear_enumerated(struct acpi_device *adev) 1055{ 1056} 1057 1058static inline int acpi_reconfig_notifier_register(struct notifier_block *nb) 1059{ 1060 return -EINVAL; 1061} 1062 1063static inline int acpi_reconfig_notifier_unregister(struct notifier_block *nb) 1064{ 1065 return -EINVAL; 1066} 1067 1068static inline struct acpi_device *acpi_resource_consumer(struct resource *res) 1069{ 1070 return NULL; 1071} 1072 1073static inline int acpi_get_local_address(acpi_handle handle, u32 *addr) 1074{ 1075 return -ENODEV; 1076} 1077 1078static inline const char *acpi_get_subsystem_id(acpi_handle handle) 1079{ 1080 return ERR_PTR(-ENODEV); 1081} 1082 1083static inline int acpi_register_wakeup_handler(int wake_irq, 1084 bool (*wakeup)(void *context), void *context) 1085{ 1086 return -ENXIO; 1087} 1088 1089static inline void acpi_unregister_wakeup_handler( 1090 bool (*wakeup)(void *context), void *context) { } 1091 1092struct acpi_osc_context; 1093static inline u32 acpi_osc_ctx_get_pci_control(struct acpi_osc_context *context) 1094{ 1095 return 0; 1096} 1097 1098static inline u32 acpi_osc_ctx_get_cxl_control(struct acpi_osc_context *context) 1099{ 1100 return 0; 1101} 1102 1103static inline bool acpi_sleep_state_supported(u8 sleep_state) 1104{ 1105 return false; 1106} 1107 1108static inline acpi_handle acpi_get_processor_handle(int cpu) 1109{ 1110 return NULL; 1111} 1112 1113static inline int acpi_mrrm_max_mem_region(void) 1114{ 1115 return 1; 1116} 1117 1118#endif /* !CONFIG_ACPI */ 1119 1120#ifdef CONFIG_ACPI_HMAT 1121int hmat_get_extended_linear_cache_size(struct resource *backing_res, int nid, 1122 resource_size_t *size); 1123#else 1124static inline int hmat_get_extended_linear_cache_size(struct resource *backing_res, 1125 int nid, resource_size_t *size) 1126{ 1127 return -EOPNOTSUPP; 1128} 1129#endif 1130 1131extern void arch_post_acpi_subsys_init(void); 1132 1133#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC 1134int acpi_ioapic_add(acpi_handle root); 1135#else 1136static inline int acpi_ioapic_add(acpi_handle root) { return 0; } 1137#endif 1138 1139#ifdef CONFIG_ACPI 1140void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, 1141 u32 pm1a_ctrl, u32 pm1b_ctrl)); 1142 1143acpi_status acpi_os_prepare_sleep(u8 sleep_state, 1144 u32 pm1a_control, u32 pm1b_control); 1145 1146void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state, 1147 u32 val_a, u32 val_b)); 1148 1149acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, 1150 u32 val_a, u32 val_b); 1151struct acpi_s2idle_dev_ops { 1152 struct list_head list_node; 1153 void (*prepare)(void); 1154 void (*check)(void); 1155 void (*restore)(void); 1156}; 1157#if defined(CONFIG_SUSPEND) && defined(CONFIG_X86) 1158int acpi_register_lps0_dev(struct acpi_s2idle_dev_ops *arg); 1159void acpi_unregister_lps0_dev(struct acpi_s2idle_dev_ops *arg); 1160#else /* CONFIG_SUSPEND && CONFIG_X86 */ 1161static inline int acpi_register_lps0_dev(struct acpi_s2idle_dev_ops *arg) 1162{ 1163 return -ENODEV; 1164} 1165static inline void acpi_unregister_lps0_dev(struct acpi_s2idle_dev_ops *arg) 1166{ 1167} 1168#endif /* CONFIG_SUSPEND && CONFIG_X86 */ 1169void arch_reserve_mem_area(acpi_physical_address addr, size_t size); 1170#else 1171#define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0) 1172#endif 1173 1174#if defined(CONFIG_ACPI) && defined(CONFIG_PM) 1175int acpi_dev_suspend(struct device *dev, bool wakeup); 1176int acpi_dev_resume(struct device *dev); 1177int acpi_subsys_runtime_suspend(struct device *dev); 1178int acpi_subsys_runtime_resume(struct device *dev); 1179int acpi_dev_pm_attach(struct device *dev, bool power_on); 1180bool acpi_storage_d3(struct device *dev); 1181bool acpi_dev_state_d0(struct device *dev); 1182#else 1183static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; } 1184static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; } 1185static inline int acpi_dev_pm_attach(struct device *dev, bool power_on) 1186{ 1187 return 0; 1188} 1189static inline bool acpi_storage_d3(struct device *dev) 1190{ 1191 return false; 1192} 1193static inline bool acpi_dev_state_d0(struct device *dev) 1194{ 1195 return true; 1196} 1197#endif 1198 1199#if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP) 1200int acpi_subsys_prepare(struct device *dev); 1201void acpi_subsys_complete(struct device *dev); 1202int acpi_subsys_suspend_late(struct device *dev); 1203int acpi_subsys_suspend_noirq(struct device *dev); 1204int acpi_subsys_suspend(struct device *dev); 1205int acpi_subsys_freeze(struct device *dev); 1206int acpi_subsys_poweroff(struct device *dev); 1207int acpi_subsys_restore_early(struct device *dev); 1208#else 1209static inline int acpi_subsys_prepare(struct device *dev) { return 0; } 1210static inline void acpi_subsys_complete(struct device *dev) {} 1211static inline int acpi_subsys_suspend_late(struct device *dev) { return 0; } 1212static inline int acpi_subsys_suspend_noirq(struct device *dev) { return 0; } 1213static inline int acpi_subsys_suspend(struct device *dev) { return 0; } 1214static inline int acpi_subsys_freeze(struct device *dev) { return 0; } 1215static inline int acpi_subsys_poweroff(struct device *dev) { return 0; } 1216static inline int acpi_subsys_restore_early(struct device *dev) { return 0; } 1217#endif 1218 1219#if defined(CONFIG_ACPI_EC) && defined(CONFIG_PM_SLEEP) 1220void acpi_ec_mark_gpe_for_wake(void); 1221void acpi_ec_set_gpe_wake_mask(u8 action); 1222#else 1223static inline void acpi_ec_mark_gpe_for_wake(void) {} 1224static inline void acpi_ec_set_gpe_wake_mask(u8 action) {} 1225#endif 1226 1227#ifdef CONFIG_ACPI 1228char *acpi_handle_path(acpi_handle handle); 1229__printf(3, 4) 1230void acpi_handle_printk(const char *level, acpi_handle handle, 1231 const char *fmt, ...); 1232void acpi_evaluation_failure_warn(acpi_handle handle, const char *name, 1233 acpi_status status); 1234#else /* !CONFIG_ACPI */ 1235static inline __printf(3, 4) void 1236acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {} 1237static inline void acpi_evaluation_failure_warn(acpi_handle handle, 1238 const char *name, 1239 acpi_status status) {} 1240#endif /* !CONFIG_ACPI */ 1241 1242#if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG) 1243__printf(3, 4) 1244void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...); 1245#endif 1246 1247/* 1248 * acpi_handle_<level>: Print message with ACPI prefix and object path 1249 * 1250 * These interfaces acquire the global namespace mutex to obtain an object 1251 * path. In interrupt context, it shows the object path as <n/a>. 1252 */ 1253#define acpi_handle_emerg(handle, fmt, ...) \ 1254 acpi_handle_printk(KERN_EMERG, handle, fmt, ##__VA_ARGS__) 1255#define acpi_handle_alert(handle, fmt, ...) \ 1256 acpi_handle_printk(KERN_ALERT, handle, fmt, ##__VA_ARGS__) 1257#define acpi_handle_crit(handle, fmt, ...) \ 1258 acpi_handle_printk(KERN_CRIT, handle, fmt, ##__VA_ARGS__) 1259#define acpi_handle_err(handle, fmt, ...) \ 1260 acpi_handle_printk(KERN_ERR, handle, fmt, ##__VA_ARGS__) 1261#define acpi_handle_warn(handle, fmt, ...) \ 1262 acpi_handle_printk(KERN_WARNING, handle, fmt, ##__VA_ARGS__) 1263#define acpi_handle_notice(handle, fmt, ...) \ 1264 acpi_handle_printk(KERN_NOTICE, handle, fmt, ##__VA_ARGS__) 1265#define acpi_handle_info(handle, fmt, ...) \ 1266 acpi_handle_printk(KERN_INFO, handle, fmt, ##__VA_ARGS__) 1267 1268#if defined(DEBUG) 1269#define acpi_handle_debug(handle, fmt, ...) \ 1270 acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__) 1271#else 1272#if defined(CONFIG_DYNAMIC_DEBUG) 1273#define acpi_handle_debug(handle, fmt, ...) \ 1274 _dynamic_func_call(fmt, __acpi_handle_debug, \ 1275 handle, pr_fmt(fmt), ##__VA_ARGS__) 1276#else 1277#define acpi_handle_debug(handle, fmt, ...) \ 1278({ \ 1279 if (0) \ 1280 acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__); \ 1281 0; \ 1282}) 1283#endif 1284#endif 1285 1286#if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB) 1287bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, 1288 struct acpi_resource_gpio **agpio); 1289bool acpi_gpio_get_io_resource(struct acpi_resource *ares, 1290 struct acpi_resource_gpio **agpio); 1291int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *con_id, int index, 1292 bool *wake_capable); 1293#else 1294static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, 1295 struct acpi_resource_gpio **agpio) 1296{ 1297 return false; 1298} 1299static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares, 1300 struct acpi_resource_gpio **agpio) 1301{ 1302 return false; 1303} 1304static inline int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *con_id, 1305 int index, bool *wake_capable) 1306{ 1307 return -ENXIO; 1308} 1309#endif 1310 1311static inline int acpi_dev_gpio_irq_wake_get(struct acpi_device *adev, int index, 1312 bool *wake_capable) 1313{ 1314 return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, wake_capable); 1315} 1316 1317static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *con_id, 1318 int index) 1319{ 1320 return acpi_dev_gpio_irq_wake_get_by(adev, con_id, index, NULL); 1321} 1322 1323static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) 1324{ 1325 return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, NULL); 1326} 1327 1328/* Device properties */ 1329 1330#ifdef CONFIG_ACPI 1331int acpi_dev_get_property(const struct acpi_device *adev, const char *name, 1332 acpi_object_type type, const union acpi_object **obj); 1333int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, 1334 const char *name, size_t index, size_t num_args, 1335 struct fwnode_reference_args *args); 1336 1337static inline int acpi_node_get_property_reference( 1338 const struct fwnode_handle *fwnode, 1339 const char *name, size_t index, 1340 struct fwnode_reference_args *args) 1341{ 1342 return __acpi_node_get_property_reference(fwnode, name, index, 1343 NR_FWNODE_REFERENCE_ARGS, args); 1344} 1345 1346static inline bool acpi_dev_has_props(const struct acpi_device *adev) 1347{ 1348 return !list_empty(&adev->data.properties); 1349} 1350 1351struct acpi_device_properties * 1352acpi_data_add_props(struct acpi_device_data *data, const guid_t *guid, 1353 union acpi_object *properties); 1354 1355int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname, 1356 void **valptr); 1357 1358struct acpi_probe_entry; 1359typedef bool (*acpi_probe_entry_validate_subtbl)(struct acpi_subtable_header *, 1360 struct acpi_probe_entry *); 1361 1362#define ACPI_TABLE_ID_LEN 5 1363 1364/** 1365 * struct acpi_probe_entry - boot-time probing entry 1366 * @id: ACPI table name 1367 * @type: Optional subtable type to match 1368 * (if @id contains subtables) 1369 * @subtable_valid: Optional callback to check the validity of 1370 * the subtable 1371 * @probe_table: Callback to the driver being probed when table 1372 * match is successful 1373 * @probe_subtbl: Callback to the driver being probed when table and 1374 * subtable match (and optional callback is successful) 1375 * @driver_data: Sideband data provided back to the driver 1376 */ 1377struct acpi_probe_entry { 1378 __u8 id[ACPI_TABLE_ID_LEN]; 1379 __u8 type; 1380 acpi_probe_entry_validate_subtbl subtable_valid; 1381 union { 1382 acpi_tbl_table_handler probe_table; 1383 acpi_tbl_entry_handler probe_subtbl; 1384 }; 1385 kernel_ulong_t driver_data; 1386}; 1387 1388void arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr); 1389 1390#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, \ 1391 valid, data, fn) \ 1392 static const struct acpi_probe_entry __acpi_probe_##name \ 1393 __used __section("__" #table "_acpi_probe_table") = { \ 1394 .id = table_id, \ 1395 .type = subtable, \ 1396 .subtable_valid = valid, \ 1397 .probe_table = fn, \ 1398 .driver_data = data, \ 1399 } 1400 1401#define ACPI_DECLARE_SUBTABLE_PROBE_ENTRY(table, name, table_id, \ 1402 subtable, valid, data, fn) \ 1403 static const struct acpi_probe_entry __acpi_probe_##name \ 1404 __used __section("__" #table "_acpi_probe_table") = { \ 1405 .id = table_id, \ 1406 .type = subtable, \ 1407 .subtable_valid = valid, \ 1408 .probe_subtbl = fn, \ 1409 .driver_data = data, \ 1410 } 1411 1412#define ACPI_PROBE_TABLE(name) __##name##_acpi_probe_table 1413#define ACPI_PROBE_TABLE_END(name) __##name##_acpi_probe_table_end 1414 1415int __acpi_probe_device_table(struct acpi_probe_entry *start, int nr); 1416 1417#define acpi_probe_device_table(t) \ 1418 ({ \ 1419 extern struct acpi_probe_entry ACPI_PROBE_TABLE(t), \ 1420 ACPI_PROBE_TABLE_END(t); \ 1421 __acpi_probe_device_table(&ACPI_PROBE_TABLE(t), \ 1422 (&ACPI_PROBE_TABLE_END(t) - \ 1423 &ACPI_PROBE_TABLE(t))); \ 1424 }) 1425#else 1426static inline int acpi_dev_get_property(struct acpi_device *adev, 1427 const char *name, acpi_object_type type, 1428 const union acpi_object **obj) 1429{ 1430 return -ENXIO; 1431} 1432 1433static inline int 1434__acpi_node_get_property_reference(const struct fwnode_handle *fwnode, 1435 const char *name, size_t index, size_t num_args, 1436 struct fwnode_reference_args *args) 1437{ 1438 return -ENXIO; 1439} 1440 1441static inline int 1442acpi_node_get_property_reference(const struct fwnode_handle *fwnode, 1443 const char *name, size_t index, 1444 struct fwnode_reference_args *args) 1445{ 1446 return -ENXIO; 1447} 1448 1449static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode, 1450 const char *propname, 1451 void **valptr) 1452{ 1453 return -ENXIO; 1454} 1455 1456static inline struct fwnode_handle * 1457acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode, 1458 struct fwnode_handle *prev) 1459{ 1460 return ERR_PTR(-ENXIO); 1461} 1462 1463static inline int 1464acpi_graph_get_remote_endpoint(const struct fwnode_handle *fwnode, 1465 struct fwnode_handle **remote, 1466 struct fwnode_handle **port, 1467 struct fwnode_handle **endpoint) 1468{ 1469 return -ENXIO; 1470} 1471 1472#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \ 1473 static const void * __acpi_table_##name[] \ 1474 __attribute__((unused)) \ 1475 = { (void *) table_id, \ 1476 (void *) subtable, \ 1477 (void *) valid, \ 1478 (void *) fn, \ 1479 (void *) data } 1480 1481#define acpi_probe_device_table(t) ({ int __r = 0; __r;}) 1482#endif 1483 1484#ifdef CONFIG_ACPI_TABLE_UPGRADE 1485void acpi_table_upgrade(void); 1486#else 1487static inline void acpi_table_upgrade(void) { } 1488#endif 1489 1490#if defined(CONFIG_ACPI) && defined(CONFIG_ACPI_WATCHDOG) 1491extern bool acpi_has_watchdog(void); 1492#else 1493static inline bool acpi_has_watchdog(void) { return false; } 1494#endif 1495 1496#ifdef CONFIG_ACPI_SPCR_TABLE 1497extern bool qdf2400_e44_present; 1498int acpi_parse_spcr(bool enable_earlycon, bool enable_console); 1499#else 1500static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console) 1501{ 1502 return -ENODEV; 1503} 1504#endif 1505 1506#if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI) 1507int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res); 1508const struct cpumask *acpi_irq_get_affinity(acpi_handle handle, 1509 unsigned int index); 1510#else 1511static inline 1512int acpi_irq_get(acpi_handle handle, unsigned int index, struct resource *res) 1513{ 1514 return -EINVAL; 1515} 1516static inline const struct cpumask *acpi_irq_get_affinity(acpi_handle handle, 1517 unsigned int index) 1518{ 1519 return NULL; 1520} 1521#endif 1522 1523#ifdef CONFIG_ACPI_LPIT 1524int lpit_read_residency_count_address(u64 *address); 1525#else 1526static inline int lpit_read_residency_count_address(u64 *address) 1527{ 1528 return -EINVAL; 1529} 1530#endif 1531 1532#ifdef CONFIG_ACPI_PROCESSOR_IDLE 1533#ifndef arch_get_idle_state_flags 1534static inline unsigned int arch_get_idle_state_flags(u32 arch_flags) 1535{ 1536 return 0; 1537} 1538#endif 1539#endif /* CONFIG_ACPI_PROCESSOR_IDLE */ 1540 1541#ifdef CONFIG_ACPI_PPTT 1542int acpi_pptt_cpu_is_thread(unsigned int cpu); 1543int find_acpi_cpu_topology(unsigned int cpu, int level); 1544int find_acpi_cpu_topology_cluster(unsigned int cpu); 1545int find_acpi_cpu_topology_package(unsigned int cpu); 1546int find_acpi_cpu_topology_hetero_id(unsigned int cpu); 1547void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, cpumask_t *cpus); 1548int find_acpi_cache_level_from_id(u32 cache_id); 1549int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id, cpumask_t *cpus); 1550#else 1551static inline int acpi_pptt_cpu_is_thread(unsigned int cpu) 1552{ 1553 return -EINVAL; 1554} 1555static inline int find_acpi_cpu_topology(unsigned int cpu, int level) 1556{ 1557 return -EINVAL; 1558} 1559static inline int find_acpi_cpu_topology_cluster(unsigned int cpu) 1560{ 1561 return -EINVAL; 1562} 1563static inline int find_acpi_cpu_topology_package(unsigned int cpu) 1564{ 1565 return -EINVAL; 1566} 1567static inline int find_acpi_cpu_topology_hetero_id(unsigned int cpu) 1568{ 1569 return -EINVAL; 1570} 1571static inline void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, 1572 cpumask_t *cpus) { } 1573static inline int find_acpi_cache_level_from_id(u32 cache_id) 1574{ 1575 return -ENOENT; 1576} 1577static inline int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id, 1578 cpumask_t *cpus) 1579{ 1580 return -ENOENT; 1581} 1582#endif 1583 1584void acpi_arch_init(void); 1585 1586#ifdef CONFIG_ACPI_PCC 1587void acpi_init_pcc(void); 1588#else 1589static inline void acpi_init_pcc(void) { } 1590#endif 1591 1592#ifdef CONFIG_ACPI_FFH 1593void acpi_init_ffh(void); 1594extern int acpi_ffh_address_space_arch_setup(void *handler_ctxt, 1595 void **region_ctxt); 1596extern int acpi_ffh_address_space_arch_handler(acpi_integer *value, 1597 void *region_context); 1598#else 1599static inline void acpi_init_ffh(void) { } 1600#endif 1601 1602#ifdef CONFIG_ACPI 1603extern void acpi_device_notify(struct device *dev); 1604extern void acpi_device_notify_remove(struct device *dev); 1605#else 1606static inline void acpi_device_notify(struct device *dev) { } 1607static inline void acpi_device_notify_remove(struct device *dev) { } 1608#endif 1609 1610static inline void acpi_use_parent_companion(struct device *dev) 1611{ 1612 ACPI_COMPANION_SET(dev, ACPI_COMPANION(dev->parent)); 1613} 1614 1615#ifdef CONFIG_ACPI_NUMA 1616bool acpi_node_backed_by_real_pxm(int nid); 1617#else 1618static inline bool acpi_node_backed_by_real_pxm(int nid) 1619{ 1620 return false; 1621} 1622#endif 1623 1624#endif /*_LINUX_ACPI_H*/