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