0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifndef _ACPIPHP_H
0022 #define _ACPIPHP_H
0023
0024 #include <linux/acpi.h>
0025 #include <linux/mutex.h>
0026 #include <linux/pci_hotplug.h>
0027
0028 struct acpiphp_context;
0029 struct acpiphp_bridge;
0030 struct acpiphp_slot;
0031
0032
0033
0034
0035 struct slot {
0036 struct hotplug_slot hotplug_slot;
0037 struct acpiphp_slot *acpi_slot;
0038 unsigned int sun;
0039 };
0040
0041 static inline const char *slot_name(struct slot *slot)
0042 {
0043 return hotplug_slot_name(&slot->hotplug_slot);
0044 }
0045
0046 static inline struct slot *to_slot(struct hotplug_slot *hotplug_slot)
0047 {
0048 return container_of(hotplug_slot, struct slot, hotplug_slot);
0049 }
0050
0051
0052
0053
0054
0055
0056 struct acpiphp_bridge {
0057 struct list_head list;
0058 struct list_head slots;
0059 struct kref ref;
0060
0061 struct acpiphp_context *context;
0062
0063 int nr_slots;
0064
0065
0066 struct pci_bus *pci_bus;
0067
0068
0069 struct pci_dev *pci_dev;
0070
0071 bool is_going_away;
0072 };
0073
0074
0075
0076
0077
0078
0079
0080 struct acpiphp_slot {
0081 struct list_head node;
0082 struct pci_bus *bus;
0083 struct list_head funcs;
0084
0085 struct slot *slot;
0086
0087 u8 device;
0088 u32 flags;
0089 };
0090
0091
0092
0093
0094
0095
0096
0097
0098 struct acpiphp_func {
0099 struct acpiphp_bridge *parent;
0100 struct acpiphp_slot *slot;
0101
0102 struct list_head sibling;
0103
0104 u8 function;
0105 u32 flags;
0106 };
0107
0108 struct acpiphp_context {
0109 struct acpi_hotplug_context hp;
0110 struct acpiphp_func func;
0111 struct acpiphp_bridge *bridge;
0112 unsigned int refcount;
0113 };
0114
0115 static inline struct acpiphp_context *to_acpiphp_context(struct acpi_hotplug_context *hp)
0116 {
0117 return container_of(hp, struct acpiphp_context, hp);
0118 }
0119
0120 static inline struct acpiphp_context *func_to_context(struct acpiphp_func *func)
0121 {
0122 return container_of(func, struct acpiphp_context, func);
0123 }
0124
0125 static inline struct acpi_device *func_to_acpi_device(struct acpiphp_func *func)
0126 {
0127 return func_to_context(func)->hp.self;
0128 }
0129
0130 static inline acpi_handle func_to_handle(struct acpiphp_func *func)
0131 {
0132 return func_to_acpi_device(func)->handle;
0133 }
0134
0135 struct acpiphp_root_context {
0136 struct acpi_hotplug_context hp;
0137 struct acpiphp_bridge *root_bridge;
0138 };
0139
0140 static inline struct acpiphp_root_context *to_acpiphp_root_context(struct acpi_hotplug_context *hp)
0141 {
0142 return container_of(hp, struct acpiphp_root_context, hp);
0143 }
0144
0145
0146
0147
0148
0149
0150
0151 struct acpiphp_attention_info {
0152 int (*set_attn)(struct hotplug_slot *slot, u8 status);
0153 int (*get_attn)(struct hotplug_slot *slot, u8 *status);
0154 struct module *owner;
0155 };
0156
0157
0158 #define ACPI_STA_ALL (0x0000000f)
0159
0160
0161
0162 #define SLOT_ENABLED (0x00000001)
0163 #define SLOT_IS_GOING_AWAY (0x00000002)
0164
0165
0166
0167 #define FUNC_HAS_STA (0x00000001)
0168 #define FUNC_HAS_EJ0 (0x00000002)
0169
0170
0171
0172
0173 int acpiphp_register_attention(struct acpiphp_attention_info *info);
0174 int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
0175 int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot, unsigned int sun);
0176 void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
0177
0178 int acpiphp_enable_slot(struct acpiphp_slot *slot);
0179 int acpiphp_disable_slot(struct acpiphp_slot *slot);
0180 u8 acpiphp_get_power_status(struct acpiphp_slot *slot);
0181 u8 acpiphp_get_attention_status(struct acpiphp_slot *slot);
0182 u8 acpiphp_get_latch_status(struct acpiphp_slot *slot);
0183 u8 acpiphp_get_adapter_status(struct acpiphp_slot *slot);
0184
0185
0186 extern bool acpiphp_disabled;
0187
0188 #endif