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 down(&ctrl->crit_sect);
246 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) {
247 err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
248 up(&ctrl->crit_sect);
249 return WRONG_BUS_FREQUENCY;
252 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
253 err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
255 err("%s: Error code (%d)\n", __FUNCTION__, rc);
256 up(&ctrl->crit_sect);
257 return WRONG_BUS_FREQUENCY;
259 up(&ctrl->crit_sect);
263 static int fix_bus_speed(struct controller *ctrl, struct slot *pslot,
264 u8 flag, enum pci_bus_speed asp, enum pci_bus_speed bsp,
265 enum pci_bus_speed msp)
269 if (flag != 0) { /* Other slots on the same bus are occupied */
271 err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bsp, asp);
272 return WRONG_BUS_FREQUENCY;
275 /* Other slots on the same bus are empty */
277 /* if adapter_speed >= bus_speed, do nothing */
280 * Try to lower bus speed to accommodate the adapter if other slots
281 * on the same controller are empty
283 if ((rc = change_bus_speed(ctrl, pslot, asp)))
288 if ((rc = change_bus_speed(ctrl, pslot, asp)))
291 if ((rc = change_bus_speed(ctrl, pslot, msp)))
300 * board_added - Called after a board has been added to the system.
302 * Turns power on for the board
306 static int board_added(struct slot *p_slot)
309 u8 slots_not_empty = 0;
311 enum pci_bus_speed adapter_speed, bus_speed, max_bus_speed;
313 struct controller *ctrl = p_slot->ctrl;
315 hp_slot = p_slot->device - ctrl->slot_device_offset;
317 dbg("%s: p_slot->device, slot_offset, hp_slot = %d, %d ,%d\n",
318 __FUNCTION__, p_slot->device,
319 ctrl->slot_device_offset, hp_slot);
321 /* Wait for exclusive access to hardware */
322 down(&ctrl->crit_sect);
324 /* Power on slot without connecting to bus */
325 rc = p_slot->hpc_ops->power_on_slot(p_slot);
327 err("%s: Failed to power on slot\n", __FUNCTION__);
328 /* Done with exclusive hardware access */
329 up(&ctrl->crit_sect);
333 rc = p_slot->hpc_ops->check_cmd_status(ctrl);
335 err("%s: Failed to power on slot, error code(%d)\n", __FUNCTION__, rc);
336 /* Done with exclusive hardware access */
337 up(&ctrl->crit_sect);
342 if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) {
344 return WRONG_BUS_FREQUENCY;
346 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) {
347 err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
348 up(&ctrl->crit_sect);
349 return WRONG_BUS_FREQUENCY;
352 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
353 err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
355 err("%s: Error code (%d)\n", __FUNCTION__, rc);
356 up(&ctrl->crit_sect);
357 return WRONG_BUS_FREQUENCY;
359 /* turn on board, blink green LED, turn off Amber LED */
360 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) {
361 err("%s: Issue of Slot Enable command failed\n", __FUNCTION__);
362 up(&ctrl->crit_sect);
366 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
367 err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
368 up(&ctrl->crit_sect);
373 rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &adapter_speed);
374 /* 0 = PCI 33Mhz, 1 = PCI 66 Mhz, 2 = PCI-X 66 PA, 4 = PCI-X 66 ECC, */
375 /* 5 = PCI-X 133 PA, 7 = PCI-X 133 ECC, 0xa = PCI-X 133 Mhz 266, */
376 /* 0xd = PCI-X 133 Mhz 533 */
377 /* This encoding is different from the one used in cur_bus_speed & */
380 if (rc || adapter_speed == PCI_SPEED_UNKNOWN) {
381 err("%s: Can't get adapter speed or bus mode mismatch\n", __FUNCTION__);
382 /* Done with exclusive hardware access */
383 up(&ctrl->crit_sect);
384 return WRONG_BUS_FREQUENCY;
387 rc = p_slot->hpc_ops->get_cur_bus_speed(p_slot, &bus_speed);
388 if (rc || bus_speed == PCI_SPEED_UNKNOWN) {
389 err("%s: Can't get bus operation speed\n", __FUNCTION__);
390 /* Done with exclusive hardware access */
391 up(&ctrl->crit_sect);
392 return WRONG_BUS_FREQUENCY;
395 rc = p_slot->hpc_ops->get_max_bus_speed(p_slot, &max_bus_speed);
396 if (rc || max_bus_speed == PCI_SPEED_UNKNOWN) {
397 err("%s: Can't get max bus operation speed\n", __FUNCTION__);
398 max_bus_speed = bus_speed;
401 /* Done with exclusive hardware access */
402 up(&ctrl->crit_sect);
404 if ((rc = p_slot->hpc_ops->get_prog_int(p_slot, &pi))) {
405 err("%s: Can't get controller programming interface, set it to 1\n", __FUNCTION__);
409 /* Check if there are other slots or devices on the same bus */
410 if (!list_empty(&ctrl->pci_dev->subordinate->devices))
413 dbg("%s: slots_not_empty %d, pi %d\n", __FUNCTION__,
414 slots_not_empty, pi);
415 dbg("adapter_speed %d, bus_speed %d, max_bus_speed %d\n",
416 adapter_speed, bus_speed, max_bus_speed);
419 dbg("%s: In PI = %d\n", __FUNCTION__, pi);
420 if ((rc = p_slot->hpc_ops->get_mode1_ECC_cap(p_slot, &mode))) {
421 err("%s: Can't get Mode1_ECC, set mode to 0\n", __FUNCTION__);
425 switch (adapter_speed) {
426 case PCI_SPEED_133MHz_PCIX_533:
427 case PCI_SPEED_133MHz_PCIX_266:
428 if ((bus_speed != adapter_speed) &&
429 ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
432 case PCI_SPEED_133MHz_PCIX_ECC:
433 case PCI_SPEED_133MHz_PCIX:
434 if (mode) { /* Bus - Mode 1 ECC */
435 if ((bus_speed != 0x7) &&
436 ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
439 if ((bus_speed != 0x4) &&
440 ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
444 case PCI_SPEED_66MHz_PCIX_ECC:
445 case PCI_SPEED_66MHz_PCIX:
446 if (mode) { /* Bus - Mode 1 ECC */
447 if ((bus_speed != 0x5) &&
448 ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
451 if ((bus_speed != 0x2) &&
452 ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
456 case PCI_SPEED_66MHz:
457 if ((bus_speed != 0x1) &&
458 ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
461 case PCI_SPEED_33MHz:
462 if (bus_speed > 0x0) {
463 if (slots_not_empty == 0) {
464 if ((rc = change_bus_speed(ctrl, p_slot, adapter_speed)))
467 err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed);
468 return WRONG_BUS_FREQUENCY;
473 err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed);
474 return WRONG_BUS_FREQUENCY;
477 /* If adpater_speed == bus_speed, nothing to do here */
478 dbg("%s: In PI = %d\n", __FUNCTION__, pi);
479 if ((adapter_speed != bus_speed) &&
480 ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
484 down(&ctrl->crit_sect);
485 /* turn on board, blink green LED, turn off Amber LED */
486 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) {
487 err("%s: Issue of Slot Enable command failed\n", __FUNCTION__);
488 up(&ctrl->crit_sect);
492 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
493 err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
494 up(&ctrl->crit_sect);
498 up(&ctrl->crit_sect);
500 /* Wait for ~1 second */
501 wait_for_ctrl_irq (ctrl);
503 dbg("%s: slot status = %x\n", __FUNCTION__, p_slot->status);
504 /* Check for a power fault */
505 if (p_slot->status == 0xFF) {
506 /* power fault occurred, but it was benign */
507 dbg("%s: power fault\n", __FUNCTION__);
513 if (shpchp_configure_device(p_slot)) {
514 err("Cannot add device at 0x%x:0x%x\n", p_slot->bus,
520 p_slot->is_a_board = 0x01;
521 p_slot->pwr_save = 1;
523 /* Wait for exclusive access to hardware */
524 down(&ctrl->crit_sect);
526 p_slot->hpc_ops->green_led_on(p_slot);
528 /* Done with exclusive hardware access */
529 up(&ctrl->crit_sect);
534 /* Wait for exclusive access to hardware */
535 down(&ctrl->crit_sect);
537 /* turn off slot, turn on Amber LED, turn off Green LED */
538 rc = p_slot->hpc_ops->slot_disable(p_slot);
540 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
541 /* Done with exclusive hardware access */
542 up(&ctrl->crit_sect);
546 rc = p_slot->hpc_ops->check_cmd_status(ctrl);
548 err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc);
549 /* Done with exclusive hardware access */
550 up(&ctrl->crit_sect);
554 /* Done with exclusive hardware access */
555 up(&ctrl->crit_sect);
562 * remove_board - Turns off slot and LED's
565 static int remove_board(struct slot *p_slot)
567 struct controller *ctrl = p_slot->ctrl;
571 if (shpchp_unconfigure_device(p_slot))
574 hp_slot = p_slot->device - ctrl->slot_device_offset;
575 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
577 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot);
579 /* Change status to shutdown */
580 if (p_slot->is_a_board)
581 p_slot->status = 0x01;
583 /* Wait for exclusive access to hardware */
584 down(&ctrl->crit_sect);
586 /* turn off slot, turn on Amber LED, turn off Green LED */
587 rc = p_slot->hpc_ops->slot_disable(p_slot);
589 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
590 /* Done with exclusive hardware access */
591 up(&ctrl->crit_sect);
595 rc = p_slot->hpc_ops->check_cmd_status(ctrl);
597 err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc);
598 /* Done with exclusive hardware access */
599 up(&ctrl->crit_sect);
603 rc = p_slot->hpc_ops->set_attention_status(p_slot, 0);
605 err("%s: Issue of Set Attention command failed\n", __FUNCTION__);
606 /* Done with exclusive hardware access */
607 up(&ctrl->crit_sect);
611 /* Done with exclusive hardware access */
612 up(&ctrl->crit_sect);
614 p_slot->pwr_save = 0;
615 p_slot->is_a_board = 0;
621 static void pushbutton_helper_thread (unsigned long data)
623 pushbutton_pending = data;
625 up(&event_semaphore);
630 * shpchp_pushbutton_thread
632 * Scheduled procedure to handle blocking stuff for the pushbuttons
633 * Handles all pending events and exits.
636 static void shpchp_pushbutton_thread (unsigned long slot)
638 struct slot *p_slot = (struct slot *) slot;
641 pushbutton_pending = 0;
644 dbg("%s: Error! slot NULL\n", __FUNCTION__);
648 p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
650 p_slot->state = POWEROFF_STATE;
652 shpchp_disable_slot(p_slot);
653 p_slot->state = STATIC_STATE;
655 p_slot->state = POWERON_STATE;
657 if (shpchp_enable_slot(p_slot)) {
658 /* Wait for exclusive access to hardware */
659 down(&p_slot->ctrl->crit_sect);
661 p_slot->hpc_ops->green_led_off(p_slot);
663 /* Done with exclusive hardware access */
664 up(&p_slot->ctrl->crit_sect);
666 p_slot->state = STATIC_STATE;
673 /* this is the main worker thread */
674 static int event_thread(void* data)
676 struct controller *ctrl;
678 daemonize("shpchpd_event");
682 dbg("!!!!event_thread sleeping\n");
683 down_interruptible (&event_semaphore);
684 dbg("event_thread woken finished = %d\n", event_finished);
685 if (event_finished || signal_pending(current))
688 if (pushbutton_pending)
689 shpchp_pushbutton_thread(pushbutton_pending);
691 for (ctrl = shpchp_ctrl_list; ctrl; ctrl=ctrl->next)
692 interrupt_event_handler(ctrl);
694 dbg("event_thread signals exit\n");
699 int shpchp_event_start_thread (void)
703 /* initialize our semaphores */
704 init_MUTEX_LOCKED(&event_exit);
707 init_MUTEX_LOCKED(&event_semaphore);
708 pid = kernel_thread(event_thread, NULL, 0);
711 err ("Can't start up our event thread\n");
718 void shpchp_event_stop_thread (void)
721 up(&event_semaphore);
726 static int update_slot_info (struct slot *slot)
728 struct hotplug_slot_info *info;
731 info = kmalloc(sizeof(*info), GFP_KERNEL);
735 slot->hpc_ops->get_power_status(slot, &(info->power_status));
736 slot->hpc_ops->get_attention_status(slot, &(info->attention_status));
737 slot->hpc_ops->get_latch_status(slot, &(info->latch_status));
738 slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status));
740 result = pci_hp_change_slot_info(slot->hotplug_slot, info);
745 static void interrupt_event_handler(struct controller *ctrl)
756 for (loop = 0; loop < 10; loop++) {
757 if (ctrl->event_queue[loop].event_type != 0) {
758 dbg("%s:loop %x event_type %x\n", __FUNCTION__, loop,
759 ctrl->event_queue[loop].event_type);
760 hp_slot = ctrl->event_queue[loop].hp_slot;
762 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
764 if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) {
765 dbg("%s: button cancel\n", __FUNCTION__);
766 del_timer(&p_slot->task_event);
768 switch (p_slot->state) {
769 case BLINKINGOFF_STATE:
770 /* Wait for exclusive access to hardware */
771 down(&ctrl->crit_sect);
773 p_slot->hpc_ops->green_led_on(p_slot);
775 p_slot->hpc_ops->set_attention_status(p_slot, 0);
777 /* Done with exclusive hardware access */
778 up(&ctrl->crit_sect);
780 case BLINKINGON_STATE:
781 /* Wait for exclusive access to hardware */
782 down(&ctrl->crit_sect);
784 p_slot->hpc_ops->green_led_off(p_slot);
786 p_slot->hpc_ops->set_attention_status(p_slot, 0);
788 /* Done with exclusive hardware access */
789 up(&ctrl->crit_sect);
793 warn("Not a valid state\n");
796 info(msg_button_cancel, p_slot->number);
797 p_slot->state = STATIC_STATE;
798 } else if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) {
799 /* Button Pressed (No action on 1st press...) */
800 dbg("%s: Button pressed\n", __FUNCTION__);
802 p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
805 dbg("%s: slot is on\n", __FUNCTION__);
806 p_slot->state = BLINKINGOFF_STATE;
807 info(msg_button_off, p_slot->number);
810 dbg("%s: slot is off\n", __FUNCTION__);
811 p_slot->state = BLINKINGON_STATE;
812 info(msg_button_on, p_slot->number);
815 /* Wait for exclusive access to hardware */
816 down(&ctrl->crit_sect);
818 /* blink green LED and turn off amber */
819 p_slot->hpc_ops->green_led_blink(p_slot);
821 p_slot->hpc_ops->set_attention_status(p_slot, 0);
823 /* Done with exclusive hardware access */
824 up(&ctrl->crit_sect);
826 init_timer(&p_slot->task_event);
827 p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */
828 p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread;
829 p_slot->task_event.data = (unsigned long) p_slot;
831 dbg("%s: add_timer p_slot = %p\n", __FUNCTION__,(void *) p_slot);
832 add_timer(&p_slot->task_event);
833 } else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) {
834 /***********POWER FAULT********************/
835 dbg("%s: power fault\n", __FUNCTION__);
836 /* Wait for exclusive access to hardware */
837 down(&ctrl->crit_sect);
839 p_slot->hpc_ops->set_attention_status(p_slot, 1);
841 p_slot->hpc_ops->green_led_off(p_slot);
843 /* Done with exclusive hardware access */
844 up(&ctrl->crit_sect);
846 /* refresh notification */
848 update_slot_info(p_slot);
851 ctrl->event_queue[loop].event_type = 0;
855 } /* End of FOR loop */
862 int shpchp_enable_slot (struct slot *p_slot)
867 /* Check to see if (latch closed, card present, power off) */
868 down(&p_slot->ctrl->crit_sect);
869 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
870 if (rc || !getstatus) {
871 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
872 up(&p_slot->ctrl->crit_sect);
875 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
876 if (rc || getstatus) {
877 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
878 up(&p_slot->ctrl->crit_sect);
881 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
882 if (rc || getstatus) {
883 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number);
884 up(&p_slot->ctrl->crit_sect);
887 up(&p_slot->ctrl->crit_sect);
889 p_slot->is_a_board = 1;
891 /* We have to save the presence info for these slots */
892 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
893 p_slot->hpc_ops->get_power_status(p_slot, &(p_slot->pwr_save));
894 dbg("%s: p_slot->pwr_save %x\n", __FUNCTION__, p_slot->pwr_save);
895 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
897 rc = board_added(p_slot);
899 p_slot->hpc_ops->get_adapter_status(p_slot,
900 &(p_slot->presence_save));
901 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
904 update_slot_info(p_slot);
909 int shpchp_disable_slot (struct slot *p_slot)
917 /* Check to see if (latch closed, card present, power on) */
918 down(&p_slot->ctrl->crit_sect);
920 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
921 if (ret || !getstatus) {
922 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
923 up(&p_slot->ctrl->crit_sect);
926 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
927 if (ret || getstatus) {
928 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
929 up(&p_slot->ctrl->crit_sect);
932 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
933 if (ret || !getstatus) {
934 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number);
935 up(&p_slot->ctrl->crit_sect);
938 up(&p_slot->ctrl->crit_sect);
940 ret = remove_board(p_slot);
941 update_slot_info(p_slot);