2 * Standard Hot Plug Controller Driver
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 * Copyright (C) 2003-2004 Intel Corporation
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
30 #include <linux/module.h>
31 #include <linux/kernel.h>
32 #include <linux/types.h>
33 #include <linux/smp_lock.h>
34 #include <linux/pci.h>
38 static void interrupt_event_handler(struct controller
*ctrl
);
40 static struct semaphore event_semaphore
; /* mutex for process loop (up if something to process) */
41 static struct semaphore event_exit
; /* guard ensure thread has exited before calling it quits */
42 static int event_finished
;
43 static unsigned long pushbutton_pending
; /* = 0 */
45 u8
shpchp_handle_attention_button(u8 hp_slot
, void *inst_id
)
47 struct controller
*ctrl
= (struct controller
*) inst_id
;
51 struct event_info
*taskInfo
;
53 /* Attention Button Change */
54 dbg("shpchp: Attention button interrupt received.\n");
56 /* This is the structure that tells the worker thread what to do */
57 taskInfo
= &(ctrl
->event_queue
[ctrl
->next_event
]);
58 p_slot
= shpchp_find_slot(ctrl
, hp_slot
+ ctrl
->slot_device_offset
);
60 p_slot
->hpc_ops
->get_adapter_status(p_slot
, &(p_slot
->presence_save
));
61 p_slot
->hpc_ops
->get_latch_status(p_slot
, &getstatus
);
63 ctrl
->next_event
= (ctrl
->next_event
+ 1) % 10;
64 taskInfo
->hp_slot
= hp_slot
;
69 * Button pressed - See if need to TAKE ACTION!!!
71 info("Button pressed on Slot(%d)\n", ctrl
->first_slot
+ hp_slot
);
72 taskInfo
->event_type
= INT_BUTTON_PRESS
;
74 if ((p_slot
->state
== BLINKINGON_STATE
)
75 || (p_slot
->state
== BLINKINGOFF_STATE
)) {
76 /* Cancel if we are still blinking; this means that we press the
77 * attention again before the 5 sec. limit expires to cancel hot-add
80 taskInfo
->event_type
= INT_BUTTON_CANCEL
;
81 info("Button cancel on Slot(%d)\n", ctrl
->first_slot
+ hp_slot
);
82 } else if ((p_slot
->state
== POWERON_STATE
)
83 || (p_slot
->state
== POWEROFF_STATE
)) {
84 /* Ignore if the slot is on power-on or power-off state; this
85 * means that the previous attention button action to hot-add or
86 * hot-remove is undergoing
88 taskInfo
->event_type
= INT_BUTTON_IGNORE
;
89 info("Button ignore on Slot(%d)\n", ctrl
->first_slot
+ hp_slot
);
93 up(&event_semaphore
); /* signal event thread that new event is posted */
99 u8
shpchp_handle_switch_change(u8 hp_slot
, void *inst_id
)
101 struct controller
*ctrl
= (struct controller
*) inst_id
;
105 struct event_info
*taskInfo
;
108 dbg("shpchp: Switch interrupt received.\n");
110 /* This is the structure that tells the worker thread
113 taskInfo
= &(ctrl
->event_queue
[ctrl
->next_event
]);
114 ctrl
->next_event
= (ctrl
->next_event
+ 1) % 10;
115 taskInfo
->hp_slot
= hp_slot
;
118 p_slot
= shpchp_find_slot(ctrl
, hp_slot
+ ctrl
->slot_device_offset
);
119 p_slot
->hpc_ops
->get_adapter_status(p_slot
, &(p_slot
->presence_save
));
120 p_slot
->hpc_ops
->get_latch_status(p_slot
, &getstatus
);
121 dbg("%s: Card present %x Power status %x\n", __FUNCTION__
,
122 p_slot
->presence_save
, p_slot
->pwr_save
);
128 info("Latch open on Slot(%d)\n", ctrl
->first_slot
+ hp_slot
);
129 taskInfo
->event_type
= INT_SWITCH_OPEN
;
130 if (p_slot
->pwr_save
&& p_slot
->presence_save
) {
131 taskInfo
->event_type
= INT_POWER_FAULT
;
132 err("Surprise Removal of card\n");
138 info("Latch close on Slot(%d)\n", ctrl
->first_slot
+ hp_slot
);
139 taskInfo
->event_type
= INT_SWITCH_CLOSE
;
143 up(&event_semaphore
); /* signal event thread that new event is posted */
148 u8
shpchp_handle_presence_change(u8 hp_slot
, void *inst_id
)
150 struct controller
*ctrl
= (struct controller
*) inst_id
;
154 struct event_info
*taskInfo
;
156 /* Presence Change */
157 dbg("shpchp: Presence/Notify input change.\n");
159 /* This is the structure that tells the worker thread
162 taskInfo
= &(ctrl
->event_queue
[ctrl
->next_event
]);
163 ctrl
->next_event
= (ctrl
->next_event
+ 1) % 10;
164 taskInfo
->hp_slot
= hp_slot
;
167 p_slot
= shpchp_find_slot(ctrl
, hp_slot
+ ctrl
->slot_device_offset
);
170 * Save the presence state
172 p_slot
->hpc_ops
->get_adapter_status(p_slot
, &(p_slot
->presence_save
));
173 if (p_slot
->presence_save
) {
177 info("Card present on Slot(%d)\n", ctrl
->first_slot
+ hp_slot
);
178 taskInfo
->event_type
= INT_PRESENCE_ON
;
183 info("Card not present on Slot(%d)\n", ctrl
->first_slot
+ hp_slot
);
184 taskInfo
->event_type
= INT_PRESENCE_OFF
;
188 up(&event_semaphore
); /* signal event thread that new event is posted */
193 u8
shpchp_handle_power_fault(u8 hp_slot
, void *inst_id
)
195 struct controller
*ctrl
= (struct controller
*) inst_id
;
198 struct event_info
*taskInfo
;
201 dbg("shpchp: Power fault interrupt received.\n");
203 /* This is the structure that tells the worker thread
206 taskInfo
= &(ctrl
->event_queue
[ctrl
->next_event
]);
207 ctrl
->next_event
= (ctrl
->next_event
+ 1) % 10;
208 taskInfo
->hp_slot
= hp_slot
;
211 p_slot
= shpchp_find_slot(ctrl
, hp_slot
+ ctrl
->slot_device_offset
);
213 if ( !(p_slot
->hpc_ops
->query_power_fault(p_slot
))) {
215 * Power fault Cleared
217 info("Power fault cleared on Slot(%d)\n", ctrl
->first_slot
+ hp_slot
);
218 p_slot
->status
= 0x00;
219 taskInfo
->event_type
= INT_POWER_FAULT_CLEAR
;
224 info("Power fault on Slot(%d)\n", ctrl
->first_slot
+ hp_slot
);
225 taskInfo
->event_type
= INT_POWER_FAULT
;
226 /* set power fault status for this board */
227 p_slot
->status
= 0xFF;
228 info("power fault bit %x set\n", hp_slot
);
231 up(&event_semaphore
); /* signal event thread that new event is posted */
236 /* The following routines constitute the bulk of the
237 hotplug controller logic
239 static int change_bus_speed(struct controller
*ctrl
, struct slot
*p_slot
,
240 enum pci_bus_speed speed
)
244 dbg("%s: change to speed %d\n", __FUNCTION__
, speed
);
245 if ((rc
= p_slot
->hpc_ops
->set_bus_speed_mode(p_slot
, speed
))) {
246 err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__
);
247 return WRONG_BUS_FREQUENCY
;
252 static int fix_bus_speed(struct controller
*ctrl
, struct slot
*pslot
,
253 u8 flag
, enum pci_bus_speed asp
, enum pci_bus_speed bsp
,
254 enum pci_bus_speed msp
)
258 if (flag
!= 0) { /* Other slots on the same bus are occupied */
260 err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__
, bsp
, asp
);
261 return WRONG_BUS_FREQUENCY
;
264 /* Other slots on the same bus are empty */
266 /* if adapter_speed >= bus_speed, do nothing */
269 * Try to lower bus speed to accommodate the adapter if other slots
270 * on the same controller are empty
272 if ((rc
= change_bus_speed(ctrl
, pslot
, asp
)))
277 if ((rc
= change_bus_speed(ctrl
, pslot
, asp
)))
280 if ((rc
= change_bus_speed(ctrl
, pslot
, msp
)))
289 * board_added - Called after a board has been added to the system.
291 * Turns power on for the board
295 static int board_added(struct slot
*p_slot
)
298 u8 slots_not_empty
= 0;
300 enum pci_bus_speed adapter_speed
, bus_speed
, max_bus_speed
;
302 struct controller
*ctrl
= p_slot
->ctrl
;
304 hp_slot
= p_slot
->device
- ctrl
->slot_device_offset
;
306 dbg("%s: p_slot->device, slot_offset, hp_slot = %d, %d ,%d\n",
307 __FUNCTION__
, p_slot
->device
,
308 ctrl
->slot_device_offset
, hp_slot
);
310 /* Power on slot without connecting to bus */
311 rc
= p_slot
->hpc_ops
->power_on_slot(p_slot
);
313 err("%s: Failed to power on slot\n", __FUNCTION__
);
317 if ((ctrl
->pci_dev
->vendor
== 0x8086) && (ctrl
->pci_dev
->device
== 0x0332)) {
319 return WRONG_BUS_FREQUENCY
;
321 if ((rc
= p_slot
->hpc_ops
->set_bus_speed_mode(p_slot
, PCI_SPEED_33MHz
))) {
322 err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__
);
323 return WRONG_BUS_FREQUENCY
;
326 /* turn on board, blink green LED, turn off Amber LED */
327 if ((rc
= p_slot
->hpc_ops
->slot_enable(p_slot
))) {
328 err("%s: Issue of Slot Enable command failed\n", __FUNCTION__
);
333 rc
= p_slot
->hpc_ops
->get_adapter_speed(p_slot
, &adapter_speed
);
334 /* 0 = PCI 33Mhz, 1 = PCI 66 Mhz, 2 = PCI-X 66 PA, 4 = PCI-X 66 ECC, */
335 /* 5 = PCI-X 133 PA, 7 = PCI-X 133 ECC, 0xa = PCI-X 133 Mhz 266, */
336 /* 0xd = PCI-X 133 Mhz 533 */
337 /* This encoding is different from the one used in cur_bus_speed & */
340 if (rc
|| adapter_speed
== PCI_SPEED_UNKNOWN
) {
341 err("%s: Can't get adapter speed or bus mode mismatch\n", __FUNCTION__
);
342 return WRONG_BUS_FREQUENCY
;
345 rc
= p_slot
->hpc_ops
->get_cur_bus_speed(p_slot
, &bus_speed
);
346 if (rc
|| bus_speed
== PCI_SPEED_UNKNOWN
) {
347 err("%s: Can't get bus operation speed\n", __FUNCTION__
);
348 return WRONG_BUS_FREQUENCY
;
351 rc
= p_slot
->hpc_ops
->get_max_bus_speed(p_slot
, &max_bus_speed
);
352 if (rc
|| max_bus_speed
== PCI_SPEED_UNKNOWN
) {
353 err("%s: Can't get max bus operation speed\n", __FUNCTION__
);
354 max_bus_speed
= bus_speed
;
357 if ((rc
= p_slot
->hpc_ops
->get_prog_int(p_slot
, &pi
))) {
358 err("%s: Can't get controller programming interface, set it to 1\n", __FUNCTION__
);
362 /* Check if there are other slots or devices on the same bus */
363 if (!list_empty(&ctrl
->pci_dev
->subordinate
->devices
))
366 dbg("%s: slots_not_empty %d, pi %d\n", __FUNCTION__
,
367 slots_not_empty
, pi
);
368 dbg("adapter_speed %d, bus_speed %d, max_bus_speed %d\n",
369 adapter_speed
, bus_speed
, max_bus_speed
);
372 dbg("%s: In PI = %d\n", __FUNCTION__
, pi
);
373 if ((rc
= p_slot
->hpc_ops
->get_mode1_ECC_cap(p_slot
, &mode
))) {
374 err("%s: Can't get Mode1_ECC, set mode to 0\n", __FUNCTION__
);
378 switch (adapter_speed
) {
379 case PCI_SPEED_133MHz_PCIX_533
:
380 case PCI_SPEED_133MHz_PCIX_266
:
381 if ((bus_speed
!= adapter_speed
) &&
382 ((rc
= fix_bus_speed(ctrl
, p_slot
, slots_not_empty
, adapter_speed
, bus_speed
, max_bus_speed
))))
385 case PCI_SPEED_133MHz_PCIX_ECC
:
386 case PCI_SPEED_133MHz_PCIX
:
387 if (mode
) { /* Bus - Mode 1 ECC */
388 if ((bus_speed
!= 0x7) &&
389 ((rc
= fix_bus_speed(ctrl
, p_slot
, slots_not_empty
, adapter_speed
, bus_speed
, max_bus_speed
))))
392 if ((bus_speed
!= 0x4) &&
393 ((rc
= fix_bus_speed(ctrl
, p_slot
, slots_not_empty
, adapter_speed
, bus_speed
, max_bus_speed
))))
397 case PCI_SPEED_66MHz_PCIX_ECC
:
398 case PCI_SPEED_66MHz_PCIX
:
399 if (mode
) { /* Bus - Mode 1 ECC */
400 if ((bus_speed
!= 0x5) &&
401 ((rc
= fix_bus_speed(ctrl
, p_slot
, slots_not_empty
, adapter_speed
, bus_speed
, max_bus_speed
))))
404 if ((bus_speed
!= 0x2) &&
405 ((rc
= fix_bus_speed(ctrl
, p_slot
, slots_not_empty
, adapter_speed
, bus_speed
, max_bus_speed
))))
409 case PCI_SPEED_66MHz
:
410 if ((bus_speed
!= 0x1) &&
411 ((rc
= fix_bus_speed(ctrl
, p_slot
, slots_not_empty
, adapter_speed
, bus_speed
, max_bus_speed
))))
414 case PCI_SPEED_33MHz
:
415 if (bus_speed
> 0x0) {
416 if (slots_not_empty
== 0) {
417 if ((rc
= change_bus_speed(ctrl
, p_slot
, adapter_speed
)))
420 err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__
, bus_speed
, adapter_speed
);
421 return WRONG_BUS_FREQUENCY
;
426 err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__
, bus_speed
, adapter_speed
);
427 return WRONG_BUS_FREQUENCY
;
430 /* If adpater_speed == bus_speed, nothing to do here */
431 dbg("%s: In PI = %d\n", __FUNCTION__
, pi
);
432 if ((adapter_speed
!= bus_speed
) &&
433 ((rc
= fix_bus_speed(ctrl
, p_slot
, slots_not_empty
, adapter_speed
, bus_speed
, max_bus_speed
))))
437 /* turn on board, blink green LED, turn off Amber LED */
438 if ((rc
= p_slot
->hpc_ops
->slot_enable(p_slot
))) {
439 err("%s: Issue of Slot Enable command failed\n", __FUNCTION__
);
443 /* Wait for ~1 second */
446 dbg("%s: slot status = %x\n", __FUNCTION__
, p_slot
->status
);
447 /* Check for a power fault */
448 if (p_slot
->status
== 0xFF) {
449 /* power fault occurred, but it was benign */
450 dbg("%s: power fault\n", __FUNCTION__
);
456 if (shpchp_configure_device(p_slot
)) {
457 err("Cannot add device at 0x%x:0x%x\n", p_slot
->bus
,
463 p_slot
->is_a_board
= 0x01;
464 p_slot
->pwr_save
= 1;
466 p_slot
->hpc_ops
->green_led_on(p_slot
);
471 /* turn off slot, turn on Amber LED, turn off Green LED */
472 rc
= p_slot
->hpc_ops
->slot_disable(p_slot
);
474 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__
);
483 * remove_board - Turns off slot and LED's
486 static int remove_board(struct slot
*p_slot
)
488 struct controller
*ctrl
= p_slot
->ctrl
;
492 if (shpchp_unconfigure_device(p_slot
))
495 hp_slot
= p_slot
->device
- ctrl
->slot_device_offset
;
496 p_slot
= shpchp_find_slot(ctrl
, hp_slot
+ ctrl
->slot_device_offset
);
498 dbg("In %s, hp_slot = %d\n", __FUNCTION__
, hp_slot
);
500 /* Change status to shutdown */
501 if (p_slot
->is_a_board
)
502 p_slot
->status
= 0x01;
504 /* turn off slot, turn on Amber LED, turn off Green LED */
505 rc
= p_slot
->hpc_ops
->slot_disable(p_slot
);
507 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__
);
511 rc
= p_slot
->hpc_ops
->set_attention_status(p_slot
, 0);
513 err("%s: Issue of Set Attention command failed\n", __FUNCTION__
);
517 p_slot
->pwr_save
= 0;
518 p_slot
->is_a_board
= 0;
524 static void pushbutton_helper_thread (unsigned long data
)
526 pushbutton_pending
= data
;
528 up(&event_semaphore
);
533 * shpchp_pushbutton_thread
535 * Scheduled procedure to handle blocking stuff for the pushbuttons
536 * Handles all pending events and exits.
539 static void shpchp_pushbutton_thread (unsigned long slot
)
541 struct slot
*p_slot
= (struct slot
*) slot
;
544 pushbutton_pending
= 0;
547 dbg("%s: Error! slot NULL\n", __FUNCTION__
);
551 p_slot
->hpc_ops
->get_power_status(p_slot
, &getstatus
);
553 p_slot
->state
= POWEROFF_STATE
;
555 shpchp_disable_slot(p_slot
);
556 p_slot
->state
= STATIC_STATE
;
558 p_slot
->state
= POWERON_STATE
;
560 if (shpchp_enable_slot(p_slot
))
561 p_slot
->hpc_ops
->green_led_off(p_slot
);
563 p_slot
->state
= STATIC_STATE
;
570 /* this is the main worker thread */
571 static int event_thread(void* data
)
573 struct controller
*ctrl
;
575 daemonize("shpchpd_event");
579 dbg("!!!!event_thread sleeping\n");
580 down_interruptible (&event_semaphore
);
581 dbg("event_thread woken finished = %d\n", event_finished
);
582 if (event_finished
|| signal_pending(current
))
585 if (pushbutton_pending
)
586 shpchp_pushbutton_thread(pushbutton_pending
);
588 list_for_each_entry(ctrl
, &shpchp_ctrl_list
, ctrl_list
)
589 interrupt_event_handler(ctrl
);
591 dbg("event_thread signals exit\n");
596 int shpchp_event_start_thread (void)
600 /* initialize our semaphores */
601 init_MUTEX_LOCKED(&event_exit
);
604 init_MUTEX_LOCKED(&event_semaphore
);
605 pid
= kernel_thread(event_thread
, NULL
, 0);
608 err ("Can't start up our event thread\n");
615 void shpchp_event_stop_thread (void)
618 up(&event_semaphore
);
623 static int update_slot_info (struct slot
*slot
)
625 struct hotplug_slot_info
*info
;
628 info
= kmalloc(sizeof(*info
), GFP_KERNEL
);
632 slot
->hpc_ops
->get_power_status(slot
, &(info
->power_status
));
633 slot
->hpc_ops
->get_attention_status(slot
, &(info
->attention_status
));
634 slot
->hpc_ops
->get_latch_status(slot
, &(info
->latch_status
));
635 slot
->hpc_ops
->get_adapter_status(slot
, &(info
->adapter_status
));
637 result
= pci_hp_change_slot_info(slot
->hotplug_slot
, info
);
642 static void interrupt_event_handler(struct controller
*ctrl
)
653 for (loop
= 0; loop
< 10; loop
++) {
654 if (ctrl
->event_queue
[loop
].event_type
!= 0) {
655 dbg("%s:loop %x event_type %x\n", __FUNCTION__
, loop
,
656 ctrl
->event_queue
[loop
].event_type
);
657 hp_slot
= ctrl
->event_queue
[loop
].hp_slot
;
659 p_slot
= shpchp_find_slot(ctrl
, hp_slot
+ ctrl
->slot_device_offset
);
661 if (ctrl
->event_queue
[loop
].event_type
== INT_BUTTON_CANCEL
) {
662 dbg("%s: button cancel\n", __FUNCTION__
);
663 del_timer(&p_slot
->task_event
);
665 switch (p_slot
->state
) {
666 case BLINKINGOFF_STATE
:
667 p_slot
->hpc_ops
->green_led_on(p_slot
);
668 p_slot
->hpc_ops
->set_attention_status(p_slot
, 0);
670 case BLINKINGON_STATE
:
671 p_slot
->hpc_ops
->green_led_off(p_slot
);
672 p_slot
->hpc_ops
->set_attention_status(p_slot
, 0);
675 warn("Not a valid state\n");
678 info(msg_button_cancel
, p_slot
->number
);
679 p_slot
->state
= STATIC_STATE
;
680 } else if (ctrl
->event_queue
[loop
].event_type
== INT_BUTTON_PRESS
) {
681 /* Button Pressed (No action on 1st press...) */
682 dbg("%s: Button pressed\n", __FUNCTION__
);
684 p_slot
->hpc_ops
->get_power_status(p_slot
, &getstatus
);
687 dbg("%s: slot is on\n", __FUNCTION__
);
688 p_slot
->state
= BLINKINGOFF_STATE
;
689 info(msg_button_off
, p_slot
->number
);
692 dbg("%s: slot is off\n", __FUNCTION__
);
693 p_slot
->state
= BLINKINGON_STATE
;
694 info(msg_button_on
, p_slot
->number
);
697 /* blink green LED and turn off amber */
698 p_slot
->hpc_ops
->green_led_blink(p_slot
);
699 p_slot
->hpc_ops
->set_attention_status(p_slot
, 0);
701 init_timer(&p_slot
->task_event
);
702 p_slot
->task_event
.expires
= jiffies
+ 5 * HZ
; /* 5 second delay */
703 p_slot
->task_event
.function
= (void (*)(unsigned long)) pushbutton_helper_thread
;
704 p_slot
->task_event
.data
= (unsigned long) p_slot
;
706 dbg("%s: add_timer p_slot = %p\n", __FUNCTION__
,(void *) p_slot
);
707 add_timer(&p_slot
->task_event
);
708 } else if (ctrl
->event_queue
[loop
].event_type
== INT_POWER_FAULT
) {
709 /***********POWER FAULT********************/
710 dbg("%s: power fault\n", __FUNCTION__
);
711 p_slot
->hpc_ops
->set_attention_status(p_slot
, 1);
712 p_slot
->hpc_ops
->green_led_off(p_slot
);
714 /* refresh notification */
716 update_slot_info(p_slot
);
719 ctrl
->event_queue
[loop
].event_type
= 0;
723 } /* End of FOR loop */
730 int shpchp_enable_slot (struct slot
*p_slot
)
733 int rc
, retval
= -ENODEV
;
735 /* Check to see if (latch closed, card present, power off) */
736 mutex_lock(&p_slot
->ctrl
->crit_sect
);
737 rc
= p_slot
->hpc_ops
->get_adapter_status(p_slot
, &getstatus
);
738 if (rc
|| !getstatus
) {
739 info("%s: no adapter on slot(%x)\n", __FUNCTION__
, p_slot
->number
);
742 rc
= p_slot
->hpc_ops
->get_latch_status(p_slot
, &getstatus
);
743 if (rc
|| getstatus
) {
744 info("%s: latch open on slot(%x)\n", __FUNCTION__
, p_slot
->number
);
747 rc
= p_slot
->hpc_ops
->get_power_status(p_slot
, &getstatus
);
748 if (rc
|| getstatus
) {
749 info("%s: already enabled on slot(%x)\n", __FUNCTION__
, p_slot
->number
);
753 p_slot
->is_a_board
= 1;
755 /* We have to save the presence info for these slots */
756 p_slot
->hpc_ops
->get_adapter_status(p_slot
, &(p_slot
->presence_save
));
757 p_slot
->hpc_ops
->get_power_status(p_slot
, &(p_slot
->pwr_save
));
758 dbg("%s: p_slot->pwr_save %x\n", __FUNCTION__
, p_slot
->pwr_save
);
759 p_slot
->hpc_ops
->get_latch_status(p_slot
, &getstatus
);
761 if(((p_slot
->ctrl
->pci_dev
->vendor
== PCI_VENDOR_ID_AMD
) ||
762 (p_slot
->ctrl
->pci_dev
->device
== PCI_DEVICE_ID_AMD_POGO_7458
))
763 && p_slot
->ctrl
->num_slots
== 1) {
764 /* handle amd pogo errata; this must be done before enable */
765 amd_pogo_errata_save_misc_reg(p_slot
);
766 retval
= board_added(p_slot
);
767 /* handle amd pogo errata; this must be done after enable */
768 amd_pogo_errata_restore_misc_reg(p_slot
);
770 retval
= board_added(p_slot
);
773 p_slot
->hpc_ops
->get_adapter_status(p_slot
,
774 &(p_slot
->presence_save
));
775 p_slot
->hpc_ops
->get_latch_status(p_slot
, &getstatus
);
778 update_slot_info(p_slot
);
780 mutex_unlock(&p_slot
->ctrl
->crit_sect
);
785 int shpchp_disable_slot (struct slot
*p_slot
)
788 int rc
, retval
= -ENODEV
;
793 /* Check to see if (latch closed, card present, power on) */
794 mutex_lock(&p_slot
->ctrl
->crit_sect
);
796 rc
= p_slot
->hpc_ops
->get_adapter_status(p_slot
, &getstatus
);
797 if (rc
|| !getstatus
) {
798 info("%s: no adapter on slot(%x)\n", __FUNCTION__
, p_slot
->number
);
801 rc
= p_slot
->hpc_ops
->get_latch_status(p_slot
, &getstatus
);
802 if (rc
|| getstatus
) {
803 info("%s: latch open on slot(%x)\n", __FUNCTION__
, p_slot
->number
);
806 rc
= p_slot
->hpc_ops
->get_power_status(p_slot
, &getstatus
);
807 if (rc
|| !getstatus
) {
808 info("%s: already disabled slot(%x)\n", __FUNCTION__
, p_slot
->number
);
812 retval
= remove_board(p_slot
);
813 update_slot_info(p_slot
);
815 mutex_unlock(&p_slot
->ctrl
->crit_sect
);