^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * acpi_bus.h - ACPI Bus Driver ($Revision: 22 $)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifndef __ACPI_BUS_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define __ACPI_BUS_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/property.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /* TBD: Make dynamic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define ACPI_MAX_HANDLES 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct acpi_handle_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) acpi_handle handles[ACPI_MAX_HANDLES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /* acpi_utils.h */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) acpi_extract_package(union acpi_object *package,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct acpi_buffer *format, struct acpi_buffer *buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) acpi_evaluate_integer(acpi_handle handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) acpi_string pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct acpi_object_list *arguments, unsigned long long *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) acpi_evaluate_reference(acpi_handle handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) acpi_string pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct acpi_object_list *arguments,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct acpi_handle_list *list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) acpi_evaluate_ost(acpi_handle handle, u32 source_event, u32 status_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct acpi_buffer *status_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) bool acpi_has_method(acpi_handle handle, char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) acpi_status acpi_execute_simple_method(acpi_handle handle, char *method,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) u64 arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) acpi_status acpi_evaluate_ej0(acpi_handle handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) acpi_status acpi_evaluate_lck(acpi_handle handle, int lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) acpi_status acpi_evaluate_reg(acpi_handle handle, u8 space_id, u32 function);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) bool acpi_ata_match(acpi_handle handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) bool acpi_bay_match(acpi_handle handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) bool acpi_dock_match(acpi_handle handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) union acpi_object *acpi_evaluate_dsm(acpi_handle handle, const guid_t *guid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) u64 rev, u64 func, union acpi_object *argv4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static inline union acpi_object *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u64 func, union acpi_object *argv4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) acpi_object_type type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) union acpi_object *obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) obj = acpi_evaluate_dsm(handle, guid, rev, func, argv4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) if (obj && obj->type != type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) ACPI_FREE(obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) obj = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) return obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define ACPI_INIT_DSM_ARGV4(cnt, eles) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) .package.type = ACPI_TYPE_PACKAGE, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) .package.count = (cnt), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) .package.elements = (eles) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) bool acpi_dev_found(const char *hid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #ifdef CONFIG_ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct proc_dir_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define ACPI_BUS_FILE_ROOT "acpi"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) extern struct proc_dir_entry *acpi_root_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) enum acpi_bus_device_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) ACPI_BUS_TYPE_DEVICE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) ACPI_BUS_TYPE_POWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) ACPI_BUS_TYPE_PROCESSOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) ACPI_BUS_TYPE_THERMAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) ACPI_BUS_TYPE_POWER_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) ACPI_BUS_TYPE_SLEEP_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) ACPI_BUS_TYPE_ECDT_EC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) ACPI_BUS_DEVICE_TYPE_COUNT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct acpi_driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct acpi_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * ACPI Scan Handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct acpi_hotplug_profile {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct kobject kobj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int (*scan_dependent)(struct acpi_device *adev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) void (*notify_online)(struct acpi_device *adev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) bool enabled:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) bool demand_offline:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct kobject *kobj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return container_of(kobj, struct acpi_hotplug_profile, kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct acpi_scan_handler {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) const struct acpi_device_id *ids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct list_head list_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) bool (*match)(const char *idstr, const struct acpi_device_id **matchid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) void (*detach)(struct acpi_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) void (*bind)(struct device *phys_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) void (*unbind)(struct device *phys_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct acpi_hotplug_profile hotplug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * ACPI Hotplug Context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * --------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct acpi_hotplug_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) struct acpi_device *self;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) int (*notify)(struct acpi_device *, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) void (*uevent)(struct acpi_device *, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) void (*fixup)(struct acpi_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * ACPI Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * -----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) typedef int (*acpi_op_add) (struct acpi_device * device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) typedef int (*acpi_op_remove) (struct acpi_device * device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct acpi_device_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) acpi_op_add add;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) acpi_op_remove remove;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) acpi_op_notify notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) #define ACPI_DRIVER_ALL_NOTIFY_EVENTS 0x1 /* system AND device events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct acpi_driver {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) char name[80];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) char class[80];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) const struct acpi_device_id *ids; /* Supported Hardware IDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) unsigned int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct acpi_device_ops ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) struct device_driver drv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct module *owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * ACPI Device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * -----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) /* Status (_STA) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) struct acpi_device_status {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) u32 present:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) u32 enabled:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) u32 show_in_ui:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) u32 functional:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) u32 battery_present:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) u32 reserved:27;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) /* Flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) struct acpi_device_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) u32 dynamic_status:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) u32 removable:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) u32 ejectable:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) u32 power_manageable:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) u32 match_driver:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) u32 initialized:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) u32 visited:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) u32 hotplug_notify:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) u32 is_dock_station:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) u32 of_compatible_ok:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) u32 coherent_dma:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) u32 cca_seen:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) u32 enumeration_by_parent:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) u32 reserved:19;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) /* File System */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) struct acpi_device_dir {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct proc_dir_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) #define acpi_device_dir(d) ((d)->dir.entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) /* Plug and Play */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) typedef char acpi_bus_id[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) typedef u64 acpi_bus_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) typedef char acpi_device_name[40];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) typedef char acpi_device_class[20];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct acpi_hardware_id {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) const char *id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) struct acpi_pnp_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) u32 hardware_id:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) u32 bus_address:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) u32 platform_id:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) u32 reserved:29;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) struct acpi_device_pnp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) acpi_bus_id bus_id; /* Object name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) int instance_no; /* Instance number of this object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) struct acpi_pnp_type type; /* ID type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) acpi_bus_address bus_address; /* _ADR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) char *unique_id; /* _UID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) struct list_head ids; /* _HID and _CIDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) acpi_device_name device_name; /* Driver-determined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) acpi_device_class device_class; /* " */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) union acpi_object *str_obj; /* unicode string for _STR method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) #define acpi_device_bid(d) ((d)->pnp.bus_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) #define acpi_device_adr(d) ((d)->pnp.bus_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) const char *acpi_device_hid(struct acpi_device *device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) #define acpi_device_uid(d) ((d)->pnp.unique_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) #define acpi_device_name(d) ((d)->pnp.device_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) #define acpi_device_class(d) ((d)->pnp.device_class)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) /* Power Management */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) struct acpi_device_power_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) u32 explicit_get:1; /* _PSC present? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) u32 power_resources:1; /* Power resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) u32 inrush_current:1; /* Serialize Dx->D0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) u32 power_removed:1; /* Optimize Dx->D0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) u32 ignore_parent:1; /* Power is independent of parent power state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) u32 dsw_present:1; /* _DSW present? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) u32 reserved:26;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) struct acpi_device_power_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) u8 valid:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) u8 explicit_set:1; /* _PSx present? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) u8 reserved:6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) } flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) int power; /* % Power (compared to D0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) int latency; /* Dx->D0 time (microseconds) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) struct list_head resources; /* Power resources referenced */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) struct acpi_device_power {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) int state; /* Current state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) struct acpi_device_power_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) struct acpi_device_power_state states[ACPI_D_STATE_COUNT]; /* Power states (D0-D3Cold) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) /* Performance Management */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) struct acpi_device_perf_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) u8 reserved:8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct acpi_device_perf_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) u8 valid:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) u8 reserved:7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) } flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) u8 power; /* % Power (compared to P0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) u8 performance; /* % Performance ( " ) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) int latency; /* Px->P0 time (microseconds) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) struct acpi_device_perf {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) int state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) struct acpi_device_perf_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) int state_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) struct acpi_device_perf_state *states;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) /* Wakeup Management */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) struct acpi_device_wakeup_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) u8 valid:1; /* Can successfully enable wakeup? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) u8 notifier_present:1; /* Wake-up notify handler has been installed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) struct acpi_device_wakeup_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) void (*func)(struct acpi_device_wakeup_context *context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) struct acpi_device_wakeup {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) acpi_handle gpe_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) u64 gpe_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) u64 sleep_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) struct list_head resources;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) struct acpi_device_wakeup_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) struct acpi_device_wakeup_context context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) struct wakeup_source *ws;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) int prepare_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) int enable_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) struct acpi_device_physical_node {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) unsigned int node_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) struct list_head node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) bool put_online:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) struct acpi_device_properties {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) const guid_t *guid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) const union acpi_object *properties;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) /* ACPI Device Specific Data (_DSD) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) struct acpi_device_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) const union acpi_object *pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) struct list_head properties;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) const union acpi_object *of_compatible;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) struct list_head subnodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) struct acpi_gpio_mapping;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) /* Device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) struct acpi_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) int device_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) acpi_handle handle; /* no handle for fixed hardware */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) struct fwnode_handle fwnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) struct acpi_device *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) struct list_head children;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) struct list_head node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) struct list_head wakeup_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) struct list_head del_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) struct acpi_device_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) struct acpi_device_flags flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) struct acpi_device_pnp pnp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) struct acpi_device_power power;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) struct acpi_device_wakeup wakeup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) struct acpi_device_perf performance;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) struct acpi_device_dir dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) struct acpi_device_data data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) struct acpi_scan_handler *handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) struct acpi_hotplug_context *hp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) struct acpi_driver *driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) const struct acpi_gpio_mapping *driver_gpios;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) void *driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) struct device dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) unsigned int physical_node_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) unsigned int dep_unmet;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) struct list_head physical_node_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) struct mutex physical_node_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) void (*remove)(struct acpi_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) /* Non-device subnode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) struct acpi_data_node {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) acpi_handle handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) struct fwnode_handle fwnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) struct fwnode_handle *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) struct acpi_device_data data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) struct list_head sibling;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) struct kobject kobj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) struct completion kobj_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) extern const struct fwnode_operations acpi_device_fwnode_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) extern const struct fwnode_operations acpi_data_fwnode_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) extern const struct fwnode_operations acpi_static_fwnode_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) bool is_acpi_device_node(const struct fwnode_handle *fwnode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) bool is_acpi_data_node(const struct fwnode_handle *fwnode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) static inline bool is_acpi_node(const struct fwnode_handle *fwnode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) return (is_acpi_device_node(fwnode) || is_acpi_data_node(fwnode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) #define to_acpi_device_node(__fwnode) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) typeof(__fwnode) __to_acpi_device_node_fwnode = __fwnode; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) is_acpi_device_node(__to_acpi_device_node_fwnode) ? \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) container_of(__to_acpi_device_node_fwnode, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) struct acpi_device, fwnode) : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) NULL; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) #define to_acpi_data_node(__fwnode) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) typeof(__fwnode) __to_acpi_data_node_fwnode = __fwnode; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) is_acpi_data_node(__to_acpi_data_node_fwnode) ? \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) container_of(__to_acpi_data_node_fwnode, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) struct acpi_data_node, fwnode) : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) NULL; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) static inline bool is_acpi_static_node(const struct fwnode_handle *fwnode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) return !IS_ERR_OR_NULL(fwnode) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) fwnode->ops == &acpi_static_fwnode_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) static inline bool acpi_data_node_match(const struct fwnode_handle *fwnode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) return is_acpi_data_node(fwnode) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) (!strcmp(to_acpi_data_node(fwnode)->name, name)) : false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) return &adev->fwnode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) static inline void *acpi_driver_data(struct acpi_device *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) return d->driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) #define to_acpi_device(d) container_of(d, struct acpi_device, dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) #define to_acpi_driver(d) container_of(d, struct acpi_driver, drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) static inline void acpi_set_device_status(struct acpi_device *adev, u32 sta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) *((u32 *)&adev->status) = sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) static inline void acpi_set_hp_context(struct acpi_device *adev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) struct acpi_hotplug_context *hp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) hp->self = adev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) adev->hp = hp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) void acpi_initialize_hp_context(struct acpi_device *adev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) struct acpi_hotplug_context *hp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) int (*notify)(struct acpi_device *, u32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) void (*uevent)(struct acpi_device *, u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) /* acpi_device.dev.bus == &acpi_bus_type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) extern struct bus_type acpi_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) * Events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) * ------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) struct acpi_bus_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) struct list_head node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) acpi_device_class device_class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) acpi_bus_id bus_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) u32 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) u32 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) extern struct kobject *acpi_kobj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) void acpi_bus_private_data_handler(acpi_handle, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) int acpi_bus_get_private_data(acpi_handle, void **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) int acpi_bus_attach_private_data(acpi_handle, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) void acpi_bus_detach_private_data(acpi_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) extern int register_acpi_notifier(struct notifier_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) extern int unregister_acpi_notifier(struct notifier_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) * External Functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) struct acpi_device *acpi_bus_get_acpi_device(acpi_handle handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) void acpi_bus_put_acpi_device(struct acpi_device *adev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) acpi_status acpi_bus_get_status_handle(acpi_handle handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) unsigned long long *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) int acpi_bus_get_status(struct acpi_device *device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) int acpi_bus_set_power(acpi_handle handle, int state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) const char *acpi_power_state_string(int state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) int acpi_device_set_power(struct acpi_device *device, int state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) int acpi_bus_init_power(struct acpi_device *device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) int acpi_device_fix_up_power(struct acpi_device *device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) int acpi_bus_update_power(acpi_handle handle, int *state_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) int acpi_device_update_power(struct acpi_device *device, int *state_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) bool acpi_bus_power_manageable(acpi_handle handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) int acpi_device_power_add_dependent(struct acpi_device *adev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) void acpi_device_power_remove_dependent(struct acpi_device *adev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) bool acpi_bus_can_wakeup(acpi_handle handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) static inline bool acpi_bus_can_wakeup(acpi_handle handle) { return false; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) void acpi_scan_lock_acquire(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) void acpi_scan_lock_release(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) void acpi_lock_hp_context(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) void acpi_unlock_hp_context(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) int acpi_scan_add_handler(struct acpi_scan_handler *handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) int acpi_bus_register_driver(struct acpi_driver *driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) void acpi_bus_unregister_driver(struct acpi_driver *driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) int acpi_bus_scan(acpi_handle handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) void acpi_bus_trim(struct acpi_device *start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) int acpi_match_device_ids(struct acpi_device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) const struct acpi_device_id *ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) void acpi_set_modalias(struct acpi_device *adev, const char *default_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) char *modalias, size_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) int acpi_create_dir(struct acpi_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) void acpi_remove_dir(struct acpi_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) static inline bool acpi_device_enumerated(struct acpi_device *adev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) return adev && adev->flags.initialized && adev->flags.visited;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * module_acpi_driver(acpi_driver) - Helper macro for registering an ACPI driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) * @__acpi_driver: acpi_driver struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) * Helper macro for ACPI drivers which do not do anything special in module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) * init/exit. This eliminates a lot of boilerplate. Each module may only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) * use this macro once, and calling it replaces module_init() and module_exit()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) #define module_acpi_driver(__acpi_driver) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) module_driver(__acpi_driver, acpi_bus_register_driver, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) acpi_bus_unregister_driver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) * Bind physical devices with ACPI devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) struct acpi_bus_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) bool (*match)(struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) struct acpi_device * (*find_companion)(struct device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) void (*setup)(struct device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) void (*cleanup)(struct device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) int register_acpi_bus_type(struct acpi_bus_type *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) int unregister_acpi_bus_type(struct acpi_bus_type *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) int acpi_bind_one(struct device *dev, struct acpi_device *adev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) int acpi_unbind_one(struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) struct acpi_pci_root {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) struct acpi_device * device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) struct pci_bus *bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) u16 segment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) struct resource secondary; /* downstream bus range */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) u32 osc_support_set; /* _OSC state of support bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) u32 osc_control_set; /* _OSC state of control bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) phys_addr_t mcfg_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) /* helper */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) bool acpi_dma_supported(struct acpi_device *adev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) int acpi_dma_get_range(struct device *dev, u64 *dma_addr, u64 *offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) u64 *size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) const u32 *input_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) static inline int acpi_dma_configure(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) enum dev_dma_attr attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) return acpi_dma_configure_id(dev, attr, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) u64 address, bool check_children);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) int acpi_is_root_bridge(acpi_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) int acpi_enable_wakeup_device_power(struct acpi_device *dev, int state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) int acpi_disable_wakeup_device_power(struct acpi_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) #ifdef CONFIG_X86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) bool acpi_device_override_status(struct acpi_device *adev, unsigned long long *status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) static inline bool acpi_device_override_status(struct acpi_device *adev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) unsigned long long *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) void acpi_pm_wakeup_event(struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) void (*func)(struct acpi_device_wakeup_context *context));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) acpi_status acpi_remove_pm_notifier(struct acpi_device *adev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) bool acpi_pm_device_can_wakeup(struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) int acpi_pm_device_sleep_state(struct device *, int *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) int acpi_pm_set_device_wakeup(struct device *dev, bool enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) static inline void acpi_pm_wakeup_event(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) static inline acpi_status acpi_add_pm_notifier(struct acpi_device *adev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) void (*func)(struct acpi_device_wakeup_context *context))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) return AE_SUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) static inline acpi_status acpi_remove_pm_notifier(struct acpi_device *adev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) return AE_SUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) static inline bool acpi_pm_device_can_wakeup(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) static inline int acpi_pm_device_sleep_state(struct device *d, int *p, int m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) if (p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) *p = ACPI_STATE_D0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3_COLD) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) m : ACPI_STATE_D0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) static inline int acpi_pm_set_device_wakeup(struct device *dev, bool enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) #ifdef CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) bool acpi_sleep_state_supported(u8 sleep_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) static inline bool acpi_sleep_state_supported(u8 sleep_state) { return false; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) #ifdef CONFIG_ACPI_SLEEP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) u32 acpi_target_system_state(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) static inline u32 acpi_target_system_state(void) { return ACPI_STATE_S0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) static inline bool acpi_device_power_manageable(struct acpi_device *adev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) return adev->flags.power_manageable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) static inline bool acpi_device_can_wakeup(struct acpi_device *adev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) return adev->wakeup.flags.valid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) return adev->power.states[ACPI_STATE_D3_COLD].flags.valid ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) ((acpi_gbl_FADT.header.revision < 6) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) struct acpi_device *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) static inline void acpi_dev_put(struct acpi_device *adev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) if (adev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) put_device(&adev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) #else /* CONFIG_ACPI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) static inline int register_acpi_bus_type(void *bus) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) static inline int unregister_acpi_bus_type(void *bus) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) #endif /* CONFIG_ACPI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) #endif /*__ACPI_BUS_H__*/