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
34
35#ifndef _ACPIPHP_H
36#define _ACPIPHP_H
37
38#include <linux/acpi.h>
39#include <linux/mutex.h>
40#include <linux/pci_hotplug.h>
41
42#define dbg(format, arg...) \
43 do { \
44 if (acpiphp_debug) \
45 printk(KERN_DEBUG "%s: " format, \
46 MY_NAME , ## arg); \
47 } while (0)
48#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
49#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
50#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
51
52struct acpiphp_context;
53struct acpiphp_bridge;
54struct acpiphp_slot;
55
56
57
58
59struct slot {
60 struct hotplug_slot *hotplug_slot;
61 struct acpiphp_slot *acpi_slot;
62 struct hotplug_slot_info info;
63 unsigned int sun;
64};
65
66static inline const char *slot_name(struct slot *slot)
67{
68 return hotplug_slot_name(slot->hotplug_slot);
69}
70
71
72
73
74
75
76struct acpiphp_bridge {
77 struct list_head list;
78 struct list_head slots;
79 struct kref ref;
80
81 struct acpiphp_context *context;
82
83 int nr_slots;
84
85
86 struct pci_bus *pci_bus;
87
88
89 struct pci_dev *pci_dev;
90};
91
92
93
94
95
96
97
98struct acpiphp_slot {
99 struct list_head node;
100 struct pci_bus *bus;
101 struct list_head funcs;
102
103 struct slot *slot;
104 struct mutex crit_sect;
105
106 u8 device;
107 u32 flags;
108};
109
110
111
112
113
114
115
116
117struct acpiphp_func {
118 struct acpiphp_bridge *parent;
119 struct acpiphp_slot *slot;
120
121 struct list_head sibling;
122
123 u8 function;
124 u32 flags;
125};
126
127struct acpiphp_context {
128 acpi_handle handle;
129 struct acpiphp_func func;
130 struct acpiphp_bridge *bridge;
131 unsigned int refcount;
132};
133
134static inline struct acpiphp_context *func_to_context(struct acpiphp_func *func)
135{
136 return container_of(func, struct acpiphp_context, func);
137}
138
139static inline acpi_handle func_to_handle(struct acpiphp_func *func)
140{
141 return func_to_context(func)->handle;
142}
143
144
145
146
147
148
149
150struct acpiphp_attention_info
151{
152 int (*set_attn)(struct hotplug_slot *slot, u8 status);
153 int (*get_attn)(struct hotplug_slot *slot, u8 *status);
154 struct module *owner;
155};
156
157
158#define ACPI_STA_ALL (0x0000000f)
159
160
161
162#define SLOT_ENABLED (0x00000001)
163
164
165
166#define FUNC_HAS_STA (0x00000001)
167#define FUNC_HAS_EJ0 (0x00000002)
168#define FUNC_HAS_DCK (0x00000004)
169
170
171
172
173int acpiphp_register_attention(struct acpiphp_attention_info*info);
174int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
175int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot, unsigned int sun);
176void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
177
178
179typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
180
181int acpiphp_enable_slot(struct acpiphp_slot *slot);
182int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot);
183u8 acpiphp_get_power_status(struct acpiphp_slot *slot);
184u8 acpiphp_get_attention_status(struct acpiphp_slot *slot);
185u8 acpiphp_get_latch_status(struct acpiphp_slot *slot);
186u8 acpiphp_get_adapter_status(struct acpiphp_slot *slot);
187
188
189extern bool acpiphp_debug;
190extern bool acpiphp_disabled;
191
192#endif
193