Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * acpi/internal.h
0004  * For use by Linux/ACPI infrastructure, not drivers
0005  *
0006  * Copyright (c) 2009, Intel Corporation.
0007  */
0008 
0009 #ifndef _ACPI_INTERNAL_H_
0010 #define _ACPI_INTERNAL_H_
0011 
0012 #include <linux/idr.h>
0013 
0014 int early_acpi_osi_init(void);
0015 int acpi_osi_init(void);
0016 acpi_status acpi_os_initialize1(void);
0017 void acpi_scan_init(void);
0018 #ifdef CONFIG_PCI
0019 void acpi_pci_root_init(void);
0020 void acpi_pci_link_init(void);
0021 #else
0022 static inline void acpi_pci_root_init(void) {}
0023 static inline void acpi_pci_link_init(void) {}
0024 #endif
0025 void acpi_processor_init(void);
0026 void acpi_platform_init(void);
0027 void acpi_pnp_init(void);
0028 void acpi_int340x_thermal_init(void);
0029 #ifdef CONFIG_ARM_AMBA
0030 void acpi_amba_init(void);
0031 #else
0032 static inline void acpi_amba_init(void) {}
0033 #endif
0034 int acpi_sysfs_init(void);
0035 void acpi_gpe_apply_masked_gpes(void);
0036 void acpi_container_init(void);
0037 void acpi_memory_hotplug_init(void);
0038 #ifdef  CONFIG_ACPI_HOTPLUG_IOAPIC
0039 void pci_ioapic_remove(struct acpi_pci_root *root);
0040 int acpi_ioapic_remove(struct acpi_pci_root *root);
0041 #else
0042 static inline void pci_ioapic_remove(struct acpi_pci_root *root) { return; }
0043 static inline int acpi_ioapic_remove(struct acpi_pci_root *root) { return 0; }
0044 #endif
0045 #ifdef CONFIG_ACPI_DOCK
0046 void register_dock_dependent_device(struct acpi_device *adev,
0047                     acpi_handle dshandle);
0048 int dock_notify(struct acpi_device *adev, u32 event);
0049 void acpi_dock_add(struct acpi_device *adev);
0050 #else
0051 static inline void register_dock_dependent_device(struct acpi_device *adev,
0052                           acpi_handle dshandle) {}
0053 static inline int dock_notify(struct acpi_device *adev, u32 event) { return -ENODEV; }
0054 static inline void acpi_dock_add(struct acpi_device *adev) {}
0055 #endif
0056 #ifdef CONFIG_X86
0057 void acpi_cmos_rtc_init(void);
0058 #else
0059 static inline void acpi_cmos_rtc_init(void) {}
0060 #endif
0061 int acpi_rev_override_setup(char *str);
0062 
0063 void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug,
0064                     const char *name);
0065 int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler,
0066                        const char *hotplug_profile_name);
0067 void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, bool val);
0068 
0069 #ifdef CONFIG_DEBUG_FS
0070 extern struct dentry *acpi_debugfs_dir;
0071 void acpi_debugfs_init(void);
0072 #else
0073 static inline void acpi_debugfs_init(void) { return; }
0074 #endif
0075 #ifdef CONFIG_PCI
0076 void acpi_lpss_init(void);
0077 #else
0078 static inline void acpi_lpss_init(void) {}
0079 #endif
0080 
0081 void acpi_apd_init(void);
0082 
0083 acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src);
0084 bool acpi_queue_hotplug_work(struct work_struct *work);
0085 void acpi_device_hotplug(struct acpi_device *adev, u32 src);
0086 bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent);
0087 
0088 acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context);
0089 void acpi_scan_table_notify(void);
0090 
0091 /* --------------------------------------------------------------------------
0092                      Device Node Initialization / Removal
0093    -------------------------------------------------------------------------- */
0094 #define ACPI_STA_DEFAULT (ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | \
0095               ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING)
0096 
0097 extern struct list_head acpi_bus_id_list;
0098 
0099 struct acpi_device_bus_id {
0100     const char *bus_id;
0101     struct ida instance_ida;
0102     struct list_head node;
0103 };
0104 
0105 int acpi_device_add(struct acpi_device *device,
0106             void (*release)(struct device *));
0107 void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
0108                  int type);
0109 int acpi_device_setup_files(struct acpi_device *dev);
0110 void acpi_device_remove_files(struct acpi_device *dev);
0111 void acpi_device_add_finalize(struct acpi_device *device);
0112 void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
0113 bool acpi_device_is_present(const struct acpi_device *adev);
0114 bool acpi_device_is_battery(struct acpi_device *adev);
0115 bool acpi_device_is_first_physical_node(struct acpi_device *adev,
0116                     const struct device *dev);
0117 int acpi_bus_register_early_device(int type);
0118 
0119 /* --------------------------------------------------------------------------
0120                      Device Matching and Notification
0121    -------------------------------------------------------------------------- */
0122 struct acpi_device *acpi_companion_match(const struct device *dev);
0123 int __acpi_device_uevent_modalias(struct acpi_device *adev,
0124                   struct kobj_uevent_env *env);
0125 
0126 /* --------------------------------------------------------------------------
0127                                   Power Resource
0128    -------------------------------------------------------------------------- */
0129 int acpi_power_init(void);
0130 void acpi_power_resources_list_free(struct list_head *list);
0131 int acpi_extract_power_resources(union acpi_object *package, unsigned int start,
0132                  struct list_head *list);
0133 struct acpi_device *acpi_add_power_resource(acpi_handle handle);
0134 void acpi_power_add_remove_device(struct acpi_device *adev, bool add);
0135 int acpi_power_wakeup_list_init(struct list_head *list, int *system_level);
0136 int acpi_device_sleep_wake(struct acpi_device *dev,
0137                int enable, int sleep_state, int dev_state);
0138 int acpi_power_get_inferred_state(struct acpi_device *device, int *state);
0139 int acpi_power_on_resources(struct acpi_device *device, int state);
0140 int acpi_power_transition(struct acpi_device *device, int state);
0141 void acpi_turn_off_unused_power_resources(void);
0142 
0143 /* --------------------------------------------------------------------------
0144                               Device Power Management
0145    -------------------------------------------------------------------------- */
0146 int acpi_device_get_power(struct acpi_device *device, int *state);
0147 int acpi_wakeup_device_init(void);
0148 
0149 /* --------------------------------------------------------------------------
0150                                   Processor
0151    -------------------------------------------------------------------------- */
0152 #ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC
0153 void acpi_early_processor_set_pdc(void);
0154 #else
0155 static inline void acpi_early_processor_set_pdc(void) {}
0156 #endif
0157 
0158 #ifdef CONFIG_X86
0159 void acpi_early_processor_osc(void);
0160 #else
0161 static inline void acpi_early_processor_osc(void) {}
0162 #endif
0163 
0164 /* --------------------------------------------------------------------------
0165                                   Embedded Controller
0166    -------------------------------------------------------------------------- */
0167 
0168 enum acpi_ec_event_state {
0169     EC_EVENT_READY = 0, /* Event work can be submitted */
0170     EC_EVENT_IN_PROGRESS,   /* Event work is pending or being processed */
0171     EC_EVENT_COMPLETE,  /* Event work processing has completed */
0172 };
0173 
0174 struct acpi_ec {
0175     acpi_handle handle;
0176     int gpe;
0177     int irq;
0178     unsigned long command_addr;
0179     unsigned long data_addr;
0180     bool global_lock;
0181     unsigned long flags;
0182     unsigned long reference_count;
0183     struct mutex mutex;
0184     wait_queue_head_t wait;
0185     struct list_head list;
0186     struct transaction *curr;
0187     spinlock_t lock;
0188     struct work_struct work;
0189     unsigned long timestamp;
0190     enum acpi_ec_event_state event_state;
0191     unsigned int events_to_process;
0192     unsigned int events_in_progress;
0193     unsigned int queries_in_progress;
0194     bool busy_polling;
0195     unsigned int polling_guard;
0196 };
0197 
0198 extern struct acpi_ec *first_ec;
0199 
0200 /* If we find an EC via the ECDT, we need to keep a ptr to its context */
0201 /* External interfaces use first EC only, so remember */
0202 typedef int (*acpi_ec_query_func) (void *data);
0203 
0204 void acpi_ec_init(void);
0205 void acpi_ec_ecdt_probe(void);
0206 void acpi_ec_dsdt_probe(void);
0207 void acpi_ec_block_transactions(void);
0208 void acpi_ec_unblock_transactions(void);
0209 int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
0210                   acpi_handle handle, acpi_ec_query_func func,
0211                   void *data);
0212 void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
0213 
0214 #ifdef CONFIG_PM_SLEEP
0215 void acpi_ec_flush_work(void);
0216 bool acpi_ec_dispatch_gpe(void);
0217 #endif
0218 
0219 
0220 /*--------------------------------------------------------------------------
0221                                   Suspend/Resume
0222   -------------------------------------------------------------------------- */
0223 #ifdef CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT
0224 extern bool acpi_s2idle_wakeup(void);
0225 extern int acpi_sleep_init(void);
0226 #else
0227 static inline bool acpi_s2idle_wakeup(void) { return false; }
0228 static inline int acpi_sleep_init(void) { return -ENXIO; }
0229 #endif
0230 
0231 #ifdef CONFIG_ACPI_SLEEP
0232 void acpi_sleep_proc_init(void);
0233 int suspend_nvs_alloc(void);
0234 void suspend_nvs_free(void);
0235 int suspend_nvs_save(void);
0236 void suspend_nvs_restore(void);
0237 #else
0238 static inline void acpi_sleep_proc_init(void) {}
0239 static inline int suspend_nvs_alloc(void) { return 0; }
0240 static inline void suspend_nvs_free(void) {}
0241 static inline int suspend_nvs_save(void) { return 0; }
0242 static inline void suspend_nvs_restore(void) {}
0243 #endif
0244 
0245 #ifdef CONFIG_X86
0246 bool force_storage_d3(void);
0247 #else
0248 static inline bool force_storage_d3(void)
0249 {
0250     return false;
0251 }
0252 #endif
0253 
0254 /*--------------------------------------------------------------------------
0255                 Device properties
0256   -------------------------------------------------------------------------- */
0257 #define ACPI_DT_NAMESPACE_HID   "PRP0001"
0258 
0259 void acpi_init_properties(struct acpi_device *adev);
0260 void acpi_free_properties(struct acpi_device *adev);
0261 
0262 #ifdef CONFIG_X86
0263 void acpi_extract_apple_properties(struct acpi_device *adev);
0264 #else
0265 static inline void acpi_extract_apple_properties(struct acpi_device *adev) {}
0266 #endif
0267 
0268 /*--------------------------------------------------------------------------
0269                 Watchdog
0270   -------------------------------------------------------------------------- */
0271 
0272 #ifdef CONFIG_ACPI_WATCHDOG
0273 void acpi_watchdog_init(void);
0274 #else
0275 static inline void acpi_watchdog_init(void) {}
0276 #endif
0277 
0278 #ifdef CONFIG_ACPI_LPIT
0279 void acpi_init_lpit(void);
0280 #else
0281 static inline void acpi_init_lpit(void) { }
0282 #endif
0283 
0284 #endif /* _ACPI_INTERNAL_H_ */