aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/pciehp.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/pciehp.h')
-rw-r--r--drivers/pci/hotplug/pciehp.h194
1 files changed, 57 insertions, 137 deletions
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 4fb12fcda563..d19fcae8a7c0 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -44,15 +44,20 @@ extern int pciehp_poll_time;
44extern int pciehp_debug; 44extern int pciehp_debug;
45extern int pciehp_force; 45extern int pciehp_force;
46 46
47/*#define dbg(format, arg...) do { if (pciehp_debug) printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); } while (0)*/ 47#define dbg(format, arg...) \
48#define dbg(format, arg...) do { if (pciehp_debug) printk("%s: " format, MY_NAME , ## arg); } while (0) 48 do { \
49#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg) 49 if (pciehp_debug) \
50#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) 50 printk("%s: " format, MY_NAME , ## arg); \
51#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 51 } while (0)
52 52#define err(format, arg...) \
53 printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
54#define info(format, arg...) \
55 printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
56#define warn(format, arg...) \
57 printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
53 58
59#define SLOT_NAME_SIZE 10
54struct slot { 60struct slot {
55 struct slot *next;
56 u8 bus; 61 u8 bus;
57 u8 device; 62 u8 device;
58 u32 number; 63 u32 number;
@@ -63,6 +68,8 @@ struct slot {
63 struct hpc_ops *hpc_ops; 68 struct hpc_ops *hpc_ops;
64 struct hotplug_slot *hotplug_slot; 69 struct hotplug_slot *hotplug_slot;
65 struct list_head slot_list; 70 struct list_head slot_list;
71 char name[SLOT_NAME_SIZE];
72 unsigned long last_emi_toggle;
66}; 73};
67 74
68struct event_info { 75struct event_info {
@@ -70,34 +77,15 @@ struct event_info {
70 u8 hp_slot; 77 u8 hp_slot;
71}; 78};
72 79
73typedef u8(*php_intr_callback_t) (u8 hp_slot, void *instance_id);
74
75struct php_ctlr_state_s {
76 struct php_ctlr_state_s *pnext;
77 struct pci_dev *pci_dev;
78 unsigned int irq;
79 unsigned long flags; /* spinlock's */
80 u32 slot_device_offset;
81 u32 num_slots;
82 struct timer_list int_poll_timer; /* Added for poll event */
83 php_intr_callback_t attention_button_callback;
84 php_intr_callback_t switch_change_callback;
85 php_intr_callback_t presence_change_callback;
86 php_intr_callback_t power_fault_callback;
87 void *callback_instance_id;
88 struct ctrl_reg *creg; /* Ptr to controller register space */
89};
90
91#define MAX_EVENTS 10 80#define MAX_EVENTS 10
92struct controller { 81struct controller {
93 struct controller *next; 82 struct controller *next;
94 struct mutex crit_sect; /* critical section mutex */ 83 struct mutex crit_sect; /* critical section mutex */
95 struct mutex ctrl_lock; /* controller lock */ 84 struct mutex ctrl_lock; /* controller lock */
96 struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
97 int num_slots; /* Number of slots on ctlr */ 85 int num_slots; /* Number of slots on ctlr */
98 int slot_num_inc; /* 1 or -1 */ 86 int slot_num_inc; /* 1 or -1 */
99 struct pci_dev *pci_dev; 87 struct pci_dev *pci_dev;
100 struct pci_bus *pci_bus; 88 struct list_head slot_list;
101 struct event_info event_queue[MAX_EVENTS]; 89 struct event_info event_queue[MAX_EVENTS];
102 struct slot *slot; 90 struct slot *slot;
103 struct hpc_ops *hpc_ops; 91 struct hpc_ops *hpc_ops;
@@ -112,6 +100,8 @@ struct controller {
112 u8 ctrlcap; 100 u8 ctrlcap;
113 u16 vendor_id; 101 u16 vendor_id;
114 u8 cap_base; 102 u8 cap_base;
103 struct timer_list poll_timer;
104 volatile int cmd_busy;
115}; 105};
116 106
117#define INT_BUTTON_IGNORE 0 107#define INT_BUTTON_IGNORE 0
@@ -131,8 +121,6 @@ struct controller {
131#define POWERON_STATE 3 121#define POWERON_STATE 3
132#define POWEROFF_STATE 4 122#define POWEROFF_STATE 4
133 123
134#define PCI_TO_PCI_BRIDGE_CLASS 0x00060400
135
136/* Error messages */ 124/* Error messages */
137#define INTERLOCK_OPEN 0x00000002 125#define INTERLOCK_OPEN 0x00000002
138#define ADD_NOT_SUPPORTED 0x00000003 126#define ADD_NOT_SUPPORTED 0x00000003
@@ -144,10 +132,6 @@ struct controller {
144#define WRONG_BUS_FREQUENCY 0x0000000D 132#define WRONG_BUS_FREQUENCY 0x0000000D
145#define POWER_FAILURE 0x0000000E 133#define POWER_FAILURE 0x0000000E
146 134
147#define REMOVE_NOT_SUPPORTED 0x00000003
148
149#define DISABLE_CARD 1
150
151/* Field definitions in Slot Capabilities Register */ 135/* Field definitions in Slot Capabilities Register */
152#define ATTN_BUTTN_PRSN 0x00000001 136#define ATTN_BUTTN_PRSN 0x00000001
153#define PWR_CTRL_PRSN 0x00000002 137#define PWR_CTRL_PRSN 0x00000002
@@ -155,6 +139,7 @@ struct controller {
155#define ATTN_LED_PRSN 0x00000008 139#define ATTN_LED_PRSN 0x00000008
156#define PWR_LED_PRSN 0x00000010 140#define PWR_LED_PRSN 0x00000010
157#define HP_SUPR_RM_SUP 0x00000020 141#define HP_SUPR_RM_SUP 0x00000020
142#define EMI_PRSN 0x00020000
158 143
159#define ATTN_BUTTN(cap) (cap & ATTN_BUTTN_PRSN) 144#define ATTN_BUTTN(cap) (cap & ATTN_BUTTN_PRSN)
160#define POWER_CTRL(cap) (cap & PWR_CTRL_PRSN) 145#define POWER_CTRL(cap) (cap & PWR_CTRL_PRSN)
@@ -162,130 +147,65 @@ struct controller {
162#define ATTN_LED(cap) (cap & ATTN_LED_PRSN) 147#define ATTN_LED(cap) (cap & ATTN_LED_PRSN)
163#define PWR_LED(cap) (cap & PWR_LED_PRSN) 148#define PWR_LED(cap) (cap & PWR_LED_PRSN)
164#define HP_SUPR_RM(cap) (cap & HP_SUPR_RM_SUP) 149#define HP_SUPR_RM(cap) (cap & HP_SUPR_RM_SUP)
165 150#define EMI(cap) (cap & EMI_PRSN)
166/* 151
167 * error Messages 152extern int pciehp_event_start_thread(void);
168 */ 153extern void pciehp_event_stop_thread(void);
169#define msg_initialization_err "Initialization failure, error=%d\n" 154extern int pciehp_enable_slot(struct slot *slot);
170#define msg_button_on "PCI slot #%s - powering on due to button press.\n" 155extern int pciehp_disable_slot(struct slot *slot);
171#define msg_button_off "PCI slot #%s - powering off due to button press.\n" 156extern u8 pciehp_handle_attention_button(u8 hp_slot, struct controller *ctrl);
172#define msg_button_cancel "PCI slot #%s - action canceled due to button press.\n" 157extern u8 pciehp_handle_switch_change(u8 hp_slot, struct controller *ctrl);
173#define msg_button_ignore "PCI slot #%s - button press ignored. (action in progress...)\n" 158extern u8 pciehp_handle_presence_change(u8 hp_slot, struct controller *ctrl);
174 159extern u8 pciehp_handle_power_fault(u8 hp_slot, struct controller *ctrl);
175/* controller functions */ 160extern int pciehp_configure_device(struct slot *p_slot);
176extern int pciehp_event_start_thread (void); 161extern int pciehp_unconfigure_device(struct slot *p_slot);
177extern void pciehp_event_stop_thread (void); 162int pcie_init(struct controller *ctrl, struct pcie_device *dev);
178extern int pciehp_enable_slot (struct slot *slot);
179extern int pciehp_disable_slot (struct slot *slot);
180
181extern u8 pciehp_handle_attention_button (u8 hp_slot, void *inst_id);
182extern u8 pciehp_handle_switch_change (u8 hp_slot, void *inst_id);
183extern u8 pciehp_handle_presence_change (u8 hp_slot, void *inst_id);
184extern u8 pciehp_handle_power_fault (u8 hp_slot, void *inst_id);
185/* extern void long_delay (int delay); */
186
187/* pci functions */
188extern int pciehp_configure_device (struct slot *p_slot);
189extern int pciehp_unconfigure_device (struct slot *p_slot);
190
191
192 163
193/* Global variables */ 164/* Global variables */
194extern struct controller *pciehp_ctrl_list; 165extern struct controller *pciehp_ctrl_list;
195 166
196/* Inline functions */
197
198static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device) 167static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
199{ 168{
200 struct slot *p_slot, *tmp_slot = NULL; 169 struct slot *slot;
201
202 p_slot = ctrl->slot;
203 170
204 while (p_slot && (p_slot->device != device)) { 171 list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
205 tmp_slot = p_slot; 172 if (slot->device == device)
206 p_slot = p_slot->next; 173 return slot;
207 } 174 }
208 if (p_slot == NULL) {
209 err("ERROR: pciehp_find_slot device=0x%x\n", device);
210 p_slot = tmp_slot;
211 }
212
213 return p_slot;
214}
215
216static inline int wait_for_ctrl_irq(struct controller *ctrl)
217{
218 int retval = 0;
219
220 DECLARE_WAITQUEUE(wait, current);
221
222 add_wait_queue(&ctrl->queue, &wait);
223 if (!pciehp_poll_mode)
224 /* Sleep for up to 1 second */
225 msleep_interruptible(1000);
226 else
227 msleep_interruptible(2500);
228
229 remove_wait_queue(&ctrl->queue, &wait);
230 if (signal_pending(current))
231 retval = -EINTR;
232
233 return retval;
234}
235
236#define SLOT_NAME_SIZE 10
237 175
238static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) 176 err("%s: slot (device=0x%x) not found\n", __FUNCTION__, device);
239{ 177 return NULL;
240 snprintf(buffer, buffer_size, "%04d_%04d", slot->bus, slot->number);
241} 178}
242 179
243enum php_ctlr_type {
244 PCI,
245 ISA,
246 ACPI
247};
248
249int pcie_init(struct controller *ctrl, struct pcie_device *dev);
250
251/* This has no meaning for PCI Express, as there is only 1 slot per port */
252int pcie_get_ctlr_slot_config(struct controller *ctrl,
253 int *num_ctlr_slots,
254 int *first_device_num,
255 int *physical_slot_num,
256 u8 *ctrlcap);
257
258struct hpc_ops { 180struct hpc_ops {
259 int (*power_on_slot) (struct slot *slot); 181 int (*power_on_slot)(struct slot *slot);
260 int (*power_off_slot) (struct slot *slot); 182 int (*power_off_slot)(struct slot *slot);
261 int (*get_power_status) (struct slot *slot, u8 *status); 183 int (*get_power_status)(struct slot *slot, u8 *status);
262 int (*get_attention_status) (struct slot *slot, u8 *status); 184 int (*get_attention_status)(struct slot *slot, u8 *status);
263 int (*set_attention_status) (struct slot *slot, u8 status); 185 int (*set_attention_status)(struct slot *slot, u8 status);
264 int (*get_latch_status) (struct slot *slot, u8 *status); 186 int (*get_latch_status)(struct slot *slot, u8 *status);
265 int (*get_adapter_status) (struct slot *slot, u8 *status); 187 int (*get_adapter_status)(struct slot *slot, u8 *status);
266 188 int (*get_emi_status)(struct slot *slot, u8 *status);
267 int (*get_max_bus_speed) (struct slot *slot, enum pci_bus_speed *speed); 189 int (*toggle_emi)(struct slot *slot);
268 int (*get_cur_bus_speed) (struct slot *slot, enum pci_bus_speed *speed); 190 int (*get_max_bus_speed)(struct slot *slot, enum pci_bus_speed *speed);
269 191 int (*get_cur_bus_speed)(struct slot *slot, enum pci_bus_speed *speed);
270 int (*get_max_lnk_width) (struct slot *slot, enum pcie_link_width *value); 192 int (*get_max_lnk_width)(struct slot *slot, enum pcie_link_width *val);
271 int (*get_cur_lnk_width) (struct slot *slot, enum pcie_link_width *value); 193 int (*get_cur_lnk_width)(struct slot *slot, enum pcie_link_width *val);
272 194 int (*query_power_fault)(struct slot *slot);
273 int (*query_power_fault) (struct slot *slot); 195 void (*green_led_on)(struct slot *slot);
274 void (*green_led_on) (struct slot *slot); 196 void (*green_led_off)(struct slot *slot);
275 void (*green_led_off) (struct slot *slot); 197 void (*green_led_blink)(struct slot *slot);
276 void (*green_led_blink) (struct slot *slot); 198 void (*release_ctlr)(struct controller *ctrl);
277 void (*release_ctlr) (struct controller *ctrl); 199 int (*check_lnk_status)(struct controller *ctrl);
278 int (*check_lnk_status) (struct controller *ctrl);
279}; 200};
280 201
281
282#ifdef CONFIG_ACPI 202#ifdef CONFIG_ACPI
283#include <acpi/acpi.h> 203#include <acpi/acpi.h>
284#include <acpi/acpi_bus.h> 204#include <acpi/acpi_bus.h>
285#include <acpi/actypes.h> 205#include <acpi/actypes.h>
286#include <linux/pci-acpi.h> 206#include <linux/pci-acpi.h>
287 207
288#define pciehp_get_hp_hw_control_from_firmware(dev) \ 208#define pciehp_get_hp_hw_control_from_firmware(dev) \
289 pciehp_acpi_get_hp_hw_control_from_firmware(dev) 209 pciehp_acpi_get_hp_hw_control_from_firmware(dev)
290static inline int pciehp_get_hp_params_from_firmware(struct pci_dev *dev, 210static inline int pciehp_get_hp_params_from_firmware(struct pci_dev *dev,
291 struct hotplug_params *hpp) 211 struct hotplug_params *hpp)