aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/pciehp_ctrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/pciehp_ctrl.c')
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c109
1 files changed, 44 insertions, 65 deletions
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index b97cb4c3e0fe..84487d126e4d 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -82,7 +82,7 @@ u8 pciehp_handle_switch_change(struct slot *p_slot)
82 /* Switch Change */ 82 /* Switch Change */
83 ctrl_dbg(ctrl, "Switch interrupt received\n"); 83 ctrl_dbg(ctrl, "Switch interrupt received\n");
84 84
85 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 85 pciehp_get_latch_status(p_slot, &getstatus);
86 if (getstatus) { 86 if (getstatus) {
87 /* 87 /*
88 * Switch opened 88 * Switch opened
@@ -114,7 +114,7 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
114 /* Switch is open, assume a presence change 114 /* Switch is open, assume a presence change
115 * Save the presence state 115 * Save the presence state
116 */ 116 */
117 p_slot->hpc_ops->get_adapter_status(p_slot, &presence_save); 117 pciehp_get_adapter_status(p_slot, &presence_save);
118 if (presence_save) { 118 if (presence_save) {
119 /* 119 /*
120 * Card Present 120 * Card Present
@@ -143,7 +143,7 @@ u8 pciehp_handle_power_fault(struct slot *p_slot)
143 /* power fault */ 143 /* power fault */
144 ctrl_dbg(ctrl, "Power fault interrupt received\n"); 144 ctrl_dbg(ctrl, "Power fault interrupt received\n");
145 145
146 if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { 146 if (!pciehp_query_power_fault(p_slot)) {
147 /* 147 /*
148 * power fault Cleared 148 * power fault Cleared
149 */ 149 */
@@ -172,7 +172,7 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
172{ 172{
173 /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ 173 /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
174 if (POWER_CTRL(ctrl)) { 174 if (POWER_CTRL(ctrl)) {
175 if (pslot->hpc_ops->power_off_slot(pslot)) { 175 if (pciehp_power_off_slot(pslot)) {
176 ctrl_err(ctrl, 176 ctrl_err(ctrl,
177 "Issue of Slot Power Off command failed\n"); 177 "Issue of Slot Power Off command failed\n");
178 return; 178 return;
@@ -186,10 +186,10 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
186 } 186 }
187 187
188 if (PWR_LED(ctrl)) 188 if (PWR_LED(ctrl))
189 pslot->hpc_ops->green_led_off(pslot); 189 pciehp_green_led_off(pslot);
190 190
191 if (ATTN_LED(ctrl)) { 191 if (ATTN_LED(ctrl)) {
192 if (pslot->hpc_ops->set_attention_status(pslot, 1)) { 192 if (pciehp_set_attention_status(pslot, 1)) {
193 ctrl_err(ctrl, 193 ctrl_err(ctrl,
194 "Issue of Set Attention Led command failed\n"); 194 "Issue of Set Attention Led command failed\n");
195 return; 195 return;
@@ -208,24 +208,20 @@ static int board_added(struct slot *p_slot)
208{ 208{
209 int retval = 0; 209 int retval = 0;
210 struct controller *ctrl = p_slot->ctrl; 210 struct controller *ctrl = p_slot->ctrl;
211 struct pci_bus *parent = ctrl->pci_dev->subordinate; 211 struct pci_bus *parent = ctrl->pcie->port->subordinate;
212
213 ctrl_dbg(ctrl, "%s: slot device, slot offset, hp slot = %d, %d, %d\n",
214 __func__, p_slot->device, ctrl->slot_device_offset,
215 p_slot->hp_slot);
216 212
217 if (POWER_CTRL(ctrl)) { 213 if (POWER_CTRL(ctrl)) {
218 /* Power on slot */ 214 /* Power on slot */
219 retval = p_slot->hpc_ops->power_on_slot(p_slot); 215 retval = pciehp_power_on_slot(p_slot);
220 if (retval) 216 if (retval)
221 return retval; 217 return retval;
222 } 218 }
223 219
224 if (PWR_LED(ctrl)) 220 if (PWR_LED(ctrl))
225 p_slot->hpc_ops->green_led_blink(p_slot); 221 pciehp_green_led_blink(p_slot);
226 222
227 /* Check link training status */ 223 /* Check link training status */
228 retval = p_slot->hpc_ops->check_lnk_status(ctrl); 224 retval = pciehp_check_link_status(ctrl);
229 if (retval) { 225 if (retval) {
230 ctrl_err(ctrl, "Failed to check link status\n"); 226 ctrl_err(ctrl, "Failed to check link status\n");
231 set_slot_off(ctrl, p_slot); 227 set_slot_off(ctrl, p_slot);
@@ -233,21 +229,21 @@ static int board_added(struct slot *p_slot)
233 } 229 }
234 230
235 /* Check for a power fault */ 231 /* Check for a power fault */
236 if (p_slot->hpc_ops->query_power_fault(p_slot)) { 232 if (pciehp_query_power_fault(p_slot)) {
237 ctrl_dbg(ctrl, "Power fault detected\n"); 233 ctrl_dbg(ctrl, "Power fault detected\n");
238 retval = POWER_FAILURE; 234 retval = -EIO;
239 goto err_exit; 235 goto err_exit;
240 } 236 }
241 237
242 retval = pciehp_configure_device(p_slot); 238 retval = pciehp_configure_device(p_slot);
243 if (retval) { 239 if (retval) {
244 ctrl_err(ctrl, "Cannot add device at %04x:%02x:%02x\n", 240 ctrl_err(ctrl, "Cannot add device at %04x:%02x:00\n",
245 pci_domain_nr(parent), p_slot->bus, p_slot->device); 241 pci_domain_nr(parent), parent->number);
246 goto err_exit; 242 goto err_exit;
247 } 243 }
248 244
249 if (PWR_LED(ctrl)) 245 if (PWR_LED(ctrl))
250 p_slot->hpc_ops->green_led_on(p_slot); 246 pciehp_green_led_on(p_slot);
251 247
252 return 0; 248 return 0;
253 249
@@ -269,11 +265,9 @@ static int remove_board(struct slot *p_slot)
269 if (retval) 265 if (retval)
270 return retval; 266 return retval;
271 267
272 ctrl_dbg(ctrl, "%s: hp_slot = %d\n", __func__, p_slot->hp_slot);
273
274 if (POWER_CTRL(ctrl)) { 268 if (POWER_CTRL(ctrl)) {
275 /* power off slot */ 269 /* power off slot */
276 retval = p_slot->hpc_ops->power_off_slot(p_slot); 270 retval = pciehp_power_off_slot(p_slot);
277 if (retval) { 271 if (retval) {
278 ctrl_err(ctrl, 272 ctrl_err(ctrl,
279 "Issue of Slot Disable command failed\n"); 273 "Issue of Slot Disable command failed\n");
@@ -287,9 +281,9 @@ static int remove_board(struct slot *p_slot)
287 msleep(1000); 281 msleep(1000);
288 } 282 }
289 283
284 /* turn off Green LED */
290 if (PWR_LED(ctrl)) 285 if (PWR_LED(ctrl))
291 /* turn off Green LED */ 286 pciehp_green_led_off(p_slot);
292 p_slot->hpc_ops->green_led_off(p_slot);
293 287
294 return 0; 288 return 0;
295} 289}
@@ -317,18 +311,17 @@ static void pciehp_power_thread(struct work_struct *work)
317 case POWEROFF_STATE: 311 case POWEROFF_STATE:
318 mutex_unlock(&p_slot->lock); 312 mutex_unlock(&p_slot->lock);
319 ctrl_dbg(p_slot->ctrl, 313 ctrl_dbg(p_slot->ctrl,
320 "Disabling domain:bus:device=%04x:%02x:%02x\n", 314 "Disabling domain:bus:device=%04x:%02x:00\n",
321 pci_domain_nr(p_slot->ctrl->pci_dev->subordinate), 315 pci_domain_nr(p_slot->ctrl->pcie->port->subordinate),
322 p_slot->bus, p_slot->device); 316 p_slot->ctrl->pcie->port->subordinate->number);
323 pciehp_disable_slot(p_slot); 317 pciehp_disable_slot(p_slot);
324 mutex_lock(&p_slot->lock); 318 mutex_lock(&p_slot->lock);
325 p_slot->state = STATIC_STATE; 319 p_slot->state = STATIC_STATE;
326 break; 320 break;
327 case POWERON_STATE: 321 case POWERON_STATE:
328 mutex_unlock(&p_slot->lock); 322 mutex_unlock(&p_slot->lock);
329 if (pciehp_enable_slot(p_slot) && 323 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl))
330 PWR_LED(p_slot->ctrl)) 324 pciehp_green_led_off(p_slot);
331 p_slot->hpc_ops->green_led_off(p_slot);
332 mutex_lock(&p_slot->lock); 325 mutex_lock(&p_slot->lock);
333 p_slot->state = STATIC_STATE; 326 p_slot->state = STATIC_STATE;
334 break; 327 break;
@@ -379,10 +372,10 @@ static int update_slot_info(struct slot *slot)
379 if (!info) 372 if (!info)
380 return -ENOMEM; 373 return -ENOMEM;
381 374
382 slot->hpc_ops->get_power_status(slot, &(info->power_status)); 375 pciehp_get_power_status(slot, &info->power_status);
383 slot->hpc_ops->get_attention_status(slot, &(info->attention_status)); 376 pciehp_get_attention_status(slot, &info->attention_status);
384 slot->hpc_ops->get_latch_status(slot, &(info->latch_status)); 377 pciehp_get_latch_status(slot, &info->latch_status);
385 slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status)); 378 pciehp_get_adapter_status(slot, &info->adapter_status);
386 379
387 result = pci_hp_change_slot_info(slot->hotplug_slot, info); 380 result = pci_hp_change_slot_info(slot->hotplug_slot, info);
388 kfree (info); 381 kfree (info);
@@ -399,7 +392,7 @@ static void handle_button_press_event(struct slot *p_slot)
399 392
400 switch (p_slot->state) { 393 switch (p_slot->state) {
401 case STATIC_STATE: 394 case STATIC_STATE:
402 p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 395 pciehp_get_power_status(p_slot, &getstatus);
403 if (getstatus) { 396 if (getstatus) {
404 p_slot->state = BLINKINGOFF_STATE; 397 p_slot->state = BLINKINGOFF_STATE;
405 ctrl_info(ctrl, 398 ctrl_info(ctrl,
@@ -413,9 +406,9 @@ static void handle_button_press_event(struct slot *p_slot)
413 } 406 }
414 /* blink green LED and turn off amber */ 407 /* blink green LED and turn off amber */
415 if (PWR_LED(ctrl)) 408 if (PWR_LED(ctrl))
416 p_slot->hpc_ops->green_led_blink(p_slot); 409 pciehp_green_led_blink(p_slot);
417 if (ATTN_LED(ctrl)) 410 if (ATTN_LED(ctrl))
418 p_slot->hpc_ops->set_attention_status(p_slot, 0); 411 pciehp_set_attention_status(p_slot, 0);
419 412
420 schedule_delayed_work(&p_slot->work, 5*HZ); 413 schedule_delayed_work(&p_slot->work, 5*HZ);
421 break; 414 break;
@@ -430,13 +423,13 @@ static void handle_button_press_event(struct slot *p_slot)
430 cancel_delayed_work(&p_slot->work); 423 cancel_delayed_work(&p_slot->work);
431 if (p_slot->state == BLINKINGOFF_STATE) { 424 if (p_slot->state == BLINKINGOFF_STATE) {
432 if (PWR_LED(ctrl)) 425 if (PWR_LED(ctrl))
433 p_slot->hpc_ops->green_led_on(p_slot); 426 pciehp_green_led_on(p_slot);
434 } else { 427 } else {
435 if (PWR_LED(ctrl)) 428 if (PWR_LED(ctrl))
436 p_slot->hpc_ops->green_led_off(p_slot); 429 pciehp_green_led_off(p_slot);
437 } 430 }
438 if (ATTN_LED(ctrl)) 431 if (ATTN_LED(ctrl))
439 p_slot->hpc_ops->set_attention_status(p_slot, 0); 432 pciehp_set_attention_status(p_slot, 0);
440 ctrl_info(ctrl, "PCI slot #%s - action canceled " 433 ctrl_info(ctrl, "PCI slot #%s - action canceled "
441 "due to button press\n", slot_name(p_slot)); 434 "due to button press\n", slot_name(p_slot));
442 p_slot->state = STATIC_STATE; 435 p_slot->state = STATIC_STATE;
@@ -474,7 +467,7 @@ static void handle_surprise_event(struct slot *p_slot)
474 info->p_slot = p_slot; 467 info->p_slot = p_slot;
475 INIT_WORK(&info->work, pciehp_power_thread); 468 INIT_WORK(&info->work, pciehp_power_thread);
476 469
477 p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 470 pciehp_get_adapter_status(p_slot, &getstatus);
478 if (!getstatus) 471 if (!getstatus)
479 p_slot->state = POWEROFF_STATE; 472 p_slot->state = POWEROFF_STATE;
480 else 473 else
@@ -498,9 +491,9 @@ static void interrupt_event_handler(struct work_struct *work)
498 if (!POWER_CTRL(ctrl)) 491 if (!POWER_CTRL(ctrl))
499 break; 492 break;
500 if (ATTN_LED(ctrl)) 493 if (ATTN_LED(ctrl))
501 p_slot->hpc_ops->set_attention_status(p_slot, 1); 494 pciehp_set_attention_status(p_slot, 1);
502 if (PWR_LED(ctrl)) 495 if (PWR_LED(ctrl))
503 p_slot->hpc_ops->green_led_off(p_slot); 496 pciehp_green_led_off(p_slot);
504 break; 497 break;
505 case INT_PRESENCE_ON: 498 case INT_PRESENCE_ON:
506 case INT_PRESENCE_OFF: 499 case INT_PRESENCE_OFF:
@@ -525,45 +518,38 @@ int pciehp_enable_slot(struct slot *p_slot)
525 int rc; 518 int rc;
526 struct controller *ctrl = p_slot->ctrl; 519 struct controller *ctrl = p_slot->ctrl;
527 520
528 /* Check to see if (latch closed, card present, power off) */ 521 rc = pciehp_get_adapter_status(p_slot, &getstatus);
529 mutex_lock(&p_slot->ctrl->crit_sect);
530
531 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
532 if (rc || !getstatus) { 522 if (rc || !getstatus) {
533 ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot)); 523 ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot));
534 mutex_unlock(&p_slot->ctrl->crit_sect);
535 return -ENODEV; 524 return -ENODEV;
536 } 525 }
537 if (MRL_SENS(p_slot->ctrl)) { 526 if (MRL_SENS(p_slot->ctrl)) {
538 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 527 rc = pciehp_get_latch_status(p_slot, &getstatus);
539 if (rc || getstatus) { 528 if (rc || getstatus) {
540 ctrl_info(ctrl, "Latch open on slot(%s)\n", 529 ctrl_info(ctrl, "Latch open on slot(%s)\n",
541 slot_name(p_slot)); 530 slot_name(p_slot));
542 mutex_unlock(&p_slot->ctrl->crit_sect);
543 return -ENODEV; 531 return -ENODEV;
544 } 532 }
545 } 533 }
546 534
547 if (POWER_CTRL(p_slot->ctrl)) { 535 if (POWER_CTRL(p_slot->ctrl)) {
548 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 536 rc = pciehp_get_power_status(p_slot, &getstatus);
549 if (rc || getstatus) { 537 if (rc || getstatus) {
550 ctrl_info(ctrl, "Already enabled on slot(%s)\n", 538 ctrl_info(ctrl, "Already enabled on slot(%s)\n",
551 slot_name(p_slot)); 539 slot_name(p_slot));
552 mutex_unlock(&p_slot->ctrl->crit_sect);
553 return -EINVAL; 540 return -EINVAL;
554 } 541 }
555 } 542 }
556 543
557 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 544 pciehp_get_latch_status(p_slot, &getstatus);
558 545
559 rc = board_added(p_slot); 546 rc = board_added(p_slot);
560 if (rc) { 547 if (rc) {
561 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 548 pciehp_get_latch_status(p_slot, &getstatus);
562 } 549 }
563 550
564 update_slot_info(p_slot); 551 update_slot_info(p_slot);
565 552
566 mutex_unlock(&p_slot->ctrl->crit_sect);
567 return rc; 553 return rc;
568} 554}
569 555
@@ -577,35 +563,29 @@ int pciehp_disable_slot(struct slot *p_slot)
577 if (!p_slot->ctrl) 563 if (!p_slot->ctrl)
578 return 1; 564 return 1;
579 565
580 /* Check to see if (latch closed, card present, power on) */
581 mutex_lock(&p_slot->ctrl->crit_sect);
582
583 if (!HP_SUPR_RM(p_slot->ctrl)) { 566 if (!HP_SUPR_RM(p_slot->ctrl)) {
584 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 567 ret = pciehp_get_adapter_status(p_slot, &getstatus);
585 if (ret || !getstatus) { 568 if (ret || !getstatus) {
586 ctrl_info(ctrl, "No adapter on slot(%s)\n", 569 ctrl_info(ctrl, "No adapter on slot(%s)\n",
587 slot_name(p_slot)); 570 slot_name(p_slot));
588 mutex_unlock(&p_slot->ctrl->crit_sect);
589 return -ENODEV; 571 return -ENODEV;
590 } 572 }
591 } 573 }
592 574
593 if (MRL_SENS(p_slot->ctrl)) { 575 if (MRL_SENS(p_slot->ctrl)) {
594 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 576 ret = pciehp_get_latch_status(p_slot, &getstatus);
595 if (ret || getstatus) { 577 if (ret || getstatus) {
596 ctrl_info(ctrl, "Latch open on slot(%s)\n", 578 ctrl_info(ctrl, "Latch open on slot(%s)\n",
597 slot_name(p_slot)); 579 slot_name(p_slot));
598 mutex_unlock(&p_slot->ctrl->crit_sect);
599 return -ENODEV; 580 return -ENODEV;
600 } 581 }
601 } 582 }
602 583
603 if (POWER_CTRL(p_slot->ctrl)) { 584 if (POWER_CTRL(p_slot->ctrl)) {
604 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 585 ret = pciehp_get_power_status(p_slot, &getstatus);
605 if (ret || !getstatus) { 586 if (ret || !getstatus) {
606 ctrl_info(ctrl, "Already disabled on slot(%s)\n", 587 ctrl_info(ctrl, "Already disabled on slot(%s)\n",
607 slot_name(p_slot)); 588 slot_name(p_slot));
608 mutex_unlock(&p_slot->ctrl->crit_sect);
609 return -EINVAL; 589 return -EINVAL;
610 } 590 }
611 } 591 }
@@ -613,7 +593,6 @@ int pciehp_disable_slot(struct slot *p_slot)
613 ret = remove_board(p_slot); 593 ret = remove_board(p_slot);
614 update_slot_info(p_slot); 594 update_slot_info(p_slot);
615 595
616 mutex_unlock(&p_slot->ctrl->crit_sect);
617 return ret; 596 return ret;
618} 597}
619 598