ia64/linux-2.6.18-xen.hg

annotate include/acpi/acpi_bus.h @ 768:fad85221407b

Expose HID, UID, SEG, BBN of PCI root bridge via sysfs.

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