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