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
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>
36 #include <linux/acpi.h>
37 #include "pci_hotplug.h"
39 #include <acpi/acpi_bus.h>
41 #define dbg(format, arg...) \
44 printk(KERN_DEBUG "%s: " format, \
47 #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
48 #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
49 #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
51 #define SLOT_MAGIC 0x67267322
52 /* name size which is used for entries in pcihpfs */
53 #define SLOT_NAME_SIZE 16 /* {_SUN} */
55 struct acpiphp_bridge;
60 * struct slot - slot information for each *physical* slot
65 struct hotplug_slot *hotplug_slot;
66 struct list_head slot_list;
68 struct acpiphp_slot *acpi_slot;
72 * struct pci_resource - describes pci resource (mem, pfmem, io, bus)
75 struct pci_resource * next;
81 * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters
82 * @cache_line_size in DWORD
83 * @latency_timer in PCI clock
96 * struct acpiphp_bridge - PCI bridge information
98 * for each bridge device in ACPI namespace
100 struct acpiphp_bridge {
101 struct list_head list;
103 struct acpiphp_slot *slots;
113 /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */
114 struct pci_bus *pci_bus;
116 /* PCI-to-PCI bridge device */
117 struct pci_dev *pci_dev;
119 /* ACPI 2.0 _HPP parameters */
120 struct hpp_param hpp;
124 /* available resources on this bus */
125 struct pci_resource *mem_head;
126 struct pci_resource *p_mem_head;
127 struct pci_resource *io_head;
128 struct pci_resource *bus_head;
133 * struct acpiphp_slot - PCI slot information
135 * PCI slot information for each *physical* PCI slot
137 struct acpiphp_slot {
138 struct acpiphp_slot *next;
139 struct acpiphp_bridge *bridge; /* parent */
140 struct list_head funcs; /* one slot may have different
141 objects (i.e. for each function) */
142 struct semaphore crit_sect;
144 u32 id; /* slot id (serial #) for hotplug core */
145 u8 device; /* pci device# */
147 u32 sun; /* ACPI _SUN (slot unique number) */
148 u32 slotno; /* slot number relative to bridge */
149 u32 flags; /* see below */
154 * struct acpiphp_func - PCI function information
156 * PCI function information for each object in ACPI namespace
157 * typically 8 objects per slot (i.e. for each PCI function)
159 struct acpiphp_func {
160 struct acpiphp_slot *slot; /* parent */
162 struct list_head sibling;
163 struct pci_dev *pci_dev;
167 u8 function; /* pci function# */
168 u32 flags; /* see below */
170 /* resources used for this function */
171 struct pci_resource *mem_head;
172 struct pci_resource *p_mem_head;
173 struct pci_resource *io_head;
174 struct pci_resource *bus_head;
178 /* PCI bus bridge HID */
179 #define ACPI_PCI_HOST_HID "PNP0A03"
181 /* PCI BRIDGE type */
182 #define BRIDGE_TYPE_HOST 0
183 #define BRIDGE_TYPE_P2P 1
185 /* ACPI _STA method value (ignore bit 4; battery present) */
186 #define ACPI_STA_PRESENT (0x00000001)
187 #define ACPI_STA_ENABLED (0x00000002)
188 #define ACPI_STA_SHOW_IN_UI (0x00000004)
189 #define ACPI_STA_FUNCTIONING (0x00000008)
190 #define ACPI_STA_ALL (0x0000000f)
193 #define BRIDGE_HAS_STA (0x00000001)
194 #define BRIDGE_HAS_EJ0 (0x00000002)
195 #define BRIDGE_HAS_HPP (0x00000004)
196 #define BRIDGE_HAS_PS0 (0x00000010)
197 #define BRIDGE_HAS_PS1 (0x00000020)
198 #define BRIDGE_HAS_PS2 (0x00000040)
199 #define BRIDGE_HAS_PS3 (0x00000080)
203 #define SLOT_POWEREDON (0x00000001)
204 #define SLOT_ENABLED (0x00000002)
205 #define SLOT_MULTIFUNCTION (0x00000004)
209 #define FUNC_HAS_STA (0x00000001)
210 #define FUNC_HAS_EJ0 (0x00000002)
211 #define FUNC_HAS_PS0 (0x00000010)
212 #define FUNC_HAS_PS1 (0x00000020)
213 #define FUNC_HAS_PS2 (0x00000040)
214 #define FUNC_HAS_PS3 (0x00000080)
216 /* function prototypes */
219 extern int acpiphp_glue_init (void);
220 extern void acpiphp_glue_exit (void);
221 extern int acpiphp_get_num_slots (void);
222 extern struct acpiphp_slot *get_slot_from_id (int id);
223 typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
224 extern int acpiphp_for_each_slot (acpiphp_callback fn, void *data);
226 extern int acpiphp_check_bridge (struct acpiphp_bridge *bridge);
227 extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
228 extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
229 extern u8 acpiphp_get_power_status (struct acpiphp_slot *slot);
230 extern u8 acpiphp_get_attention_status (struct acpiphp_slot *slot);
231 extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
232 extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
233 extern u32 acpiphp_get_address (struct acpiphp_slot *slot);
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);
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 */
256 extern int acpiphp_debug;
258 #endif /* _ACPIPHP_H */