acpi_bus.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. /*
  2. * acpi_bus.h - ACPI Bus Driver ($Revision: 22 $)
  3. *
  4. * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  5. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  6. *
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at
  12. * your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  22. *
  23. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. */
  25. #ifndef __ACPI_BUS_H__
  26. #define __ACPI_BUS_H__
  27. #include <linux/kobject.h>
  28. #include <acpi/acpi.h>
  29. #define PREFIX "ACPI: "
  30. /* TBD: Make dynamic */
  31. #define ACPI_MAX_HANDLES 10
  32. struct acpi_handle_list {
  33. u32 count;
  34. acpi_handle handles[ACPI_MAX_HANDLES];
  35. };
  36. /* acpi_utils.h */
  37. acpi_status
  38. acpi_extract_package (
  39. union acpi_object *package,
  40. struct acpi_buffer *format,
  41. struct acpi_buffer *buffer);
  42. acpi_status
  43. acpi_evaluate_integer (
  44. acpi_handle handle,
  45. acpi_string pathname,
  46. struct acpi_object_list *arguments,
  47. unsigned long *data);
  48. acpi_status
  49. acpi_evaluate_reference (
  50. acpi_handle handle,
  51. acpi_string pathname,
  52. struct acpi_object_list *arguments,
  53. struct acpi_handle_list *list);
  54. #ifdef CONFIG_ACPI_BUS
  55. #include <linux/proc_fs.h>
  56. #define ACPI_BUS_FILE_ROOT "acpi"
  57. extern struct proc_dir_entry *acpi_root_dir;
  58. extern FADT_DESCRIPTOR acpi_fadt;
  59. enum acpi_bus_removal_type {
  60. ACPI_BUS_REMOVAL_NORMAL = 0,
  61. ACPI_BUS_REMOVAL_EJECT,
  62. ACPI_BUS_REMOVAL_SUPRISE,
  63. ACPI_BUS_REMOVAL_TYPE_COUNT
  64. };
  65. enum acpi_bus_device_type {
  66. ACPI_BUS_TYPE_DEVICE = 0,
  67. ACPI_BUS_TYPE_POWER,
  68. ACPI_BUS_TYPE_PROCESSOR,
  69. ACPI_BUS_TYPE_THERMAL,
  70. ACPI_BUS_TYPE_SYSTEM,
  71. ACPI_BUS_TYPE_POWER_BUTTON,
  72. ACPI_BUS_TYPE_SLEEP_BUTTON,
  73. ACPI_BUS_DEVICE_TYPE_COUNT
  74. };
  75. struct acpi_driver;
  76. struct acpi_device;
  77. /*
  78. * ACPI Driver
  79. * -----------
  80. */
  81. typedef int (*acpi_op_add) (struct acpi_device *device);
  82. typedef int (*acpi_op_remove) (struct acpi_device *device, int type);
  83. typedef int (*acpi_op_lock) (struct acpi_device *device, int type);
  84. typedef int (*acpi_op_start) (struct acpi_device *device);
  85. typedef int (*acpi_op_stop) (struct acpi_device *device, int type);
  86. typedef int (*acpi_op_suspend) (struct acpi_device *device, int state);
  87. typedef int (*acpi_op_resume) (struct acpi_device *device, int state);
  88. typedef int (*acpi_op_scan) (struct acpi_device *device);
  89. typedef int (*acpi_op_bind) (struct acpi_device *device);
  90. typedef int (*acpi_op_unbind) (struct acpi_device *device);
  91. typedef int (*acpi_op_match) (struct acpi_device *device,
  92. struct acpi_driver *driver);
  93. struct acpi_bus_ops {
  94. u32 acpi_op_add:1;
  95. u32 acpi_op_remove:1;
  96. u32 acpi_op_lock:1;
  97. u32 acpi_op_start:1;
  98. u32 acpi_op_stop:1;
  99. u32 acpi_op_suspend:1;
  100. u32 acpi_op_resume:1;
  101. u32 acpi_op_scan:1;
  102. u32 acpi_op_bind:1;
  103. u32 acpi_op_unbind:1;
  104. u32 acpi_op_match:1;
  105. u32 reserved:21;
  106. };
  107. struct acpi_device_ops {
  108. acpi_op_add add;
  109. acpi_op_remove remove;
  110. acpi_op_lock lock;
  111. acpi_op_start start;
  112. acpi_op_stop stop;
  113. acpi_op_suspend suspend;
  114. acpi_op_resume resume;
  115. acpi_op_scan scan;
  116. acpi_op_bind bind;
  117. acpi_op_unbind unbind;
  118. acpi_op_match match;
  119. };
  120. struct acpi_driver {
  121. struct list_head node;
  122. char name[80];
  123. char class[80];
  124. atomic_t references;
  125. char *ids; /* Supported Hardware IDs */
  126. struct acpi_device_ops ops;
  127. };
  128. /*
  129. * ACPI Device
  130. * -----------
  131. */
  132. /* Status (_STA) */
  133. struct acpi_device_status {
  134. u32 present:1;
  135. u32 enabled:1;
  136. u32 show_in_ui:1;
  137. u32 functional:1;
  138. u32 battery_present:1;
  139. u32 reserved:27;
  140. };
  141. /* Flags */
  142. struct acpi_device_flags {
  143. u32 dynamic_status:1;
  144. u32 hardware_id:1;
  145. u32 compatible_ids:1;
  146. u32 bus_address:1;
  147. u32 unique_id:1;
  148. u32 removable:1;
  149. u32 ejectable:1;
  150. u32 lockable:1;
  151. u32 suprise_removal_ok:1;
  152. u32 power_manageable:1;
  153. u32 performance_manageable:1;
  154. u32 wake_capable:1; /* Wakeup(_PRW) supported? */
  155. u32 reserved:20;
  156. };
  157. /* File System */
  158. struct acpi_device_dir {
  159. struct proc_dir_entry *entry;
  160. };
  161. #define acpi_device_dir(d) ((d)->dir.entry)
  162. /* Plug and Play */
  163. typedef char acpi_bus_id[5];
  164. typedef unsigned long acpi_bus_address;
  165. typedef char acpi_hardware_id[9];
  166. typedef char acpi_unique_id[9];
  167. typedef char acpi_device_name[40];
  168. typedef char acpi_device_class[20];
  169. struct acpi_device_pnp {
  170. acpi_bus_id bus_id; /* Object name */
  171. acpi_bus_address bus_address; /* _ADR */
  172. acpi_hardware_id hardware_id; /* _HID */
  173. struct acpi_compatible_id_list *cid_list; /* _CIDs */
  174. acpi_unique_id unique_id; /* _UID */
  175. acpi_device_name device_name; /* Driver-determined */
  176. acpi_device_class device_class; /* " */
  177. };
  178. #define acpi_device_bid(d) ((d)->pnp.bus_id)
  179. #define acpi_device_adr(d) ((d)->pnp.bus_address)
  180. #define acpi_device_hid(d) ((d)->pnp.hardware_id)
  181. #define acpi_device_uid(d) ((d)->pnp.unique_id)
  182. #define acpi_device_name(d) ((d)->pnp.device_name)
  183. #define acpi_device_class(d) ((d)->pnp.device_class)
  184. /* Power Management */
  185. struct acpi_device_power_flags {
  186. u32 explicit_get:1; /* _PSC present? */
  187. u32 power_resources:1; /* Power resources */
  188. u32 inrush_current:1; /* Serialize Dx->D0 */
  189. u32 power_removed:1; /* Optimize Dx->D0 */
  190. u32 reserved:28;
  191. };
  192. struct acpi_device_power_state {
  193. struct {
  194. u8 valid:1;
  195. u8 explicit_set:1; /* _PSx present? */
  196. u8 reserved:6;
  197. } flags;
  198. int power; /* % Power (compared to D0) */
  199. int latency; /* Dx->D0 time (microseconds) */
  200. struct acpi_handle_list resources; /* Power resources referenced */
  201. };
  202. struct acpi_device_power {
  203. int state; /* Current state */
  204. struct acpi_device_power_flags flags;
  205. struct acpi_device_power_state states[4]; /* Power states (D0-D3) */
  206. };
  207. /* Performance Management */
  208. struct acpi_device_perf_flags {
  209. u8 reserved:8;
  210. };
  211. struct acpi_device_perf_state {
  212. struct {
  213. u8 valid:1;
  214. u8 reserved:7;
  215. } flags;
  216. u8 power; /* % Power (compared to P0) */
  217. u8 performance; /* % Performance ( " ) */
  218. int latency; /* Px->P0 time (microseconds) */
  219. };
  220. struct acpi_device_perf {
  221. int state;
  222. struct acpi_device_perf_flags flags;
  223. int state_count;
  224. struct acpi_device_perf_state *states;
  225. };
  226. /* Wakeup Management */
  227. struct acpi_device_wakeup_flags {
  228. u8 valid:1; /* Can successfully enable wakeup? */
  229. u8 run_wake:1; /* Run-Wake GPE devices */
  230. };
  231. struct acpi_device_wakeup_state {
  232. u8 enabled:1;
  233. u8 active:1;
  234. };
  235. struct acpi_device_wakeup {
  236. acpi_handle gpe_device;
  237. acpi_integer gpe_number;;
  238. acpi_integer sleep_state;
  239. struct acpi_handle_list resources;
  240. struct acpi_device_wakeup_state state;
  241. struct acpi_device_wakeup_flags flags;
  242. };
  243. /* Device */
  244. struct acpi_device {
  245. acpi_handle handle;
  246. struct acpi_device *parent;
  247. struct list_head children;
  248. struct list_head node;
  249. struct list_head wakeup_list;
  250. struct list_head g_list;
  251. struct acpi_device_status status;
  252. struct acpi_device_flags flags;
  253. struct acpi_device_pnp pnp;
  254. struct acpi_device_power power;
  255. struct acpi_device_wakeup wakeup;
  256. struct acpi_device_perf performance;
  257. struct acpi_device_dir dir;
  258. struct acpi_device_ops ops;
  259. struct acpi_driver *driver;
  260. void *driver_data;
  261. struct kobject kobj;
  262. };
  263. #define acpi_driver_data(d) ((d)->driver_data)
  264. /*
  265. * Events
  266. * ------
  267. */
  268. struct acpi_bus_event {
  269. struct list_head node;
  270. acpi_device_class device_class;
  271. acpi_bus_id bus_id;
  272. u32 type;
  273. u32 data;
  274. };
  275. extern struct subsystem acpi_subsys;
  276. /*
  277. * External Functions
  278. */
  279. int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
  280. void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context);
  281. int acpi_bus_get_status (struct acpi_device *device);
  282. int acpi_bus_get_power (acpi_handle handle, int *state);
  283. int acpi_bus_set_power (acpi_handle handle, int state);
  284. int acpi_bus_generate_event (struct acpi_device *device, u8 type, int data);
  285. int acpi_bus_receive_event (struct acpi_bus_event *event);
  286. int acpi_bus_register_driver (struct acpi_driver *driver);
  287. int acpi_bus_unregister_driver (struct acpi_driver *driver);
  288. int acpi_bus_add (struct acpi_device **child, struct acpi_device *parent,
  289. acpi_handle handle, int type);
  290. int acpi_bus_start (struct acpi_device *device);
  291. int acpi_match_ids (struct acpi_device *device, char *ids);
  292. int acpi_create_dir(struct acpi_device *);
  293. void acpi_remove_dir(struct acpi_device *);
  294. #endif /*CONFIG_ACPI_BUS*/
  295. #endif /*__ACPI_BUS_H__*/