[DRIVERS] Spelling fixes by Josh Soref. CORE-12286
[reactos.git] / reactos / drivers / bus / acpi / include / acpi_bus.h
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
26 #ifndef __ACPI_BUS_H__
27 #define __ACPI_BUS_H__
28
29 #include <acpi.h>
30
31 #include "list.h"
32
33
34 /* TBD: Make dynamic */
35 #define ACPI_MAX_HANDLES 10
36 struct acpi_handle_list {
37 UINT32 count;
38 ACPI_HANDLE handles[ACPI_MAX_HANDLES];
39 };
40
41
42 /* acpi_utils.h */
43 ACPI_STATUS
44 acpi_extract_package (
45 ACPI_OBJECT *package,
46 ACPI_BUFFER *format,
47 ACPI_BUFFER *buffer);
48 ACPI_STATUS
49 acpi_evaluate_integer (
50 ACPI_HANDLE handle,
51 ACPI_STRING pathname,
52 struct acpi_object_list *arguments,
53 unsigned long long *data);
54 ACPI_STATUS
55 acpi_evaluate_reference (
56 ACPI_HANDLE handle,
57 ACPI_STRING pathname,
58 struct acpi_object_list *arguments,
59 struct acpi_handle_list *list);
60
61 enum acpi_bus_removal_type {
62 ACPI_BUS_REMOVAL_NORMAL = 0,
63 ACPI_BUS_REMOVAL_EJECT,
64 ACPI_BUS_REMOVAL_SUPRISE,
65 ACPI_BUS_REMOVAL_TYPE_COUNT
66 };
67
68 enum acpi_bus_device_type {
69 ACPI_BUS_TYPE_DEVICE = 0,
70 ACPI_BUS_TYPE_POWER,
71 ACPI_BUS_TYPE_PROCESSOR,
72 ACPI_BUS_TYPE_THERMAL,
73 ACPI_BUS_TYPE_SYSTEM,
74 ACPI_BUS_TYPE_POWER_BUTTON,
75 ACPI_BUS_TYPE_SLEEP_BUTTON,
76 ACPI_BUS_TYPE_POWER_BUTTONF,
77 ACPI_BUS_TYPE_SLEEP_BUTTONF,
78 ACPI_BUS_DEVICE_TYPE_COUNT
79 };
80
81 struct acpi_driver;
82 struct acpi_device;
83
84
85 /*
86 * ACPI Driver
87 * -----------
88 */
89
90 typedef int (*acpi_op_add) (struct acpi_device *device);
91 typedef int (*acpi_op_remove) (struct acpi_device *device, int type);
92 typedef int (*acpi_op_start) (struct acpi_device *device);
93 typedef int (*acpi_op_suspend) (struct acpi_device *device, int state);
94 typedef int (*acpi_op_resume) (struct acpi_device *device, int state);
95 typedef int (*acpi_op_scan) (struct acpi_device *device);
96 typedef int (*acpi_op_bind) (struct acpi_device *device);
97 typedef int (*acpi_op_unbind) (struct acpi_device * device);
98 typedef void (*acpi_op_notify) (struct acpi_device * device, UINT32 event);
99
100 struct acpi_bus_ops {
101 UINT32 acpi_op_add:1;
102 UINT32 acpi_op_start:1;
103 };
104
105 struct acpi_device_ops {
106 acpi_op_add add;
107 acpi_op_remove remove;
108 acpi_op_start start;
109 acpi_op_suspend suspend;
110 acpi_op_resume resume;
111 acpi_op_bind bind;
112 acpi_op_unbind unbind;
113 acpi_op_notify notify;
114 acpi_op_scan scan;
115 };
116
117 #define ACPI_DRIVER_ALL_NOTIFY_EVENTS 0x1 /* system AND device events */
118
119 struct acpi_driver {
120 struct list_head node;
121 char name[80];
122 char class[80];
123 int references;
124 unsigned int flags;
125 char *ids; /* Supported Hardware IDs */
126 struct acpi_device_ops ops;
127 };
128
129 /*
130 * ACPI Device
131 * -----------
132 */
133
134 /* Status (_STA) */
135
136 struct acpi_device_status {
137 UINT32 present:1;
138 UINT32 enabled:1;
139 UINT32 show_in_ui:1;
140 UINT32 functional:1;
141 UINT32 battery_present:1;
142 UINT32 reserved:27;
143 };
144
145
146 /* Flags */
147
148 struct acpi_device_flags {
149 UINT32 dynamic_status:1;
150 UINT32 hardware_id:1;
151 UINT32 compatible_ids:1;
152 UINT32 bus_address:1;
153 UINT32 unique_id:1;
154 UINT32 removable:1;
155 UINT32 ejectable:1;
156 UINT32 lockable:1;
157 UINT32 surprise_removal_ok:1;
158 UINT32 power_manageable:1;
159 UINT32 performance_manageable:1;
160 UINT32 wake_capable:1;
161 UINT32 force_power_state:1;
162 UINT32 reserved:20;
163 };
164
165 /* Plug and Play */
166
167 typedef char acpi_bus_id[8];
168 typedef unsigned long acpi_bus_address;
169 typedef char *acpi_hardware_id;
170 typedef char acpi_unique_id[9];
171 typedef char acpi_device_name[40];
172 typedef char acpi_device_class[20];
173
174 struct acpi_device_pnp {
175 acpi_bus_id bus_id; /* Object name */
176 acpi_bus_address bus_address; /* _ADR */
177 acpi_hardware_id hardware_id; /* _HID */
178 ACPI_PNP_DEVICE_ID_LIST *cid_list; /* _CIDs */
179 acpi_unique_id unique_id; /* _UID */
180 acpi_device_name device_name; /* Driver-determined */
181 acpi_device_class device_class; /* " */
182 };
183
184 #define acpi_device_bid(d) ((d)->pnp.bus_id)
185 #define acpi_device_adr(d) ((d)->pnp.bus_address)
186 #define acpi_device_hid(d) ((d)->pnp.hardware_id)
187 #define acpi_device_uid(d) ((d)->pnp.unique_id)
188 #define acpi_device_name(d) ((d)->pnp.device_name)
189 #define acpi_device_class(d) ((d)->pnp.device_class)
190
191
192 /* Power Management */
193
194 struct acpi_device_power_flags {
195 UINT32 explicit_get:1; /* _PSC present? */
196 UINT32 power_resources:1; /* Power resources */
197 UINT32 inrush_current:1; /* Serialize Dx->D0 */
198 UINT32 power_removed:1; /* Optimize Dx->D0 */
199 UINT32 reserved:28;
200 };
201
202 struct acpi_device_power_state {
203 struct {
204 UINT8 valid:1;
205 UINT8 explicit_set:1; /* _PSx present? */
206 UINT8 reserved:6;
207 } flags;
208 int power; /* % Power (compared to D0) */
209 int latency; /* Dx->D0 time (microseconds) */
210 struct acpi_handle_list resources; /* Power resources referenced */
211 };
212
213 struct acpi_device_power {
214 int state; /* Current state */
215 struct acpi_device_power_flags flags;
216 struct acpi_device_power_state states[4]; /* Power states (D0-D3) */
217 };
218
219
220 /* Performance Management */
221
222 struct acpi_device_perf_flags {
223 UINT8 reserved:8;
224 };
225
226 struct acpi_device_perf_state {
227 struct {
228 UINT8 valid:1;
229 UINT8 reserved:7;
230 } flags;
231 UINT8 power; /* % Power (compared to P0) */
232 UINT8 performance; /* % Performance ( " ) */
233 int latency; /* Px->P0 time (microseconds) */
234 };
235
236 struct acpi_device_perf {
237 int state;
238 struct acpi_device_perf_flags flags;
239 int state_count;
240 struct acpi_device_perf_state *states;
241 };
242
243 /* Wakeup Management */
244 struct acpi_device_wakeup_flags {
245 UINT8 valid:1; /* Can successfully enable wakeup? */
246 UINT8 run_wake:1; /* Run-Wake GPE devices */
247 };
248
249 struct acpi_device_wakeup_state {
250 UINT8 enabled:1;
251 };
252
253 struct acpi_device_wakeup {
254 ACPI_HANDLE gpe_device;
255 ACPI_INTEGER gpe_number;
256 ACPI_INTEGER sleep_state;
257 struct acpi_handle_list resources;
258 struct acpi_device_wakeup_state state;
259 struct acpi_device_wakeup_flags flags;
260 int prepare_count;
261 };
262
263
264 /* Device */
265
266 struct acpi_device {
267 int device_type;
268 ACPI_HANDLE handle;
269 struct acpi_device *parent;
270 struct list_head children;
271 struct list_head node;
272 struct list_head wakeup_list;
273 struct acpi_device_status status;
274 struct acpi_device_flags flags;
275 struct acpi_device_pnp pnp;
276 struct acpi_device_power power;
277 struct acpi_device_wakeup wakeup;
278 struct acpi_device_perf performance;
279 struct acpi_device_ops ops;
280 struct acpi_driver *driver;
281 void *driver_data;
282 struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */
283 enum acpi_bus_removal_type removal_type; /* indicate for different removal type */
284
285 };
286
287 #define acpi_driver_data(d) ((d)->driver_data)
288
289 #define to_acpi_device(d) container_of(d, struct acpi_device, dev)
290 #define to_acpi_driver(d) container_of(d, struct acpi_driver, drv)
291
292 /* acpi_device.dev.bus == &acpi_bus_type */
293 extern struct bus_type acpi_bus_type;
294
295 /*
296 * Events
297 * ------
298 */
299
300 struct acpi_bus_event {
301 struct list_head node;
302 acpi_device_class device_class;
303 acpi_bus_id bus_id;
304 UINT32 type;
305 UINT32 data;
306 };
307
308
309 /*
310 * External Functions
311 */
312 int acpi_bus_get_private_data(ACPI_HANDLE, void **);
313
314 void acpi_bus_data_handler(ACPI_HANDLE handle, void *context);
315 ACPI_STATUS acpi_bus_get_status_handle(ACPI_HANDLE handle,
316 unsigned long long *sta);
317 int acpi_bus_get_status(struct acpi_device *device);
318 int acpi_bus_get_power(ACPI_HANDLE handle, int *state);
319 int acpi_bus_set_power(ACPI_HANDLE handle, int state);
320 BOOLEAN acpi_bus_power_manageable(ACPI_HANDLE handle);
321 BOOLEAN acpi_bus_can_wakeup(ACPI_HANDLE handle);
322 int acpi_bus_generate_proc_event(struct acpi_device *device, UINT8 type, int data);
323 int acpi_bus_generate_event(struct acpi_device *device, UINT8 type, int data);
324 int acpi_bus_receive_event(struct acpi_bus_event *event);
325 int acpi_bus_register_driver(struct acpi_driver *driver);
326 void acpi_bus_unregister_driver(struct acpi_driver *driver);
327 int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent,
328 ACPI_HANDLE handle, int type);
329 int acpi_bus_trim(struct acpi_device *start, int rmdevice);
330 int acpi_bus_start(struct acpi_device *device);
331 ACPI_STATUS acpi_bus_get_ejd(ACPI_HANDLE handle, ACPI_HANDLE * ejd);
332 int acpi_match_device_ids(struct acpi_device *device,
333 const struct acpi_pnp_device_id *ids);
334 int acpi_bus_get_device(ACPI_HANDLE handle, struct acpi_device **device);
335 int acpi_init(void);
336 ACPI_STATUS acpi_suspend (UINT32 state);
337
338 /*
339 * Bind physical devices with ACPI devices
340 */
341 //struct acpi_bus_type {
342 // struct list_head list;
343 // struct bus_type *bus;
344 // /* For general devices under the bus */
345 // int (*find_device) (struct device *, ACPI_HANDLE *);
346 // /* For bridges, such as PCI root bridge, IDE controller */
347 // int (*find_bridge) (struct device *, ACPI_HANDLE *);
348 //};
349 //int register_acpi_bus_type(struct acpi_bus_type *);
350 //int unregister_acpi_bus_type(struct acpi_bus_type *);
351 //struct device *acpi_get_physical_device(ACPI_HANDLE);
352
353 struct acpi_pci_root {
354 struct list_head node;
355 struct acpi_device * device;
356 struct acpi_pci_id id;
357 struct pci_bus *bus;
358 UINT16 segment;
359 UINT8 bus_nr;
360
361 UINT32 osc_support_set; /* _OSC state of support bits */
362 UINT32 osc_control_set; /* _OSC state of control bits */
363 UINT32 osc_control_qry; /* the latest _OSC query result */
364
365 UINT32 osc_queried:1; /* has _OSC control been queried? */
366 };
367
368 //static inline int acpi_pm_device_sleep_state(struct device *d, int *p)
369 //{
370 // if (p)
371 // *p = ACPI_STATE_D0;
372 // return ACPI_STATE_D3;
373 //}
374 //static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
375 //{
376 // return -1;
377 //}
378
379 /* system defines: move to bigger header */
380 extern enum acpi_irq_model_id acpi_irq_model;
381
382 enum acpi_irq_model_id {
383 ACPI_IRQ_MODEL_PIC = 0,
384 ACPI_IRQ_MODEL_IOAPIC,
385 ACPI_IRQ_MODEL_IOSAPIC,
386 ACPI_IRQ_MODEL_COUNT
387 };
388
389
390
391 #endif /*__ACPI_BUS_H__*/