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 #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
;
59 * struct slot - slot information for each *physical* slot
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)
74 struct pci_resource
* next
;
80 * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters
81 * @cache_line_size in DWORD
82 * @latency_timer in PCI clock
95 * struct acpiphp_bridge - PCI bridge information
97 * for each bridge device in ACPI namespace
99 struct acpiphp_bridge
{
100 struct list_head list
;
102 struct acpiphp_slot
*slots
;
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
;
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
;
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)
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)
202 #define SLOT_POWEREDON (0x00000001)
203 #define SLOT_ENABLED (0x00000002)
204 #define SLOT_MULTIFUNCTION (x000000004)
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 */
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
);
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 */