Lines Matching +full:power +full:- +full:button

5  * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
7 * Copyright (C) 2003-2004 Intel Corporation
48 return -ENOMEM; in queue_interrupt_event()
50 info->event_type = event_type; in queue_interrupt_event()
51 info->p_slot = p_slot; in queue_interrupt_event()
52 INIT_WORK(&info->work, interrupt_event_handler); in queue_interrupt_event()
54 queue_work(shpchp_wq, &info->work); in queue_interrupt_event()
64 /* Attention Button Change */ in shpchp_handle_attention_button()
65 ctrl_dbg(ctrl, "Attention button interrupt received\n"); in shpchp_handle_attention_button()
67 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); in shpchp_handle_attention_button()
68 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); in shpchp_handle_attention_button()
71 * Button pressed - See if need to TAKE ACTION!!! in shpchp_handle_attention_button()
73 ctrl_info(ctrl, "Button pressed on Slot(%s)\n", slot_name(p_slot)); in shpchp_handle_attention_button()
91 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); in shpchp_handle_switch_change()
92 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); in shpchp_handle_switch_change()
93 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); in shpchp_handle_switch_change()
94 ctrl_dbg(ctrl, "Card present %x Power status %x\n", in shpchp_handle_switch_change()
95 p_slot->presence_save, p_slot->pwr_save); in shpchp_handle_switch_change()
103 if (p_slot->pwr_save && p_slot->presence_save) { in shpchp_handle_switch_change()
128 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); in shpchp_handle_presence_change()
133 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); in shpchp_handle_presence_change()
134 if (p_slot->presence_save) { in shpchp_handle_presence_change()
160 /* Power fault */ in shpchp_handle_power_fault()
161 ctrl_dbg(ctrl, "Power fault interrupt received\n"); in shpchp_handle_power_fault()
163 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); in shpchp_handle_power_fault()
165 if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { in shpchp_handle_power_fault()
167 * Power fault Cleared in shpchp_handle_power_fault()
169 ctrl_info(ctrl, "Power fault cleared on Slot(%s)\n", in shpchp_handle_power_fault()
171 p_slot->status = 0x00; in shpchp_handle_power_fault()
175 * Power fault in shpchp_handle_power_fault()
177 ctrl_info(ctrl, "Power fault on Slot(%s)\n", slot_name(p_slot)); in shpchp_handle_power_fault()
179 /* set power fault status for this board */ in shpchp_handle_power_fault()
180 p_slot->status = 0xFF; in shpchp_handle_power_fault()
181 ctrl_info(ctrl, "Power fault bit %x set\n", hp_slot); in shpchp_handle_power_fault()
198 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) { in change_bus_speed()
236 * board_added - Called after a board has been added to the system.
239 * Turns power on for the board.
248 struct controller *ctrl = p_slot->ctrl; in board_added()
249 struct pci_bus *parent = ctrl->pci_dev->subordinate; in board_added()
251 hp_slot = p_slot->device - ctrl->slot_device_offset; in board_added()
254 "%s: p_slot->device, slot_offset, hp_slot = %d, %d ,%d\n", in board_added()
255 __func__, p_slot->device, ctrl->slot_device_offset, hp_slot); in board_added()
257 /* Power on slot without connecting to bus */ in board_added()
258 rc = p_slot->hpc_ops->power_on_slot(p_slot); in board_added()
260 ctrl_err(ctrl, "Failed to power on slot\n"); in board_added()
261 return -1; in board_added()
264 if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) { in board_added()
268 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { in board_added()
275 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { in board_added()
281 rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &asp); in board_added()
288 bsp = ctrl->pci_dev->bus->cur_bus_speed; in board_added()
289 msp = ctrl->pci_dev->bus->max_bus_speed; in board_added()
292 if (!list_empty(&ctrl->pci_dev->subordinate->devices)) in board_added()
304 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { in board_added()
312 ctrl_dbg(ctrl, "%s: slot status = %x\n", __func__, p_slot->status); in board_added()
313 /* Check for a power fault */ in board_added()
314 if (p_slot->status == 0xFF) { in board_added()
315 /* power fault occurred, but it was benign */ in board_added()
316 ctrl_dbg(ctrl, "%s: Power fault\n", __func__); in board_added()
318 p_slot->status = 0; in board_added()
324 pci_domain_nr(parent), p_slot->bus, p_slot->device); in board_added()
328 p_slot->status = 0; in board_added()
329 p_slot->is_a_board = 0x01; in board_added()
330 p_slot->pwr_save = 1; in board_added()
332 p_slot->hpc_ops->green_led_on(p_slot); in board_added()
338 rc = p_slot->hpc_ops->slot_disable(p_slot); in board_added()
350 * remove_board - Turns off slot and LEDs
355 struct controller *ctrl = p_slot->ctrl; in remove_board()
362 hp_slot = p_slot->device - ctrl->slot_device_offset; in remove_board()
363 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); in remove_board()
368 if (p_slot->is_a_board) in remove_board()
369 p_slot->status = 0x01; in remove_board()
372 rc = p_slot->hpc_ops->slot_disable(p_slot); in remove_board()
379 rc = p_slot->hpc_ops->set_attention_status(p_slot, 0); in remove_board()
385 p_slot->pwr_save = 0; in remove_board()
386 p_slot->is_a_board = 0; in remove_board()
398 * shpchp_pushbutton_thread - handle pushbutton events
408 struct slot *p_slot = info->p_slot; in shpchp_pushbutton_thread()
410 mutex_lock(&p_slot->lock); in shpchp_pushbutton_thread()
411 switch (p_slot->state) { in shpchp_pushbutton_thread()
413 mutex_unlock(&p_slot->lock); in shpchp_pushbutton_thread()
415 mutex_lock(&p_slot->lock); in shpchp_pushbutton_thread()
416 p_slot->state = STATIC_STATE; in shpchp_pushbutton_thread()
419 mutex_unlock(&p_slot->lock); in shpchp_pushbutton_thread()
421 p_slot->hpc_ops->green_led_off(p_slot); in shpchp_pushbutton_thread()
422 mutex_lock(&p_slot->lock); in shpchp_pushbutton_thread()
423 p_slot->state = STATIC_STATE; in shpchp_pushbutton_thread()
428 mutex_unlock(&p_slot->lock); in shpchp_pushbutton_thread()
440 ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n", in shpchp_queue_pushbutton_work()
444 info->p_slot = p_slot; in shpchp_queue_pushbutton_work()
445 INIT_WORK(&info->work, shpchp_pushbutton_thread); in shpchp_queue_pushbutton_work()
447 mutex_lock(&p_slot->lock); in shpchp_queue_pushbutton_work()
448 switch (p_slot->state) { in shpchp_queue_pushbutton_work()
450 p_slot->state = POWEROFF_STATE; in shpchp_queue_pushbutton_work()
453 p_slot->state = POWERON_STATE; in shpchp_queue_pushbutton_work()
459 queue_work(shpchp_ordered_wq, &info->work); in shpchp_queue_pushbutton_work()
461 mutex_unlock(&p_slot->lock); in shpchp_queue_pushbutton_work()
471 return -ENOMEM; in update_slot_info()
473 slot->hpc_ops->get_power_status(slot, &(info->power_status)); in update_slot_info()
474 slot->hpc_ops->get_attention_status(slot, &(info->attention_status)); in update_slot_info()
475 slot->hpc_ops->get_latch_status(slot, &(info->latch_status)); in update_slot_info()
476 slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status)); in update_slot_info()
478 result = pci_hp_change_slot_info(slot->hotplug_slot, info); in update_slot_info()
484 * Note: This function must be called with slot->lock held
489 struct controller *ctrl = p_slot->ctrl; in handle_button_press_event()
491 switch (p_slot->state) { in handle_button_press_event()
493 p_slot->hpc_ops->get_power_status(p_slot, &getstatus); in handle_button_press_event()
495 p_slot->state = BLINKINGOFF_STATE; in handle_button_press_event()
496 ctrl_info(ctrl, "PCI slot #%s - powering off due to " in handle_button_press_event()
497 "button press.\n", slot_name(p_slot)); in handle_button_press_event()
499 p_slot->state = BLINKINGON_STATE; in handle_button_press_event()
500 ctrl_info(ctrl, "PCI slot #%s - powering on due to " in handle_button_press_event()
501 "button press.\n", slot_name(p_slot)); in handle_button_press_event()
504 p_slot->hpc_ops->green_led_blink(p_slot); in handle_button_press_event()
505 p_slot->hpc_ops->set_attention_status(p_slot, 0); in handle_button_press_event()
507 queue_delayed_work(shpchp_wq, &p_slot->work, 5*HZ); in handle_button_press_event()
514 * expires to cancel hot-add or hot-remove in handle_button_press_event()
516 ctrl_info(ctrl, "Button cancel on Slot(%s)\n", in handle_button_press_event()
518 cancel_delayed_work(&p_slot->work); in handle_button_press_event()
519 if (p_slot->state == BLINKINGOFF_STATE) in handle_button_press_event()
520 p_slot->hpc_ops->green_led_on(p_slot); in handle_button_press_event()
522 p_slot->hpc_ops->green_led_off(p_slot); in handle_button_press_event()
523 p_slot->hpc_ops->set_attention_status(p_slot, 0); in handle_button_press_event()
524 ctrl_info(ctrl, "PCI slot #%s - action canceled due to " in handle_button_press_event()
525 "button press\n", slot_name(p_slot)); in handle_button_press_event()
526 p_slot->state = STATIC_STATE; in handle_button_press_event()
531 * Ignore if the slot is on power-on or power-off state; in handle_button_press_event()
532 * this means that the previous attention button action in handle_button_press_event()
533 * to hot-add or hot-remove is undergoing in handle_button_press_event()
535 ctrl_info(ctrl, "Button ignore on Slot(%s)\n", in handle_button_press_event()
548 struct slot *p_slot = info->p_slot; in interrupt_event_handler()
550 mutex_lock(&p_slot->lock); in interrupt_event_handler()
551 switch (info->event_type) { in interrupt_event_handler()
556 ctrl_dbg(p_slot->ctrl, "%s: Power fault\n", __func__); in interrupt_event_handler()
557 p_slot->hpc_ops->set_attention_status(p_slot, 1); in interrupt_event_handler()
558 p_slot->hpc_ops->green_led_off(p_slot); in interrupt_event_handler()
564 mutex_unlock(&p_slot->lock); in interrupt_event_handler()
573 int rc, retval = -ENODEV; in shpchp_enable_slot()
574 struct controller *ctrl = p_slot->ctrl; in shpchp_enable_slot()
576 /* Check to see if (latch closed, card present, power off) */ in shpchp_enable_slot()
577 mutex_lock(&p_slot->ctrl->crit_sect); in shpchp_enable_slot()
578 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); in shpchp_enable_slot()
583 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); in shpchp_enable_slot()
588 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); in shpchp_enable_slot()
595 p_slot->is_a_board = 1; in shpchp_enable_slot()
598 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); in shpchp_enable_slot()
599 p_slot->hpc_ops->get_power_status(p_slot, &(p_slot->pwr_save)); in shpchp_enable_slot()
600 ctrl_dbg(ctrl, "%s: p_slot->pwr_save %x\n", __func__, p_slot->pwr_save); in shpchp_enable_slot()
601 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); in shpchp_enable_slot()
603 if(((p_slot->ctrl->pci_dev->vendor == PCI_VENDOR_ID_AMD) || in shpchp_enable_slot()
604 (p_slot->ctrl->pci_dev->device == PCI_DEVICE_ID_AMD_POGO_7458)) in shpchp_enable_slot()
605 && p_slot->ctrl->num_slots == 1) { in shpchp_enable_slot()
615 p_slot->hpc_ops->get_adapter_status(p_slot, in shpchp_enable_slot()
616 &(p_slot->presence_save)); in shpchp_enable_slot()
617 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); in shpchp_enable_slot()
622 mutex_unlock(&p_slot->ctrl->crit_sect); in shpchp_enable_slot()
630 int rc, retval = -ENODEV; in shpchp_disable_slot()
631 struct controller *ctrl = p_slot->ctrl; in shpchp_disable_slot()
633 if (!p_slot->ctrl) in shpchp_disable_slot()
634 return -ENODEV; in shpchp_disable_slot()
636 /* Check to see if (latch closed, card present, power on) */ in shpchp_disable_slot()
637 mutex_lock(&p_slot->ctrl->crit_sect); in shpchp_disable_slot()
639 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); in shpchp_disable_slot()
644 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); in shpchp_disable_slot()
649 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); in shpchp_disable_slot()
659 mutex_unlock(&p_slot->ctrl->crit_sect); in shpchp_disable_slot()
665 int retval = -ENODEV; in shpchp_sysfs_enable_slot()
666 struct controller *ctrl = p_slot->ctrl; in shpchp_sysfs_enable_slot()
668 mutex_lock(&p_slot->lock); in shpchp_sysfs_enable_slot()
669 switch (p_slot->state) { in shpchp_sysfs_enable_slot()
671 cancel_delayed_work(&p_slot->work); in shpchp_sysfs_enable_slot()
673 p_slot->state = POWERON_STATE; in shpchp_sysfs_enable_slot()
674 mutex_unlock(&p_slot->lock); in shpchp_sysfs_enable_slot()
676 mutex_lock(&p_slot->lock); in shpchp_sysfs_enable_slot()
677 p_slot->state = STATIC_STATE; in shpchp_sysfs_enable_slot()
693 mutex_unlock(&p_slot->lock); in shpchp_sysfs_enable_slot()
700 int retval = -ENODEV; in shpchp_sysfs_disable_slot()
701 struct controller *ctrl = p_slot->ctrl; in shpchp_sysfs_disable_slot()
703 mutex_lock(&p_slot->lock); in shpchp_sysfs_disable_slot()
704 switch (p_slot->state) { in shpchp_sysfs_disable_slot()
706 cancel_delayed_work(&p_slot->work); in shpchp_sysfs_disable_slot()
708 p_slot->state = POWEROFF_STATE; in shpchp_sysfs_disable_slot()
709 mutex_unlock(&p_slot->lock); in shpchp_sysfs_disable_slot()
711 mutex_lock(&p_slot->lock); in shpchp_sysfs_disable_slot()
712 p_slot->state = STATIC_STATE; in shpchp_sysfs_disable_slot()
728 mutex_unlock(&p_slot->lock); in shpchp_sysfs_disable_slot()