[PATCH] aic7xxx_osm build fix
[cris-mirror.git] / drivers / pci / hotplug / acpiphp.h
blobd9499874c8a90e84cfa5df3f33732c0b03c5604d
1 /*
2 * ACPI PCI Hot Plug Controller Driver
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
8 * Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com)
9 * Copyright (C) 2002,2003 NEC Corporation
11 * All rights reserved.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or (at
16 * your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
21 * NON INFRINGEMENT. See the GNU General Public License for more
22 * details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 * Send feedback to <gregkh@us.ibm.com>,
29 * <t-kochi@bq.jp.nec.com>
33 #ifndef _ACPIPHP_H
34 #define _ACPIPHP_H
36 #include <linux/acpi.h>
37 #include <linux/kobject.h> /* for KOBJ_NAME_LEN */
38 #include "pci_hotplug.h"
40 #define dbg(format, arg...) \
41 do { \
42 if (acpiphp_debug) \
43 printk(KERN_DEBUG "%s: " format, \
44 MY_NAME , ## arg); \
45 } while (0)
46 #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
47 #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
48 #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
50 /* name size which is used for entries in pcihpfs */
51 #define SLOT_NAME_SIZE KOBJ_NAME_LEN /* {_SUN} */
53 struct acpiphp_bridge;
54 struct acpiphp_slot;
55 struct pci_resource;
58 * struct slot - slot information for each *physical* slot
60 struct slot {
61 u8 number;
62 struct hotplug_slot *hotplug_slot;
63 struct list_head slot_list;
65 struct acpiphp_slot *acpi_slot;
69 * struct pci_resource - describes pci resource (mem, pfmem, io, bus)
71 struct pci_resource {
72 struct pci_resource * next;
73 u64 base;
74 u32 length;
77 /**
78 * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters
79 * @cache_line_size in DWORD
80 * @latency_timer in PCI clock
81 * @enable_SERR 0 or 1
82 * @enable_PERR 0 or 1
84 struct hpp_param {
85 u8 cache_line_size;
86 u8 latency_timer;
87 u8 enable_SERR;
88 u8 enable_PERR;
92 /**
93 * struct acpiphp_bridge - PCI bridge information
95 * for each bridge device in ACPI namespace
97 struct acpiphp_bridge {
98 struct list_head list;
99 acpi_handle handle;
100 struct acpiphp_slot *slots;
101 int type;
102 int nr_slots;
104 u8 seg;
105 u8 bus;
106 u8 sub;
108 u32 flags;
110 /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */
111 struct pci_bus *pci_bus;
113 /* PCI-to-PCI bridge device */
114 struct pci_dev *pci_dev;
116 /* ACPI 2.0 _HPP parameters */
117 struct hpp_param hpp;
119 spinlock_t res_lock;
121 /* available resources on this bus */
122 struct pci_resource *mem_head;
123 struct pci_resource *p_mem_head;
124 struct pci_resource *io_head;
125 struct pci_resource *bus_head;
130 * struct acpiphp_slot - PCI slot information
132 * PCI slot information for each *physical* PCI slot
134 struct acpiphp_slot {
135 struct acpiphp_slot *next;
136 struct acpiphp_bridge *bridge; /* parent */
137 struct list_head funcs; /* one slot may have different
138 objects (i.e. for each function) */
139 struct semaphore crit_sect;
141 u32 id; /* slot id (serial #) for hotplug core */
142 u8 device; /* pci device# */
144 u32 sun; /* ACPI _SUN (slot unique number) */
145 u32 slotno; /* slot number relative to bridge */
146 u32 flags; /* see below */
151 * struct acpiphp_func - PCI function information
153 * PCI function information for each object in ACPI namespace
154 * typically 8 objects per slot (i.e. for each PCI function)
156 struct acpiphp_func {
157 struct acpiphp_slot *slot; /* parent */
159 struct list_head sibling;
160 struct pci_dev *pci_dev;
162 acpi_handle handle;
164 u8 function; /* pci function# */
165 u32 flags; /* see below */
167 /* resources used for this function */
168 struct pci_resource *mem_head;
169 struct pci_resource *p_mem_head;
170 struct pci_resource *io_head;
171 struct pci_resource *bus_head;
175 * struct acpiphp_attention_info - device specific attention registration
177 * ACPI has no generic method of setting/getting attention status
178 * this allows for device specific driver registration
180 struct acpiphp_attention_info
182 int (*set_attn)(struct hotplug_slot *slot, u8 status);
183 int (*get_attn)(struct hotplug_slot *slot, u8 *status);
184 struct module *owner;
187 /* PCI bus bridge HID */
188 #define ACPI_PCI_HOST_HID "PNP0A03"
190 /* PCI BRIDGE type */
191 #define BRIDGE_TYPE_HOST 0
192 #define BRIDGE_TYPE_P2P 1
194 /* ACPI _STA method value (ignore bit 4; battery present) */
195 #define ACPI_STA_PRESENT (0x00000001)
196 #define ACPI_STA_ENABLED (0x00000002)
197 #define ACPI_STA_SHOW_IN_UI (0x00000004)
198 #define ACPI_STA_FUNCTIONING (0x00000008)
199 #define ACPI_STA_ALL (0x0000000f)
201 /* bridge flags */
202 #define BRIDGE_HAS_STA (0x00000001)
203 #define BRIDGE_HAS_EJ0 (0x00000002)
204 #define BRIDGE_HAS_HPP (0x00000004)
205 #define BRIDGE_HAS_PS0 (0x00000010)
206 #define BRIDGE_HAS_PS1 (0x00000020)
207 #define BRIDGE_HAS_PS2 (0x00000040)
208 #define BRIDGE_HAS_PS3 (0x00000080)
210 /* slot flags */
212 #define SLOT_POWEREDON (0x00000001)
213 #define SLOT_ENABLED (0x00000002)
214 #define SLOT_MULTIFUNCTION (0x00000004)
216 /* function flags */
218 #define FUNC_HAS_STA (0x00000001)
219 #define FUNC_HAS_EJ0 (0x00000002)
220 #define FUNC_HAS_PS0 (0x00000010)
221 #define FUNC_HAS_PS1 (0x00000020)
222 #define FUNC_HAS_PS2 (0x00000040)
223 #define FUNC_HAS_PS3 (0x00000080)
225 /* function prototypes */
227 /* acpiphp_core.c */
228 extern int acpiphp_register_attention(struct acpiphp_attention_info*info);
229 extern int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
231 /* acpiphp_glue.c */
232 extern int acpiphp_glue_init (void);
233 extern void acpiphp_glue_exit (void);
234 extern int acpiphp_get_num_slots (void);
235 extern struct acpiphp_slot *get_slot_from_id (int id);
236 typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
238 extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
239 extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
240 extern u8 acpiphp_get_power_status (struct acpiphp_slot *slot);
241 extern u8 acpiphp_get_attention_status (struct acpiphp_slot *slot);
242 extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
243 extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
244 extern u32 acpiphp_get_address (struct acpiphp_slot *slot);
246 /* acpiphp_pci.c */
247 extern struct pci_dev *acpiphp_allocate_pcidev (struct pci_bus *pbus, int dev, int fn);
248 extern int acpiphp_configure_slot (struct acpiphp_slot *slot);
249 extern int acpiphp_configure_function (struct acpiphp_func *func);
250 extern void acpiphp_unconfigure_function (struct acpiphp_func *func);
251 extern int acpiphp_detect_pci_resource (struct acpiphp_bridge *bridge);
252 extern int acpiphp_init_func_resource (struct acpiphp_func *func);
254 /* acpiphp_res.c */
255 extern struct pci_resource *acpiphp_get_io_resource (struct pci_resource **head, u32 size);
256 extern struct pci_resource *acpiphp_get_resource (struct pci_resource **head, u32 size);
257 extern struct pci_resource *acpiphp_get_resource_with_base (struct pci_resource **head, u64 base, u32 size);
258 extern int acpiphp_resource_sort_and_combine (struct pci_resource **head);
259 extern struct pci_resource *acpiphp_make_resource (u64 base, u32 length);
260 extern void acpiphp_move_resource (struct pci_resource **from, struct pci_resource **to);
261 extern void acpiphp_free_resource (struct pci_resource **res);
262 extern void acpiphp_dump_resource (struct acpiphp_bridge *bridge); /* debug */
263 extern void acpiphp_dump_func_resource (struct acpiphp_func *func); /* debug */
265 /* variables */
266 extern int acpiphp_debug;
268 #endif /* _ACPIPHP_H */