aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/pciehp_hpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/pciehp_hpc.c')
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c301
1 files changed, 164 insertions, 137 deletions
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index ed901b5c2798..98eee63f3ec5 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -107,32 +107,29 @@ enum ctrl_offsets {
107}; 107};
108static int pcie_cap_base = 0; /* Base of the PCI Express capability item structure */ 108static int pcie_cap_base = 0; /* Base of the PCI Express capability item structure */
109 109
110#define PCIE_CAP_ID(cb) ( cb + PCIECAPID ) 110static inline int pciehp_readw(struct controller *ctrl, int reg, u16 *value)
111#define NXT_CAP_PTR(cb) ( cb + NXTCAPPTR ) 111{
112#define CAP_REG(cb) ( cb + CAPREG ) 112 struct pci_dev *dev = ctrl->pci_dev;
113#define DEV_CAP(cb) ( cb + DEVCAP ) 113 return pci_read_config_word(dev, ctrl->cap_base + reg, value);
114#define DEV_CTRL(cb) ( cb + DEVCTRL ) 114}
115#define DEV_STATUS(cb) ( cb + DEVSTATUS ) 115
116#define LNK_CAP(cb) ( cb + LNKCAP ) 116static inline int pciehp_readl(struct controller *ctrl, int reg, u32 *value)
117#define LNK_CTRL(cb) ( cb + LNKCTRL ) 117{
118#define LNK_STATUS(cb) ( cb + LNKSTATUS ) 118 struct pci_dev *dev = ctrl->pci_dev;
119#define SLOT_CAP(cb) ( cb + SLOTCAP ) 119 return pci_read_config_dword(dev, ctrl->cap_base + reg, value);
120#define SLOT_CTRL(cb) ( cb + SLOTCTRL ) 120}
121#define SLOT_STATUS(cb) ( cb + SLOTSTATUS ) 121
122#define ROOT_CTRL(cb) ( cb + ROOTCTRL ) 122static inline int pciehp_writew(struct controller *ctrl, int reg, u16 value)
123#define ROOT_STATUS(cb) ( cb + ROOTSTATUS ) 123{
124 124 struct pci_dev *dev = ctrl->pci_dev;
125#define hp_register_read_word(pdev, reg , value) \ 125 return pci_write_config_word(dev, ctrl->cap_base + reg, value);
126 pci_read_config_word(pdev, reg, &value) 126}
127 127
128#define hp_register_read_dword(pdev, reg , value) \ 128static inline int pciehp_writel(struct controller *ctrl, int reg, u32 value)
129 pci_read_config_dword(pdev, reg, &value) 129{
130 130 struct pci_dev *dev = ctrl->pci_dev;
131#define hp_register_write_word(pdev, reg , value) \ 131 return pci_write_config_dword(dev, ctrl->cap_base + reg, value);
132 pci_write_config_word(pdev, reg, value) 132}
133
134#define hp_register_dwrite_word(pdev, reg , value) \
135 pci_write_config_dword(pdev, reg, value)
136 133
137/* Field definitions in PCI Express Capabilities Register */ 134/* Field definitions in PCI Express Capabilities Register */
138#define CAP_VER 0x000F 135#define CAP_VER 0x000F
@@ -260,22 +257,22 @@ static int pcie_write_cmd(struct slot *slot, u16 cmd)
260 u16 slot_status; 257 u16 slot_status;
261 258
262 DBG_ENTER_ROUTINE 259 DBG_ENTER_ROUTINE
263 260
264 retval = hp_register_read_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 261 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
265 if (retval) { 262 if (retval) {
266 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 263 err("%s: Cannot read SLOTSTATUS register\n", __FUNCTION__);
267 return retval; 264 return retval;
268 } 265 }
269 266
270 if ((slot_status & CMD_COMPLETED) == CMD_COMPLETED ) { 267 if ((slot_status & CMD_COMPLETED) == CMD_COMPLETED ) {
271 /* After 1 sec and CMD_COMPLETED still not set, just proceed forward to issue 268 /* After 1 sec and CMD_COMPLETED still not set, just proceed forward to issue
272 the next command according to spec. Just print out the error message */ 269 the next command according to spec. Just print out the error message */
273 dbg("%s : CMD_COMPLETED not clear after 1 sec.\n", __FUNCTION__); 270 dbg("%s : CMD_COMPLETED not clear after 1 sec.\n", __FUNCTION__);
274 } 271 }
275 272
276 retval = hp_register_write_word(ctrl->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), cmd | CMD_CMPL_INTR_ENABLE); 273 retval = pciehp_writew(ctrl, SLOTCTRL, (cmd | CMD_CMPL_INTR_ENABLE));
277 if (retval) { 274 if (retval) {
278 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 275 err("%s: Cannot write to SLOTCTRL register\n", __FUNCTION__);
279 return retval; 276 return retval;
280 } 277 }
281 278
@@ -290,9 +287,9 @@ static int hpc_check_lnk_status(struct controller *ctrl)
290 287
291 DBG_ENTER_ROUTINE 288 DBG_ENTER_ROUTINE
292 289
293 retval = hp_register_read_word(ctrl->pci_dev, LNK_STATUS(ctrl->cap_base), lnk_status); 290 retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status);
294 if (retval) { 291 if (retval) {
295 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); 292 err("%s: Cannot read LNKSTATUS register\n", __FUNCTION__);
296 return retval; 293 return retval;
297 } 294 }
298 295
@@ -318,13 +315,14 @@ static int hpc_get_attention_status(struct slot *slot, u8 *status)
318 315
319 DBG_ENTER_ROUTINE 316 DBG_ENTER_ROUTINE
320 317
321 retval = hp_register_read_word(ctrl->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 318 retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl);
322 if (retval) { 319 if (retval) {
323 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 320 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
324 return retval; 321 return retval;
325 } 322 }
326 323
327 dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__,SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 324 dbg("%s: SLOTCTRL %x, value read %x\n",
325 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_ctrl);
328 326
329 atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6; 327 atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6;
330 328
@@ -359,12 +357,13 @@ static int hpc_get_power_status(struct slot *slot, u8 *status)
359 357
360 DBG_ENTER_ROUTINE 358 DBG_ENTER_ROUTINE
361 359
362 retval = hp_register_read_word(ctrl->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 360 retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl);
363 if (retval) { 361 if (retval) {
364 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 362 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
365 return retval; 363 return retval;
366 } 364 }
367 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 365 dbg("%s: SLOTCTRL %x value read %x\n",
366 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_ctrl);
368 367
369 pwr_state = (slot_ctrl & PWR_CTRL) >> 10; 368 pwr_state = (slot_ctrl & PWR_CTRL) >> 10;
370 369
@@ -393,9 +392,9 @@ static int hpc_get_latch_status(struct slot *slot, u8 *status)
393 392
394 DBG_ENTER_ROUTINE 393 DBG_ENTER_ROUTINE
395 394
396 retval = hp_register_read_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 395 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
397 if (retval) { 396 if (retval) {
398 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 397 err("%s: Cannot read SLOTSTATUS register\n", __FUNCTION__);
399 return retval; 398 return retval;
400 } 399 }
401 400
@@ -414,9 +413,9 @@ static int hpc_get_adapter_status(struct slot *slot, u8 *status)
414 413
415 DBG_ENTER_ROUTINE 414 DBG_ENTER_ROUTINE
416 415
417 retval = hp_register_read_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 416 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
418 if (retval) { 417 if (retval) {
419 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 418 err("%s: Cannot read SLOTSTATUS register\n", __FUNCTION__);
420 return retval; 419 return retval;
421 } 420 }
422 card_state = (u8)((slot_status & PRSN_STATE) >> 6); 421 card_state = (u8)((slot_status & PRSN_STATE) >> 6);
@@ -435,9 +434,9 @@ static int hpc_query_power_fault(struct slot *slot)
435 434
436 DBG_ENTER_ROUTINE 435 DBG_ENTER_ROUTINE
437 436
438 retval = hp_register_read_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 437 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
439 if (retval) { 438 if (retval) {
440 err("%s : Cannot check for power fault\n", __FUNCTION__); 439 err("%s: Cannot check for power fault\n", __FUNCTION__);
441 return retval; 440 return retval;
442 } 441 }
443 pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1); 442 pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1);
@@ -455,9 +454,9 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
455 454
456 DBG_ENTER_ROUTINE 455 DBG_ENTER_ROUTINE
457 456
458 rc = hp_register_read_word(ctrl->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 457 rc = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl);
459 if (rc) { 458 if (rc) {
460 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 459 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
461 return rc; 460 return rc;
462 } 461 }
463 462
@@ -478,7 +477,8 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
478 slot_cmd = slot_cmd | HP_INTR_ENABLE; 477 slot_cmd = slot_cmd | HP_INTR_ENABLE;
479 478
480 pcie_write_cmd(slot, slot_cmd); 479 pcie_write_cmd(slot, slot_cmd);
481 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 480 dbg("%s: SLOTCTRL %x write cmd %x\n",
481 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_cmd);
482 482
483 DBG_LEAVE_ROUTINE 483 DBG_LEAVE_ROUTINE
484 return rc; 484 return rc;
@@ -494,9 +494,9 @@ static void hpc_set_green_led_on(struct slot *slot)
494 494
495 DBG_ENTER_ROUTINE 495 DBG_ENTER_ROUTINE
496 496
497 rc = hp_register_read_word(ctrl->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 497 rc = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl);
498 if (rc) { 498 if (rc) {
499 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 499 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
500 return; 500 return;
501 } 501 }
502 slot_cmd = (slot_ctrl & ~PWR_LED_CTRL) | 0x0100; 502 slot_cmd = (slot_ctrl & ~PWR_LED_CTRL) | 0x0100;
@@ -505,7 +505,8 @@ static void hpc_set_green_led_on(struct slot *slot)
505 505
506 pcie_write_cmd(slot, slot_cmd); 506 pcie_write_cmd(slot, slot_cmd);
507 507
508 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 508 dbg("%s: SLOTCTRL %x write cmd %x\n",
509 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_cmd);
509 DBG_LEAVE_ROUTINE 510 DBG_LEAVE_ROUTINE
510 return; 511 return;
511} 512}
@@ -519,9 +520,9 @@ static void hpc_set_green_led_off(struct slot *slot)
519 520
520 DBG_ENTER_ROUTINE 521 DBG_ENTER_ROUTINE
521 522
522 rc = hp_register_read_word(ctrl->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 523 rc = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl);
523 if (rc) { 524 if (rc) {
524 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 525 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
525 return; 526 return;
526 } 527 }
527 528
@@ -530,7 +531,8 @@ static void hpc_set_green_led_off(struct slot *slot)
530 if (!pciehp_poll_mode) 531 if (!pciehp_poll_mode)
531 slot_cmd = slot_cmd | HP_INTR_ENABLE; 532 slot_cmd = slot_cmd | HP_INTR_ENABLE;
532 pcie_write_cmd(slot, slot_cmd); 533 pcie_write_cmd(slot, slot_cmd);
533 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 534 dbg("%s: SLOTCTRL %x write cmd %x\n",
535 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_cmd);
534 536
535 DBG_LEAVE_ROUTINE 537 DBG_LEAVE_ROUTINE
536 return; 538 return;
@@ -545,9 +547,9 @@ static void hpc_set_green_led_blink(struct slot *slot)
545 547
546 DBG_ENTER_ROUTINE 548 DBG_ENTER_ROUTINE
547 549
548 rc = hp_register_read_word(ctrl->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 550 rc = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl);
549 if (rc) { 551 if (rc) {
550 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 552 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
551 return; 553 return;
552 } 554 }
553 555
@@ -557,7 +559,8 @@ static void hpc_set_green_led_blink(struct slot *slot)
557 slot_cmd = slot_cmd | HP_INTR_ENABLE; 559 slot_cmd = slot_cmd | HP_INTR_ENABLE;
558 pcie_write_cmd(slot, slot_cmd); 560 pcie_write_cmd(slot, slot_cmd);
559 561
560 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 562 dbg("%s: SLOTCTRL %x write cmd %x\n",
563 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_cmd);
561 DBG_LEAVE_ROUTINE 564 DBG_LEAVE_ROUTINE
562 return; 565 return;
563} 566}
@@ -586,17 +589,24 @@ static int hpc_power_on_slot(struct slot * slot)
586 dbg("%s: slot->hp_slot %x\n", __FUNCTION__, slot->hp_slot); 589 dbg("%s: slot->hp_slot %x\n", __FUNCTION__, slot->hp_slot);
587 590
588 /* Clear sticky power-fault bit from previous power failures */ 591 /* Clear sticky power-fault bit from previous power failures */
589 hp_register_read_word(ctrl->pci_dev, 592 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
590 SLOT_STATUS(ctrl->cap_base), slot_status); 593 if (retval) {
594 err("%s: Cannot read SLOTSTATUS register\n", __FUNCTION__);
595 return retval;
596 }
591 slot_status &= PWR_FAULT_DETECTED; 597 slot_status &= PWR_FAULT_DETECTED;
592 if (slot_status) 598 if (slot_status) {
593 hp_register_write_word(ctrl->pci_dev, 599 retval = pciehp_writew(ctrl, SLOTSTATUS, slot_status);
594 SLOT_STATUS(ctrl->cap_base), slot_status); 600 if (retval) {
601 err("%s: Cannot write to SLOTSTATUS register\n",
602 __FUNCTION__);
603 return retval;
604 }
605 }
595 606
596 retval = hp_register_read_word(ctrl->pci_dev, 607 retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl);
597 SLOT_CTRL(ctrl->cap_base), slot_ctrl);
598 if (retval) { 608 if (retval) {
599 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 609 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
600 return retval; 610 return retval;
601 } 611 }
602 612
@@ -616,7 +626,8 @@ static int hpc_power_on_slot(struct slot * slot)
616 err("%s: Write %x command failed!\n", __FUNCTION__, slot_cmd); 626 err("%s: Write %x command failed!\n", __FUNCTION__, slot_cmd);
617 return -1; 627 return -1;
618 } 628 }
619 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 629 dbg("%s: SLOTCTRL %x write cmd %x\n",
630 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_cmd);
620 631
621 DBG_LEAVE_ROUTINE 632 DBG_LEAVE_ROUTINE
622 633
@@ -634,9 +645,9 @@ static int hpc_power_off_slot(struct slot * slot)
634 645
635 dbg("%s: slot->hp_slot %x\n", __FUNCTION__, slot->hp_slot); 646 dbg("%s: slot->hp_slot %x\n", __FUNCTION__, slot->hp_slot);
636 647
637 retval = hp_register_read_word(ctrl->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 648 retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl);
638 if (retval) { 649 if (retval) {
639 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 650 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
640 return retval; 651 return retval;
641 } 652 }
642 653
@@ -661,7 +672,8 @@ static int hpc_power_off_slot(struct slot * slot)
661 err("%s: Write command failed!\n", __FUNCTION__); 672 err("%s: Write command failed!\n", __FUNCTION__);
662 return -1; 673 return -1;
663 } 674 }
664 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 675 dbg("%s: SLOTCTRL %x write cmd %x\n",
676 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_cmd);
665 677
666 DBG_LEAVE_ROUTINE 678 DBG_LEAVE_ROUTINE
667 679
@@ -676,9 +688,9 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
676 int hp_slot = 0; /* only 1 slot per PCI Express port */ 688 int hp_slot = 0; /* only 1 slot per PCI Express port */
677 int rc = 0; 689 int rc = 0;
678 690
679 rc = hp_register_read_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 691 rc = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
680 if (rc) { 692 if (rc) {
681 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 693 err("%s: Cannot read SLOTSTATUS register\n", __FUNCTION__);
682 return IRQ_NONE; 694 return IRQ_NONE;
683 } 695 }
684 696
@@ -694,33 +706,38 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
694 dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc); 706 dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc);
695 /* Mask Hot-plug Interrupt Enable */ 707 /* Mask Hot-plug Interrupt Enable */
696 if (!pciehp_poll_mode) { 708 if (!pciehp_poll_mode) {
697 rc = hp_register_read_word(ctrl->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word); 709 rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word);
698 if (rc) { 710 if (rc) {
699 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 711 err("%s: Cannot read SLOT_CTRL register\n",
712 __FUNCTION__);
700 return IRQ_NONE; 713 return IRQ_NONE;
701 } 714 }
702 715
703 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 716 dbg("%s: pciehp_readw(SLOTCTRL) with value %x\n",
717 __FUNCTION__, temp_word);
704 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 718 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00;
705 719 rc = pciehp_writew(ctrl, SLOTCTRL, temp_word);
706 rc = hp_register_write_word(ctrl->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
707 if (rc) { 720 if (rc) {
708 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 721 err("%s: Cannot write to SLOTCTRL register\n",
722 __FUNCTION__);
709 return IRQ_NONE; 723 return IRQ_NONE;
710 } 724 }
711 725
712 rc = hp_register_read_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 726 rc = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
713 if (rc) { 727 if (rc) {
714 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 728 err("%s: Cannot read SLOT_STATUS register\n",
729 __FUNCTION__);
715 return IRQ_NONE; 730 return IRQ_NONE;
716 } 731 }
717 dbg("%s: hp_register_read_word SLOT_STATUS with value %x\n", __FUNCTION__, slot_status); 732 dbg("%s: pciehp_readw(SLOTSTATUS) with value %x\n",
733 __FUNCTION__, slot_status);
718 734
719 /* Clear command complete interrupt caused by this write */ 735 /* Clear command complete interrupt caused by this write */
720 temp_word = 0x1f; 736 temp_word = 0x1f;
721 rc = hp_register_write_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 737 rc = pciehp_writew(ctrl, SLOTSTATUS, temp_word);
722 if (rc) { 738 if (rc) {
723 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 739 err("%s: Cannot write to SLOTSTATUS register\n",
740 __FUNCTION__);
724 return IRQ_NONE; 741 return IRQ_NONE;
725 } 742 }
726 } 743 }
@@ -746,42 +763,47 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
746 763
747 /* Clear all events after serving them */ 764 /* Clear all events after serving them */
748 temp_word = 0x1F; 765 temp_word = 0x1F;
749 rc = hp_register_write_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 766 rc = pciehp_writew(ctrl, SLOTSTATUS, temp_word);
750 if (rc) { 767 if (rc) {
751 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 768 err("%s: Cannot write to SLOTSTATUS register\n", __FUNCTION__);
752 return IRQ_NONE; 769 return IRQ_NONE;
753 } 770 }
754 /* Unmask Hot-plug Interrupt Enable */ 771 /* Unmask Hot-plug Interrupt Enable */
755 if (!pciehp_poll_mode) { 772 if (!pciehp_poll_mode) {
756 rc = hp_register_read_word(ctrl->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word); 773 rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word);
757 if (rc) { 774 if (rc) {
758 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 775 err("%s: Cannot read SLOTCTRL register\n",
776 __FUNCTION__);
759 return IRQ_NONE; 777 return IRQ_NONE;
760 } 778 }
761 779
762 dbg("%s: Unmask Hot-plug Interrupt Enable\n", __FUNCTION__); 780 dbg("%s: Unmask Hot-plug Interrupt Enable\n", __FUNCTION__);
763 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE; 781 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE;
764 782
765 rc = hp_register_write_word(ctrl->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word); 783 rc = pciehp_writew(ctrl, SLOTCTRL, temp_word);
766 if (rc) { 784 if (rc) {
767 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 785 err("%s: Cannot write to SLOTCTRL register\n",
786 __FUNCTION__);
768 return IRQ_NONE; 787 return IRQ_NONE;
769 } 788 }
770 789
771 rc = hp_register_read_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 790 rc = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
772 if (rc) { 791 if (rc) {
773 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 792 err("%s: Cannot read SLOT_STATUS register\n",
793 __FUNCTION__);
774 return IRQ_NONE; 794 return IRQ_NONE;
775 } 795 }
776 796
777 /* Clear command complete interrupt caused by this write */ 797 /* Clear command complete interrupt caused by this write */
778 temp_word = 0x1F; 798 temp_word = 0x1F;
779 rc = hp_register_write_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 799 rc = pciehp_writew(ctrl, SLOTSTATUS, temp_word);
780 if (rc) { 800 if (rc) {
781 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 801 err("%s: Cannot write to SLOTSTATUS failed\n",
802 __FUNCTION__);
782 return IRQ_NONE; 803 return IRQ_NONE;
783 } 804 }
784 dbg("%s: hp_register_write_word SLOT_STATUS with value %x\n", __FUNCTION__, temp_word); 805 dbg("%s: pciehp_writew(SLOTSTATUS) with value %x\n",
806 __FUNCTION__, temp_word);
785 } 807 }
786 808
787 return IRQ_HANDLED; 809 return IRQ_HANDLED;
@@ -796,9 +818,9 @@ static int hpc_get_max_lnk_speed (struct slot *slot, enum pci_bus_speed *value)
796 818
797 DBG_ENTER_ROUTINE 819 DBG_ENTER_ROUTINE
798 820
799 retval = hp_register_read_dword(ctrl->pci_dev, LNK_CAP(ctrl->cap_base), lnk_cap); 821 retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap);
800 if (retval) { 822 if (retval) {
801 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__); 823 err("%s: Cannot read LNKCAP register\n", __FUNCTION__);
802 return retval; 824 return retval;
803 } 825 }
804 826
@@ -826,9 +848,9 @@ static int hpc_get_max_lnk_width (struct slot *slot, enum pcie_link_width *value
826 848
827 DBG_ENTER_ROUTINE 849 DBG_ENTER_ROUTINE
828 850
829 retval = hp_register_read_dword(ctrl->pci_dev, LNK_CAP(ctrl->cap_base), lnk_cap); 851 retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap);
830 if (retval) { 852 if (retval) {
831 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__); 853 err("%s: Cannot read LNKCAP register\n", __FUNCTION__);
832 return retval; 854 return retval;
833 } 855 }
834 856
@@ -877,9 +899,9 @@ static int hpc_get_cur_lnk_speed (struct slot *slot, enum pci_bus_speed *value)
877 899
878 DBG_ENTER_ROUTINE 900 DBG_ENTER_ROUTINE
879 901
880 retval = hp_register_read_word(ctrl->pci_dev, LNK_STATUS(ctrl->cap_base), lnk_status); 902 retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status);
881 if (retval) { 903 if (retval) {
882 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); 904 err("%s: Cannot read LNKSTATUS register\n", __FUNCTION__);
883 return retval; 905 return retval;
884 } 906 }
885 907
@@ -907,9 +929,9 @@ static int hpc_get_cur_lnk_width (struct slot *slot, enum pcie_link_width *value
907 929
908 DBG_ENTER_ROUTINE 930 DBG_ENTER_ROUTINE
909 931
910 retval = hp_register_read_word(ctrl->pci_dev, LNK_STATUS(ctrl->cap_base), lnk_status); 932 retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status);
911 if (retval) { 933 if (retval) {
912 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); 934 err("%s: Cannot read LNKSTATUS register\n", __FUNCTION__);
913 return retval; 935 return retval;
914 } 936 }
915 937
@@ -1073,12 +1095,13 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1073 1095
1074 dbg("%s: pcie_cap_base %x\n", __FUNCTION__, pcie_cap_base); 1096 dbg("%s: pcie_cap_base %x\n", __FUNCTION__, pcie_cap_base);
1075 1097
1076 rc = hp_register_read_word(pdev, CAP_REG(ctrl->cap_base), cap_reg); 1098 rc = pciehp_readw(ctrl, CAPREG, &cap_reg);
1077 if (rc) { 1099 if (rc) {
1078 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__); 1100 err("%s: Cannot read CAPREG register\n", __FUNCTION__);
1079 goto abort_free_ctlr; 1101 goto abort_free_ctlr;
1080 } 1102 }
1081 dbg("%s: CAP_REG offset %x cap_reg %x\n", __FUNCTION__, CAP_REG(ctrl->cap_base), cap_reg); 1103 dbg("%s: CAPREG offset %x cap_reg %x\n",
1104 __FUNCTION__, ctrl->cap_base + CAPREG, cap_reg);
1082 1105
1083 if (((cap_reg & SLOT_IMPL) == 0) || (((cap_reg & DEV_PORT_TYPE) != 0x0040) 1106 if (((cap_reg & SLOT_IMPL) == 0) || (((cap_reg & DEV_PORT_TYPE) != 0x0040)
1084 && ((cap_reg & DEV_PORT_TYPE) != 0x0060))) { 1107 && ((cap_reg & DEV_PORT_TYPE) != 0x0060))) {
@@ -1086,31 +1109,34 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1086 goto abort_free_ctlr; 1109 goto abort_free_ctlr;
1087 } 1110 }
1088 1111
1089 rc = hp_register_read_dword(ctrl->pci_dev, SLOT_CAP(ctrl->cap_base), slot_cap); 1112 rc = pciehp_readl(ctrl, SLOTCAP, &slot_cap);
1090 if (rc) { 1113 if (rc) {
1091 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__); 1114 err("%s: Cannot read SLOTCAP register\n", __FUNCTION__);
1092 goto abort_free_ctlr; 1115 goto abort_free_ctlr;
1093 } 1116 }
1094 dbg("%s: SLOT_CAP offset %x slot_cap %x\n", __FUNCTION__, SLOT_CAP(ctrl->cap_base), slot_cap); 1117 dbg("%s: SLOTCAP offset %x slot_cap %x\n",
1118 __FUNCTION__, ctrl->cap_base + SLOTCAP, slot_cap);
1095 1119
1096 if (!(slot_cap & HP_CAP)) { 1120 if (!(slot_cap & HP_CAP)) {
1097 dbg("%s : This slot is not hot-plug capable\n", __FUNCTION__); 1121 dbg("%s : This slot is not hot-plug capable\n", __FUNCTION__);
1098 goto abort_free_ctlr; 1122 goto abort_free_ctlr;
1099 } 1123 }
1100 /* For debugging purpose */ 1124 /* For debugging purpose */
1101 rc = hp_register_read_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1125 rc = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
1102 if (rc) { 1126 if (rc) {
1103 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1127 err("%s: Cannot read SLOTSTATUS register\n", __FUNCTION__);
1104 goto abort_free_ctlr; 1128 goto abort_free_ctlr;
1105 } 1129 }
1106 dbg("%s: SLOT_STATUS offset %x slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), slot_status); 1130 dbg("%s: SLOTSTATUS offset %x slot_status %x\n",
1131 __FUNCTION__, ctrl->cap_base + SLOTSTATUS, slot_status);
1107 1132
1108 rc = hp_register_read_word(ctrl->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 1133 rc = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl);
1109 if (rc) { 1134 if (rc) {
1110 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1135 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
1111 goto abort_free_ctlr; 1136 goto abort_free_ctlr;
1112 } 1137 }
1113 dbg("%s: SLOT_CTRL offset %x slot_ctrl %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 1138 dbg("%s: SLOTCTRL offset %x slot_ctrl %x\n",
1139 __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_ctrl);
1114 1140
1115 if (first) { 1141 if (first) {
1116 spin_lock_init(&hpc_event_lock); 1142 spin_lock_init(&hpc_event_lock);
@@ -1139,31 +1165,32 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1139 ctrl->ctrlcap = slot_cap & 0x0000007f; 1165 ctrl->ctrlcap = slot_cap & 0x0000007f;
1140 1166
1141 /* Mask Hot-plug Interrupt Enable */ 1167 /* Mask Hot-plug Interrupt Enable */
1142 rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1168 rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word);
1143 if (rc) { 1169 if (rc) {
1144 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1170 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
1145 goto abort_free_ctlr; 1171 goto abort_free_ctlr;
1146 } 1172 }
1147 1173
1148 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), temp_word); 1174 dbg("%s: SLOTCTRL %x value read %x\n",
1175 __FUNCTION__, ctrl->cap_base + SLOTCTRL, temp_word);
1149 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 1176 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00;
1150 1177
1151 rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1178 rc = pciehp_writew(ctrl, SLOTCTRL, temp_word);
1152 if (rc) { 1179 if (rc) {
1153 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1180 err("%s: Cannot write to SLOTCTRL register\n", __FUNCTION__);
1154 goto abort_free_ctlr; 1181 goto abort_free_ctlr;
1155 } 1182 }
1156 1183
1157 rc = hp_register_read_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1184 rc = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
1158 if (rc) { 1185 if (rc) {
1159 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1186 err("%s: Cannot read SLOTSTATUS register\n", __FUNCTION__);
1160 goto abort_free_ctlr; 1187 goto abort_free_ctlr;
1161 } 1188 }
1162 1189
1163 temp_word = 0x1F; /* Clear all events */ 1190 temp_word = 0x1F; /* Clear all events */
1164 rc = hp_register_write_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 1191 rc = pciehp_writew(ctrl, SLOTSTATUS, temp_word);
1165 if (rc) { 1192 if (rc) {
1166 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1193 err("%s: Cannot write to SLOTSTATUS register\n", __FUNCTION__);
1167 goto abort_free_ctlr; 1194 goto abort_free_ctlr;
1168 } 1195 }
1169 1196
@@ -1186,9 +1213,9 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1186 dbg("pciehp ctrl b:d:f:irq=0x%x:%x:%x:%x\n", pdev->bus->number, 1213 dbg("pciehp ctrl b:d:f:irq=0x%x:%x:%x:%x\n", pdev->bus->number,
1187 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), dev->irq); 1214 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), dev->irq);
1188 1215
1189 rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1216 rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word);
1190 if (rc) { 1217 if (rc) {
1191 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1218 err("%s: Cannot read SLOTCTRL register\n", __FUNCTION__);
1192 goto abort_free_irq; 1219 goto abort_free_irq;
1193 } 1220 }
1194 1221
@@ -1212,21 +1239,21 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1212 } 1239 }
1213 1240
1214 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */ 1241 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */
1215 rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1242 rc = pciehp_writew(ctrl, SLOTCTRL, temp_word);
1216 if (rc) { 1243 if (rc) {
1217 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1244 err("%s: Cannot write to SLOTCTRL register\n", __FUNCTION__);
1218 goto abort_free_irq; 1245 goto abort_free_irq;
1219 } 1246 }
1220 rc = hp_register_read_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1247 rc = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
1221 if (rc) { 1248 if (rc) {
1222 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1249 err("%s: Cannot read SLOTSTATUS register\n", __FUNCTION__);
1223 goto abort_disable_intr; 1250 goto abort_disable_intr;
1224 } 1251 }
1225 1252
1226 temp_word = 0x1F; /* Clear all events */ 1253 temp_word = 0x1F; /* Clear all events */
1227 rc = hp_register_write_word(ctrl->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 1254 rc = pciehp_writew(ctrl, SLOTSTATUS, temp_word);
1228 if (rc) { 1255 if (rc) {
1229 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1256 err("%s: Cannot write to SLOTSTATUS register\n", __FUNCTION__);
1230 goto abort_disable_intr; 1257 goto abort_disable_intr;
1231 } 1258 }
1232 1259
@@ -1247,10 +1274,10 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1247 1274
1248 /* We end up here for the many possible ways to fail this API. */ 1275 /* We end up here for the many possible ways to fail this API. */
1249abort_disable_intr: 1276abort_disable_intr:
1250 rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1277 rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word);
1251 if (!rc) { 1278 if (!rc) {
1252 temp_word &= ~(intr_enable | HP_INTR_ENABLE); 1279 temp_word &= ~(intr_enable | HP_INTR_ENABLE);
1253 rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1280 rc = pciehp_writew(ctrl, SLOTCTRL, temp_word);
1254 } 1281 }
1255 if (rc) 1282 if (rc)
1256 err("%s : disabling interrupts failed\n", __FUNCTION__); 1283 err("%s : disabling interrupts failed\n", __FUNCTION__);