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 * 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)
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)
212 #define SLOT_POWEREDON (0x00000001)
213 #define SLOT_ENABLED (0x00000002)
214 #define SLOT_MULTIFUNCTION (0x00000004)
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 */
228 extern int acpiphp_register_attention(struct acpiphp_attention_info
*info
);
229 extern int acpiphp_unregister_attention(struct acpiphp_attention_info
*info
);
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
);
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
);
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 */
266 extern int acpiphp_debug
;
268 #endif /* _ACPIPHP_H */