aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/shpchp.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/shpchp.h')
-rw-r--r--drivers/pci/hotplug/shpchp.h122
1 files changed, 18 insertions, 104 deletions
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index b7d1c61d6bbb..abe2cf411e68 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.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 "pci_hotplug.h" 35#include "pci_hotplug.h"
38 36
39#if !defined(MODULE) 37#if !defined(MODULE)
@@ -52,42 +50,18 @@ extern int shpchp_debug;
52#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) 50#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
53#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 51#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
54 52
55struct pci_func {
56 struct pci_func *next;
57 u8 bus;
58 u8 device;
59 u8 function;
60 u8 is_a_board;
61 u16 status;
62 u8 configured;
63 u8 switch_save;
64 u8 presence_save;
65 u8 pwr_save;
66 u32 base_length[0x06];
67 u8 base_type[0x06];
68 u16 reserved2;
69 u32 config_space[0x20];
70 struct pci_resource *mem_head;
71 struct pci_resource *p_mem_head;
72 struct pci_resource *io_head;
73 struct pci_resource *bus_head;
74 struct pci_dev* pci_dev;
75};
76
77#define SLOT_MAGIC 0x67267321 53#define SLOT_MAGIC 0x67267321
78struct slot { 54struct slot {
79 u32 magic; 55 u32 magic;
80 struct slot *next; 56 struct slot *next;
81 u8 bus; 57 u8 bus;
82 u8 device; 58 u8 device;
59 u16 status;
83 u32 number; 60 u32 number;
84 u8 is_a_board; 61 u8 is_a_board;
85 u8 configured;
86 u8 state; 62 u8 state;
87 u8 switch_save;
88 u8 presence_save; 63 u8 presence_save;
89 u32 capabilities; 64 u8 pwr_save;
90 u16 reserved2;
91 struct timer_list task_event; 65 struct timer_list task_event;
92 u8 hp_slot; 66 u8 hp_slot;
93 struct controller *ctrl; 67 struct controller *ctrl;
@@ -96,12 +70,6 @@ struct slot {
96 struct list_head slot_list; 70 struct list_head slot_list;
97}; 71};
98 72
99struct pci_resource {
100 struct pci_resource * next;
101 u32 base;
102 u32 length;
103};
104
105struct event_info { 73struct event_info {
106 u32 event_type; 74 u32 event_type;
107 u8 hp_slot; 75 u8 hp_slot;
@@ -110,13 +78,9 @@ struct event_info {
110struct controller { 78struct controller {
111 struct controller *next; 79 struct controller *next;
112 struct semaphore crit_sect; /* critical section semaphore */ 80 struct semaphore crit_sect; /* critical section semaphore */
113 void * hpc_ctlr_handle; /* HPC controller handle */ 81 struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
114 int num_slots; /* Number of slots on ctlr */ 82 int num_slots; /* Number of slots on ctlr */
115 int slot_num_inc; /* 1 or -1 */ 83 int slot_num_inc; /* 1 or -1 */
116 struct pci_resource *mem_head;
117 struct pci_resource *p_mem_head;
118 struct pci_resource *io_head;
119 struct pci_resource *bus_head;
120 struct pci_dev *pci_dev; 84 struct pci_dev *pci_dev;
121 struct pci_bus *pci_bus; 85 struct pci_bus *pci_bus;
122 struct event_info event_queue[10]; 86 struct event_info event_queue[10];
@@ -124,33 +88,21 @@ struct controller {
124 struct hpc_ops *hpc_ops; 88 struct hpc_ops *hpc_ops;
125 wait_queue_head_t queue; /* sleep & wake process */ 89 wait_queue_head_t queue; /* sleep & wake process */
126 u8 next_event; 90 u8 next_event;
127 u8 seg;
128 u8 bus; 91 u8 bus;
129 u8 device; 92 u8 device;
130 u8 function; 93 u8 function;
131 u8 rev;
132 u8 slot_device_offset; 94 u8 slot_device_offset;
133 u8 add_support; 95 u8 add_support;
134 enum pci_bus_speed speed; 96 enum pci_bus_speed speed;
135 u32 first_slot; /* First physical slot number */ 97 u32 first_slot; /* First physical slot number */
136 u8 slot_bus; /* Bus where the slots handled by this controller sit */ 98 u8 slot_bus; /* Bus where the slots handled by this controller sit */
137 u8 push_flag;
138 u16 ctlrcap;
139 u16 vendor_id;
140};
141
142struct irq_mapping {
143 u8 barber_pole;
144 u8 valid_INT;
145 u8 interrupt[4];
146}; 99};
147 100
148struct resource_lists { 101struct hotplug_params {
149 struct pci_resource *mem_head; 102 u8 cache_line_size;
150 struct pci_resource *p_mem_head; 103 u8 latency_timer;
151 struct pci_resource *io_head; 104 u8 enable_serr;
152 struct pci_resource *bus_head; 105 u8 enable_perr;
153 struct irq_mapping *irqs;
154}; 106};
155 107
156/* Define AMD SHPC ID */ 108/* Define AMD SHPC ID */
@@ -194,24 +146,16 @@ struct resource_lists {
194 * error Messages 146 * error Messages
195 */ 147 */
196#define msg_initialization_err "Initialization failure, error=%d\n" 148#define msg_initialization_err "Initialization failure, error=%d\n"
197#define msg_HPC_rev_error "Unsupported revision of the PCI hot plug controller found.\n"
198#define msg_HPC_non_shpc "The PCI hot plug controller is not supported by this driver.\n"
199#define msg_HPC_not_supported "This system is not supported by this version of shpcphd mdoule. Upgrade to a newer version of shpchpd\n"
200#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"
201#define msg_button_on "PCI slot #%d - powering on due to button press.\n" 149#define msg_button_on "PCI slot #%d - powering on due to button press.\n"
202#define msg_button_off "PCI slot #%d - powering off due to button press.\n" 150#define msg_button_off "PCI slot #%d - powering off due to button press.\n"
203#define msg_button_cancel "PCI slot #%d - action canceled due to button press.\n" 151#define msg_button_cancel "PCI slot #%d - action canceled due to button press.\n"
204#define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n"
205 152
206/* sysfs functions for the hotplug controller info */ 153/* sysfs functions for the hotplug controller info */
207extern void shpchp_create_ctrl_files (struct controller *ctrl); 154extern void shpchp_create_ctrl_files (struct controller *ctrl);
208 155
209/* controller functions */ 156/* controller functions */
210extern int shpchprm_find_available_resources(struct controller *ctrl);
211extern int shpchp_event_start_thread(void); 157extern int shpchp_event_start_thread(void);
212extern void shpchp_event_stop_thread(void); 158extern void shpchp_event_stop_thread(void);
213extern struct pci_func *shpchp_slot_create(unsigned char busnumber);
214extern struct pci_func *shpchp_slot_find(unsigned char bus, unsigned char device, unsigned char index);
215extern int shpchp_enable_slot(struct slot *slot); 159extern int shpchp_enable_slot(struct slot *slot);
216extern int shpchp_disable_slot(struct slot *slot); 160extern int shpchp_disable_slot(struct slot *slot);
217 161
@@ -220,29 +164,20 @@ extern u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id);
220extern u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id); 164extern u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id);
221extern u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id); 165extern u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id);
222 166
223/* resource functions */
224extern int shpchp_resource_sort_and_combine(struct pci_resource **head);
225
226/* pci functions */ 167/* pci functions */
227extern int shpchp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num);
228/*extern int shpchp_get_bus_dev(struct controller *ctrl, u8 *bus_num, u8 *dev_num, struct slot *slot);*/
229extern int shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num); 168extern int shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num);
230extern int shpchp_save_used_resources(struct controller *ctrl, struct pci_func * func, int flag); 169extern int shpchp_configure_device(struct slot *p_slot);
231extern int shpchp_save_slot_config(struct controller *ctrl, struct pci_func * new_slot); 170extern int shpchp_unconfigure_device(struct slot *p_slot);
232extern void shpchp_destroy_board_resources(struct pci_func * func); 171extern void get_hp_hw_control_from_firmware(struct pci_dev *dev);
233extern int shpchp_return_board_resources(struct pci_func * func, struct resource_lists * resources); 172extern void get_hp_params_from_firmware(struct pci_dev *dev,
234extern void shpchp_destroy_resource_list(struct resource_lists * resources); 173 struct hotplug_params *hpp);
235extern int shpchp_configure_device(struct controller* ctrl, struct pci_func* func); 174extern int shpchprm_get_physical_slot_number(struct controller *ctrl,
236extern int shpchp_unconfigure_device(struct pci_func* func); 175 u32 *sun, u8 busnum, u8 devnum);
176extern void shpchp_remove_ctrl_files(struct controller *ctrl);
237 177
238 178
239/* Global variables */ 179/* Global variables */
240extern struct controller *shpchp_ctrl_list; 180extern struct controller *shpchp_ctrl_list;
241extern struct pci_func *shpchp_slot_list[256];
242
243/* These are added to support AMD shpc */
244extern u8 shpchp_nic_irq;
245extern u8 shpchp_disk_irq;
246 181
247struct ctrl_reg { 182struct ctrl_reg {
248 volatile u32 base_offset; 183 volatile u32 base_offset;
@@ -298,7 +233,7 @@ enum ctrl_offsets {
298 SLOT11 = offsetof(struct ctrl_reg, slot11), 233 SLOT11 = offsetof(struct ctrl_reg, slot11),
299 SLOT12 = offsetof(struct ctrl_reg, slot12), 234 SLOT12 = offsetof(struct ctrl_reg, slot12),
300}; 235};
301typedef u8(*php_intr_callback_t) (unsigned int change_id, void *instance_id); 236typedef u8(*php_intr_callback_t) (u8 hp_slot, void *instance_id);
302struct php_ctlr_state_s { 237struct php_ctlr_state_s {
303 struct php_ctlr_state_s *pnext; 238 struct php_ctlr_state_s *pnext;
304 struct pci_dev *pci_dev; 239 struct pci_dev *pci_dev;
@@ -359,12 +294,9 @@ static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device)
359 294
360 p_slot = ctrl->slot; 295 p_slot = ctrl->slot;
361 296
362 dbg("p_slot = %p\n", p_slot);
363
364 while (p_slot && (p_slot->device != device)) { 297 while (p_slot && (p_slot->device != device)) {
365 tmp_slot = p_slot; 298 tmp_slot = p_slot;
366 p_slot = p_slot->next; 299 p_slot = p_slot->next;
367 dbg("In while loop, p_slot = %p\n", p_slot);
368 } 300 }
369 if (p_slot == NULL) { 301 if (p_slot == NULL) {
370 err("ERROR: shpchp_find_slot device=0x%x\n", device); 302 err("ERROR: shpchp_find_slot device=0x%x\n", device);
@@ -379,8 +311,6 @@ static inline int wait_for_ctrl_irq (struct controller *ctrl)
379 DECLARE_WAITQUEUE(wait, current); 311 DECLARE_WAITQUEUE(wait, current);
380 int retval = 0; 312 int retval = 0;
381 313
382 dbg("%s : start\n",__FUNCTION__);
383
384 add_wait_queue(&ctrl->queue, &wait); 314 add_wait_queue(&ctrl->queue, &wait);
385 315
386 if (!shpchp_poll_mode) { 316 if (!shpchp_poll_mode) {
@@ -394,19 +324,9 @@ static inline int wait_for_ctrl_irq (struct controller *ctrl)
394 if (signal_pending(current)) 324 if (signal_pending(current))
395 retval = -EINTR; 325 retval = -EINTR;
396 326
397 dbg("%s : end\n", __FUNCTION__);
398 return retval; 327 return retval;
399} 328}
400 329
401/* Puts node back in the resource list pointed to by head */
402static inline void return_resource(struct pci_resource **head, struct pci_resource *node)
403{
404 if (!node || !head)
405 return;
406 node->next = *head;
407 *head = node;
408}
409
410#define SLOT_NAME_SIZE 10 330#define SLOT_NAME_SIZE 10
411 331
412static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) 332static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
@@ -420,11 +340,7 @@ enum php_ctlr_type {
420 ACPI 340 ACPI
421}; 341};
422 342
423int shpc_init( struct controller *ctrl, struct pci_dev *pdev, 343int shpc_init( struct controller *ctrl, struct pci_dev *pdev);
424 php_intr_callback_t attention_button_callback,
425 php_intr_callback_t switch_change_callback,
426 php_intr_callback_t presence_change_callback,
427 php_intr_callback_t power_fault_callback);
428 344
429int shpc_get_ctlr_slot_config( struct controller *ctrl, 345int shpc_get_ctlr_slot_config( struct controller *ctrl,
430 int *num_ctlr_slots, 346 int *num_ctlr_slots,
@@ -437,8 +353,6 @@ struct hpc_ops {
437 int (*power_on_slot ) (struct slot *slot); 353 int (*power_on_slot ) (struct slot *slot);
438 int (*slot_enable ) (struct slot *slot); 354 int (*slot_enable ) (struct slot *slot);
439 int (*slot_disable ) (struct slot *slot); 355 int (*slot_disable ) (struct slot *slot);
440 int (*enable_all_slots) (struct slot *slot);
441 int (*pwr_on_all_slots) (struct slot *slot);
442 int (*set_bus_speed_mode) (struct slot *slot, enum pci_bus_speed speed); 356 int (*set_bus_speed_mode) (struct slot *slot, enum pci_bus_speed speed);
443 int (*get_power_status) (struct slot *slot, u8 *status); 357 int (*get_power_status) (struct slot *slot, u8 *status);
444 int (*get_attention_status) (struct slot *slot, u8 *status); 358 int (*get_attention_status) (struct slot *slot, u8 *status);