aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/pciehp_ctrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/pciehp_ctrl.c')
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c56
1 files changed, 13 insertions, 43 deletions
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index b60e4973289c..dcfbfffa17c6 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -27,15 +27,9 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
33#include <linux/types.h> 32#include <linux/types.h>
34#include <linux/slab.h>
35#include <linux/workqueue.h>
36#include <linux/interrupt.h>
37#include <linux/delay.h>
38#include <linux/wait.h>
39#include <linux/smp_lock.h> 33#include <linux/smp_lock.h>
40#include <linux/pci.h> 34#include <linux/pci.h>
41#include "../pci.h" 35#include "../pci.h"
@@ -64,10 +58,9 @@ u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
64 taskInfo = &(ctrl->event_queue[ctrl->next_event]); 58 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
65 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 59 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
66 60
67 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
68 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 61 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
69 62
70 ctrl->next_event = (ctrl->next_event + 1) % 10; 63 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
71 taskInfo->hp_slot = hp_slot; 64 taskInfo->hp_slot = hp_slot;
72 65
73 rc++; 66 rc++;
@@ -118,12 +111,11 @@ u8 pciehp_handle_switch_change(u8 hp_slot, void *inst_id)
118 * what to do 111 * what to do
119 */ 112 */
120 taskInfo = &(ctrl->event_queue[ctrl->next_event]); 113 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
121 ctrl->next_event = (ctrl->next_event + 1) % 10; 114 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
122 taskInfo->hp_slot = hp_slot; 115 taskInfo->hp_slot = hp_slot;
123 116
124 rc++; 117 rc++;
125 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 118 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
126 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
127 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 119 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
128 120
129 if (getstatus) { 121 if (getstatus) {
@@ -131,14 +123,12 @@ u8 pciehp_handle_switch_change(u8 hp_slot, void *inst_id)
131 * Switch opened 123 * Switch opened
132 */ 124 */
133 info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot); 125 info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot);
134 p_slot->switch_save = 0;
135 taskInfo->event_type = INT_SWITCH_OPEN; 126 taskInfo->event_type = INT_SWITCH_OPEN;
136 } else { 127 } else {
137 /* 128 /*
138 * Switch closed 129 * Switch closed
139 */ 130 */
140 info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot); 131 info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot);
141 p_slot->switch_save = 0x10;
142 taskInfo->event_type = INT_SWITCH_CLOSE; 132 taskInfo->event_type = INT_SWITCH_CLOSE;
143 } 133 }
144 134
@@ -152,7 +142,7 @@ u8 pciehp_handle_presence_change(u8 hp_slot, void *inst_id)
152{ 142{
153 struct controller *ctrl = (struct controller *) inst_id; 143 struct controller *ctrl = (struct controller *) inst_id;
154 struct slot *p_slot; 144 struct slot *p_slot;
155 u8 rc = 0; 145 u8 presence_save, rc = 0;
156 struct event_info *taskInfo; 146 struct event_info *taskInfo;
157 147
158 /* Presence Change */ 148 /* Presence Change */
@@ -162,7 +152,7 @@ u8 pciehp_handle_presence_change(u8 hp_slot, void *inst_id)
162 * what to do 152 * what to do
163 */ 153 */
164 taskInfo = &(ctrl->event_queue[ctrl->next_event]); 154 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
165 ctrl->next_event = (ctrl->next_event + 1) % 10; 155 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
166 taskInfo->hp_slot = hp_slot; 156 taskInfo->hp_slot = hp_slot;
167 157
168 rc++; 158 rc++;
@@ -171,8 +161,8 @@ u8 pciehp_handle_presence_change(u8 hp_slot, void *inst_id)
171 /* Switch is open, assume a presence change 161 /* Switch is open, assume a presence change
172 * Save the presence state 162 * Save the presence state
173 */ 163 */
174 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); 164 p_slot->hpc_ops->get_adapter_status(p_slot, &presence_save);
175 if (p_slot->presence_save) { 165 if (presence_save) {
176 /* 166 /*
177 * Card Present 167 * Card Present
178 */ 168 */
@@ -206,7 +196,7 @@ u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id)
206 * what to do 196 * what to do
207 */ 197 */
208 taskInfo = &(ctrl->event_queue[ctrl->next_event]); 198 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
209 ctrl->next_event = (ctrl->next_event + 1) % 10; 199 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
210 taskInfo->hp_slot = hp_slot; 200 taskInfo->hp_slot = hp_slot;
211 201
212 rc++; 202 rc++;
@@ -279,11 +269,10 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
279 * Configures board 269 * Configures board
280 * 270 *
281 */ 271 */
282static u32 board_added(struct slot *p_slot) 272static int board_added(struct slot *p_slot)
283{ 273{
284 u8 hp_slot; 274 u8 hp_slot;
285 u32 temp_register = 0xFFFFFFFF; 275 int rc = 0;
286 u32 rc = 0;
287 struct controller *ctrl = p_slot->ctrl; 276 struct controller *ctrl = p_slot->ctrl;
288 277
289 hp_slot = p_slot->device - ctrl->slot_device_offset; 278 hp_slot = p_slot->device - ctrl->slot_device_offset;
@@ -333,8 +322,6 @@ static u32 board_added(struct slot *p_slot)
333 /* Check for a power fault */ 322 /* Check for a power fault */
334 if (p_slot->status == 0xFF) { 323 if (p_slot->status == 0xFF) {
335 /* power fault occurred, but it was benign */ 324 /* power fault occurred, but it was benign */
336 temp_register = 0xFFFFFFFF;
337 dbg("%s: temp register set to %x by power fault\n", __FUNCTION__, temp_register);
338 rc = POWER_FAILURE; 325 rc = POWER_FAILURE;
339 p_slot->status = 0; 326 p_slot->status = 0;
340 goto err_exit; 327 goto err_exit;
@@ -348,8 +335,6 @@ static u32 board_added(struct slot *p_slot)
348 } 335 }
349 336
350 p_slot->status = 0; 337 p_slot->status = 0;
351 p_slot->switch_save = 0x10;
352 p_slot->is_a_board = 0x01;
353 338
354 /* 339 /*
355 * Some PCI Express root ports require fixup after hot-plug operation. 340 * Some PCI Express root ports require fixup after hot-plug operation.
@@ -380,11 +365,11 @@ err_exit:
380 * remove_board - Turns off slot and LED's 365 * remove_board - Turns off slot and LED's
381 * 366 *
382 */ 367 */
383static u32 remove_board(struct slot *p_slot) 368static int remove_board(struct slot *p_slot)
384{ 369{
385 u8 device; 370 u8 device;
386 u8 hp_slot; 371 u8 hp_slot;
387 u32 rc; 372 int rc;
388 struct controller *ctrl = p_slot->ctrl; 373 struct controller *ctrl = p_slot->ctrl;
389 374
390 if (pciehp_unconfigure_device(p_slot)) 375 if (pciehp_unconfigure_device(p_slot))
@@ -398,9 +383,7 @@ static u32 remove_board(struct slot *p_slot)
398 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot); 383 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot);
399 384
400 /* Change status to shutdown */ 385 /* Change status to shutdown */
401 if (p_slot->is_a_board) 386 p_slot->status = 0x01;
402 p_slot->status = 0x01;
403 p_slot->configured = 0;
404 387
405 /* Wait for exclusive access to hardware */ 388 /* Wait for exclusive access to hardware */
406 down(&ctrl->crit_sect); 389 down(&ctrl->crit_sect);
@@ -428,9 +411,6 @@ static u32 remove_board(struct slot *p_slot)
428 /* Done with exclusive hardware access */ 411 /* Done with exclusive hardware access */
429 up(&ctrl->crit_sect); 412 up(&ctrl->crit_sect);
430 413
431 p_slot->switch_save = 0x10;
432 p_slot->is_a_board = 0;
433
434 return 0; 414 return 0;
435} 415}
436 416
@@ -633,7 +613,7 @@ static void interrupt_event_handler(struct controller *ctrl)
633 while (change) { 613 while (change) {
634 change = 0; 614 change = 0;
635 615
636 for (loop = 0; loop < 10; loop++) { 616 for (loop = 0; loop < MAX_EVENTS; loop++) {
637 if (ctrl->event_queue[loop].event_type != 0) { 617 if (ctrl->event_queue[loop].event_type != 0) {
638 hp_slot = ctrl->event_queue[loop].hp_slot; 618 hp_slot = ctrl->event_queue[loop].hp_slot;
639 619
@@ -816,21 +796,11 @@ int pciehp_enable_slot(struct slot *p_slot)
816 } 796 }
817 up(&p_slot->ctrl->crit_sect); 797 up(&p_slot->ctrl->crit_sect);
818 798
819 p_slot->configured = 0;
820 p_slot->is_a_board = 1;
821
822 /* We have to save the presence info for these slots */
823 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
824 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 799 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
825 p_slot->switch_save = !getstatus? 0x10:0;
826 800
827 rc = board_added(p_slot); 801 rc = board_added(p_slot);
828 if (rc) { 802 if (rc) {
829 /* We have to save the presence info for these slots */
830 p_slot->hpc_ops->get_adapter_status(p_slot,
831 &(p_slot->presence_save));
832 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 803 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
833 p_slot->switch_save = !getstatus? 0x10:0;
834 } 804 }
835 805
836 if (p_slot) 806 if (p_slot)