internal.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * acpi/internal.h
  4. * For use by Linux/ACPI infrastructure, not drivers
  5. *
  6. * Copyright (c) 2009, Intel Corporation.
  7. */
  8. #ifndef _ACPI_INTERNAL_H_
  9. #define _ACPI_INTERNAL_H_
  10. #include <linux/idr.h>
  11. #define PREFIX "ACPI: "
  12. int early_acpi_osi_init(void);
  13. int acpi_osi_init(void);
  14. acpi_status acpi_os_initialize1(void);
  15. int acpi_scan_init(void);
  16. #ifdef CONFIG_PCI
  17. void acpi_pci_root_init(void);
  18. void acpi_pci_link_init(void);
  19. #else
  20. static inline void acpi_pci_root_init(void) {}
  21. static inline void acpi_pci_link_init(void) {}
  22. #endif
  23. void acpi_processor_init(void);
  24. void acpi_platform_init(void);
  25. void acpi_pnp_init(void);
  26. void acpi_int340x_thermal_init(void);
  27. #ifdef CONFIG_ARM_AMBA
  28. void acpi_amba_init(void);
  29. #else
  30. static inline void acpi_amba_init(void) {}
  31. #endif
  32. int acpi_sysfs_init(void);
  33. void acpi_gpe_apply_masked_gpes(void);
  34. void acpi_container_init(void);
  35. void acpi_memory_hotplug_init(void);
  36. #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
  37. void pci_ioapic_remove(struct acpi_pci_root *root);
  38. int acpi_ioapic_remove(struct acpi_pci_root *root);
  39. #else
  40. static inline void pci_ioapic_remove(struct acpi_pci_root *root) { return; }
  41. static inline int acpi_ioapic_remove(struct acpi_pci_root *root) { return 0; }
  42. #endif
  43. #ifdef CONFIG_ACPI_DOCK
  44. void register_dock_dependent_device(struct acpi_device *adev,
  45. acpi_handle dshandle);
  46. int dock_notify(struct acpi_device *adev, u32 event);
  47. void acpi_dock_add(struct acpi_device *adev);
  48. #else
  49. static inline void register_dock_dependent_device(struct acpi_device *adev,
  50. acpi_handle dshandle) {}
  51. static inline int dock_notify(struct acpi_device *adev, u32 event) { return -ENODEV; }
  52. static inline void acpi_dock_add(struct acpi_device *adev) {}
  53. #endif
  54. #ifdef CONFIG_X86
  55. void acpi_cmos_rtc_init(void);
  56. #else
  57. static inline void acpi_cmos_rtc_init(void) {}
  58. #endif
  59. int acpi_rev_override_setup(char *str);
  60. void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug,
  61. const char *name);
  62. int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler,
  63. const char *hotplug_profile_name);
  64. void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, bool val);
  65. #ifdef CONFIG_DEBUG_FS
  66. extern struct dentry *acpi_debugfs_dir;
  67. void acpi_debugfs_init(void);
  68. #else
  69. static inline void acpi_debugfs_init(void) { return; }
  70. #endif
  71. #ifdef CONFIG_PCI
  72. void acpi_lpss_init(void);
  73. #else
  74. static inline void acpi_lpss_init(void) {}
  75. #endif
  76. void acpi_apd_init(void);
  77. acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src);
  78. bool acpi_queue_hotplug_work(struct work_struct *work);
  79. void acpi_device_hotplug(struct acpi_device *adev, u32 src);
  80. bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent);
  81. acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context);
  82. void acpi_scan_table_handler(u32 event, void *table, void *context);
  83. /* --------------------------------------------------------------------------
  84. Device Node Initialization / Removal
  85. -------------------------------------------------------------------------- */
  86. #define ACPI_STA_DEFAULT (ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | \
  87. ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING)
  88. extern struct list_head acpi_bus_id_list;
  89. #define ACPI_MAX_DEVICE_INSTANCES 4096
  90. struct acpi_device_bus_id {
  91. const char *bus_id;
  92. struct ida instance_ida;
  93. struct list_head node;
  94. };
  95. int acpi_device_add(struct acpi_device *device,
  96. void (*release)(struct device *));
  97. void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
  98. int type, unsigned long long sta);
  99. int acpi_device_setup_files(struct acpi_device *dev);
  100. void acpi_device_remove_files(struct acpi_device *dev);
  101. void acpi_device_add_finalize(struct acpi_device *device);
  102. void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
  103. bool acpi_device_is_present(const struct acpi_device *adev);
  104. bool acpi_device_is_battery(struct acpi_device *adev);
  105. bool acpi_device_is_first_physical_node(struct acpi_device *adev,
  106. const struct device *dev);
  107. int acpi_bus_register_early_device(int type);
  108. /* --------------------------------------------------------------------------
  109. Device Matching and Notification
  110. -------------------------------------------------------------------------- */
  111. struct acpi_device *acpi_companion_match(const struct device *dev);
  112. int __acpi_device_uevent_modalias(struct acpi_device *adev,
  113. struct kobj_uevent_env *env);
  114. /* --------------------------------------------------------------------------
  115. Power Resource
  116. -------------------------------------------------------------------------- */
  117. int acpi_power_init(void);
  118. void acpi_power_resources_list_free(struct list_head *list);
  119. int acpi_extract_power_resources(union acpi_object *package, unsigned int start,
  120. struct list_head *list);
  121. int acpi_add_power_resource(acpi_handle handle);
  122. void acpi_power_add_remove_device(struct acpi_device *adev, bool add);
  123. int acpi_power_wakeup_list_init(struct list_head *list, int *system_level);
  124. int acpi_device_sleep_wake(struct acpi_device *dev,
  125. int enable, int sleep_state, int dev_state);
  126. int acpi_power_get_inferred_state(struct acpi_device *device, int *state);
  127. int acpi_power_on_resources(struct acpi_device *device, int state);
  128. int acpi_power_transition(struct acpi_device *device, int state);
  129. /* --------------------------------------------------------------------------
  130. Device Power Management
  131. -------------------------------------------------------------------------- */
  132. int acpi_device_get_power(struct acpi_device *device, int *state);
  133. int acpi_wakeup_device_init(void);
  134. /* --------------------------------------------------------------------------
  135. Processor
  136. -------------------------------------------------------------------------- */
  137. #ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC
  138. void acpi_early_processor_set_pdc(void);
  139. #else
  140. static inline void acpi_early_processor_set_pdc(void) {}
  141. #endif
  142. #ifdef CONFIG_X86
  143. void acpi_early_processor_osc(void);
  144. #else
  145. static inline void acpi_early_processor_osc(void) {}
  146. #endif
  147. /* --------------------------------------------------------------------------
  148. Embedded Controller
  149. -------------------------------------------------------------------------- */
  150. struct acpi_ec {
  151. acpi_handle handle;
  152. int gpe;
  153. int irq;
  154. unsigned long command_addr;
  155. unsigned long data_addr;
  156. bool global_lock;
  157. unsigned long flags;
  158. unsigned long reference_count;
  159. struct mutex mutex;
  160. wait_queue_head_t wait;
  161. struct list_head list;
  162. struct transaction *curr;
  163. spinlock_t lock;
  164. struct work_struct work;
  165. unsigned long timestamp;
  166. unsigned long nr_pending_queries;
  167. unsigned int events_in_progress;
  168. unsigned int queries_in_progress;
  169. bool busy_polling;
  170. unsigned int polling_guard;
  171. };
  172. extern struct acpi_ec *first_ec;
  173. /* If we find an EC via the ECDT, we need to keep a ptr to its context */
  174. /* External interfaces use first EC only, so remember */
  175. typedef int (*acpi_ec_query_func) (void *data);
  176. void acpi_ec_init(void);
  177. void acpi_ec_ecdt_probe(void);
  178. void acpi_ec_dsdt_probe(void);
  179. void acpi_ec_block_transactions(void);
  180. void acpi_ec_unblock_transactions(void);
  181. int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
  182. acpi_handle handle, acpi_ec_query_func func,
  183. void *data);
  184. void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
  185. #ifdef CONFIG_PM_SLEEP
  186. void acpi_ec_flush_work(void);
  187. bool acpi_ec_dispatch_gpe(void);
  188. #endif
  189. /*--------------------------------------------------------------------------
  190. Suspend/Resume
  191. -------------------------------------------------------------------------- */
  192. #ifdef CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT
  193. extern bool acpi_s2idle_wakeup(void);
  194. extern int acpi_sleep_init(void);
  195. #else
  196. static inline bool acpi_s2idle_wakeup(void) { return false; }
  197. static inline int acpi_sleep_init(void) { return -ENXIO; }
  198. #endif
  199. #ifdef CONFIG_ACPI_SLEEP
  200. void acpi_sleep_proc_init(void);
  201. int suspend_nvs_alloc(void);
  202. void suspend_nvs_free(void);
  203. int suspend_nvs_save(void);
  204. void suspend_nvs_restore(void);
  205. #else
  206. static inline void acpi_sleep_proc_init(void) {}
  207. static inline int suspend_nvs_alloc(void) { return 0; }
  208. static inline void suspend_nvs_free(void) {}
  209. static inline int suspend_nvs_save(void) { return 0; }
  210. static inline void suspend_nvs_restore(void) {}
  211. #endif
  212. /*--------------------------------------------------------------------------
  213. Device properties
  214. -------------------------------------------------------------------------- */
  215. #define ACPI_DT_NAMESPACE_HID "PRP0001"
  216. void acpi_init_properties(struct acpi_device *adev);
  217. void acpi_free_properties(struct acpi_device *adev);
  218. #ifdef CONFIG_X86
  219. void acpi_extract_apple_properties(struct acpi_device *adev);
  220. #else
  221. static inline void acpi_extract_apple_properties(struct acpi_device *adev) {}
  222. #endif
  223. /*--------------------------------------------------------------------------
  224. Watchdog
  225. -------------------------------------------------------------------------- */
  226. #ifdef CONFIG_ACPI_WATCHDOG
  227. void acpi_watchdog_init(void);
  228. #else
  229. static inline void acpi_watchdog_init(void) {}
  230. #endif
  231. #ifdef CONFIG_ACPI_LPIT
  232. void acpi_init_lpit(void);
  233. #else
  234. static inline void acpi_init_lpit(void) { }
  235. #endif
  236. #endif /* _ACPI_INTERNAL_H_ */