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 <linux/kobject.h> /* for KOBJ_NAME_LEN */
38 #include "pci_hotplug.h"
40 #define dbg(format, arg...) \
43 printk(KERN_DEBUG "%s: " format, \
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;
58 * struct slot - slot information for each *physical* slot
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)
72 struct pci_resource * next;
78 * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters
79 * @cache_line_size in DWORD
80 * @latency_timer in PCI clock
93 * struct acpiphp_bridge - PCI bridge information
95 * for each bridge device in ACPI namespace
97 struct acpiphp_bridge {
98 struct list_head list;
100 struct acpiphp_slot *slots;
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;
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;
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 /* PCI bus bridge HID */
176 #define ACPI_PCI_HOST_HID "PNP0A03"
178 /* PCI BRIDGE type */
179 #define BRIDGE_TYPE_HOST 0
180 #define BRIDGE_TYPE_P2P 1
182 /* ACPI _STA method value (ignore bit 4; battery present) */
183 #define ACPI_STA_PRESENT (0x00000001)
184 #define ACPI_STA_ENABLED (0x00000002)
185 #define ACPI_STA_SHOW_IN_UI (0x00000004)
186 #define ACPI_STA_FUNCTIONING (0x00000008)
187 #define ACPI_STA_ALL (0x0000000f)
190 #define BRIDGE_HAS_STA (0x00000001)
191 #define BRIDGE_HAS_EJ0 (0x00000002)
192 #define BRIDGE_HAS_HPP (0x00000004)
193 #define BRIDGE_HAS_PS0 (0x00000010)
194 #define BRIDGE_HAS_PS1 (0x00000020)
195 #define BRIDGE_HAS_PS2 (0x00000040)
196 #define BRIDGE_HAS_PS3 (0x00000080)
200 #define SLOT_POWEREDON (0x00000001)
201 #define SLOT_ENABLED (0x00000002)
202 #define SLOT_MULTIFUNCTION (0x00000004)
206 #define FUNC_HAS_STA (0x00000001)
207 #define FUNC_HAS_EJ0 (0x00000002)
208 #define FUNC_HAS_PS0 (0x00000010)
209 #define FUNC_HAS_PS1 (0x00000020)
210 #define FUNC_HAS_PS2 (0x00000040)
211 #define FUNC_HAS_PS3 (0x00000080)
213 /* function prototypes */
216 extern int acpiphp_glue_init (void);
217 extern void acpiphp_glue_exit (void);
218 extern int acpiphp_get_num_slots (void);
219 extern struct acpiphp_slot *get_slot_from_id (int id);
220 typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
222 extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
223 extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
224 extern u8 acpiphp_get_power_status (struct acpiphp_slot *slot);
225 extern u8 acpiphp_get_attention_status (struct acpiphp_slot *slot);
226 extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
227 extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
228 extern u32 acpiphp_get_address (struct acpiphp_slot *slot);
231 extern struct pci_dev *acpiphp_allocate_pcidev (struct pci_bus *pbus, int dev, int fn);
232 extern int acpiphp_configure_slot (struct acpiphp_slot *slot);
233 extern int acpiphp_configure_function (struct acpiphp_func *func);
234 extern void acpiphp_unconfigure_function (struct acpiphp_func *func);
235 extern int acpiphp_detect_pci_resource (struct acpiphp_bridge *bridge);
236 extern int acpiphp_init_func_resource (struct acpiphp_func *func);
239 extern struct pci_resource *acpiphp_get_io_resource (struct pci_resource **head, u32 size);
240 extern struct pci_resource *acpiphp_get_resource (struct pci_resource **head, u32 size);
241 extern struct pci_resource *acpiphp_get_resource_with_base (struct pci_resource **head, u64 base, u32 size);
242 extern int acpiphp_resource_sort_and_combine (struct pci_resource **head);
243 extern struct pci_resource *acpiphp_make_resource (u64 base, u32 length);
244 extern void acpiphp_move_resource (struct pci_resource **from, struct pci_resource **to);
245 extern void acpiphp_free_resource (struct pci_resource **res);
246 extern void acpiphp_dump_resource (struct acpiphp_bridge *bridge); /* debug */
247 extern void acpiphp_dump_func_resource (struct acpiphp_func *func); /* debug */
250 extern int acpiphp_debug;
252 #endif /* _ACPIPHP_H */