Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * PCI Express Hot Plug Controller Driver |
| 3 | * |
| 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 |
| 8 | * |
| 9 | * All rights reserved. |
| 10 | * |
| 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. |
| 15 | * |
| 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 |
| 20 | * details. |
| 21 | * |
| 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. |
| 25 | * |
Kristen Accardi | 8cf4c19 | 2005-08-16 15:16:10 -0700 | [diff] [blame] | 26 | * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | * |
| 28 | */ |
| 29 | |
| 30 | #include <linux/config.h> |
| 31 | #include <linux/module.h> |
| 32 | #include <linux/kernel.h> |
| 33 | #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> |
| 40 | #include <linux/pci.h> |
| 41 | #include "../pci.h" |
| 42 | #include "pciehp.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | static void interrupt_event_handler(struct controller *ctrl); |
| 45 | |
| 46 | static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */ |
| 47 | static struct semaphore event_exit; /* guard ensure thread has exited before calling it quits */ |
| 48 | static int event_finished; |
| 49 | static unsigned long pushbutton_pending; /* = 0 */ |
| 50 | static unsigned long surprise_rm_pending; /* = 0 */ |
| 51 | |
| 52 | u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id) |
| 53 | { |
| 54 | struct controller *ctrl = (struct controller *) inst_id; |
| 55 | struct slot *p_slot; |
| 56 | u8 rc = 0; |
| 57 | u8 getstatus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | struct event_info *taskInfo; |
| 59 | |
| 60 | /* Attention Button Change */ |
| 61 | dbg("pciehp: Attention button interrupt received.\n"); |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | /* This is the structure that tells the worker thread what to do */ |
| 64 | taskInfo = &(ctrl->event_queue[ctrl->next_event]); |
| 65 | p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
| 66 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 67 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
| 69 | |
| 70 | ctrl->next_event = (ctrl->next_event + 1) % 10; |
| 71 | taskInfo->hp_slot = hp_slot; |
| 72 | |
| 73 | rc++; |
| 74 | |
| 75 | /* |
| 76 | * Button pressed - See if need to TAKE ACTION!!! |
| 77 | */ |
| 78 | info("Button pressed on Slot(%d)\n", ctrl->first_slot + hp_slot); |
| 79 | taskInfo->event_type = INT_BUTTON_PRESS; |
| 80 | |
| 81 | if ((p_slot->state == BLINKINGON_STATE) |
| 82 | || (p_slot->state == BLINKINGOFF_STATE)) { |
| 83 | /* Cancel if we are still blinking; this means that we press the |
| 84 | * attention again before the 5 sec. limit expires to cancel hot-add |
| 85 | * or hot-remove |
| 86 | */ |
| 87 | taskInfo->event_type = INT_BUTTON_CANCEL; |
| 88 | info("Button cancel on Slot(%d)\n", ctrl->first_slot + hp_slot); |
| 89 | } else if ((p_slot->state == POWERON_STATE) |
| 90 | || (p_slot->state == POWEROFF_STATE)) { |
| 91 | /* Ignore if the slot is on power-on or power-off state; this |
| 92 | * means that the previous attention button action to hot-add or |
| 93 | * hot-remove is undergoing |
| 94 | */ |
| 95 | taskInfo->event_type = INT_BUTTON_IGNORE; |
| 96 | info("Button ignore on Slot(%d)\n", ctrl->first_slot + hp_slot); |
| 97 | } |
| 98 | |
| 99 | if (rc) |
| 100 | up(&event_semaphore); /* signal event thread that new event is posted */ |
| 101 | |
| 102 | return 0; |
| 103 | |
| 104 | } |
| 105 | |
| 106 | u8 pciehp_handle_switch_change(u8 hp_slot, void *inst_id) |
| 107 | { |
| 108 | struct controller *ctrl = (struct controller *) inst_id; |
| 109 | struct slot *p_slot; |
| 110 | u8 rc = 0; |
| 111 | u8 getstatus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | struct event_info *taskInfo; |
| 113 | |
| 114 | /* Switch Change */ |
| 115 | dbg("pciehp: Switch interrupt received.\n"); |
| 116 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | /* This is the structure that tells the worker thread |
| 118 | * what to do |
| 119 | */ |
| 120 | taskInfo = &(ctrl->event_queue[ctrl->next_event]); |
| 121 | ctrl->next_event = (ctrl->next_event + 1) % 10; |
| 122 | taskInfo->hp_slot = hp_slot; |
| 123 | |
| 124 | rc++; |
| 125 | p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 126 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
| 128 | |
| 129 | if (getstatus) { |
| 130 | /* |
| 131 | * Switch opened |
| 132 | */ |
| 133 | info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot); |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 134 | p_slot->switch_save = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | taskInfo->event_type = INT_SWITCH_OPEN; |
| 136 | } else { |
| 137 | /* |
| 138 | * Switch closed |
| 139 | */ |
| 140 | info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot); |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 141 | p_slot->switch_save = 0x10; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | taskInfo->event_type = INT_SWITCH_CLOSE; |
| 143 | } |
| 144 | |
| 145 | if (rc) |
| 146 | up(&event_semaphore); /* signal event thread that new event is posted */ |
| 147 | |
| 148 | return rc; |
| 149 | } |
| 150 | |
| 151 | u8 pciehp_handle_presence_change(u8 hp_slot, void *inst_id) |
| 152 | { |
| 153 | struct controller *ctrl = (struct controller *) inst_id; |
| 154 | struct slot *p_slot; |
| 155 | u8 rc = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | struct event_info *taskInfo; |
| 157 | |
| 158 | /* Presence Change */ |
| 159 | dbg("pciehp: Presence/Notify input change.\n"); |
| 160 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | /* This is the structure that tells the worker thread |
| 162 | * what to do |
| 163 | */ |
| 164 | taskInfo = &(ctrl->event_queue[ctrl->next_event]); |
| 165 | ctrl->next_event = (ctrl->next_event + 1) % 10; |
| 166 | taskInfo->hp_slot = hp_slot; |
| 167 | |
| 168 | rc++; |
| 169 | p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
| 170 | |
| 171 | /* Switch is open, assume a presence change |
| 172 | * Save the presence state |
| 173 | */ |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 174 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); |
| 175 | if (p_slot->presence_save) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | /* |
| 177 | * Card Present |
| 178 | */ |
| 179 | info("Card present on Slot(%d)\n", ctrl->first_slot + hp_slot); |
| 180 | taskInfo->event_type = INT_PRESENCE_ON; |
| 181 | } else { |
| 182 | /* |
| 183 | * Not Present |
| 184 | */ |
| 185 | info("Card not present on Slot(%d)\n", ctrl->first_slot + hp_slot); |
| 186 | taskInfo->event_type = INT_PRESENCE_OFF; |
| 187 | } |
| 188 | |
| 189 | if (rc) |
| 190 | up(&event_semaphore); /* signal event thread that new event is posted */ |
| 191 | |
| 192 | return rc; |
| 193 | } |
| 194 | |
| 195 | u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id) |
| 196 | { |
| 197 | struct controller *ctrl = (struct controller *) inst_id; |
| 198 | struct slot *p_slot; |
| 199 | u8 rc = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | struct event_info *taskInfo; |
| 201 | |
| 202 | /* power fault */ |
| 203 | dbg("pciehp: Power fault interrupt received.\n"); |
| 204 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | /* this is the structure that tells the worker thread |
| 206 | * what to do |
| 207 | */ |
| 208 | taskInfo = &(ctrl->event_queue[ctrl->next_event]); |
| 209 | ctrl->next_event = (ctrl->next_event + 1) % 10; |
| 210 | taskInfo->hp_slot = hp_slot; |
| 211 | |
| 212 | rc++; |
| 213 | p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
| 214 | |
| 215 | if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { |
| 216 | /* |
| 217 | * power fault Cleared |
| 218 | */ |
| 219 | info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot); |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 220 | p_slot->status = 0x00; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | taskInfo->event_type = INT_POWER_FAULT_CLEAR; |
| 222 | } else { |
| 223 | /* |
| 224 | * power fault |
| 225 | */ |
| 226 | info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot); |
| 227 | taskInfo->event_type = INT_POWER_FAULT; |
| 228 | /* set power fault status for this board */ |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 229 | p_slot->status = 0xFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | info("power fault bit %x set\n", hp_slot); |
| 231 | } |
| 232 | if (rc) |
| 233 | up(&event_semaphore); /* signal event thread that new event is posted */ |
| 234 | |
| 235 | return rc; |
| 236 | } |
| 237 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | /* The following routines constitute the bulk of the |
| 239 | hotplug controller logic |
| 240 | */ |
| 241 | |
| 242 | static void set_slot_off(struct controller *ctrl, struct slot * pslot) |
| 243 | { |
| 244 | /* Wait for exclusive access to hardware */ |
| 245 | down(&ctrl->crit_sect); |
| 246 | |
| 247 | /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ |
| 248 | if (POWER_CTRL(ctrl->ctrlcap)) { |
| 249 | if (pslot->hpc_ops->power_off_slot(pslot)) { |
| 250 | err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__); |
| 251 | up(&ctrl->crit_sect); |
| 252 | return; |
| 253 | } |
| 254 | wait_for_ctrl_irq (ctrl); |
| 255 | } |
| 256 | |
| 257 | if (PWR_LED(ctrl->ctrlcap)) { |
| 258 | pslot->hpc_ops->green_led_off(pslot); |
| 259 | wait_for_ctrl_irq (ctrl); |
| 260 | } |
| 261 | |
| 262 | if (ATTN_LED(ctrl->ctrlcap)) { |
| 263 | if (pslot->hpc_ops->set_attention_status(pslot, 1)) { |
| 264 | err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__); |
| 265 | up(&ctrl->crit_sect); |
| 266 | return; |
| 267 | } |
| 268 | wait_for_ctrl_irq (ctrl); |
| 269 | } |
| 270 | |
| 271 | /* Done with exclusive hardware access */ |
| 272 | up(&ctrl->crit_sect); |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * board_added - Called after a board has been added to the system. |
| 277 | * |
| 278 | * Turns power on for the board |
| 279 | * Configures board |
| 280 | * |
| 281 | */ |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 282 | static u32 board_added(struct slot *p_slot) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | { |
| 284 | u8 hp_slot; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | u32 temp_register = 0xFFFFFFFF; |
| 286 | u32 rc = 0; |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 287 | struct controller *ctrl = p_slot->ctrl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 289 | hp_slot = p_slot->device - ctrl->slot_device_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 291 | dbg("%s: p_slot->device, slot_offset, hp_slot = %d, %d ,%d\n", __FUNCTION__, p_slot->device, ctrl->slot_device_offset, hp_slot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | |
| 293 | /* Wait for exclusive access to hardware */ |
| 294 | down(&ctrl->crit_sect); |
| 295 | |
| 296 | if (POWER_CTRL(ctrl->ctrlcap)) { |
| 297 | /* Power on slot */ |
| 298 | rc = p_slot->hpc_ops->power_on_slot(p_slot); |
| 299 | if (rc) { |
| 300 | up(&ctrl->crit_sect); |
| 301 | return -1; |
| 302 | } |
| 303 | |
| 304 | /* Wait for the command to complete */ |
| 305 | wait_for_ctrl_irq (ctrl); |
| 306 | } |
| 307 | |
| 308 | if (PWR_LED(ctrl->ctrlcap)) { |
| 309 | p_slot->hpc_ops->green_led_blink(p_slot); |
| 310 | |
| 311 | /* Wait for the command to complete */ |
| 312 | wait_for_ctrl_irq (ctrl); |
| 313 | } |
| 314 | |
| 315 | /* Done with exclusive hardware access */ |
| 316 | up(&ctrl->crit_sect); |
| 317 | |
| 318 | /* Wait for ~1 second */ |
| 319 | dbg("%s: before long_delay\n", __FUNCTION__); |
| 320 | wait_for_ctrl_irq (ctrl); |
| 321 | dbg("%s: afterlong_delay\n", __FUNCTION__); |
| 322 | |
| 323 | /* Check link training status */ |
| 324 | rc = p_slot->hpc_ops->check_lnk_status(ctrl); |
| 325 | if (rc) { |
| 326 | err("%s: Failed to check link status\n", __FUNCTION__); |
| 327 | set_slot_off(ctrl, p_slot); |
| 328 | return rc; |
| 329 | } |
| 330 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 331 | dbg("%s: slot status = %x\n", __FUNCTION__, p_slot->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
| 333 | /* Check for a power fault */ |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 334 | if (p_slot->status == 0xFF) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | /* 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; |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 339 | p_slot->status = 0; |
rajesh.shah@intel.com | 71b720c | 2005-10-31 16:20:06 -0800 | [diff] [blame] | 340 | goto err_exit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | } |
| 342 | |
rajesh.shah@intel.com | 71b720c | 2005-10-31 16:20:06 -0800 | [diff] [blame] | 343 | rc = pciehp_configure_device(p_slot); |
| 344 | if (rc) { |
| 345 | err("Cannot add device 0x%x:%x\n", p_slot->bus, |
| 346 | p_slot->device); |
| 347 | goto err_exit; |
| 348 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 350 | p_slot->status = 0; |
| 351 | p_slot->switch_save = 0x10; |
| 352 | p_slot->is_a_board = 0x01; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | |
rajesh.shah@intel.com | 71b720c | 2005-10-31 16:20:06 -0800 | [diff] [blame] | 354 | /* |
| 355 | * Some PCI Express root ports require fixup after hot-plug operation. |
| 356 | */ |
| 357 | if (pcie_mch_quirk) |
| 358 | pci_fixup_device(pci_fixup_final, ctrl->pci_dev); |
| 359 | if (PWR_LED(ctrl->ctrlcap)) { |
| 360 | /* Wait for exclusive access to hardware */ |
| 361 | down(&ctrl->crit_sect); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
rajesh.shah@intel.com | 71b720c | 2005-10-31 16:20:06 -0800 | [diff] [blame] | 363 | p_slot->hpc_ops->green_led_on(p_slot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | |
rajesh.shah@intel.com | 71b720c | 2005-10-31 16:20:06 -0800 | [diff] [blame] | 365 | /* Wait for the command to complete */ |
| 366 | wait_for_ctrl_irq (ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | |
rajesh.shah@intel.com | 71b720c | 2005-10-31 16:20:06 -0800 | [diff] [blame] | 368 | /* Done with exclusive hardware access */ |
| 369 | up(&ctrl->crit_sect); |
| 370 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | return 0; |
rajesh.shah@intel.com | 71b720c | 2005-10-31 16:20:06 -0800 | [diff] [blame] | 372 | |
| 373 | err_exit: |
| 374 | set_slot_off(ctrl, p_slot); |
| 375 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | |
| 379 | /** |
| 380 | * remove_board - Turns off slot and LED's |
| 381 | * |
| 382 | */ |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 383 | static u32 remove_board(struct slot *p_slot) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | u8 device; |
| 386 | u8 hp_slot; |
| 387 | u32 rc; |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 388 | struct controller *ctrl = p_slot->ctrl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 390 | if (pciehp_unconfigure_device(p_slot)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | return 1; |
| 392 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 393 | device = p_slot->device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 395 | hp_slot = p_slot->device - ctrl->slot_device_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
| 397 | |
| 398 | dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot); |
| 399 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | /* Change status to shutdown */ |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 401 | if (p_slot->is_a_board) |
| 402 | p_slot->status = 0x01; |
| 403 | p_slot->configured = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | |
| 405 | /* Wait for exclusive access to hardware */ |
| 406 | down(&ctrl->crit_sect); |
| 407 | |
| 408 | if (POWER_CTRL(ctrl->ctrlcap)) { |
| 409 | /* power off slot */ |
| 410 | rc = p_slot->hpc_ops->power_off_slot(p_slot); |
| 411 | if (rc) { |
| 412 | err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); |
| 413 | up(&ctrl->crit_sect); |
| 414 | return rc; |
| 415 | } |
| 416 | /* Wait for the command to complete */ |
| 417 | wait_for_ctrl_irq (ctrl); |
| 418 | } |
| 419 | |
| 420 | if (PWR_LED(ctrl->ctrlcap)) { |
| 421 | /* turn off Green LED */ |
| 422 | p_slot->hpc_ops->green_led_off(p_slot); |
| 423 | |
| 424 | /* Wait for the command to complete */ |
| 425 | wait_for_ctrl_irq (ctrl); |
| 426 | } |
| 427 | |
| 428 | /* Done with exclusive hardware access */ |
| 429 | up(&ctrl->crit_sect); |
| 430 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 431 | p_slot->switch_save = 0x10; |
| 432 | p_slot->is_a_board = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | |
| 434 | return 0; |
| 435 | } |
| 436 | |
| 437 | |
| 438 | static void pushbutton_helper_thread(unsigned long data) |
| 439 | { |
| 440 | pushbutton_pending = data; |
| 441 | |
| 442 | up(&event_semaphore); |
| 443 | } |
| 444 | |
| 445 | /** |
| 446 | * pciehp_pushbutton_thread |
| 447 | * |
| 448 | * Scheduled procedure to handle blocking stuff for the pushbuttons |
| 449 | * Handles all pending events and exits. |
| 450 | * |
| 451 | */ |
| 452 | static void pciehp_pushbutton_thread(unsigned long slot) |
| 453 | { |
| 454 | struct slot *p_slot = (struct slot *) slot; |
| 455 | u8 getstatus; |
| 456 | |
| 457 | pushbutton_pending = 0; |
| 458 | |
| 459 | if (!p_slot) { |
| 460 | dbg("%s: Error! slot NULL\n", __FUNCTION__); |
| 461 | return; |
| 462 | } |
| 463 | |
| 464 | p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
| 465 | if (getstatus) { |
| 466 | p_slot->state = POWEROFF_STATE; |
| 467 | dbg("In power_down_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device); |
| 468 | |
| 469 | pciehp_disable_slot(p_slot); |
| 470 | p_slot->state = STATIC_STATE; |
| 471 | } else { |
| 472 | p_slot->state = POWERON_STATE; |
| 473 | dbg("In add_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device); |
| 474 | |
| 475 | if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { |
| 476 | /* Wait for exclusive access to hardware */ |
| 477 | down(&p_slot->ctrl->crit_sect); |
| 478 | |
| 479 | p_slot->hpc_ops->green_led_off(p_slot); |
| 480 | |
| 481 | /* Wait for the command to complete */ |
| 482 | wait_for_ctrl_irq (p_slot->ctrl); |
| 483 | |
| 484 | /* Done with exclusive hardware access */ |
| 485 | up(&p_slot->ctrl->crit_sect); |
| 486 | } |
| 487 | p_slot->state = STATIC_STATE; |
| 488 | } |
| 489 | |
| 490 | return; |
| 491 | } |
| 492 | |
| 493 | /** |
| 494 | * pciehp_surprise_rm_thread |
| 495 | * |
| 496 | * Scheduled procedure to handle blocking stuff for the surprise removal |
| 497 | * Handles all pending events and exits. |
| 498 | * |
| 499 | */ |
| 500 | static void pciehp_surprise_rm_thread(unsigned long slot) |
| 501 | { |
| 502 | struct slot *p_slot = (struct slot *) slot; |
| 503 | u8 getstatus; |
| 504 | |
| 505 | surprise_rm_pending = 0; |
| 506 | |
| 507 | if (!p_slot) { |
| 508 | dbg("%s: Error! slot NULL\n", __FUNCTION__); |
| 509 | return; |
| 510 | } |
| 511 | |
| 512 | p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
| 513 | if (!getstatus) { |
| 514 | p_slot->state = POWEROFF_STATE; |
| 515 | dbg("In removing board, b:d(%x:%x)\n", p_slot->bus, p_slot->device); |
| 516 | |
| 517 | pciehp_disable_slot(p_slot); |
| 518 | p_slot->state = STATIC_STATE; |
| 519 | } else { |
| 520 | p_slot->state = POWERON_STATE; |
| 521 | dbg("In add_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device); |
| 522 | |
| 523 | if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { |
| 524 | /* Wait for exclusive access to hardware */ |
| 525 | down(&p_slot->ctrl->crit_sect); |
| 526 | |
| 527 | p_slot->hpc_ops->green_led_off(p_slot); |
| 528 | |
| 529 | /* Wait for the command to complete */ |
| 530 | wait_for_ctrl_irq (p_slot->ctrl); |
| 531 | |
| 532 | /* Done with exclusive hardware access */ |
| 533 | up(&p_slot->ctrl->crit_sect); |
| 534 | } |
| 535 | p_slot->state = STATIC_STATE; |
| 536 | } |
| 537 | |
| 538 | return; |
| 539 | } |
| 540 | |
| 541 | |
| 542 | |
| 543 | /* this is the main worker thread */ |
| 544 | static int event_thread(void* data) |
| 545 | { |
| 546 | struct controller *ctrl; |
| 547 | lock_kernel(); |
| 548 | daemonize("pciehpd_event"); |
| 549 | |
| 550 | unlock_kernel(); |
| 551 | |
| 552 | while (1) { |
| 553 | dbg("!!!!event_thread sleeping\n"); |
| 554 | down_interruptible (&event_semaphore); |
| 555 | dbg("event_thread woken finished = %d\n", event_finished); |
| 556 | if (event_finished || signal_pending(current)) |
| 557 | break; |
| 558 | /* Do stuff here */ |
| 559 | if (pushbutton_pending) |
| 560 | pciehp_pushbutton_thread(pushbutton_pending); |
| 561 | else if (surprise_rm_pending) |
| 562 | pciehp_surprise_rm_thread(surprise_rm_pending); |
| 563 | else |
| 564 | for (ctrl = pciehp_ctrl_list; ctrl; ctrl=ctrl->next) |
| 565 | interrupt_event_handler(ctrl); |
| 566 | } |
| 567 | dbg("event_thread signals exit\n"); |
| 568 | up(&event_exit); |
| 569 | return 0; |
| 570 | } |
| 571 | |
| 572 | int pciehp_event_start_thread(void) |
| 573 | { |
| 574 | int pid; |
| 575 | |
| 576 | /* initialize our semaphores */ |
| 577 | init_MUTEX_LOCKED(&event_exit); |
| 578 | event_finished=0; |
| 579 | |
| 580 | init_MUTEX_LOCKED(&event_semaphore); |
| 581 | pid = kernel_thread(event_thread, NULL, 0); |
| 582 | |
| 583 | if (pid < 0) { |
| 584 | err ("Can't start up our event thread\n"); |
| 585 | return -1; |
| 586 | } |
| 587 | dbg("Our event thread pid = %d\n", pid); |
| 588 | return 0; |
| 589 | } |
| 590 | |
| 591 | |
| 592 | void pciehp_event_stop_thread(void) |
| 593 | { |
| 594 | event_finished = 1; |
| 595 | dbg("event_thread finish command given\n"); |
| 596 | up(&event_semaphore); |
| 597 | dbg("wait for event_thread to exit\n"); |
| 598 | down(&event_exit); |
| 599 | } |
| 600 | |
| 601 | |
| 602 | static int update_slot_info(struct slot *slot) |
| 603 | { |
| 604 | struct hotplug_slot_info *info; |
| 605 | /* char buffer[SLOT_NAME_SIZE]; */ |
| 606 | int result; |
| 607 | |
| 608 | info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); |
| 609 | if (!info) |
| 610 | return -ENOMEM; |
| 611 | |
| 612 | /* make_slot_name (&buffer[0], SLOT_NAME_SIZE, slot); */ |
| 613 | |
| 614 | slot->hpc_ops->get_power_status(slot, &(info->power_status)); |
| 615 | slot->hpc_ops->get_attention_status(slot, &(info->attention_status)); |
| 616 | slot->hpc_ops->get_latch_status(slot, &(info->latch_status)); |
| 617 | slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status)); |
| 618 | |
| 619 | /* result = pci_hp_change_slot_info(buffer, info); */ |
| 620 | result = pci_hp_change_slot_info(slot->hotplug_slot, info); |
| 621 | kfree (info); |
| 622 | return result; |
| 623 | } |
| 624 | |
| 625 | static void interrupt_event_handler(struct controller *ctrl) |
| 626 | { |
| 627 | int loop = 0; |
| 628 | int change = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | u8 hp_slot; |
| 630 | u8 getstatus; |
| 631 | struct slot *p_slot; |
| 632 | |
| 633 | while (change) { |
| 634 | change = 0; |
| 635 | |
| 636 | for (loop = 0; loop < 10; loop++) { |
| 637 | if (ctrl->event_queue[loop].event_type != 0) { |
| 638 | hp_slot = ctrl->event_queue[loop].hp_slot; |
| 639 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); |
| 641 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 642 | dbg("hp_slot %d, p_slot %p\n", hp_slot, p_slot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | |
| 644 | if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) { |
| 645 | dbg("button cancel\n"); |
| 646 | del_timer(&p_slot->task_event); |
| 647 | |
| 648 | switch (p_slot->state) { |
| 649 | case BLINKINGOFF_STATE: |
| 650 | /* Wait for exclusive access to hardware */ |
| 651 | down(&ctrl->crit_sect); |
| 652 | |
| 653 | if (PWR_LED(ctrl->ctrlcap)) { |
| 654 | p_slot->hpc_ops->green_led_on(p_slot); |
| 655 | /* Wait for the command to complete */ |
| 656 | wait_for_ctrl_irq (ctrl); |
| 657 | } |
| 658 | if (ATTN_LED(ctrl->ctrlcap)) { |
| 659 | p_slot->hpc_ops->set_attention_status(p_slot, 0); |
| 660 | |
| 661 | /* Wait for the command to complete */ |
| 662 | wait_for_ctrl_irq (ctrl); |
| 663 | } |
| 664 | /* Done with exclusive hardware access */ |
| 665 | up(&ctrl->crit_sect); |
| 666 | break; |
| 667 | case BLINKINGON_STATE: |
| 668 | /* Wait for exclusive access to hardware */ |
| 669 | down(&ctrl->crit_sect); |
| 670 | |
| 671 | if (PWR_LED(ctrl->ctrlcap)) { |
| 672 | p_slot->hpc_ops->green_led_off(p_slot); |
| 673 | /* Wait for the command to complete */ |
| 674 | wait_for_ctrl_irq (ctrl); |
| 675 | } |
| 676 | if (ATTN_LED(ctrl->ctrlcap)){ |
| 677 | p_slot->hpc_ops->set_attention_status(p_slot, 0); |
| 678 | /* Wait for the command to complete */ |
| 679 | wait_for_ctrl_irq (ctrl); |
| 680 | } |
| 681 | /* Done with exclusive hardware access */ |
| 682 | up(&ctrl->crit_sect); |
| 683 | |
| 684 | break; |
| 685 | default: |
| 686 | warn("Not a valid state\n"); |
| 687 | return; |
| 688 | } |
| 689 | info(msg_button_cancel, p_slot->number); |
| 690 | p_slot->state = STATIC_STATE; |
| 691 | } |
| 692 | /* ***********Button Pressed (No action on 1st press...) */ |
| 693 | else if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) { |
| 694 | |
| 695 | if (ATTN_BUTTN(ctrl->ctrlcap)) { |
| 696 | dbg("Button pressed\n"); |
| 697 | p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
| 698 | if (getstatus) { |
| 699 | /* slot is on */ |
| 700 | dbg("slot is on\n"); |
| 701 | p_slot->state = BLINKINGOFF_STATE; |
| 702 | info(msg_button_off, p_slot->number); |
| 703 | } else { |
| 704 | /* slot is off */ |
| 705 | dbg("slot is off\n"); |
| 706 | p_slot->state = BLINKINGON_STATE; |
| 707 | info(msg_button_on, p_slot->number); |
| 708 | } |
| 709 | |
| 710 | /* Wait for exclusive access to hardware */ |
| 711 | down(&ctrl->crit_sect); |
| 712 | |
| 713 | /* blink green LED and turn off amber */ |
| 714 | if (PWR_LED(ctrl->ctrlcap)) { |
| 715 | p_slot->hpc_ops->green_led_blink(p_slot); |
| 716 | /* Wait for the command to complete */ |
| 717 | wait_for_ctrl_irq (ctrl); |
| 718 | } |
| 719 | |
| 720 | if (ATTN_LED(ctrl->ctrlcap)) { |
| 721 | p_slot->hpc_ops->set_attention_status(p_slot, 0); |
| 722 | |
| 723 | /* Wait for the command to complete */ |
| 724 | wait_for_ctrl_irq (ctrl); |
| 725 | } |
| 726 | |
| 727 | /* Done with exclusive hardware access */ |
| 728 | up(&ctrl->crit_sect); |
| 729 | |
| 730 | init_timer(&p_slot->task_event); |
| 731 | p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */ |
| 732 | p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread; |
| 733 | p_slot->task_event.data = (unsigned long) p_slot; |
| 734 | |
| 735 | dbg("add_timer p_slot = %p\n", (void *) p_slot); |
| 736 | add_timer(&p_slot->task_event); |
| 737 | } |
| 738 | } |
| 739 | /***********POWER FAULT********************/ |
| 740 | else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) { |
| 741 | if (POWER_CTRL(ctrl->ctrlcap)) { |
| 742 | dbg("power fault\n"); |
| 743 | /* Wait for exclusive access to hardware */ |
| 744 | down(&ctrl->crit_sect); |
| 745 | |
| 746 | if (ATTN_LED(ctrl->ctrlcap)) { |
| 747 | p_slot->hpc_ops->set_attention_status(p_slot, 1); |
| 748 | wait_for_ctrl_irq (ctrl); |
| 749 | } |
| 750 | |
| 751 | if (PWR_LED(ctrl->ctrlcap)) { |
| 752 | p_slot->hpc_ops->green_led_off(p_slot); |
| 753 | wait_for_ctrl_irq (ctrl); |
| 754 | } |
| 755 | |
| 756 | /* Done with exclusive hardware access */ |
| 757 | up(&ctrl->crit_sect); |
| 758 | } |
| 759 | } |
| 760 | /***********SURPRISE REMOVAL********************/ |
| 761 | else if ((ctrl->event_queue[loop].event_type == INT_PRESENCE_ON) || |
| 762 | (ctrl->event_queue[loop].event_type == INT_PRESENCE_OFF)) { |
| 763 | if (HP_SUPR_RM(ctrl->ctrlcap)) { |
| 764 | dbg("Surprise Removal\n"); |
| 765 | if (p_slot) { |
| 766 | surprise_rm_pending = (unsigned long) p_slot; |
| 767 | up(&event_semaphore); |
| 768 | update_slot_info(p_slot); |
| 769 | } |
| 770 | } |
| 771 | } else { |
| 772 | /* refresh notification */ |
| 773 | if (p_slot) |
| 774 | update_slot_info(p_slot); |
| 775 | } |
| 776 | |
| 777 | ctrl->event_queue[loop].event_type = 0; |
| 778 | |
| 779 | change = 1; |
| 780 | } |
| 781 | } /* End of FOR loop */ |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | |
| 786 | int pciehp_enable_slot(struct slot *p_slot) |
| 787 | { |
| 788 | u8 getstatus = 0; |
| 789 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | |
| 791 | /* Check to see if (latch closed, card present, power off) */ |
| 792 | down(&p_slot->ctrl->crit_sect); |
| 793 | |
| 794 | rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
| 795 | if (rc || !getstatus) { |
| 796 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); |
| 797 | up(&p_slot->ctrl->crit_sect); |
| 798 | return 1; |
| 799 | } |
| 800 | if (MRL_SENS(p_slot->ctrl->ctrlcap)) { |
| 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); |
| 804 | up(&p_slot->ctrl->crit_sect); |
| 805 | return 1; |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | if (POWER_CTRL(p_slot->ctrl->ctrlcap)) { |
| 810 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
| 811 | if (rc || getstatus) { |
| 812 | info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); |
| 813 | up(&p_slot->ctrl->crit_sect); |
| 814 | return 1; |
| 815 | } |
| 816 | } |
| 817 | up(&p_slot->ctrl->crit_sect); |
| 818 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 819 | p_slot->configured = 0; |
| 820 | p_slot->is_a_board = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | |
| 822 | /* We have to save the presence info for these slots */ |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 823 | p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 824 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 825 | p_slot->switch_save = !getstatus? 0x10:0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 827 | rc = board_added(p_slot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | if (rc) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | /* We have to save the presence info for these slots */ |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 830 | p_slot->hpc_ops->get_adapter_status(p_slot, |
| 831 | &(p_slot->presence_save)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 833 | p_slot->switch_save = !getstatus? 0x10:0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | if (p_slot) |
| 837 | update_slot_info(p_slot); |
| 838 | |
| 839 | return rc; |
| 840 | } |
| 841 | |
| 842 | |
| 843 | int pciehp_disable_slot(struct slot *p_slot) |
| 844 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | u8 getstatus = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | |
| 848 | if (!p_slot->ctrl) |
| 849 | return 1; |
| 850 | |
| 851 | /* Check to see if (latch closed, card present, power on) */ |
| 852 | down(&p_slot->ctrl->crit_sect); |
| 853 | |
| 854 | if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) { |
| 855 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
| 856 | if (ret || !getstatus) { |
| 857 | info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); |
| 858 | up(&p_slot->ctrl->crit_sect); |
| 859 | return 1; |
| 860 | } |
| 861 | } |
| 862 | |
| 863 | if (MRL_SENS(p_slot->ctrl->ctrlcap)) { |
| 864 | ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
| 865 | if (ret || getstatus) { |
| 866 | info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); |
| 867 | up(&p_slot->ctrl->crit_sect); |
| 868 | return 1; |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | if (POWER_CTRL(p_slot->ctrl->ctrlcap)) { |
| 873 | ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
| 874 | if (ret || !getstatus) { |
| 875 | info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); |
| 876 | up(&p_slot->ctrl->crit_sect); |
| 877 | return 1; |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | up(&p_slot->ctrl->crit_sect); |
| 882 | |
rajesh.shah@intel.com | ca22a5e | 2005-10-31 16:20:08 -0800 | [diff] [blame^] | 883 | ret = remove_board(p_slot); |
| 884 | update_slot_info(p_slot); |
| 885 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | } |
| 887 | |