Merge with Linux 2.5.73.
[linux-2.6/linux-mips.git] / drivers / pci / hotplug / acpiphp.h
blob247714b9f80e1f5990ce7fd63c6795529bc600f7
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 #define SLOT_MAGIC 0x67267322
51 /* name size which is used for entries in pcihpfs */
52 #define SLOT_NAME_SIZE KOBJ_NAME_LEN /* {_SUN} */
54 struct acpiphp_bridge;
55 struct acpiphp_slot;
56 struct pci_resource;
59 * struct slot - slot information for each *physical* slot
61 struct slot {
62 u32 magic;
63 u8 number;
64 struct hotplug_slot *hotplug_slot;
65 struct list_head slot_list;
67 struct acpiphp_slot *acpi_slot;
71 * struct pci_resource - describes pci resource (mem, pfmem, io, bus)
73 struct pci_resource {
74 struct pci_resource * next;
75 u64 base;
76 u32 length;
79 /**
80 * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters
81 * @cache_line_size in DWORD
82 * @latency_timer in PCI clock
83 * @enable_SERR 0 or 1
84 * @enable_PERR 0 or 1
86 struct hpp_param {
87 u8 cache_line_size;
88 u8 latency_timer;
89 u8 enable_SERR;
90 u8 enable_PERR;
94 /**
95 * struct acpiphp_bridge - PCI bridge information
97 * for each bridge device in ACPI namespace
99 struct acpiphp_bridge {
100 struct list_head list;
101 acpi_handle handle;
102 struct acpiphp_slot *slots;
103 int type;
104 int nr_slots;
106 u8 seg;
107 u8 bus;
108 u8 sub;
110 u32 flags;
112 /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */
113 struct pci_bus *pci_bus;
115 /* PCI-to-PCI bridge device */
116 struct pci_dev *pci_dev;
118 /* ACPI 2.0 _HPP parameters */
119 struct hpp_param hpp;
121 spinlock_t res_lock;
123 /* available resources on this bus */
124 struct pci_resource *mem_head;
125 struct pci_resource *p_mem_head;
126 struct pci_resource *io_head;
127 struct pci_resource *bus_head;
132 * struct acpiphp_slot - PCI slot information
134 * PCI slot information for each *physical* PCI slot
136 struct acpiphp_slot {
137 struct acpiphp_slot *next;
138 struct acpiphp_bridge *bridge; /* parent */
139 struct list_head funcs; /* one slot may have different
140 objects (i.e. for each function) */
141 struct semaphore crit_sect;
143 u32 id; /* slot id (serial #) for hotplug core */
144 u8 device; /* pci device# */
146 u32 sun; /* ACPI _SUN (slot unique number) */
147 u32 slotno; /* slot number relative to bridge */
148 u32 flags; /* see below */
153 * struct acpiphp_func - PCI function information
155 * PCI function information for each object in ACPI namespace
156 * typically 8 objects per slot (i.e. for each PCI function)
158 struct acpiphp_func {
159 struct acpiphp_slot *slot; /* parent */
161 struct list_head sibling;
162 struct pci_dev *pci_dev;
164 acpi_handle handle;
166 u8 function; /* pci function# */
167 u32 flags; /* see below */
169 /* resources used for this function */
170 struct pci_resource *mem_head;
171 struct pci_resource *p_mem_head;
172 struct pci_resource *io_head;
173 struct pci_resource *bus_head;
177 /* PCI bus bridge HID */
178 #define ACPI_PCI_HOST_HID "PNP0A03"
180 /* PCI BRIDGE type */
181 #define BRIDGE_TYPE_HOST 0
182 #define BRIDGE_TYPE_P2P 1
184 /* ACPI _STA method value (ignore bit 4; battery present) */
185 #define ACPI_STA_PRESENT (0x00000001)
186 #define ACPI_STA_ENABLED (0x00000002)
187 #define ACPI_STA_SHOW_IN_UI (0x00000004)
188 #define ACPI_STA_FUNCTIONING (0x00000008)
189 #define ACPI_STA_ALL (0x0000000f)
191 /* bridge flags */
192 #define BRIDGE_HAS_STA (0x00000001)
193 #define BRIDGE_HAS_EJ0 (0x00000002)
194 #define BRIDGE_HAS_HPP (0x00000004)
195 #define BRIDGE_HAS_PS0 (0x00000010)
196 #define BRIDGE_HAS_PS1 (0x00000020)
197 #define BRIDGE_HAS_PS2 (0x00000040)
198 #define BRIDGE_HAS_PS3 (0x00000080)
200 /* slot flags */
202 #define SLOT_POWEREDON (0x00000001)
203 #define SLOT_ENABLED (0x00000002)
204 #define SLOT_MULTIFUNCTION (x000000004)
206 /* function flags */
208 #define FUNC_HAS_STA (0x00000001)
209 #define FUNC_HAS_EJ0 (0x00000002)
210 #define FUNC_HAS_PS0 (0x00000010)
211 #define FUNC_HAS_PS1 (0x00000020)
212 #define FUNC_HAS_PS2 (0x00000040)
213 #define FUNC_HAS_PS3 (0x00000080)
215 #define FUNC_EXISTS (0x10000000) /* to make sure we call _EJ0 only for existing funcs */
217 /* function prototypes */
219 /* acpiphp_glue.c */
220 extern int acpiphp_glue_init (void);
221 extern void acpiphp_glue_exit (void);
222 extern int acpiphp_get_num_slots (void);
223 extern struct acpiphp_slot *get_slot_from_id (int id);
224 typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
225 extern int acpiphp_for_each_slot (acpiphp_callback fn, void *data);
227 extern int acpiphp_check_bridge (struct acpiphp_bridge *bridge);
228 extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
229 extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
230 extern u8 acpiphp_get_power_status (struct acpiphp_slot *slot);
231 extern u8 acpiphp_get_attention_status (struct acpiphp_slot *slot);
232 extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
233 extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
235 /* acpiphp_pci.c */
236 extern struct pci_dev *acpiphp_allocate_pcidev (struct pci_bus *pbus, int dev, int fn);
237 extern int acpiphp_configure_slot (struct acpiphp_slot *slot);
238 extern int acpiphp_configure_function (struct acpiphp_func *func);
239 extern int acpiphp_unconfigure_function (struct acpiphp_func *func);
240 extern int acpiphp_detect_pci_resource (struct acpiphp_bridge *bridge);
241 extern int acpiphp_init_func_resource (struct acpiphp_func *func);
243 /* acpiphp_res.c */
244 extern struct pci_resource *acpiphp_get_io_resource (struct pci_resource **head, u32 size);
245 extern struct pci_resource *acpiphp_get_max_resource (struct pci_resource **head, u32 size);
246 extern struct pci_resource *acpiphp_get_resource (struct pci_resource **head, u32 size);
247 extern struct pci_resource *acpiphp_get_resource_with_base (struct pci_resource **head, u64 base, u32 size);
248 extern int acpiphp_resource_sort_and_combine (struct pci_resource **head);
249 extern struct pci_resource *acpiphp_make_resource (u64 base, u32 length);
250 extern void acpiphp_move_resource (struct pci_resource **from, struct pci_resource **to);
251 extern void acpiphp_free_resource (struct pci_resource **res);
252 extern void acpiphp_dump_resource (struct acpiphp_bridge *bridge); /* debug */
253 extern void acpiphp_dump_func_resource (struct acpiphp_func *func); /* debug */
255 /* variables */
256 extern int acpiphp_debug;
258 #endif /* _ACPIPHP_H */