Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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