1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef _ACPIPHP_H
22#define _ACPIPHP_H
23
24#include <linux/acpi.h>
25#include <linux/mutex.h>
26#include <linux/pci_hotplug.h>
27
28struct acpiphp_context;
29struct acpiphp_bridge;
30struct acpiphp_slot;
31
32
33
34
35struct slot {
36 struct hotplug_slot hotplug_slot;
37 struct acpiphp_slot *acpi_slot;
38 unsigned int sun;
39};
40
41static inline const char *slot_name(struct slot *slot)
42{
43 return hotplug_slot_name(&slot->hotplug_slot);
44}
45
46static inline struct slot *to_slot(struct hotplug_slot *hotplug_slot)
47{
48 return container_of(hotplug_slot, struct slot, hotplug_slot);
49}
50
51
52
53
54
55
56struct acpiphp_bridge {
57 struct list_head list;
58 struct list_head slots;
59 struct kref ref;
60
61 struct acpiphp_context *context;
62
63 int nr_slots;
64
65
66 struct pci_bus *pci_bus;
67
68
69 struct pci_dev *pci_dev;
70
71 bool is_going_away;
72};
73
74
75
76
77
78
79
80struct acpiphp_slot {
81 struct list_head node;
82 struct pci_bus *bus;
83 struct list_head funcs;
84
85 struct slot *slot;
86
87 u8 device;
88 u32 flags;
89};
90
91
92
93
94
95
96
97
98struct acpiphp_func {
99 struct acpiphp_bridge *parent;
100 struct acpiphp_slot *slot;
101
102 struct list_head sibling;
103
104 u8 function;
105 u32 flags;
106};
107
108struct acpiphp_context {
109 struct acpi_hotplug_context hp;
110 struct acpiphp_func func;
111 struct acpiphp_bridge *bridge;
112 unsigned int refcount;
113};
114
115static inline struct acpiphp_context *to_acpiphp_context(struct acpi_hotplug_context *hp)
116{
117 return container_of(hp, struct acpiphp_context, hp);
118}
119
120static inline struct acpiphp_context *func_to_context(struct acpiphp_func *func)
121{
122 return container_of(func, struct acpiphp_context, func);
123}
124
125static inline struct acpi_device *func_to_acpi_device(struct acpiphp_func *func)
126{
127 return func_to_context(func)->hp.self;
128}
129
130static inline acpi_handle func_to_handle(struct acpiphp_func *func)
131{
132 return func_to_acpi_device(func)->handle;
133}
134
135struct acpiphp_root_context {
136 struct acpi_hotplug_context hp;
137 struct acpiphp_bridge *root_bridge;
138};
139
140static inline struct acpiphp_root_context *to_acpiphp_root_context(struct acpi_hotplug_context *hp)
141{
142 return container_of(hp, struct acpiphp_root_context, hp);
143}
144
145
146
147
148
149
150
151struct acpiphp_attention_info
152{
153 int (*set_attn)(struct hotplug_slot *slot, u8 status);
154 int (*get_attn)(struct hotplug_slot *slot, u8 *status);
155 struct module *owner;
156};
157
158
159#define ACPI_STA_ALL (0x0000000f)
160
161
162
163#define SLOT_ENABLED (0x00000001)
164#define SLOT_IS_GOING_AWAY (0x00000002)
165
166
167
168#define FUNC_HAS_STA (0x00000001)
169#define FUNC_HAS_EJ0 (0x00000002)
170
171
172
173
174int acpiphp_register_attention(struct acpiphp_attention_info *info);
175int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
176int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot, unsigned int sun);
177void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
178
179
180typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
181
182int acpiphp_enable_slot(struct acpiphp_slot *slot);
183int acpiphp_disable_slot(struct acpiphp_slot *slot);
184u8 acpiphp_get_power_status(struct acpiphp_slot *slot);
185u8 acpiphp_get_attention_status(struct acpiphp_slot *slot);
186u8 acpiphp_get_latch_status(struct acpiphp_slot *slot);
187u8 acpiphp_get_adapter_status(struct acpiphp_slot *slot);
188
189
190extern bool acpiphp_disabled;
191
192#endif
193