Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
434 giacomo 1
/*
2
 *  acpi_bus.h - ACPI Bus Driver ($Revision: 1.1 $)
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 <linux/kobject.h>
30
 
31
#include <acpi/acpi.h>
32
 
33
#define PREFIX                  "ACPI: "
34
 
35
extern int                      acpi_disabled;
36
 
37
/* TBD: Make dynamic */
38
#define ACPI_MAX_HANDLES        10
39
struct acpi_handle_list {
40
        u32                     count;
41
        acpi_handle             handles[ACPI_MAX_HANDLES];
42
};
43
 
44
 
45
/* acpi_utils.h */
46
acpi_status
47
acpi_extract_package (
48
        union acpi_object       *package,
49
        struct acpi_buffer      *format,
50
        struct acpi_buffer      *buffer);
51
acpi_status
52
acpi_evaluate_integer (
53
        acpi_handle             handle,
54
        acpi_string             pathname,
55
        struct acpi_object_list *arguments,
56
        unsigned long           *data);
57
acpi_status
58
acpi_evaluate_reference (
59
        acpi_handle             handle,
60
        acpi_string             pathname,
61
        struct acpi_object_list *arguments,
62
        struct acpi_handle_list *list);
63
 
64
 
65
#ifdef CONFIG_ACPI_BUS
66
 
67
#include <linux/proc_fs.h>
68
 
69
#define ACPI_BUS_FILE_ROOT      "acpi"
70
extern struct proc_dir_entry    *acpi_root_dir;
71
extern FADT_DESCRIPTOR          acpi_fadt;
72
 
73
enum acpi_bus_removal_type {
74
        ACPI_BUS_REMOVAL_NORMAL = 0,
75
        ACPI_BUS_REMOVAL_EJECT,
76
        ACPI_BUS_REMOVAL_SUPRISE,
77
        ACPI_BUS_REMOVAL_TYPE_COUNT
78
};
79
 
80
enum acpi_bus_device_type {
81
        ACPI_BUS_TYPE_DEVICE    = 0,
82
        ACPI_BUS_TYPE_POWER,
83
        ACPI_BUS_TYPE_PROCESSOR,
84
        ACPI_BUS_TYPE_THERMAL,
85
        ACPI_BUS_TYPE_SYSTEM,
86
        ACPI_BUS_TYPE_POWER_BUTTON,
87
        ACPI_BUS_TYPE_SLEEP_BUTTON,
88
        ACPI_BUS_DEVICE_TYPE_COUNT
89
};
90
 
91
struct acpi_driver;
92
struct acpi_device;
93
 
94
 
95
/*
96
 * ACPI Driver
97
 * -----------
98
 */
99
 
100
typedef int (*acpi_op_add)      (struct acpi_device *device);
101
typedef int (*acpi_op_remove)   (struct acpi_device *device, int type);
102
typedef int (*acpi_op_lock)     (struct acpi_device *device, int type);
103
typedef int (*acpi_op_start)    (struct acpi_device *device);
104
typedef int (*acpi_op_stop)     (struct acpi_device *device, int type);
105
typedef int (*acpi_op_suspend)  (struct acpi_device *device, int state);
106
typedef int (*acpi_op_resume)   (struct acpi_device *device, int state);
107
typedef int (*acpi_op_scan)     (struct acpi_device *device);
108
typedef int (*acpi_op_bind)     (struct acpi_device *device);
109
 
110
struct acpi_device_ops {
111
        acpi_op_add             add;
112
        acpi_op_remove          remove;
113
        acpi_op_lock            lock;
114
        acpi_op_start           start;
115
        acpi_op_stop            stop;
116
        acpi_op_suspend         suspend;
117
        acpi_op_resume          resume;
118
        acpi_op_scan            scan;
119
        acpi_op_bind            bind;
120
};
121
 
122
struct acpi_driver {
123
        struct list_head        node;
124
        char                    name[80];
125
        char                    class[80];
126
        atomic_t                references;
127
        char                    *ids;           /* Supported Hardware IDs */
128
        struct acpi_device_ops  ops;
129
};
130
 
131
/*
132
 * ACPI Device
133
 * -----------
134
 */
135
 
136
/* Status (_STA) */
137
 
138
struct acpi_device_status {
139
        u32                     present:1;
140
        u32                     enabled:1;
141
        u32                     show_in_ui:1;
142
        u32                     functional:1;
143
        u32                     battery_present:1;
144
        u32                     reserved:27;
145
};
146
 
147
 
148
/* Flags */
149
 
150
struct acpi_device_flags {
151
        u32                     dynamic_status:1;
152
        u32                     hardware_id:1;
153
        u32                     compatible_ids:1;
154
        u32                     bus_address:1;
155
        u32                     unique_id:1;
156
        u32                     removable:1;
157
        u32                     ejectable:1;
158
        u32                     lockable:1;
159
        u32                     suprise_removal_ok:1;
160
        u32                     power_manageable:1;
161
        u32                     performance_manageable:1;
162
        u32                     reserved:21;
163
};
164
 
165
 
166
/* File System */
167
 
168
struct acpi_device_dir {
169
        struct proc_dir_entry   *entry;
170
};
171
 
172
#define acpi_device_dir(d)      ((d)->dir.entry)
173
 
174
 
175
/* Plug and Play */
176
 
177
typedef char                    acpi_bus_id[5];
178
typedef unsigned long           acpi_bus_address;
179
typedef char                    acpi_hardware_id[9];
180
typedef char                    acpi_unique_id[9];
181
typedef char                    acpi_device_name[40];
182
typedef char                    acpi_device_class[20];
183
 
184
struct acpi_device_pnp {
185
        acpi_bus_id             bus_id;                        /* Object name */
186
        acpi_bus_address        bus_address;                          /* _ADR */
187
        acpi_hardware_id        hardware_id;                          /* _HID */
188
        struct acpi_compatible_id_list *cid_list;                    /* _CIDs */
189
        acpi_unique_id          unique_id;                            /* _UID */
190
        acpi_device_name        device_name;             /* Driver-determined */
191
        acpi_device_class       device_class;            /*        "          */
192
};
193
 
194
#define acpi_device_bid(d)      ((d)->pnp.bus_id)
195
#define acpi_device_adr(d)      ((d)->pnp.bus_address)
196
#define acpi_device_hid(d)      ((d)->pnp.hardware_id)
197
#define acpi_device_uid(d)      ((d)->pnp.unique_id)
198
#define acpi_device_name(d)     ((d)->pnp.device_name)
199
#define acpi_device_class(d)    ((d)->pnp.device_class)
200
 
201
 
202
/* Power Management */
203
 
204
struct acpi_device_power_flags {
205
        u32                     explicit_get:1;              /* _PSC present? */
206
        u32                     power_resources:1;         /* Power resources */
207
        u32                     inrush_current:1;         /* Serialize Dx->D0 */
208
        u32                     wake_capable:1;          /* Wakeup supported? */
209
        u32                     wake_enabled:1;         /* Enabled for wakeup */
210
        u32                     power_removed:1;           /* Optimize Dx->D0 */
211
        u32                     reserved:26;
212
};
213
 
214
struct acpi_device_power_state {
215
        struct {
216
                u8                      valid:1;       
217
                u8                      explicit_set:1;      /* _PSx present? */
218
                u8                      reserved:6;
219
        }                       flags;
220
        int                     power;            /* % Power (compared to D0) */
221
        int                     latency;        /* Dx->D0 time (microseconds) */
222
        struct acpi_handle_list resources;      /* Power resources referenced */
223
};
224
 
225
struct acpi_device_power {
226
        int                     state;                       /* Current state */
227
        struct acpi_device_power_flags flags;
228
        struct acpi_device_power_state states[4];     /* Power states (D0-D3) */
229
};
230
 
231
 
232
/* Performance Management */
233
 
234
struct acpi_device_perf_flags {
235
        u8                      reserved:8;
236
};
237
 
238
struct acpi_device_perf_state {
239
        struct {
240
                u8                      valid:1;       
241
                u8                      reserved:7;
242
        }                       flags;
243
        u8                      power;            /* % Power (compared to P0) */
244
        u8                      performance;      /* % Performance (    "   ) */
245
        int                     latency;        /* Px->P0 time (microseconds) */
246
};
247
 
248
struct acpi_device_perf {
249
        int                     state;
250
        struct acpi_device_perf_flags flags;
251
        int                     state_count;
252
        struct acpi_device_perf_state *states;
253
};
254
 
255
 
256
/* Device */
257
 
258
struct acpi_device {
259
        acpi_handle             handle;
260
        struct acpi_device      *parent;
261
        struct list_head        children;
262
        struct list_head        node;
263
        struct list_head        g_list;
264
        struct acpi_device_status status;
265
        struct acpi_device_flags flags;
266
        struct acpi_device_pnp  pnp;
267
        struct acpi_device_power power;
268
        struct acpi_device_perf performance;
269
        struct acpi_device_dir  dir;
270
        struct acpi_device_ops  ops;
271
        struct acpi_driver      *driver;
272
        void                    *driver_data;
273
        struct kobject          kobj;
274
};
275
 
276
#define acpi_driver_data(d)     ((d)->driver_data)
277
 
278
 
279
/*
280
 * Events
281
 * ------
282
 */
283
 
284
struct acpi_bus_event {
285
        struct list_head        node;
286
        acpi_device_class       device_class;
287
        acpi_bus_id             bus_id;
288
        u32                     type;
289
        u32                     data;
290
};
291
 
292
extern struct subsystem acpi_subsys;
293
 
294
/*
295
 * External Functions
296
 */
297
 
298
int acpi_bus_get_device(acpi_handle, struct acpi_device **device);
299
int acpi_bus_get_status (struct acpi_device *device);
300
int acpi_bus_get_power (acpi_handle handle, int *state);
301
int acpi_bus_set_power (acpi_handle handle, int state);
302
int acpi_bus_generate_event (struct acpi_device *device, u8 type, int data);
303
int acpi_bus_receive_event (struct acpi_bus_event *event);
304
int acpi_bus_register_driver (struct acpi_driver *driver);
305
int acpi_bus_unregister_driver (struct acpi_driver *driver);
306
 
307
int acpi_create_dir(struct acpi_device *);
308
void acpi_remove_dir(struct acpi_device *);
309
 
310
#endif /*CONFIG_ACPI_BUS*/
311
 
312
#endif /*__ACPI_BUS_H__*/