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.h134
1 files changed, 34 insertions, 100 deletions
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 061ead21ef14..6a61b9f286e1 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -32,8 +32,6 @@
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <asm/semaphore.h>
36#include <asm/io.h>
37#include <linux/pcieport_if.h> 35#include <linux/pcieport_if.h>
38#include "pci_hotplug.h" 36#include "pci_hotplug.h"
39 37
@@ -42,6 +40,7 @@
42extern int pciehp_poll_mode; 40extern int pciehp_poll_mode;
43extern int pciehp_poll_time; 41extern int pciehp_poll_time;
44extern int pciehp_debug; 42extern int pciehp_debug;
43extern int pciehp_force;
45 44
46/*#define dbg(format, arg...) do { if (pciehp_debug) printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); } while (0)*/ 45/*#define dbg(format, arg...) do { if (pciehp_debug) printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); } while (0)*/
47#define dbg(format, arg...) do { if (pciehp_debug) printk("%s: " format, MY_NAME , ## arg); } while (0) 46#define dbg(format, arg...) do { if (pciehp_debug) printk("%s: " format, MY_NAME , ## arg); } while (0)
@@ -49,25 +48,11 @@ extern int pciehp_debug;
49#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) 48#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) 49#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
51 50
52struct pci_func { 51struct hotplug_params {
53 struct pci_func *next; 52 u8 cache_line_size;
54 u8 bus; 53 u8 latency_timer;
55 u8 device; 54 u8 enable_serr;
56 u8 function; 55 u8 enable_perr;
57 u8 is_a_board;
58 u16 status;
59 u8 configured;
60 u8 switch_save;
61 u8 presence_save;
62 u32 base_length[0x06];
63 u8 base_type[0x06];
64 u16 reserved2;
65 u32 config_space[0x20];
66 struct pci_resource *mem_head;
67 struct pci_resource *p_mem_head;
68 struct pci_resource *io_head;
69 struct pci_resource *bus_head;
70 struct pci_dev* pci_dev;
71}; 56};
72 57
73struct slot { 58struct slot {
@@ -75,13 +60,7 @@ struct slot {
75 u8 bus; 60 u8 bus;
76 u8 device; 61 u8 device;
77 u32 number; 62 u32 number;
78 u8 is_a_board;
79 u8 configured;
80 u8 state; 63 u8 state;
81 u8 switch_save;
82 u8 presence_save;
83 u32 capabilities;
84 u16 reserved2;
85 struct timer_list task_event; 64 struct timer_list task_event;
86 u8 hp_slot; 65 u8 hp_slot;
87 struct controller *ctrl; 66 struct controller *ctrl;
@@ -90,42 +69,47 @@ struct slot {
90 struct list_head slot_list; 69 struct list_head slot_list;
91}; 70};
92 71
93struct pci_resource {
94 struct pci_resource * next;
95 u32 base;
96 u32 length;
97};
98
99struct event_info { 72struct event_info {
100 u32 event_type; 73 u32 event_type;
101 u8 hp_slot; 74 u8 hp_slot;
102}; 75};
103 76
77typedef u8(*php_intr_callback_t) (u8 hp_slot, void *instance_id);
78
79struct php_ctlr_state_s {
80 struct php_ctlr_state_s *pnext;
81 struct pci_dev *pci_dev;
82 unsigned int irq;
83 unsigned long flags; /* spinlock's */
84 u32 slot_device_offset;
85 u32 num_slots;
86 struct timer_list int_poll_timer; /* Added for poll event */
87 php_intr_callback_t attention_button_callback;
88 php_intr_callback_t switch_change_callback;
89 php_intr_callback_t presence_change_callback;
90 php_intr_callback_t power_fault_callback;
91 void *callback_instance_id;
92 struct ctrl_reg *creg; /* Ptr to controller register space */
93};
94
95#define MAX_EVENTS 10
104struct controller { 96struct controller {
105 struct controller *next; 97 struct controller *next;
106 struct semaphore crit_sect; /* critical section semaphore */ 98 struct semaphore crit_sect; /* critical section semaphore */
107 void *hpc_ctlr_handle; /* HPC controller handle */ 99 struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
108 int num_slots; /* Number of slots on ctlr */ 100 int num_slots; /* Number of slots on ctlr */
109 int slot_num_inc; /* 1 or -1 */ 101 int slot_num_inc; /* 1 or -1 */
110 struct pci_resource *mem_head;
111 struct pci_resource *p_mem_head;
112 struct pci_resource *io_head;
113 struct pci_resource *bus_head;
114 struct pci_dev *pci_dev; 102 struct pci_dev *pci_dev;
115 struct pci_bus *pci_bus; 103 struct pci_bus *pci_bus;
116 struct event_info event_queue[10]; 104 struct event_info event_queue[MAX_EVENTS];
117 struct slot *slot; 105 struct slot *slot;
118 struct hpc_ops *hpc_ops; 106 struct hpc_ops *hpc_ops;
119 wait_queue_head_t queue; /* sleep & wake process */ 107 wait_queue_head_t queue; /* sleep & wake process */
120 u8 next_event; 108 u8 next_event;
121 u8 seg;
122 u8 bus; 109 u8 bus;
123 u8 device; 110 u8 device;
124 u8 function; 111 u8 function;
125 u8 rev;
126 u8 slot_device_offset; 112 u8 slot_device_offset;
127 u8 add_support;
128 enum pci_bus_speed speed;
129 u32 first_slot; /* First physical slot number */ /* PCIE only has 1 slot */ 113 u32 first_slot; /* First physical slot number */ /* PCIE only has 1 slot */
130 u8 slot_bus; /* Bus where the slots handled by this controller sit */ 114 u8 slot_bus; /* Bus where the slots handled by this controller sit */
131 u8 ctrlcap; 115 u8 ctrlcap;
@@ -133,20 +117,6 @@ struct controller {
133 u8 cap_base; 117 u8 cap_base;
134}; 118};
135 119
136struct irq_mapping {
137 u8 barber_pole;
138 u8 valid_INT;
139 u8 interrupt[4];
140};
141
142struct resource_lists {
143 struct pci_resource *mem_head;
144 struct pci_resource *p_mem_head;
145 struct pci_resource *io_head;
146 struct pci_resource *bus_head;
147 struct irq_mapping *irqs;
148};
149
150#define INT_BUTTON_IGNORE 0 120#define INT_BUTTON_IGNORE 0
151#define INT_PRESENCE_ON 1 121#define INT_PRESENCE_ON 1
152#define INT_PRESENCE_OFF 2 122#define INT_PRESENCE_OFF 2
@@ -200,21 +170,14 @@ struct resource_lists {
200 * error Messages 170 * error Messages
201 */ 171 */
202#define msg_initialization_err "Initialization failure, error=%d\n" 172#define msg_initialization_err "Initialization failure, error=%d\n"
203#define msg_HPC_rev_error "Unsupported revision of the PCI hot plug controller found.\n"
204#define msg_HPC_non_pcie "The PCI hot plug controller is not supported by this driver.\n"
205#define msg_HPC_not_supported "This system is not supported by this version of pciephd module. Upgrade to a newer version of pciehpd\n"
206#define msg_unable_to_save "Unable to store PCI hot plug add resource information. This system must be rebooted before adding any PCI devices.\n"
207#define msg_button_on "PCI slot #%d - powering on due to button press.\n" 173#define msg_button_on "PCI slot #%d - powering on due to button press.\n"
208#define msg_button_off "PCI slot #%d - powering off due to button press.\n" 174#define msg_button_off "PCI slot #%d - powering off due to button press.\n"
209#define msg_button_cancel "PCI slot #%d - action canceled due to button press.\n" 175#define msg_button_cancel "PCI slot #%d - action canceled due to button press.\n"
210#define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n" 176#define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n"
211 177
212/* controller functions */ 178/* controller functions */
213extern int pciehprm_find_available_resources (struct controller *ctrl);
214extern int pciehp_event_start_thread (void); 179extern int pciehp_event_start_thread (void);
215extern void pciehp_event_stop_thread (void); 180extern void pciehp_event_stop_thread (void);
216extern struct pci_func *pciehp_slot_create (unsigned char busnumber);
217extern struct pci_func *pciehp_slot_find (unsigned char bus, unsigned char device, unsigned char index);
218extern int pciehp_enable_slot (struct slot *slot); 181extern int pciehp_enable_slot (struct slot *slot);
219extern int pciehp_disable_slot (struct slot *slot); 182extern int pciehp_disable_slot (struct slot *slot);
220 183
@@ -224,25 +187,17 @@ extern u8 pciehp_handle_presence_change (u8 hp_slot, void *inst_id);
224extern u8 pciehp_handle_power_fault (u8 hp_slot, void *inst_id); 187extern u8 pciehp_handle_power_fault (u8 hp_slot, void *inst_id);
225/* extern void long_delay (int delay); */ 188/* extern void long_delay (int delay); */
226 189
227/* resource functions */
228extern int pciehp_resource_sort_and_combine (struct pci_resource **head);
229
230/* pci functions */ 190/* pci functions */
231extern int pciehp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num); 191extern int pciehp_configure_device (struct slot *p_slot);
232/*extern int pciehp_get_bus_dev (struct controller *ctrl, u8 *bus_num, u8 *dev_num, struct slot *slot);*/ 192extern int pciehp_unconfigure_device (struct slot *p_slot);
233extern int pciehp_save_config (struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num); 193extern int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev);
234extern int pciehp_save_used_resources (struct controller *ctrl, struct pci_func * func, int flag); 194extern void pciehp_get_hp_params_from_firmware(struct pci_dev *dev,
235extern int pciehp_save_slot_config (struct controller *ctrl, struct pci_func * new_slot); 195 struct hotplug_params *hpp);
236extern void pciehp_destroy_board_resources (struct pci_func * func); 196
237extern int pciehp_return_board_resources (struct pci_func * func, struct resource_lists * resources);
238extern void pciehp_destroy_resource_list (struct resource_lists * resources);
239extern int pciehp_configure_device (struct controller* ctrl, struct pci_func* func);
240extern int pciehp_unconfigure_device (struct pci_func* func);
241 197
242 198
243/* Global variables */ 199/* Global variables */
244extern struct controller *pciehp_ctrl_list; 200extern struct controller *pciehp_ctrl_list;
245extern struct pci_func *pciehp_slot_list[256];
246 201
247/* Inline functions */ 202/* Inline functions */
248 203
@@ -252,12 +207,9 @@ static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
252 207
253 p_slot = ctrl->slot; 208 p_slot = ctrl->slot;
254 209
255 dbg("p_slot = %p\n", p_slot);
256
257 while (p_slot && (p_slot->device != device)) { 210 while (p_slot && (p_slot->device != device)) {
258 tmp_slot = p_slot; 211 tmp_slot = p_slot;
259 p_slot = p_slot->next; 212 p_slot = p_slot->next;
260 dbg("In while loop, p_slot = %p\n", p_slot);
261 } 213 }
262 if (p_slot == NULL) { 214 if (p_slot == NULL) {
263 err("ERROR: pciehp_find_slot device=0x%x\n", device); 215 err("ERROR: pciehp_find_slot device=0x%x\n", device);
@@ -273,7 +225,6 @@ static inline int wait_for_ctrl_irq(struct controller *ctrl)
273 225
274 DECLARE_WAITQUEUE(wait, current); 226 DECLARE_WAITQUEUE(wait, current);
275 227
276 dbg("%s : start\n", __FUNCTION__);
277 add_wait_queue(&ctrl->queue, &wait); 228 add_wait_queue(&ctrl->queue, &wait);
278 if (!pciehp_poll_mode) 229 if (!pciehp_poll_mode)
279 /* Sleep for up to 1 second */ 230 /* Sleep for up to 1 second */
@@ -285,19 +236,9 @@ static inline int wait_for_ctrl_irq(struct controller *ctrl)
285 if (signal_pending(current)) 236 if (signal_pending(current))
286 retval = -EINTR; 237 retval = -EINTR;
287 238
288 dbg("%s : end\n", __FUNCTION__);
289 return retval; 239 return retval;
290} 240}
291 241
292/* Puts node back in the resource list pointed to by head */
293static inline void return_resource(struct pci_resource **head, struct pci_resource *node)
294{
295 if (!node || !head)
296 return;
297 node->next = *head;
298 *head = node;
299}
300
301#define SLOT_NAME_SIZE 10 242#define SLOT_NAME_SIZE 10
302 243
303static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) 244static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
@@ -311,14 +252,7 @@ enum php_ctlr_type {
311 ACPI 252 ACPI
312}; 253};
313 254
314typedef u8(*php_intr_callback_t) (unsigned int change_id, void *instance_id); 255int pcie_init(struct controller *ctrl, struct pcie_device *dev);
315
316int pcie_init(struct controller *ctrl, struct pcie_device *dev,
317 php_intr_callback_t attention_button_callback,
318 php_intr_callback_t switch_change_callback,
319 php_intr_callback_t presence_change_callback,
320 php_intr_callback_t power_fault_callback);
321
322 256
323/* This has no meaning for PCI Express, as there is only 1 slot per port */ 257/* This has no meaning for PCI Express, as there is only 1 slot per port */
324int pcie_get_ctlr_slot_config(struct controller *ctrl, 258int pcie_get_ctlr_slot_config(struct controller *ctrl,