linux/include/linux/acpi.h
<<
>>
Prefs
   1/*
   2 * acpi.h - ACPI Interface
   3 *
   4 * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
   5 *
   6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   7 *
   8 * This program is free software; you can redistribute it and/or modify
   9 * it under the terms of the GNU General Public License as published by
  10 * the Free Software Foundation; either version 2 of the License, or
  11 * (at your option) any later version.
  12 *
  13 * This program is distributed in the hope that it will be useful,
  14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16 * GNU General Public License for more details.
  17 *
  18 * You should have received a copy of the GNU General Public License
  19 * along with this program; if not, write to the Free Software
  20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21 *
  22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23 */
  24
  25#ifndef _LINUX_ACPI_H
  26#define _LINUX_ACPI_H
  27
  28#include <linux/errno.h>
  29#include <linux/ioport.h>       /* for struct resource */
  30#include <linux/resource_ext.h>
  31#include <linux/device.h>
  32#include <linux/property.h>
  33
  34#ifndef _LINUX
  35#define _LINUX
  36#endif
  37#include <acpi/acpi.h>
  38
  39#ifdef  CONFIG_ACPI
  40
  41#include <linux/list.h>
  42#include <linux/mod_devicetable.h>
  43#include <linux/dynamic_debug.h>
  44#include <linux/uuid.h>
  45
  46#include <acpi/acpi_bus.h>
  47#include <acpi/acpi_drivers.h>
  48#include <acpi/acpi_numa.h>
  49#include <acpi/acpi_io.h>
  50#include <asm/acpi.h>
  51
  52static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
  53{
  54        return adev ? adev->handle : NULL;
  55}
  56
  57#define ACPI_COMPANION(dev)     to_acpi_device_node(get_rh_dev_fwnode(dev))
  58#define ACPI_COMPANION_SET(dev, adev)   set_primary_fwnode(dev, (adev) ? \
  59        acpi_fwnode_handle(adev) : NULL)
  60#define ACPI_HANDLE(dev)                acpi_device_handle(ACPI_COMPANION(dev))
  61
  62static inline bool has_acpi_companion(struct device *dev)
  63{
  64        return is_acpi_node(get_rh_dev_fwnode(dev));
  65}
  66
  67static inline void acpi_preset_companion(struct device *dev,
  68                                         struct acpi_device *parent, u64 addr)
  69{
  70        ACPI_COMPANION_SET(dev, acpi_find_child_device(parent, addr, NULL));
  71}
  72
  73static inline const char *acpi_dev_name(struct acpi_device *adev)
  74{
  75        return dev_name(&adev->dev);
  76}
  77
  78struct device *acpi_get_first_physical_node(struct acpi_device *adev);
  79
  80enum acpi_irq_model_id {
  81        ACPI_IRQ_MODEL_PIC = 0,
  82        ACPI_IRQ_MODEL_IOAPIC,
  83        ACPI_IRQ_MODEL_IOSAPIC,
  84        ACPI_IRQ_MODEL_PLATFORM,
  85        ACPI_IRQ_MODEL_COUNT
  86};
  87
  88extern enum acpi_irq_model_id   acpi_irq_model;
  89
  90enum acpi_interrupt_id {
  91        ACPI_INTERRUPT_PMI      = 1,
  92        ACPI_INTERRUPT_INIT,
  93        ACPI_INTERRUPT_CPEI,
  94        ACPI_INTERRUPT_COUNT
  95};
  96
  97#define ACPI_SPACE_MEM          0
  98
  99enum acpi_address_range_id {
 100        ACPI_ADDRESS_RANGE_MEMORY = 1,
 101        ACPI_ADDRESS_RANGE_RESERVED = 2,
 102        ACPI_ADDRESS_RANGE_ACPI = 3,
 103        ACPI_ADDRESS_RANGE_NVS  = 4,
 104        ACPI_ADDRESS_RANGE_COUNT
 105};
 106
 107
 108/* Table Handlers */
 109
 110typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table);
 111
 112typedef int (*acpi_tbl_entry_handler)(struct acpi_subtable_header *header,
 113                                      const unsigned long end);
 114
 115#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
 116void acpi_initrd_override(void *data, size_t size);
 117#else
 118static inline void acpi_initrd_override(void *data, size_t size)
 119{
 120}
 121#endif
 122
 123struct acpi_subtable_proc {
 124        int id;
 125        acpi_tbl_entry_handler handler;
 126        int count;
 127};
 128
 129char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
 130void __acpi_unmap_table(char *map, unsigned long size);
 131int early_acpi_boot_init(void);
 132int acpi_boot_init (void);
 133void acpi_boot_table_init (void);
 134int acpi_mps_check (void);
 135int acpi_numa_init (void);
 136
 137int acpi_table_init (void);
 138int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
 139int __init acpi_parse_entries(char *id, unsigned long table_size,
 140                              acpi_tbl_entry_handler handler,
 141                              struct acpi_table_header *table_header,
 142                              int entry_id, unsigned int max_entries);
 143int __init acpi_table_parse_entries(char *id, unsigned long table_size,
 144                              int entry_id,
 145                              acpi_tbl_entry_handler handler,
 146                              unsigned int max_entries);
 147int __init acpi_table_parse_entries(char *id, unsigned long table_size,
 148                              int entry_id,
 149                              acpi_tbl_entry_handler handler,
 150                              unsigned int max_entries);
 151int __init acpi_table_parse_entries_array(char *id, unsigned long table_size,
 152                              struct acpi_subtable_proc *proc, int proc_num,
 153                              unsigned int max_entries);
 154int acpi_table_parse_madt(enum acpi_madt_type id,
 155                          acpi_tbl_entry_handler handler,
 156                          unsigned int max_entries);
 157int acpi_parse_mcfg (struct acpi_table_header *header);
 158void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
 159
 160/* the following four functions are architecture-dependent */
 161void acpi_numa_slit_init (struct acpi_table_slit *slit);
 162void acpi_numa_processor_affinity_init (struct acpi_srat_cpu_affinity *pa);
 163void acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa);
 164int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma);
 165void acpi_numa_arch_fixup(void);
 166
 167#ifdef CONFIG_ACPI_HOTPLUG_CPU
 168/* Arch dependent functions for cpu hotplug support */
 169int acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu);
 170int acpi_unmap_lsapic(int cpu);
 171#endif /* CONFIG_ACPI_HOTPLUG_CPU */
 172
 173int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
 174int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base);
 175void acpi_irq_stats_init(void);
 176extern u32 acpi_irq_handled;
 177extern u32 acpi_irq_not_handled;
 178
 179extern int sbf_port;
 180extern unsigned long acpi_realmode_flags;
 181
 182int acpi_register_gsi (struct device *dev, u32 gsi, int triggering, int polarity);
 183int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
 184int acpi_isa_irq_to_gsi (unsigned isa_irq, u32 *gsi);
 185
 186#ifdef CONFIG_X86_IO_APIC
 187extern int acpi_get_override_irq(u32 gsi, int *trigger, int *polarity);
 188#else
 189#define acpi_get_override_irq(gsi, trigger, polarity) (-1)
 190#endif
 191/*
 192 * This function undoes the effect of one call to acpi_register_gsi().
 193 * If this matches the last registration, any IRQ resources for gsi
 194 * are freed.
 195 */
 196void acpi_unregister_gsi (u32 gsi);
 197
 198struct pci_dev;
 199
 200int acpi_pci_irq_enable (struct pci_dev *dev);
 201void acpi_penalize_isa_irq(int irq, int active);
 202
 203void acpi_pci_irq_disable (struct pci_dev *dev);
 204
 205extern int ec_read(u8 addr, u8 *val);
 206extern int ec_write(u8 addr, u8 val);
 207extern int ec_transaction(u8 command,
 208                          const u8 *wdata, unsigned wdata_len,
 209                          u8 *rdata, unsigned rdata_len);
 210extern acpi_handle ec_get_handle(void);
 211
 212extern bool acpi_is_pnp_device(struct acpi_device *);
 213
 214#if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE)
 215
 216typedef void (*wmi_notify_handler) (u32 value, void *context);
 217
 218extern acpi_status wmi_evaluate_method(const char *guid, u8 instance,
 219                                        u32 method_id,
 220                                        const struct acpi_buffer *in,
 221                                        struct acpi_buffer *out);
 222extern acpi_status wmi_query_block(const char *guid, u8 instance,
 223                                        struct acpi_buffer *out);
 224extern acpi_status wmi_set_block(const char *guid, u8 instance,
 225                                        const struct acpi_buffer *in);
 226extern acpi_status wmi_install_notify_handler(const char *guid,
 227                                        wmi_notify_handler handler, void *data);
 228extern acpi_status wmi_remove_notify_handler(const char *guid);
 229extern acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out);
 230extern bool wmi_has_guid(const char *guid);
 231
 232#endif  /* CONFIG_ACPI_WMI */
 233
 234#define ACPI_VIDEO_OUTPUT_SWITCHING                     0x0001
 235#define ACPI_VIDEO_DEVICE_POSTING                       0x0002
 236#define ACPI_VIDEO_ROM_AVAILABLE                        0x0004
 237#define ACPI_VIDEO_BACKLIGHT                            0x0008
 238#define ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR               0x0010
 239#define ACPI_VIDEO_BACKLIGHT_FORCE_VIDEO                0x0020
 240#define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VENDOR        0x0040
 241#define ACPI_VIDEO_OUTPUT_SWITCHING_FORCE_VIDEO         0x0080
 242#define ACPI_VIDEO_BACKLIGHT_DMI_VENDOR                 0x0100
 243#define ACPI_VIDEO_BACKLIGHT_DMI_VIDEO                  0x0200
 244#define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VENDOR          0x0400
 245#define ACPI_VIDEO_OUTPUT_SWITCHING_DMI_VIDEO           0x0800
 246
 247#if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE)
 248
 249extern long acpi_video_get_capabilities(acpi_handle graphics_dev_handle);
 250extern long acpi_is_video_device(acpi_handle handle);
 251extern void acpi_video_dmi_promote_vendor(void);
 252extern void acpi_video_dmi_demote_vendor(void);
 253extern int acpi_video_backlight_support(void);
 254extern int acpi_video_display_switch_support(void);
 255
 256#else
 257
 258static inline long acpi_video_get_capabilities(acpi_handle graphics_dev_handle)
 259{
 260        return 0;
 261}
 262
 263static inline long acpi_is_video_device(acpi_handle handle)
 264{
 265        return 0;
 266}
 267
 268static inline void acpi_video_dmi_promote_vendor(void)
 269{
 270}
 271
 272static inline void acpi_video_dmi_demote_vendor(void)
 273{
 274}
 275
 276static inline int acpi_video_backlight_support(void)
 277{
 278        return 0;
 279}
 280
 281static inline int acpi_video_display_switch_support(void)
 282{
 283        return 0;
 284}
 285
 286#endif /* defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE) */
 287
 288extern int acpi_blacklisted(void);
 289extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d);
 290extern void acpi_osi_setup(char *str);
 291
 292#ifdef CONFIG_ACPI_NUMA
 293int acpi_map_pxm_to_online_node(int pxm);
 294int acpi_get_node(acpi_handle handle);
 295#else
 296static inline int acpi_map_pxm_to_online_node(int pxm)
 297{
 298        return 0;
 299}
 300static inline int acpi_get_node(acpi_handle handle)
 301{
 302        return 0;
 303}
 304#endif
 305extern int acpi_paddr_to_node(u64 start_addr, u64 size);
 306
 307extern int pnpacpi_disabled;
 308
 309#define PXM_INVAL       (-1)
 310
 311bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res);
 312bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res);
 313bool acpi_dev_resource_address_space(struct acpi_resource *ares,
 314                                     struct resource_win *win);
 315bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
 316                                         struct resource_win *win);
 317unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable);
 318bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
 319                                 struct resource *res);
 320
 321void acpi_dev_free_resource_list(struct list_head *list);
 322int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
 323                           int (*preproc)(struct acpi_resource *, void *),
 324                           void *preproc_data);
 325int acpi_dev_filter_resource_type(struct acpi_resource *ares,
 326                                  unsigned long types);
 327
 328static inline int acpi_dev_filter_resource_type_cb(struct acpi_resource *ares,
 329                                                   void *arg)
 330{
 331        return acpi_dev_filter_resource_type(ares, (unsigned long)arg);
 332}
 333
 334int acpi_check_resource_conflict(const struct resource *res);
 335
 336int acpi_check_region(resource_size_t start, resource_size_t n,
 337                      const char *name);
 338
 339int acpi_resources_are_enforced(void);
 340
 341#ifdef CONFIG_HIBERNATION
 342void __init acpi_no_s4_hw_signature(void);
 343#endif
 344
 345#ifdef CONFIG_PM_SLEEP
 346void __init acpi_old_suspend_ordering(void);
 347void __init acpi_nvs_nosave(void);
 348void __init acpi_nvs_nosave_s3(void);
 349#endif /* CONFIG_PM_SLEEP */
 350
 351struct acpi_osc_context {
 352        char *uuid_str;                 /* UUID string */
 353        int rev;
 354        struct acpi_buffer cap;         /* list of DWORD capabilities */
 355        struct acpi_buffer ret;         /* free by caller if success */
 356};
 357
 358acpi_status acpi_str_to_uuid(char *str, u8 *uuid);
 359acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);
 360
 361/* Indexes into _OSC Capabilities Buffer (DWORDs 2 & 3 are device-specific) */
 362#define OSC_QUERY_DWORD                         0       /* DWORD 1 */
 363#define OSC_SUPPORT_DWORD                       1       /* DWORD 2 */
 364#define OSC_CONTROL_DWORD                       2       /* DWORD 3 */
 365
 366/* _OSC Capabilities DWORD 1: Query/Control and Error Returns (generic) */
 367#define OSC_QUERY_ENABLE                        0x00000001  /* input */
 368#define OSC_REQUEST_ERROR                       0x00000002  /* return */
 369#define OSC_INVALID_UUID_ERROR                  0x00000004  /* return */
 370#define OSC_INVALID_REVISION_ERROR              0x00000008  /* return */
 371#define OSC_CAPABILITIES_MASK_ERROR             0x00000010  /* return */
 372
 373/* Platform-Wide Capabilities _OSC: Capabilities DWORD 2: Support Field */
 374#define OSC_SB_PAD_SUPPORT                      0x00000001
 375#define OSC_SB_PPC_OST_SUPPORT                  0x00000002
 376#define OSC_SB_PR3_SUPPORT                      0x00000004
 377#define OSC_SB_HOTPLUG_OST_SUPPORT              0x00000008
 378#define OSC_SB_APEI_SUPPORT                     0x00000010
 379#define OSC_SB_CPC_SUPPORT                      0x00000020
 380#define OSC_SB_CPC_DIVERSE_HIGH_SUPPORT         0x00001000
 381
 382extern bool osc_sb_apei_support_acked;
 383
 384/* PCI Host Bridge _OSC: Capabilities DWORD 2: Support Field */
 385#define OSC_PCI_EXT_CONFIG_SUPPORT              0x00000001
 386#define OSC_PCI_ASPM_SUPPORT                    0x00000002
 387#define OSC_PCI_CLOCK_PM_SUPPORT                0x00000004
 388#define OSC_PCI_SEGMENT_GROUPS_SUPPORT          0x00000008
 389#define OSC_PCI_MSI_SUPPORT                     0x00000010
 390#define OSC_PCI_SUPPORT_MASKS                   0x0000001f
 391
 392/* PCI Host Bridge _OSC: Capabilities DWORD 3: Control Field */
 393#define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL       0x00000001
 394#define OSC_PCI_SHPC_NATIVE_HP_CONTROL          0x00000002
 395#define OSC_PCI_EXPRESS_PME_CONTROL             0x00000004
 396#define OSC_PCI_EXPRESS_AER_CONTROL             0x00000008
 397#define OSC_PCI_EXPRESS_CAPABILITY_CONTROL      0x00000010
 398#define OSC_PCI_CONTROL_MASKS                   0x0000001f
 399
 400#define ACPI_GSB_ACCESS_ATTRIB_QUICK            0x00000002
 401#define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV         0x00000004
 402#define ACPI_GSB_ACCESS_ATTRIB_BYTE             0x00000006
 403#define ACPI_GSB_ACCESS_ATTRIB_WORD             0x00000008
 404#define ACPI_GSB_ACCESS_ATTRIB_BLOCK            0x0000000A
 405#define ACPI_GSB_ACCESS_ATTRIB_MULTIBYTE        0x0000000B
 406#define ACPI_GSB_ACCESS_ATTRIB_WORD_CALL        0x0000000C
 407#define ACPI_GSB_ACCESS_ATTRIB_BLOCK_CALL       0x0000000D
 408#define ACPI_GSB_ACCESS_ATTRIB_RAW_BYTES        0x0000000E
 409#define ACPI_GSB_ACCESS_ATTRIB_RAW_PROCESS      0x0000000F
 410
 411extern acpi_status acpi_pci_osc_control_set(acpi_handle handle,
 412                                             u32 *mask, u32 req);
 413
 414/* Enable _OST when all relevant hotplug operations are enabled */
 415#if defined(CONFIG_ACPI_HOTPLUG_CPU) &&                 \
 416        defined(CONFIG_ACPI_HOTPLUG_MEMORY) &&          \
 417        defined(CONFIG_ACPI_CONTAINER)
 418#define ACPI_HOTPLUG_OST
 419#endif
 420
 421/* _OST Source Event Code (OSPM Action) */
 422#define ACPI_OST_EC_OSPM_SHUTDOWN               0x100
 423#define ACPI_OST_EC_OSPM_EJECT                  0x103
 424#define ACPI_OST_EC_OSPM_INSERTION              0x200
 425
 426/* _OST General Processing Status Code */
 427#define ACPI_OST_SC_SUCCESS                     0x0
 428#define ACPI_OST_SC_NON_SPECIFIC_FAILURE        0x1
 429#define ACPI_OST_SC_UNRECOGNIZED_NOTIFY         0x2
 430
 431/* _OST OS Shutdown Processing (0x100) Status Code */
 432#define ACPI_OST_SC_OS_SHUTDOWN_DENIED          0x80
 433#define ACPI_OST_SC_OS_SHUTDOWN_IN_PROGRESS     0x81
 434#define ACPI_OST_SC_OS_SHUTDOWN_COMPLETED       0x82
 435#define ACPI_OST_SC_OS_SHUTDOWN_NOT_SUPPORTED   0x83
 436
 437/* _OST Ejection Request (0x3, 0x103) Status Code */
 438#define ACPI_OST_SC_EJECT_NOT_SUPPORTED         0x80
 439#define ACPI_OST_SC_DEVICE_IN_USE               0x81
 440#define ACPI_OST_SC_DEVICE_BUSY                 0x82
 441#define ACPI_OST_SC_EJECT_DEPENDENCY_BUSY       0x83
 442#define ACPI_OST_SC_EJECT_IN_PROGRESS           0x84
 443
 444/* _OST Insertion Request (0x200) Status Code */
 445#define ACPI_OST_SC_INSERT_IN_PROGRESS          0x80
 446#define ACPI_OST_SC_DRIVER_LOAD_FAILURE         0x81
 447#define ACPI_OST_SC_INSERT_NOT_SUPPORTED        0x82
 448
 449extern void acpi_early_init(void);
 450
 451extern int acpi_nvs_register(__u64 start, __u64 size);
 452
 453extern int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
 454                                    void *data);
 455
 456const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
 457                                               const struct device *dev);
 458
 459extern bool acpi_driver_match_device(struct device *dev,
 460                                     const struct device_driver *drv);
 461
 462struct platform_device *acpi_create_platform_device(struct acpi_device *);
 463#define ACPI_PTR(_ptr)  (_ptr)
 464
 465static inline void acpi_device_set_enumerated(struct acpi_device *adev)
 466{
 467        adev->flags.visited = true;
 468}
 469
 470static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
 471{
 472        adev->flags.visited = false;
 473}
 474
 475enum acpi_reconfig_event  {
 476        ACPI_RECONFIG_DEVICE_ADD = 0,
 477        ACPI_RECONFIG_DEVICE_REMOVE,
 478};
 479
 480int acpi_reconfig_notifier_register(struct notifier_block *nb);
 481int acpi_reconfig_notifier_unregister(struct notifier_block *nb);
 482
 483#else   /* !CONFIG_ACPI */
 484
 485#define acpi_disabled 1
 486
 487#define ACPI_COMPANION(dev)             (NULL)
 488#define ACPI_COMPANION_SET(dev, adev)   do { } while (0)
 489#define ACPI_HANDLE(dev)                (NULL)
 490
 491struct fwnode_handle;
 492
 493static inline bool is_acpi_node(struct fwnode_handle *fwnode)
 494{
 495        return false;
 496}
 497
 498static inline bool is_acpi_device_node(struct fwnode_handle *fwnode)
 499{
 500        return false;
 501}
 502
 503static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
 504{
 505        return NULL;
 506}
 507
 508static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
 509{
 510        return false;
 511}
 512
 513static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
 514{
 515        return NULL;
 516}
 517
 518static inline bool acpi_data_node_match(struct fwnode_handle *fwnode,
 519                                        const char *name)
 520{
 521        return false;
 522}
 523
 524static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
 525{
 526        return NULL;
 527}
 528
 529static inline const char *acpi_dev_name(struct acpi_device *adev)
 530{
 531        return NULL;
 532}
 533
 534static inline bool has_acpi_companion(struct device *dev)
 535{
 536        return false;
 537}
 538
 539static inline struct device *acpi_get_first_physical_node(struct acpi_device *adev)
 540{
 541        return NULL;
 542}
 543
 544static inline void acpi_early_init(void) { }
 545
 546static inline int early_acpi_boot_init(void)
 547{
 548        return 0;
 549}
 550static inline int acpi_boot_init(void)
 551{
 552        return 0;
 553}
 554
 555static inline void acpi_boot_table_init(void)
 556{
 557        return;
 558}
 559
 560static inline int acpi_mps_check(void)
 561{
 562        return 0;
 563}
 564
 565static inline int acpi_check_resource_conflict(struct resource *res)
 566{
 567        return 0;
 568}
 569
 570static inline int acpi_check_region(resource_size_t start, resource_size_t n,
 571                                    const char *name)
 572{
 573        return 0;
 574}
 575
 576struct acpi_table_header;
 577static inline int acpi_table_parse(char *id,
 578                                int (*handler)(struct acpi_table_header *))
 579{
 580        return -1;
 581}
 582
 583static inline int acpi_nvs_register(__u64 start, __u64 size)
 584{
 585        return 0;
 586}
 587
 588static inline int acpi_nvs_for_each_region(int (*func)(__u64, __u64, void *),
 589                                           void *data)
 590{
 591        return 0;
 592}
 593
 594struct acpi_device_id;
 595
 596static inline const struct acpi_device_id *acpi_match_device(
 597        const struct acpi_device_id *ids, const struct device *dev)
 598{
 599        return NULL;
 600}
 601
 602static inline bool acpi_driver_match_device(struct device *dev,
 603                                            const struct device_driver *drv)
 604{
 605        return false;
 606}
 607
 608static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,
 609                                                   const u8 *uuid,
 610                                                   int rev, int func,
 611                                                   union acpi_object *argv4)
 612{
 613        return NULL;
 614}
 615
 616#define ACPI_PTR(_ptr)  (NULL)
 617
 618static inline void acpi_device_set_enumerated(struct acpi_device *adev)
 619{
 620}
 621
 622static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
 623{
 624}
 625
 626static inline int acpi_reconfig_notifier_register(struct notifier_block *nb)
 627{
 628        return -EINVAL;
 629}
 630
 631static inline int acpi_reconfig_notifier_unregister(struct notifier_block *nb)
 632{
 633        return -EINVAL;
 634}
 635
 636#endif  /* !CONFIG_ACPI */
 637
 638#ifdef CONFIG_ACPI
 639void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
 640                               u32 pm1a_ctrl,  u32 pm1b_ctrl));
 641
 642acpi_status acpi_os_prepare_sleep(u8 sleep_state,
 643                                  u32 pm1a_control, u32 pm1b_control);
 644
 645void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
 646                                        u32 val_a,  u32 val_b));
 647
 648acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state,
 649                                           u32 val_a, u32 val_b);
 650
 651#ifdef CONFIG_X86
 652void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
 653#else
 654static inline void arch_reserve_mem_area(acpi_physical_address addr,
 655                                          size_t size)
 656{
 657}
 658#endif /* CONFIG_X86 */
 659#else
 660#define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0)
 661#endif
 662
 663#if defined(CONFIG_ACPI) && defined(CONFIG_PM_RUNTIME)
 664int acpi_dev_runtime_suspend(struct device *dev);
 665int acpi_dev_runtime_resume(struct device *dev);
 666int acpi_subsys_runtime_suspend(struct device *dev);
 667int acpi_subsys_runtime_resume(struct device *dev);
 668#else
 669static inline int acpi_dev_runtime_suspend(struct device *dev) { return 0; }
 670static inline int acpi_dev_runtime_resume(struct device *dev) { return 0; }
 671static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; }
 672static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; }
 673#endif
 674
 675#if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
 676int acpi_dev_suspend_late(struct device *dev);
 677int acpi_dev_resume_early(struct device *dev);
 678int acpi_subsys_prepare(struct device *dev);
 679int acpi_subsys_suspend_late(struct device *dev);
 680int acpi_subsys_resume_early(struct device *dev);
 681#else
 682static inline int acpi_dev_suspend_late(struct device *dev) { return 0; }
 683static inline int acpi_dev_resume_early(struct device *dev) { return 0; }
 684static inline int acpi_subsys_prepare(struct device *dev) { return 0; }
 685static inline int acpi_subsys_suspend_late(struct device *dev) { return 0; }
 686static inline int acpi_subsys_resume_early(struct device *dev) { return 0; }
 687#endif
 688
 689#if defined(CONFIG_ACPI) && defined(CONFIG_PM)
 690struct acpi_device *acpi_dev_pm_get_node(struct device *dev);
 691int acpi_dev_pm_attach(struct device *dev, bool power_on);
 692void acpi_dev_pm_detach(struct device *dev, bool power_off);
 693#else
 694static inline struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
 695{
 696        return NULL;
 697}
 698static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
 699{
 700        return -ENODEV;
 701}
 702static inline void acpi_dev_pm_detach(struct device *dev, bool power_off) {}
 703#endif
 704
 705#ifdef CONFIG_ACPI
 706__printf(3, 4)
 707void acpi_handle_printk(const char *level, acpi_handle handle,
 708                        const char *fmt, ...);
 709#else   /* !CONFIG_ACPI */
 710static inline __printf(3, 4) void
 711acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {}
 712#endif  /* !CONFIG_ACPI */
 713
 714#if defined(CONFIG_ACPI) && defined(CONFIG_DYNAMIC_DEBUG)
 715__printf(3, 4)
 716void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const char *fmt, ...);
 717#else
 718#define __acpi_handle_debug(descriptor, handle, fmt, ...)               \
 719        acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__);
 720#endif
 721
 722/*
 723 * acpi_handle_<level>: Print message with ACPI prefix and object path
 724 *
 725 * These interfaces acquire the global namespace mutex to obtain an object
 726 * path.  In interrupt context, it shows the object path as <n/a>.
 727 */
 728#define acpi_handle_emerg(handle, fmt, ...)                             \
 729        acpi_handle_printk(KERN_EMERG, handle, fmt, ##__VA_ARGS__)
 730#define acpi_handle_alert(handle, fmt, ...)                             \
 731        acpi_handle_printk(KERN_ALERT, handle, fmt, ##__VA_ARGS__)
 732#define acpi_handle_crit(handle, fmt, ...)                              \
 733        acpi_handle_printk(KERN_CRIT, handle, fmt, ##__VA_ARGS__)
 734#define acpi_handle_err(handle, fmt, ...)                               \
 735        acpi_handle_printk(KERN_ERR, handle, fmt, ##__VA_ARGS__)
 736#define acpi_handle_warn(handle, fmt, ...)                              \
 737        acpi_handle_printk(KERN_WARNING, handle, fmt, ##__VA_ARGS__)
 738#define acpi_handle_notice(handle, fmt, ...)                            \
 739        acpi_handle_printk(KERN_NOTICE, handle, fmt, ##__VA_ARGS__)
 740#define acpi_handle_info(handle, fmt, ...)                              \
 741        acpi_handle_printk(KERN_INFO, handle, fmt, ##__VA_ARGS__)
 742
 743#if defined(DEBUG)
 744#define acpi_handle_debug(handle, fmt, ...)                             \
 745        acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__)
 746#else
 747#if defined(CONFIG_DYNAMIC_DEBUG)
 748#define acpi_handle_debug(handle, fmt, ...)                             \
 749do {                                                                    \
 750        DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);                 \
 751        if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT))          \
 752                __acpi_handle_debug(&descriptor, handle, pr_fmt(fmt),   \
 753                                ##__VA_ARGS__);                         \
 754} while (0)
 755#else
 756#define acpi_handle_debug(handle, fmt, ...)                             \
 757({                                                                      \
 758        if (0)                                                          \
 759                acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__); \
 760        0;                                                              \
 761})
 762#endif
 763#endif
 764
 765struct acpi_gpio_params {
 766        unsigned int crs_entry_index;
 767        unsigned int line_index;
 768        bool active_low;
 769};
 770
 771struct acpi_gpio_mapping {
 772        const char *name;
 773        const struct acpi_gpio_params *data;
 774        unsigned int size;
 775};
 776
 777#if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB)
 778int acpi_dev_add_driver_gpios(struct acpi_device *adev,
 779                              const struct acpi_gpio_mapping *gpios);
 780
 781static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev)
 782{
 783        if (adev)
 784                adev->driver_gpios = NULL;
 785}
 786
 787int devm_acpi_dev_add_driver_gpios(struct device *dev,
 788                                   const struct acpi_gpio_mapping *gpios);
 789void devm_acpi_dev_remove_driver_gpios(struct device *dev);
 790#else
 791static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
 792                              const struct acpi_gpio_mapping *gpios)
 793{
 794        return -ENXIO;
 795}
 796static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev) {}
 797
 798static inline int devm_acpi_dev_add_driver_gpios(struct device *dev,
 799                              const struct acpi_gpio_mapping *gpios)
 800{
 801        return -ENXIO;
 802}
 803static inline void devm_acpi_dev_remove_driver_gpios(struct device *dev) {}
 804#endif
 805
 806#if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB)
 807int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index);
 808#else
 809static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
 810{
 811        return -ENXIO;
 812}
 813#endif
 814
 815/* Device properties */
 816
 817#define MAX_ACPI_REFERENCE_ARGS 8
 818struct acpi_reference_args {
 819        struct acpi_device *adev;
 820        size_t nargs;
 821        u64 args[MAX_ACPI_REFERENCE_ARGS];
 822};
 823
 824#ifdef CONFIG_ACPI
 825int acpi_dev_get_property(struct acpi_device *adev, const char *name,
 826                          acpi_object_type type, const union acpi_object **obj);
 827int acpi_node_get_property_reference(struct fwnode_handle *fwnode,
 828                                     const char *name, size_t index,
 829                                     struct acpi_reference_args *args);
 830
 831int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname,
 832                       void **valptr);
 833int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
 834                              enum dev_prop_type proptype, void *val);
 835int acpi_node_prop_read(struct fwnode_handle *fwnode, const char *propname,
 836                        enum dev_prop_type proptype, void *val, size_t nval);
 837int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
 838                       enum dev_prop_type proptype, void *val, size_t nval);
 839
 840struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
 841                                            struct fwnode_handle *subnode);
 842#else
 843static inline int acpi_dev_get_property(struct acpi_device *adev,
 844                                        const char *name, acpi_object_type type,
 845                                        const union acpi_object **obj)
 846{
 847        return -ENXIO;
 848}
 849static inline int acpi_dev_get_property_array(struct acpi_device *adev,
 850                                              const char *name,
 851                                              acpi_object_type type,
 852                                              const union acpi_object **obj)
 853{
 854        return -ENXIO;
 855}
 856static inline int acpi_node_get_property_reference(struct fwnode_handle *fwnode,
 857                                const char *name, const char *cells_name,
 858                                size_t index, struct acpi_reference_args *args)
 859{
 860        return -ENXIO;
 861}
 862
 863static inline int acpi_node_prop_get(struct fwnode_handle *fwnode,
 864                                     const char *propname,
 865                                     void **valptr)
 866{
 867        return -ENXIO;
 868}
 869
 870static inline int acpi_dev_prop_get(struct acpi_device *adev,
 871                                    const char *propname,
 872                                    void **valptr)
 873{
 874        return -ENXIO;
 875}
 876
 877static inline int acpi_dev_prop_read_single(struct acpi_device *adev,
 878                                            const char *propname,
 879                                            enum dev_prop_type proptype,
 880                                            void *val)
 881{
 882        return -ENXIO;
 883}
 884
 885static inline int acpi_node_prop_read(struct fwnode_handle *fwnode,
 886                                      const char *propname,
 887                                      enum dev_prop_type proptype,
 888                                      void *val, size_t nval)
 889{
 890        return -ENXIO;
 891}
 892
 893static inline int acpi_dev_prop_read(struct acpi_device *adev,
 894                                     const char *propname,
 895                                     enum dev_prop_type proptype,
 896                                     void *val, size_t nval)
 897{
 898        return -ENXIO;
 899}
 900
 901static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
 902                                                struct fwnode_handle *subnode)
 903{
 904        return NULL;
 905}
 906#endif
 907
 908#ifdef CONFIG_ACPI_LPIT
 909int lpit_read_residency_count_address(u64 *address);
 910#else
 911static inline int lpit_read_residency_count_address(u64 *address)
 912{
 913        return -EINVAL;
 914}
 915#endif
 916
 917#if defined(CONFIG_ACPI) && defined(CONFIG_ACPI_WATCHDOG)
 918extern bool acpi_has_watchdog(void);
 919#else
 920static inline bool acpi_has_watchdog(void) { return false; }
 921#endif
 922
 923#endif  /*_LINUX_ACPI_H*/
 924