Blame view

include/acpi/acpi_bus.h 17.7 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  /*
   *  acpi_bus.h - ACPI Bus Driver ($Revision: 22 $)
   *
   *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
   *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
   *
   * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   *
   *  This program is free software; you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation; either version 2 of the License, or (at
   *  your option) any later version.
   *
   *  This program is distributed in the hope that it will be useful, but
   *  WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   *  General Public License for more details.
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
20
21
22
23
   * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   */
  
  #ifndef __ACPI_BUS_H__
  #define __ACPI_BUS_H__
5b3272655   Patrick Mochel   ACPI: create acpi...
24
  #include <linux/device.h>
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
25
  #include <linux/property.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
27
28
29
  /* TBD: Make dynamic */
  #define ACPI_MAX_HANDLES	10
  struct acpi_handle_list {
4be44fcd3   Len Brown   [ACPI] Lindent al...
30
31
  	u32 count;
  	acpi_handle handles[ACPI_MAX_HANDLES];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
32
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33
34
  /* acpi_utils.h */
  acpi_status
4be44fcd3   Len Brown   [ACPI] Lindent al...
35
36
  acpi_extract_package(union acpi_object *package,
  		     struct acpi_buffer *format, struct acpi_buffer *buffer);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
  acpi_status
4be44fcd3   Len Brown   [ACPI] Lindent al...
38
39
  acpi_evaluate_integer(acpi_handle handle,
  		      acpi_string pathname,
27663c585   Matthew Wilcox   ACPI: Change acpi...
40
  		      struct acpi_object_list *arguments, unsigned long long *data);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41
  acpi_status
4be44fcd3   Len Brown   [ACPI] Lindent al...
42
43
44
45
  acpi_evaluate_reference(acpi_handle handle,
  			acpi_string pathname,
  			struct acpi_object_list *arguments,
  			struct acpi_handle_list *list);
275c58d77   Toshi Kani   ACPI: Add an inte...
46
  acpi_status
05730c195   Jiang Liu   ACPI: rename acpi...
47
48
  acpi_evaluate_ost(acpi_handle handle, u32 source_event, u32 status_code,
  		  struct acpi_buffer *status_buf);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49

38ac0f1b9   Matthew Garrett   ACPI: Add _PLD su...
50
  acpi_status
8ede06aba   Feng Tang   ACPI: Use ACPICA ...
51
  acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld);
952c63e95   Jiang Liu   ACPI: introduce h...
52
53
  
  bool acpi_has_method(acpi_handle handle, char *name);
0db982026   Jiang Liu   ACPI: introduce h...
54
55
  acpi_status acpi_execute_simple_method(acpi_handle handle, char *method,
  				       u64 arg);
7d2421f84   Jiang Liu   ACPI: introduce t...
56
57
  acpi_status acpi_evaluate_ej0(acpi_handle handle);
  acpi_status acpi_evaluate_lck(acpi_handle handle, int lock);
ebf4df8db   Jiang Liu   ACPI: Export acpi...
58
59
60
  bool acpi_ata_match(acpi_handle handle);
  bool acpi_bay_match(acpi_handle handle);
  bool acpi_dock_match(acpi_handle handle);
952c63e95   Jiang Liu   ACPI: introduce h...
61

c7e16e525   Jerry Hoemann   acpi: widen acpi_...
62
  bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, u64 rev, u64 funcs);
a65ac5204   Jiang Liu   ACPI: introduce h...
63
  union acpi_object *acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid,
c7e16e525   Jerry Hoemann   acpi: widen acpi_...
64
  			u64 rev, u64 func, union acpi_object *argv4);
a65ac5204   Jiang Liu   ACPI: introduce h...
65
66
  
  static inline union acpi_object *
c7e16e525   Jerry Hoemann   acpi: widen acpi_...
67
  acpi_evaluate_dsm_typed(acpi_handle handle, const u8 *uuid, u64 rev, u64 func,
a65ac5204   Jiang Liu   ACPI: introduce h...
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
  			union acpi_object *argv4, acpi_object_type type)
  {
  	union acpi_object *obj;
  
  	obj = acpi_evaluate_dsm(handle, uuid, rev, func, argv4);
  	if (obj && obj->type != type) {
  		ACPI_FREE(obj);
  		obj = NULL;
  	}
  
  	return obj;
  }
  
  #define	ACPI_INIT_DSM_ARGV4(cnt, eles)			\
  	{						\
  	  .package.type = ACPI_TYPE_PACKAGE,		\
  	  .package.count = (cnt),			\
  	  .package.elements = (eles)			\
  	}
c68ae33e7   Lukas Wunner   ACPI / utils: Ren...
87
  bool acpi_dev_found(const char *hid);
2d12b6b38   Lukas Wunner   ACPI / utils: Add...
88

76f585848   Len Brown   [ACPI] delete CON...
89
  #ifdef CONFIG_ACPI
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
90
91
92
93
  
  #include <linux/proc_fs.h>
  
  #define ACPI_BUS_FILE_ROOT	"acpi"
4be44fcd3   Len Brown   [ACPI] Lindent al...
94
  extern struct proc_dir_entry *acpi_root_dir;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
95

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
96
  enum acpi_bus_device_type {
4be44fcd3   Len Brown   [ACPI] Lindent al...
97
  	ACPI_BUS_TYPE_DEVICE = 0,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
98
99
100
  	ACPI_BUS_TYPE_POWER,
  	ACPI_BUS_TYPE_PROCESSOR,
  	ACPI_BUS_TYPE_THERMAL,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
101
102
103
104
105
106
107
  	ACPI_BUS_TYPE_POWER_BUTTON,
  	ACPI_BUS_TYPE_SLEEP_BUTTON,
  	ACPI_BUS_DEVICE_TYPE_COUNT
  };
  
  struct acpi_driver;
  struct acpi_device;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
108
  /*
ca589f946   Rafael J. Wysocki   ACPI / scan: Intr...
109
110
111
   * ACPI Scan Handler
   * -----------------
   */
a33ec399e   Rafael J. Wysocki   ACPI / scan: Intr...
112
  struct acpi_hotplug_profile {
3f8055c35   Rafael J. Wysocki   ACPI / hotplug: I...
113
  	struct kobject kobj;
3338db005   Rafael J. Wysocki   ACPI / hotplug: M...
114
  	int (*scan_dependent)(struct acpi_device *adev);
8ab17fc92   Rafael J. Wysocki   ACPI / hotplug: G...
115
  	void (*notify_online)(struct acpi_device *adev);
d22ddcbc4   Rafael J. Wysocki   ACPI / hotplug: A...
116
117
  	bool enabled:1;
  	bool demand_offline:1;
a33ec399e   Rafael J. Wysocki   ACPI / scan: Intr...
118
  };
3f8055c35   Rafael J. Wysocki   ACPI / hotplug: I...
119
120
121
122
123
  static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile(
  						struct kobject *kobj)
  {
  	return container_of(kobj, struct acpi_hotplug_profile, kobj);
  }
ca589f946   Rafael J. Wysocki   ACPI / scan: Intr...
124
125
126
  struct acpi_scan_handler {
  	const struct acpi_device_id *ids;
  	struct list_head list_node;
636c19d38   Rasmus Villemoes   ACPI / scan: cons...
127
  	bool (*match)(const char *idstr, const struct acpi_device_id **matchid);
ca589f946   Rafael J. Wysocki   ACPI / scan: Intr...
128
129
  	int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id);
  	void (*detach)(struct acpi_device *dev);
9cb32acf0   Rafael J. Wysocki   ACPI / scan: Add ...
130
131
  	void (*bind)(struct device *phys_dev);
  	void (*unbind)(struct device *phys_dev);
a33ec399e   Rafael J. Wysocki   ACPI / scan: Intr...
132
  	struct acpi_hotplug_profile hotplug;
ca589f946   Rafael J. Wysocki   ACPI / scan: Intr...
133
134
135
  };
  
  /*
3c2cc7ff9   Rafael J. Wysocki   ACPI / hotplug / ...
136
137
138
139
140
141
   * ACPI Hotplug Context
   * --------------------
   */
  
  struct acpi_hotplug_context {
  	struct acpi_device *self;
be27b3dcb   Rafael J. Wysocki   ACPI / dock: Add ...
142
143
  	int (*notify)(struct acpi_device *, u32);
  	void (*uevent)(struct acpi_device *, u32);
59b42fa01   Rafael J. Wysocki   ACPI / hotplug: A...
144
  	void (*fixup)(struct acpi_device *);
3c2cc7ff9   Rafael J. Wysocki   ACPI / hotplug / ...
145
146
147
  };
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
148
149
150
   * ACPI Driver
   * -----------
   */
4be44fcd3   Len Brown   [ACPI] Lindent al...
151
  typedef int (*acpi_op_add) (struct acpi_device * device);
51fac8388   Rafael J. Wysocki   ACPI: Remove usel...
152
  typedef int (*acpi_op_remove) (struct acpi_device * device);
46ec8598f   Bjorn Helgaas   ACPI: support acp...
153
  typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
154
155
  
  struct acpi_device_ops {
4be44fcd3   Len Brown   [ACPI] Lindent al...
156
157
  	acpi_op_add add;
  	acpi_op_remove remove;
46ec8598f   Bjorn Helgaas   ACPI: support acp...
158
  	acpi_op_notify notify;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
159
  };
6d2781310   Bjorn Helgaas   ACPI: allow drive...
160
  #define ACPI_DRIVER_ALL_NOTIFY_EVENTS	0x1	/* system AND device events */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
161
  struct acpi_driver {
4be44fcd3   Len Brown   [ACPI] Lindent al...
162
163
  	char name[80];
  	char class[80];
8c8eb78f6   Thomas Renninger   ACPI: autoload mo...
164
  	const struct acpi_device_id *ids; /* Supported Hardware IDs */
6d2781310   Bjorn Helgaas   ACPI: allow drive...
165
  	unsigned int flags;
4be44fcd3   Len Brown   [ACPI] Lindent al...
166
  	struct acpi_device_ops ops;
d43ec68e9   Patrick Mochel   ACPI: add device_...
167
  	struct device_driver drv;
1890a97ab   Patrick Mochel   ACPI: change regi...
168
  	struct module *owner;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
169
170
171
172
173
174
175
176
177
178
  };
  
  /*
   * ACPI Device
   * -----------
   */
  
  /* Status (_STA) */
  
  struct acpi_device_status {
4be44fcd3   Len Brown   [ACPI] Lindent al...
179
180
181
182
183
184
  	u32 present:1;
  	u32 enabled:1;
  	u32 show_in_ui:1;
  	u32 functional:1;
  	u32 battery_present:1;
  	u32 reserved:27;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
185
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
186
187
188
  /* Flags */
  
  struct acpi_device_flags {
4be44fcd3   Len Brown   [ACPI] Lindent al...
189
  	u32 dynamic_status:1;
4be44fcd3   Len Brown   [ACPI] Lindent al...
190
191
  	u32 removable:1;
  	u32 ejectable:1;
4be44fcd3   Len Brown   [ACPI] Lindent al...
192
  	u32 power_manageable:1;
209d3b174   Rafael J. Wysocki   ACPI: Replace ACP...
193
  	u32 match_driver:1;
202317a57   Rafael J. Wysocki   ACPI / scan: Add ...
194
195
  	u32 initialized:1;
  	u32 visited:1;
3c2cc7ff9   Rafael J. Wysocki   ACPI / hotplug / ...
196
  	u32 hotplug_notify:1;
1e2380cd1   Rafael J. Wysocki   ACPI / dock: Disp...
197
  	u32 is_dock_station:1;
5c53b262c   Rafael J. Wysocki   ACPI / property: ...
198
  	u32 of_compatible_ok:1;
d05626748   Suthikulpanit, Suravee   ACPI / scan: Pars...
199
200
201
  	u32 coherent_dma:1;
  	u32 cca_seen:1;
  	u32 reserved:20;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
202
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
203
204
205
  /* File System */
  
  struct acpi_device_dir {
4be44fcd3   Len Brown   [ACPI] Lindent al...
206
  	struct proc_dir_entry *entry;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
207
208
209
  };
  
  #define acpi_device_dir(d)	((d)->dir.entry)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
210
  /* Plug and Play */
24c5c4c2f   Zhao Yakui   ACPI: increase si...
211
  typedef char acpi_bus_id[8];
4be44fcd3   Len Brown   [ACPI] Lindent al...
212
  typedef unsigned long acpi_bus_address;
4be44fcd3   Len Brown   [ACPI] Lindent al...
213
214
  typedef char acpi_device_name[40];
  typedef char acpi_device_class[20];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
215

7f47fa6c2   Bjorn Helgaas   ACPI: maintain a ...
216
217
  struct acpi_hardware_id {
  	struct list_head list;
844142c3f   Rasmus Villemoes   ACPI / scan: cons...
218
  	const char *id;
7f47fa6c2   Bjorn Helgaas   ACPI: maintain a ...
219
  };
d4e1a692e   Toshi Kani   ACPI: Remove acpi...
220
221
222
  struct acpi_pnp_type {
  	u32 hardware_id:1;
  	u32 bus_address:1;
549e68455   Rafael J. Wysocki   ACPI / scan: intr...
223
224
  	u32 platform_id:1;
  	u32 reserved:29;
d4e1a692e   Toshi Kani   ACPI: Remove acpi...
225
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
226
  struct acpi_device_pnp {
d4e1a692e   Toshi Kani   ACPI: Remove acpi...
227
228
  	acpi_bus_id bus_id;		/* Object name */
  	struct acpi_pnp_type type;	/* ID type */
4be44fcd3   Len Brown   [ACPI] Lindent al...
229
  	acpi_bus_address bus_address;	/* _ADR */
d4e1a692e   Toshi Kani   ACPI: Remove acpi...
230
  	char *unique_id;		/* _UID */
7f47fa6c2   Bjorn Helgaas   ACPI: maintain a ...
231
  	struct list_head ids;		/* _HID and _CIDs */
4be44fcd3   Len Brown   [ACPI] Lindent al...
232
233
  	acpi_device_name device_name;	/* Driver-determined */
  	acpi_device_class device_class;	/*        "          */
d1efe3c32   Lance Ortiz   ACPI: Add new sys...
234
  	union acpi_object *str_obj;	/* unicode string for _STR method */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
235
236
237
238
  };
  
  #define acpi_device_bid(d)	((d)->pnp.bus_id)
  #define acpi_device_adr(d)	((d)->pnp.bus_address)
620e112cf   Thomas Renninger   ACPI/PNP: A HID v...
239
  const char *acpi_device_hid(struct acpi_device *device);
359597cb3   Adrian Hunter   ACPI: Add acpi_de...
240
  #define acpi_device_uid(d)	((d)->pnp.unique_id)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
241
242
  #define acpi_device_name(d)	((d)->pnp.device_name)
  #define acpi_device_class(d)	((d)->pnp.device_class)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
243
244
245
  /* Power Management */
  
  struct acpi_device_power_flags {
4be44fcd3   Len Brown   [ACPI] Lindent al...
246
247
248
249
  	u32 explicit_get:1;	/* _PSC present? */
  	u32 power_resources:1;	/* Power resources */
  	u32 inrush_current:1;	/* Serialize Dx->D0 */
  	u32 power_removed:1;	/* Optimize Dx->D0 */
644f17ad7   Mika Westerberg   ACPI / PM: allow ...
250
  	u32 ignore_parent:1;	/* Power is independent of parent power state */
f25c0ae2b   Rafael J. Wysocki   ACPI / PM: Avoid ...
251
252
  	u32 dsw_present:1;	/* _DSW present? */
  	u32 reserved:26;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
253
254
255
256
  };
  
  struct acpi_device_power_state {
  	struct {
4be44fcd3   Len Brown   [ACPI] Lindent al...
257
258
259
260
261
262
  		u8 valid:1;
  		u8 explicit_set:1;	/* _PSx present? */
  		u8 reserved:6;
  	} flags;
  	int power;		/* % Power (compared to D0) */
  	int latency;		/* Dx->D0 time (microseconds) */
0b2245273   Rafael J. Wysocki   ACPI / PM: Take o...
263
  	struct list_head resources;	/* Power resources referenced */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
264
265
266
  };
  
  struct acpi_device_power {
4be44fcd3   Len Brown   [ACPI] Lindent al...
267
  	int state;		/* Current state */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
268
  	struct acpi_device_power_flags flags;
b4a03b9aa   Lin Ming   ACPI: Fixes devic...
269
  	struct acpi_device_power_state states[ACPI_D_STATE_COUNT];	/* Power states (D0-D3Cold) */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
270
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
271
272
273
  /* Performance Management */
  
  struct acpi_device_perf_flags {
4be44fcd3   Len Brown   [ACPI] Lindent al...
274
  	u8 reserved:8;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
275
276
277
278
  };
  
  struct acpi_device_perf_state {
  	struct {
4be44fcd3   Len Brown   [ACPI] Lindent al...
279
280
281
282
283
284
  		u8 valid:1;
  		u8 reserved:7;
  	} flags;
  	u8 power;		/* % Power (compared to P0) */
  	u8 performance;		/* % Performance (    "   ) */
  	int latency;		/* Px->P0 time (microseconds) */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
285
286
287
  };
  
  struct acpi_device_perf {
4be44fcd3   Len Brown   [ACPI] Lindent al...
288
  	int state;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
289
  	struct acpi_device_perf_flags flags;
4be44fcd3   Len Brown   [ACPI] Lindent al...
290
  	int state_count;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
291
292
293
294
295
  	struct acpi_device_perf_state *states;
  };
  
  /* Wakeup Management */
  struct acpi_device_wakeup_flags {
4be44fcd3   Len Brown   [ACPI] Lindent al...
296
297
  	u8 valid:1;		/* Can successfully enable wakeup? */
  	u8 run_wake:1;		/* Run-Wake GPE devices */
b67ea7617   Rafael J. Wysocki   PCI / ACPI / PM: ...
298
  	u8 notifier_present:1;  /* Wake-up notify handler has been installed */
175f8e265   Rafael J. Wysocki   ACPI / PM: Do not...
299
  	u8 enabled:1;		/* Enabled for wakeup */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
300
  };
c072530f3   Rafael J. Wysocki   ACPI / PM: Revork...
301
302
303
304
  struct acpi_device_wakeup_context {
  	struct work_struct work;
  	struct device *dev;
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
305
  struct acpi_device_wakeup {
4be44fcd3   Len Brown   [ACPI] Lindent al...
306
  	acpi_handle gpe_device;
439913fff   Lin Ming   ACPI: replace acp...
307
308
  	u64 gpe_number;
  	u64 sleep_state;
993cbe595   Rafael J. Wysocki   ACPI / PM: Take o...
309
  	struct list_head resources;
4be44fcd3   Len Brown   [ACPI] Lindent al...
310
  	struct acpi_device_wakeup_flags flags;
c072530f3   Rafael J. Wysocki   ACPI / PM: Revork...
311
312
  	struct acpi_device_wakeup_context context;
  	struct wakeup_source *ws;
9b83ccd2f   Rafael J. Wysocki   ACPI PM: Replace ...
313
  	int prepare_count;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
314
  };
1033f9041   Lan Tianyu   ACPI: Allow ACPI ...
315
  struct acpi_device_physical_node {
007ccfcf8   Rafael J. Wysocki   ACPI: Drop physic...
316
  	unsigned int node_id;
1033f9041   Lan Tianyu   ACPI: Allow ACPI ...
317
318
  	struct list_head node;
  	struct device *dev;
683058e31   Rafael J. Wysocki   ACPI / hotplug: U...
319
  	bool put_online:1;
1033f9041   Lan Tianyu   ACPI: Allow ACPI ...
320
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
321

ffdcd955c   Mika Westerberg   ACPI: Add support...
322
323
324
325
  /* ACPI Device Specific Data (_DSD) */
  struct acpi_device_data {
  	const union acpi_object *pointer;
  	const union acpi_object *properties;
733e62513   Mika Westerberg   ACPI: Allow drive...
326
  	const union acpi_object *of_compatible;
445b0eb05   Rafael J. Wysocki   ACPI / property: ...
327
  	struct list_head subnodes;
ffdcd955c   Mika Westerberg   ACPI: Add support...
328
  };
f028d5242   Rafael J. Wysocki   ACPI / GPIO: Driv...
329
  struct acpi_gpio_mapping;
1033f9041   Lan Tianyu   ACPI: Allow ACPI ...
330
  /* Device */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
331
  struct acpi_device {
caaa6efb3   Bjorn Helgaas   ACPI: save device...
332
333
  	int device_type;
  	acpi_handle handle;		/* no handle for fixed hardware */
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
334
  	struct fwnode_handle fwnode;
4be44fcd3   Len Brown   [ACPI] Lindent al...
335
336
337
338
  	struct acpi_device *parent;
  	struct list_head children;
  	struct list_head node;
  	struct list_head wakeup_list;
d783156ea   Rafael J. Wysocki   ACPI / scan: Defi...
339
  	struct list_head del_list;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
340
341
  	struct acpi_device_status status;
  	struct acpi_device_flags flags;
4be44fcd3   Len Brown   [ACPI] Lindent al...
342
  	struct acpi_device_pnp pnp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
343
344
  	struct acpi_device_power power;
  	struct acpi_device_wakeup wakeup;
4be44fcd3   Len Brown   [ACPI] Lindent al...
345
346
  	struct acpi_device_perf performance;
  	struct acpi_device_dir dir;
ffdcd955c   Mika Westerberg   ACPI: Add support...
347
  	struct acpi_device_data data;
ca589f946   Rafael J. Wysocki   ACPI / scan: Intr...
348
  	struct acpi_scan_handler *handler;
3c2cc7ff9   Rafael J. Wysocki   ACPI / hotplug / ...
349
  	struct acpi_hotplug_context *hp;
4be44fcd3   Len Brown   [ACPI] Lindent al...
350
  	struct acpi_driver *driver;
f028d5242   Rafael J. Wysocki   ACPI / GPIO: Driv...
351
  	const struct acpi_gpio_mapping *driver_gpios;
4be44fcd3   Len Brown   [ACPI] Lindent al...
352
  	void *driver_data;
5b3272655   Patrick Mochel   ACPI: create acpi...
353
  	struct device dev;
007ccfcf8   Rafael J. Wysocki   ACPI: Drop physic...
354
  	unsigned int physical_node_count;
40e7fcb19   Lan Tianyu   ACPI: Add _DEP su...
355
  	unsigned int dep_unmet;
1033f9041   Lan Tianyu   ACPI: Allow ACPI ...
356
357
  	struct list_head physical_node_list;
  	struct mutex physical_node_lock;
b1c0f99bf   Rafael J. Wysocki   ACPI / PM: Expose...
358
  	void (*remove)(struct acpi_device *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
359
  };
445b0eb05   Rafael J. Wysocki   ACPI / property: ...
360
361
362
  /* Non-device subnode */
  struct acpi_data_node {
  	const char *name;
263b4c1a6   Rafael J. Wysocki   ACPI / property: ...
363
  	acpi_handle handle;
445b0eb05   Rafael J. Wysocki   ACPI / property: ...
364
365
366
  	struct fwnode_handle fwnode;
  	struct acpi_device_data data;
  	struct list_head sibling;
263b4c1a6   Rafael J. Wysocki   ACPI / property: ...
367
368
  	struct kobject kobj;
  	struct completion kobj_done;
445b0eb05   Rafael J. Wysocki   ACPI / property: ...
369
  };
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
370
371
  static inline bool is_acpi_node(struct fwnode_handle *fwnode)
  {
0224a4a30   Heikki Krogerus   device property: ...
372
  	return !IS_ERR_OR_NULL(fwnode) && (fwnode->type == FWNODE_ACPI
3a7a2ab83   Rafael J. Wysocki   ACPI / property: ...
373
374
375
376
377
  		|| fwnode->type == FWNODE_ACPI_DATA);
  }
  
  static inline bool is_acpi_device_node(struct fwnode_handle *fwnode)
  {
0224a4a30   Heikki Krogerus   device property: ...
378
  	return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_ACPI;
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
379
  }
3a7a2ab83   Rafael J. Wysocki   ACPI / property: ...
380
  static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
381
  {
3a7a2ab83   Rafael J. Wysocki   ACPI / property: ...
382
  	return is_acpi_device_node(fwnode) ?
ce793486e   Rafael J. Wysocki   driver core / ACP...
383
  		container_of(fwnode, struct acpi_device, fwnode) : NULL;
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
384
  }
3a7a2ab83   Rafael J. Wysocki   ACPI / property: ...
385
386
387
388
389
390
391
392
393
394
  static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
  {
  	return fwnode && fwnode->type == FWNODE_ACPI_DATA;
  }
  
  static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
  {
  	return is_acpi_data_node(fwnode) ?
  		container_of(fwnode, struct acpi_data_node, fwnode) : NULL;
  }
613e97218   Adam Thomson   device property: ...
395
396
397
398
399
400
  static inline bool acpi_data_node_match(struct fwnode_handle *fwnode,
  					const char *name)
  {
  	return is_acpi_data_node(fwnode) ?
  		(!strcmp(to_acpi_data_node(fwnode)->name, name)) : false;
  }
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
401
402
403
404
  static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
  {
  	return &adev->fwnode;
  }
db89b4f0d   Pavel Machek   ACPI: catch calls...
405
406
407
408
  static inline void *acpi_driver_data(struct acpi_device *d)
  {
  	return d->driver_data;
  }
d43ec68e9   Patrick Mochel   ACPI: add device_...
409
410
  #define to_acpi_device(d)	container_of(d, struct acpi_device, dev)
  #define to_acpi_driver(d)	container_of(d, struct acpi_driver, drv)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
411

25db115b0   Rafael J. Wysocki   ACPI: Introduce a...
412
413
414
415
  static inline void acpi_set_device_status(struct acpi_device *adev, u32 sta)
  {
  	*((u32 *)&adev->status) = sta;
  }
3c2cc7ff9   Rafael J. Wysocki   ACPI / hotplug / ...
416
  static inline void acpi_set_hp_context(struct acpi_device *adev,
ba574dc85   Rafael J. Wysocki   ACPI / hotplug: S...
417
  				       struct acpi_hotplug_context *hp)
3c2cc7ff9   Rafael J. Wysocki   ACPI / hotplug / ...
418
419
  {
  	hp->self = adev;
3c2cc7ff9   Rafael J. Wysocki   ACPI / hotplug / ...
420
421
  	adev->hp = hp;
  }
5d5132059   Rafael J. Wysocki   ACPI / ATA: Add h...
422
423
424
425
  void acpi_initialize_hp_context(struct acpi_device *adev,
  				struct acpi_hotplug_context *hp,
  				int (*notify)(struct acpi_device *, u32),
  				void (*uevent)(struct acpi_device *, u32));
55955aad7   David Brownell   PNPACPI sets pnpd...
426
427
  /* acpi_device.dev.bus == &acpi_bus_type */
  extern struct bus_type acpi_bus_type;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
428
429
430
431
432
433
  /*
   * Events
   * ------
   */
  
  struct acpi_bus_event {
4be44fcd3   Len Brown   [ACPI] Lindent al...
434
435
436
437
438
  	struct list_head node;
  	acpi_device_class device_class;
  	acpi_bus_id bus_id;
  	u32 type;
  	u32 data;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
439
  };
99e0d2fc6   Greg Kroah-Hartman   kobject: convert ...
440
  extern struct kobject *acpi_kobj;
962ce8ca0   Zhang Rui   ACPI: don't dupli...
441
  extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
8e4319c42   Bob Moore   ACPICA: Fix sever...
442
  void acpi_bus_private_data_handler(acpi_handle, void *);
207339398   Zhang Rui   ACPI: attach ther...
443
  int acpi_bus_get_private_data(acpi_handle, void **);
72013795a   Lan Tianyu   ACPI: Add acpi_bu...
444
445
  int acpi_bus_attach_private_data(acpi_handle, void *);
  void acpi_bus_detach_private_data(acpi_handle);
9ee85241f   Zhang Rui   ACPI: create noti...
446
447
448
  extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32);
  extern int register_acpi_notifier(struct notifier_block *);
  extern int unregister_acpi_notifier(struct notifier_block *);
6bd00a61a   Shaohua Li   ACPI: introduce n...
449

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
450
451
452
453
454
  /*
   * External Functions
   */
  
  int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
78ea4639a   Rafael J. Wysocki   ACPI / hotplug: F...
455
456
  struct acpi_device *acpi_bus_get_acpi_device(acpi_handle handle);
  void acpi_bus_put_acpi_device(struct acpi_device *adev);
402ac5361   Bjorn Helgaas   ACPI: add acpi_bu...
457
458
  acpi_status acpi_bus_get_status_handle(acpi_handle handle,
  				       unsigned long long *sta);
4be44fcd3   Len Brown   [ACPI] Lindent al...
459
  int acpi_bus_get_status(struct acpi_device *device);
9ce4e6071   Rafael J. Wysocki   ACPI / PM: Move d...
460

4be44fcd3   Len Brown   [ACPI] Lindent al...
461
  int acpi_bus_set_power(acpi_handle handle, int state);
96bfd3cee   Rafael J. Wysocki   ACPI / PM: Common...
462
  const char *acpi_power_state_string(int state);
ad0c3b0e4   Rafael J. Wysocki   ACPI / PM: More v...
463
  int acpi_device_get_power(struct acpi_device *device, int *state);
078eb1264   Rafael J. Wysocki   ACPI / PM: Provid...
464
  int acpi_device_set_power(struct acpi_device *device, int state);
9ce4e6071   Rafael J. Wysocki   ACPI / PM: Move d...
465
  int acpi_bus_init_power(struct acpi_device *device);
b9e95fc65   Rafael J. Wysocki   ACPI / LPSS: Powe...
466
  int acpi_device_fix_up_power(struct acpi_device *device);
25eed4072   Rafael J. Wysocki   ACPI / PM: Add fu...
467
  int acpi_bus_update_power(acpi_handle handle, int *state_p);
2bb3a2bf9   Aaron Lu   ACPI / fan: use a...
468
  int acpi_device_update_power(struct acpi_device *device, int *state_p);
3737b2b10   Rafael J. Wysocki   ACPI: Introduce a...
469
  bool acpi_bus_power_manageable(acpi_handle handle);
ec4602a95   Rafael J. Wysocki   ACPI / PM: Allow ...
470
471
  
  #ifdef CONFIG_PM
eb9d0fe40   Rafael J. Wysocki   PCI ACPI: Rework ...
472
  bool acpi_bus_can_wakeup(acpi_handle handle);
ec4602a95   Rafael J. Wysocki   ACPI / PM: Allow ...
473
474
475
  #else
  static inline bool acpi_bus_can_wakeup(acpi_handle handle) { return false; }
  #endif
9ce4e6071   Rafael J. Wysocki   ACPI / PM: Move d...
476

3757b9480   Rafael J. Wysocki   ACPI / hotplug: F...
477
478
  void acpi_scan_lock_acquire(void);
  void acpi_scan_lock_release(void);
e525506fc   Rafael J. Wysocki   ACPI / hotplug / ...
479
480
  void acpi_lock_hp_context(void);
  void acpi_unlock_hp_context(void);
ca589f946   Rafael J. Wysocki   ACPI / scan: Intr...
481
  int acpi_scan_add_handler(struct acpi_scan_handler *handler);
4be44fcd3   Len Brown   [ACPI] Lindent al...
482
  int acpi_bus_register_driver(struct acpi_driver *driver);
06ea8e08a   Bjorn Helgaas   ACPI: acpi_bus_un...
483
  void acpi_bus_unregister_driver(struct acpi_driver *driver);
b8bd759ac   Rafael J. Wysocki   ACPI / scan: Drop...
484
  int acpi_bus_scan(acpi_handle handle);
bfee26dba   Rafael J. Wysocki   ACPI / scan: Make...
485
  void acpi_bus_trim(struct acpi_device *start);
fd3509436   Len Brown   ACPICA: Lindent
486
  acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
8c8eb78f6   Thomas Renninger   ACPI: autoload mo...
487
488
  int acpi_match_device_ids(struct acpi_device *device,
  			  const struct acpi_device_id *ids);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
489
490
  int acpi_create_dir(struct acpi_device *);
  void acpi_remove_dir(struct acpi_device *);
202317a57   Rafael J. Wysocki   ACPI / scan: Add ...
491
492
493
494
  static inline bool acpi_device_enumerated(struct acpi_device *adev)
  {
  	return adev && adev->flags.initialized && adev->flags.visited;
  }
0d2cf8f5a   Mika Westerberg   ACPI: introduce m...
495
496
497
498
499
500
501
502
503
504
505
  /**
   * module_acpi_driver(acpi_driver) - Helper macro for registering an ACPI driver
   * @__acpi_driver: acpi_driver struct
   *
   * Helper macro for ACPI drivers which do not do anything special in module
   * init/exit. This eliminates a lot of boilerplate. Each module may only
   * use this macro once, and calling it replaces module_init() and module_exit()
   */
  #define module_acpi_driver(__acpi_driver) \
  	module_driver(__acpi_driver, acpi_bus_register_driver, \
  		      acpi_bus_unregister_driver)
4e10d12a3   David Shaohua Li   [ACPI] Bind PCI d...
506
507
508
  /*
   * Bind physical devices with ACPI devices
   */
4e10d12a3   David Shaohua Li   [ACPI] Bind PCI d...
509
  struct acpi_bus_type {
4be44fcd3   Len Brown   [ACPI] Lindent al...
510
  	struct list_head list;
53540098b   Rafael J. Wysocki   ACPI / glue: Add ...
511
512
  	const char *name;
  	bool (*match)(struct device *dev);
e3f02c522   Rafael J. Wysocki   ACPI / bind: Rewo...
513
  	struct acpi_device * (*find_companion)(struct device *);
11909ca1c   Rafael J. Wysocki   ACPI: Add .setup(...
514
515
  	void (*setup)(struct device *);
  	void (*cleanup)(struct device *);
4e10d12a3   David Shaohua Li   [ACPI] Bind PCI d...
516
517
518
  };
  int register_acpi_bus_type(struct acpi_bus_type *);
  int unregister_acpi_bus_type(struct acpi_bus_type *);
f1b1dc845   Zhang Rui   ACPI / PNP: do AC...
519
520
  int acpi_bind_one(struct device *dev, struct acpi_device *adev);
  int acpi_unbind_one(struct device *dev);
22c13f9d8   Thomas Renninger   ACPI: video: Igno...
521

76d56de57   Alex Chiang   ACPI: export acpi...
522
  struct acpi_pci_root {
76d56de57   Alex Chiang   ACPI: export acpi...
523
  	struct acpi_device * device;
76d56de57   Alex Chiang   ACPI: export acpi...
524
525
  	struct pci_bus *bus;
  	u16 segment;
6ad95513d   Bjorn Helgaas   ACPI: pci_root: s...
526
  	struct resource secondary;	/* downstream bus range */
76d56de57   Alex Chiang   ACPI: export acpi...
527
528
529
  
  	u32 osc_support_set;	/* _OSC state of support bits */
  	u32 osc_control_set;	/* _OSC state of control bits */
f4b57a3b4   Jiang Liu   PCI/ACPI: provide...
530
  	phys_addr_t mcfg_addr;
76d56de57   Alex Chiang   ACPI: export acpi...
531
  };
4e10d12a3   David Shaohua Li   [ACPI] Bind PCI d...
532
  /* helper */
d9fef0c4d   Rafael J. Wysocki   ACPI / bind: Simp...
533

b84f196d9   Suthikulpanit, Suravee   ACPI: Adding DMA ...
534
535
  bool acpi_dma_supported(struct acpi_device *adev);
  enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev);
d9fef0c4d   Rafael J. Wysocki   ACPI / bind: Simp...
536
537
  struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
  					   u64 address, bool check_children);
275582031   Alexander Chiang   ACPI: Introduce a...
538
  int acpi_is_root_bridge(acpi_handle);
76d56de57   Alex Chiang   ACPI: export acpi...
539
  struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
4e10d12a3   David Shaohua Li   [ACPI] Bind PCI d...
540

b67ea7617   Rafael J. Wysocki   PCI / ACPI / PM: ...
541
542
  int acpi_enable_wakeup_device_power(struct acpi_device *dev, int state);
  int acpi_disable_wakeup_device_power(struct acpi_device *dev);
aa3386015   Rafael J. Wysocki   PM: Remove CONFIG...
543
  #ifdef CONFIG_PM
c072530f3   Rafael J. Wysocki   ACPI / PM: Revork...
544
545
546
  acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev,
  				 void (*work_func)(struct work_struct *work));
  acpi_status acpi_remove_pm_notifier(struct acpi_device *adev);
ee85f5437   Huang Ying   ACPI/PM: specify ...
547
  int acpi_pm_device_sleep_state(struct device *, int *, int);
5de21bb99   Rafael J. Wysocki   ACPI / PM: Drop C...
548
  int acpi_pm_device_run_wake(struct device *, bool);
761afb869   Rafael J. Wysocki   ACPI / PM: Fix pr...
549
  #else
ec2cd81cc   Rafael J. Wysocki   ACPI / PM: Move r...
550
  static inline acpi_status acpi_add_pm_notifier(struct acpi_device *adev,
c072530f3   Rafael J. Wysocki   ACPI / PM: Revork...
551
552
  					       struct device *dev,
  				               void (*work_func)(struct work_struct *work))
ec2cd81cc   Rafael J. Wysocki   ACPI / PM: Move r...
553
554
555
  {
  	return AE_SUPPORT;
  }
c072530f3   Rafael J. Wysocki   ACPI / PM: Revork...
556
  static inline acpi_status acpi_remove_pm_notifier(struct acpi_device *adev)
ec2cd81cc   Rafael J. Wysocki   ACPI / PM: Move r...
557
558
559
  {
  	return AE_SUPPORT;
  }
b25c77efa   Rafael J. Wysocki   ACPI / PM: Rename...
560
  static inline int acpi_pm_device_sleep_state(struct device *d, int *p, int m)
296699de6   Rafael J. Wysocki   Introduce CONFIG_...
561
562
563
  {
  	if (p)
  		*p = ACPI_STATE_D0;
b25c77efa   Rafael J. Wysocki   ACPI / PM: Rename...
564

8ad928d52   Rafael J. Wysocki   ACPI / PM: Use AC...
565
566
  	return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3_COLD) ?
  		m : ACPI_STATE_D0;
296699de6   Rafael J. Wysocki   Introduce CONFIG_...
567
  }
b24e50988   Lin Ming   ACPI, PCI: Move a...
568
569
570
571
  static inline int acpi_pm_device_run_wake(struct device *dev, bool enable)
  {
  	return -ENODEV;
  }
bdda27fb9   Rafael J. Wysocki   ACPI / PM: Fix de...
572
573
574
575
576
  #endif
  
  #ifdef CONFIG_PM_SLEEP
  int acpi_pm_device_sleep_wake(struct device *, bool);
  #else
f7a1b8609   David Howells   Fix acpi_pm_devic...
577
578
579
580
  static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
  {
  	return -ENODEV;
  }
761afb869   Rafael J. Wysocki   ACPI / PM: Fix pr...
581
  #endif
fd4aff1a2   Shaohua Li   ACPI: Add acpi_pm...
582

99926a8cd   David Rientjes   ACPI / PM: Fix bu...
583
584
585
586
587
  #ifdef CONFIG_ACPI_SLEEP
  u32 acpi_target_system_state(void);
  #else
  static inline u32 acpi_target_system_state(void) { return ACPI_STATE_S0; }
  #endif
078eb1264   Rafael J. Wysocki   ACPI / PM: Provid...
588
589
590
591
592
593
594
595
596
  static inline bool acpi_device_power_manageable(struct acpi_device *adev)
  {
  	return adev->flags.power_manageable;
  }
  
  static inline bool acpi_device_can_wakeup(struct acpi_device *adev)
  {
  	return adev->wakeup.flags.valid;
  }
1399dfcdf   Aaron Lu   ACPI / PM: Introd...
597
598
  static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
  {
cd7f84c02   Ken Xue   ACPI / PM: Suppor...
599
600
601
  	return adev->power.states[ACPI_STATE_D3_COLD].flags.valid ||
  		((acpi_gbl_FADT.header.revision < 6) &&
  		adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set);
1399dfcdf   Aaron Lu   ACPI / PM: Introd...
602
  }
66886d6f8   Matthew Garrett   ACPI: Add stubs f...
603
  #else	/* CONFIG_ACPI */
7ae30986d   Len Brown   ACPI: fix acpi_bu...
604
605
  static inline int register_acpi_bus_type(void *bus) { return 0; }
  static inline int unregister_acpi_bus_type(void *bus) { return 0; }
66886d6f8   Matthew Garrett   ACPI: Add stubs f...
606

fd3509436   Len Brown   ACPICA: Lindent
607
  #endif				/* CONFIG_ACPI */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
608
609
  
  #endif /*__ACPI_BUS_H__*/