1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#ifndef _ACPIPHP_H
34#define _ACPIPHP_H
35
36#include <linux/acpi.h>
37#include "pci_hotplug.h"
38
39#include <acpi/acpi_bus.h>
40
41#define dbg(format, arg...) \
42 do { \
43 if (acpiphp_debug) \
44 printk(KERN_DEBUG "%s: " format, \
45 MY_NAME , ## arg); \
46 } while (0)
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)
50
51#define SLOT_MAGIC 0x67267322
52
53#define SLOT_NAME_SIZE 16
54
55struct acpiphp_bridge;
56struct acpiphp_slot;
57struct pci_resource;
58
59
60
61
62struct slot {
63 u32 magic;
64 u8 number;
65 struct hotplug_slot *hotplug_slot;
66 struct list_head slot_list;
67
68 struct acpiphp_slot *acpi_slot;
69};
70
71
72
73
74struct pci_resource {
75 struct pci_resource * next;
76 u64 base;
77 u32 length;
78};
79
80
81
82
83
84
85
86
87struct hpp_param {
88 u8 cache_line_size;
89 u8 latency_timer;
90 u8 enable_SERR;
91 u8 enable_PERR;
92};
93
94
95
96
97
98
99
100struct acpiphp_bridge {
101 struct list_head list;
102 acpi_handle handle;
103 struct acpiphp_slot *slots;
104 int type;
105 int nr_slots;
106
107 u8 seg;
108 u8 bus;
109 u8 sub;
110
111 u32 flags;
112
113
114 struct pci_bus *pci_bus;
115
116
117 struct pci_dev *pci_dev;
118
119
120 struct hpp_param hpp;
121
122 spinlock_t res_lock;
123
124
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;
129};
130
131
132
133
134
135
136
137struct acpiphp_slot {
138 struct acpiphp_slot *next;
139 struct acpiphp_bridge *bridge;
140 struct list_head funcs;
141
142 struct semaphore crit_sect;
143
144 u32 id;
145 u8 device;
146
147 u32 sun;
148 u32 slotno;
149 u32 flags;
150};
151
152
153
154
155
156
157
158
159struct acpiphp_func {
160 struct acpiphp_slot *slot;
161
162 struct list_head sibling;
163 struct pci_dev *pci_dev;
164
165 acpi_handle handle;
166
167 u8 function;
168 u32 flags;
169
170
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;
175};
176
177
178
179#define ACPI_PCI_HOST_HID "PNP0A03"
180
181
182#define BRIDGE_TYPE_HOST 0
183#define BRIDGE_TYPE_P2P 1
184
185
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)
191
192
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)
200
201
202
203#define SLOT_POWEREDON (0x00000001)
204#define SLOT_ENABLED (0x00000002)
205#define SLOT_MULTIFUNCTION (0x00000004)
206
207
208
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)
215
216
217
218
219extern int acpiphp_glue_init (void);
220extern void acpiphp_glue_exit (void);
221extern int acpiphp_get_num_slots (void);
222extern struct acpiphp_slot *get_slot_from_id (int id);
223typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
224extern int acpiphp_for_each_slot (acpiphp_callback fn, void *data);
225
226extern int acpiphp_check_bridge (struct acpiphp_bridge *bridge);
227extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
228extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
229extern u8 acpiphp_get_power_status (struct acpiphp_slot *slot);
230extern u8 acpiphp_get_attention_status (struct acpiphp_slot *slot);
231extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
232extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
233extern u32 acpiphp_get_address (struct acpiphp_slot *slot);
234
235
236extern struct pci_dev *acpiphp_allocate_pcidev (struct pci_bus *pbus, int dev, int fn);
237extern int acpiphp_configure_slot (struct acpiphp_slot *slot);
238extern int acpiphp_configure_function (struct acpiphp_func *func);
239extern int acpiphp_unconfigure_function (struct acpiphp_func *func);
240extern int acpiphp_detect_pci_resource (struct acpiphp_bridge *bridge);
241extern int acpiphp_init_func_resource (struct acpiphp_func *func);
242
243
244extern struct pci_resource *acpiphp_get_io_resource (struct pci_resource **head, u32 size);
245extern struct pci_resource *acpiphp_get_max_resource (struct pci_resource **head, u32 size);
246extern struct pci_resource *acpiphp_get_resource (struct pci_resource **head, u32 size);
247extern struct pci_resource *acpiphp_get_resource_with_base (struct pci_resource **head, u64 base, u32 size);
248extern int acpiphp_resource_sort_and_combine (struct pci_resource **head);
249extern struct pci_resource *acpiphp_make_resource (u64 base, u32 length);
250extern void acpiphp_move_resource (struct pci_resource **from, struct pci_resource **to);
251extern void acpiphp_free_resource (struct pci_resource **res);
252extern void acpiphp_dump_resource (struct acpiphp_bridge *bridge);
253extern void acpiphp_dump_func_resource (struct acpiphp_func *func);
254
255
256extern int acpiphp_debug;
257
258#endif
259