aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/kernel/pci_sabre.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc64/kernel/pci_sabre.c')
-rw-r--r--arch/sparc64/kernel/pci_sabre.c204
1 files changed, 104 insertions, 100 deletions
diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c
index 397862fbd9e1..4cefe6e83b24 100644
--- a/arch/sparc64/kernel/pci_sabre.c
+++ b/arch/sparc64/kernel/pci_sabre.c
@@ -13,12 +13,12 @@
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14 14
15#include <asm/apb.h> 15#include <asm/apb.h>
16#include <asm/pbm.h>
17#include <asm/iommu.h> 16#include <asm/iommu.h>
18#include <asm/irq.h> 17#include <asm/irq.h>
19#include <asm/smp.h> 18#include <asm/smp.h>
20#include <asm/oplib.h> 19#include <asm/oplib.h>
21#include <asm/prom.h> 20#include <asm/prom.h>
21#include <asm/of_device.h>
22 22
23#include "pci_impl.h" 23#include "pci_impl.h"
24#include "iommu_common.h" 24#include "iommu_common.h"
@@ -494,11 +494,11 @@ static struct pci_ops sabre_ops = {
494}; 494};
495 495
496/* SABRE error handling support. */ 496/* SABRE error handling support. */
497static void sabre_check_iommu_error(struct pci_controller_info *p, 497static void sabre_check_iommu_error(struct pci_pbm_info *pbm,
498 unsigned long afsr, 498 unsigned long afsr,
499 unsigned long afar) 499 unsigned long afar)
500{ 500{
501 struct iommu *iommu = p->pbm_A.iommu; 501 struct iommu *iommu = pbm->iommu;
502 unsigned long iommu_tag[16]; 502 unsigned long iommu_tag[16];
503 unsigned long iommu_data[16]; 503 unsigned long iommu_data[16];
504 unsigned long flags; 504 unsigned long flags;
@@ -526,8 +526,8 @@ static void sabre_check_iommu_error(struct pci_controller_info *p,
526 type_string = "Unknown"; 526 type_string = "Unknown";
527 break; 527 break;
528 }; 528 };
529 printk("SABRE%d: IOMMU Error, type[%s]\n", 529 printk("%s: IOMMU Error, type[%s]\n",
530 p->index, type_string); 530 pbm->name, type_string);
531 531
532 /* Enter diagnostic mode and probe for error'd 532 /* Enter diagnostic mode and probe for error'd
533 * entries in the IOTLB. 533 * entries in the IOTLB.
@@ -536,7 +536,7 @@ static void sabre_check_iommu_error(struct pci_controller_info *p,
536 sabre_write(iommu->iommu_control, 536 sabre_write(iommu->iommu_control,
537 (control | SABRE_IOMMUCTRL_DENAB)); 537 (control | SABRE_IOMMUCTRL_DENAB));
538 for (i = 0; i < 16; i++) { 538 for (i = 0; i < 16; i++) {
539 unsigned long base = p->pbm_A.controller_regs; 539 unsigned long base = pbm->controller_regs;
540 540
541 iommu_tag[i] = 541 iommu_tag[i] =
542 sabre_read(base + SABRE_IOMMU_TAG + (i * 8UL)); 542 sabre_read(base + SABRE_IOMMU_TAG + (i * 8UL));
@@ -566,13 +566,13 @@ static void sabre_check_iommu_error(struct pci_controller_info *p,
566 type_string = "Unknown"; 566 type_string = "Unknown";
567 break; 567 break;
568 }; 568 };
569 printk("SABRE%d: IOMMU TAG(%d)[RAW(%016lx)error(%s)wr(%d)sz(%dK)vpg(%08lx)]\n", 569 printk("%s: IOMMU TAG(%d)[RAW(%016lx)error(%s)wr(%d)sz(%dK)vpg(%08lx)]\n",
570 p->index, i, tag, type_string, 570 pbm->name, i, tag, type_string,
571 ((tag & SABRE_IOMMUTAG_WRITE) ? 1 : 0), 571 ((tag & SABRE_IOMMUTAG_WRITE) ? 1 : 0),
572 ((tag & SABRE_IOMMUTAG_SIZE) ? 64 : 8), 572 ((tag & SABRE_IOMMUTAG_SIZE) ? 64 : 8),
573 ((tag & SABRE_IOMMUTAG_VPN) << IOMMU_PAGE_SHIFT)); 573 ((tag & SABRE_IOMMUTAG_VPN) << IOMMU_PAGE_SHIFT));
574 printk("SABRE%d: IOMMU DATA(%d)[RAW(%016lx)valid(%d)used(%d)cache(%d)ppg(%016lx)\n", 574 printk("%s: IOMMU DATA(%d)[RAW(%016lx)valid(%d)used(%d)cache(%d)ppg(%016lx)\n",
575 p->index, i, data, 575 pbm->name, i, data,
576 ((data & SABRE_IOMMUDATA_VALID) ? 1 : 0), 576 ((data & SABRE_IOMMUDATA_VALID) ? 1 : 0),
577 ((data & SABRE_IOMMUDATA_USED) ? 1 : 0), 577 ((data & SABRE_IOMMUDATA_USED) ? 1 : 0),
578 ((data & SABRE_IOMMUDATA_CACHE) ? 1 : 0), 578 ((data & SABRE_IOMMUDATA_CACHE) ? 1 : 0),
@@ -584,9 +584,9 @@ static void sabre_check_iommu_error(struct pci_controller_info *p,
584 584
585static irqreturn_t sabre_ue_intr(int irq, void *dev_id) 585static irqreturn_t sabre_ue_intr(int irq, void *dev_id)
586{ 586{
587 struct pci_controller_info *p = dev_id; 587 struct pci_pbm_info *pbm = dev_id;
588 unsigned long afsr_reg = p->pbm_A.controller_regs + SABRE_UE_AFSR; 588 unsigned long afsr_reg = pbm->controller_regs + SABRE_UE_AFSR;
589 unsigned long afar_reg = p->pbm_A.controller_regs + SABRE_UECE_AFAR; 589 unsigned long afar_reg = pbm->controller_regs + SABRE_UECE_AFAR;
590 unsigned long afsr, afar, error_bits; 590 unsigned long afsr, afar, error_bits;
591 int reported; 591 int reported;
592 592
@@ -604,21 +604,21 @@ static irqreturn_t sabre_ue_intr(int irq, void *dev_id)
604 sabre_write(afsr_reg, error_bits); 604 sabre_write(afsr_reg, error_bits);
605 605
606 /* Log the error. */ 606 /* Log the error. */
607 printk("SABRE%d: Uncorrectable Error, primary error type[%s%s]\n", 607 printk("%s: Uncorrectable Error, primary error type[%s%s]\n",
608 p->index, 608 pbm->name,
609 ((error_bits & SABRE_UEAFSR_PDRD) ? 609 ((error_bits & SABRE_UEAFSR_PDRD) ?
610 "DMA Read" : 610 "DMA Read" :
611 ((error_bits & SABRE_UEAFSR_PDWR) ? 611 ((error_bits & SABRE_UEAFSR_PDWR) ?
612 "DMA Write" : "???")), 612 "DMA Write" : "???")),
613 ((error_bits & SABRE_UEAFSR_PDTE) ? 613 ((error_bits & SABRE_UEAFSR_PDTE) ?
614 ":Translation Error" : "")); 614 ":Translation Error" : ""));
615 printk("SABRE%d: bytemask[%04lx] dword_offset[%lx] was_block(%d)\n", 615 printk("%s: bytemask[%04lx] dword_offset[%lx] was_block(%d)\n",
616 p->index, 616 pbm->name,
617 (afsr & SABRE_UEAFSR_BMSK) >> 32UL, 617 (afsr & SABRE_UEAFSR_BMSK) >> 32UL,
618 (afsr & SABRE_UEAFSR_OFF) >> 29UL, 618 (afsr & SABRE_UEAFSR_OFF) >> 29UL,
619 ((afsr & SABRE_UEAFSR_BLK) ? 1 : 0)); 619 ((afsr & SABRE_UEAFSR_BLK) ? 1 : 0));
620 printk("SABRE%d: UE AFAR [%016lx]\n", p->index, afar); 620 printk("%s: UE AFAR [%016lx]\n", pbm->name, afar);
621 printk("SABRE%d: UE Secondary errors [", p->index); 621 printk("%s: UE Secondary errors [", pbm->name);
622 reported = 0; 622 reported = 0;
623 if (afsr & SABRE_UEAFSR_SDRD) { 623 if (afsr & SABRE_UEAFSR_SDRD) {
624 reported++; 624 reported++;
@@ -637,16 +637,16 @@ static irqreturn_t sabre_ue_intr(int irq, void *dev_id)
637 printk("]\n"); 637 printk("]\n");
638 638
639 /* Interrogate IOMMU for error status. */ 639 /* Interrogate IOMMU for error status. */
640 sabre_check_iommu_error(p, afsr, afar); 640 sabre_check_iommu_error(pbm, afsr, afar);
641 641
642 return IRQ_HANDLED; 642 return IRQ_HANDLED;
643} 643}
644 644
645static irqreturn_t sabre_ce_intr(int irq, void *dev_id) 645static irqreturn_t sabre_ce_intr(int irq, void *dev_id)
646{ 646{
647 struct pci_controller_info *p = dev_id; 647 struct pci_pbm_info *pbm = dev_id;
648 unsigned long afsr_reg = p->pbm_A.controller_regs + SABRE_CE_AFSR; 648 unsigned long afsr_reg = pbm->controller_regs + SABRE_CE_AFSR;
649 unsigned long afar_reg = p->pbm_A.controller_regs + SABRE_UECE_AFAR; 649 unsigned long afar_reg = pbm->controller_regs + SABRE_UECE_AFAR;
650 unsigned long afsr, afar, error_bits; 650 unsigned long afsr, afar, error_bits;
651 int reported; 651 int reported;
652 652
@@ -663,8 +663,8 @@ static irqreturn_t sabre_ce_intr(int irq, void *dev_id)
663 sabre_write(afsr_reg, error_bits); 663 sabre_write(afsr_reg, error_bits);
664 664
665 /* Log the error. */ 665 /* Log the error. */
666 printk("SABRE%d: Correctable Error, primary error type[%s]\n", 666 printk("%s: Correctable Error, primary error type[%s]\n",
667 p->index, 667 pbm->name,
668 ((error_bits & SABRE_CEAFSR_PDRD) ? 668 ((error_bits & SABRE_CEAFSR_PDRD) ?
669 "DMA Read" : 669 "DMA Read" :
670 ((error_bits & SABRE_CEAFSR_PDWR) ? 670 ((error_bits & SABRE_CEAFSR_PDWR) ?
@@ -673,15 +673,15 @@ static irqreturn_t sabre_ce_intr(int irq, void *dev_id)
673 /* XXX Use syndrome and afar to print out module string just like 673 /* XXX Use syndrome and afar to print out module string just like
674 * XXX UDB CE trap handler does... -DaveM 674 * XXX UDB CE trap handler does... -DaveM
675 */ 675 */
676 printk("SABRE%d: syndrome[%02lx] bytemask[%04lx] dword_offset[%lx] " 676 printk("%s: syndrome[%02lx] bytemask[%04lx] dword_offset[%lx] "
677 "was_block(%d)\n", 677 "was_block(%d)\n",
678 p->index, 678 pbm->name,
679 (afsr & SABRE_CEAFSR_ESYND) >> 48UL, 679 (afsr & SABRE_CEAFSR_ESYND) >> 48UL,
680 (afsr & SABRE_CEAFSR_BMSK) >> 32UL, 680 (afsr & SABRE_CEAFSR_BMSK) >> 32UL,
681 (afsr & SABRE_CEAFSR_OFF) >> 29UL, 681 (afsr & SABRE_CEAFSR_OFF) >> 29UL,
682 ((afsr & SABRE_CEAFSR_BLK) ? 1 : 0)); 682 ((afsr & SABRE_CEAFSR_BLK) ? 1 : 0));
683 printk("SABRE%d: CE AFAR [%016lx]\n", p->index, afar); 683 printk("%s: CE AFAR [%016lx]\n", pbm->name, afar);
684 printk("SABRE%d: CE Secondary errors [", p->index); 684 printk("%s: CE Secondary errors [", pbm->name);
685 reported = 0; 685 reported = 0;
686 if (afsr & SABRE_CEAFSR_SDRD) { 686 if (afsr & SABRE_CEAFSR_SDRD) {
687 reported++; 687 reported++;
@@ -698,13 +698,13 @@ static irqreturn_t sabre_ce_intr(int irq, void *dev_id)
698 return IRQ_HANDLED; 698 return IRQ_HANDLED;
699} 699}
700 700
701static irqreturn_t sabre_pcierr_intr_other(struct pci_controller_info *p) 701static irqreturn_t sabre_pcierr_intr_other(struct pci_pbm_info *pbm)
702{ 702{
703 unsigned long csr_reg, csr, csr_error_bits; 703 unsigned long csr_reg, csr, csr_error_bits;
704 irqreturn_t ret = IRQ_NONE; 704 irqreturn_t ret = IRQ_NONE;
705 u16 stat; 705 u16 stat;
706 706
707 csr_reg = p->pbm_A.controller_regs + SABRE_PCICTRL; 707 csr_reg = pbm->controller_regs + SABRE_PCICTRL;
708 csr = sabre_read(csr_reg); 708 csr = sabre_read(csr_reg);
709 csr_error_bits = 709 csr_error_bits =
710 csr & SABRE_PCICTRL_SERR; 710 csr & SABRE_PCICTRL_SERR;
@@ -714,8 +714,8 @@ static irqreturn_t sabre_pcierr_intr_other(struct pci_controller_info *p)
714 714
715 /* Log 'em. */ 715 /* Log 'em. */
716 if (csr_error_bits & SABRE_PCICTRL_SERR) 716 if (csr_error_bits & SABRE_PCICTRL_SERR)
717 printk("SABRE%d: PCI SERR signal asserted.\n", 717 printk("%s: PCI SERR signal asserted.\n",
718 p->index); 718 pbm->name);
719 ret = IRQ_HANDLED; 719 ret = IRQ_HANDLED;
720 } 720 }
721 pci_bus_read_config_word(sabre_root_bus, 0, 721 pci_bus_read_config_word(sabre_root_bus, 0,
@@ -725,8 +725,8 @@ static irqreturn_t sabre_pcierr_intr_other(struct pci_controller_info *p)
725 PCI_STATUS_REC_TARGET_ABORT | 725 PCI_STATUS_REC_TARGET_ABORT |
726 PCI_STATUS_REC_MASTER_ABORT | 726 PCI_STATUS_REC_MASTER_ABORT |
727 PCI_STATUS_SIG_SYSTEM_ERROR)) { 727 PCI_STATUS_SIG_SYSTEM_ERROR)) {
728 printk("SABRE%d: PCI bus error, PCI_STATUS[%04x]\n", 728 printk("%s: PCI bus error, PCI_STATUS[%04x]\n",
729 p->index, stat); 729 pbm->name, stat);
730 pci_bus_write_config_word(sabre_root_bus, 0, 730 pci_bus_write_config_word(sabre_root_bus, 0,
731 PCI_STATUS, 0xffff); 731 PCI_STATUS, 0xffff);
732 ret = IRQ_HANDLED; 732 ret = IRQ_HANDLED;
@@ -736,13 +736,13 @@ static irqreturn_t sabre_pcierr_intr_other(struct pci_controller_info *p)
736 736
737static irqreturn_t sabre_pcierr_intr(int irq, void *dev_id) 737static irqreturn_t sabre_pcierr_intr(int irq, void *dev_id)
738{ 738{
739 struct pci_controller_info *p = dev_id; 739 struct pci_pbm_info *pbm = dev_id;
740 unsigned long afsr_reg, afar_reg; 740 unsigned long afsr_reg, afar_reg;
741 unsigned long afsr, afar, error_bits; 741 unsigned long afsr, afar, error_bits;
742 int reported; 742 int reported;
743 743
744 afsr_reg = p->pbm_A.controller_regs + SABRE_PIOAFSR; 744 afsr_reg = pbm->controller_regs + SABRE_PIOAFSR;
745 afar_reg = p->pbm_A.controller_regs + SABRE_PIOAFAR; 745 afar_reg = pbm->controller_regs + SABRE_PIOAFAR;
746 746
747 /* Latch error status. */ 747 /* Latch error status. */
748 afar = sabre_read(afar_reg); 748 afar = sabre_read(afar_reg);
@@ -755,12 +755,12 @@ static irqreturn_t sabre_pcierr_intr(int irq, void *dev_id)
755 SABRE_PIOAFSR_SMA | SABRE_PIOAFSR_STA | 755 SABRE_PIOAFSR_SMA | SABRE_PIOAFSR_STA |
756 SABRE_PIOAFSR_SRTRY | SABRE_PIOAFSR_SPERR); 756 SABRE_PIOAFSR_SRTRY | SABRE_PIOAFSR_SPERR);
757 if (!error_bits) 757 if (!error_bits)
758 return sabre_pcierr_intr_other(p); 758 return sabre_pcierr_intr_other(pbm);
759 sabre_write(afsr_reg, error_bits); 759 sabre_write(afsr_reg, error_bits);
760 760
761 /* Log the error. */ 761 /* Log the error. */
762 printk("SABRE%d: PCI Error, primary error type[%s]\n", 762 printk("%s: PCI Error, primary error type[%s]\n",
763 p->index, 763 pbm->name,
764 (((error_bits & SABRE_PIOAFSR_PMA) ? 764 (((error_bits & SABRE_PIOAFSR_PMA) ?
765 "Master Abort" : 765 "Master Abort" :
766 ((error_bits & SABRE_PIOAFSR_PTA) ? 766 ((error_bits & SABRE_PIOAFSR_PTA) ?
@@ -769,12 +769,12 @@ static irqreturn_t sabre_pcierr_intr(int irq, void *dev_id)
769 "Excessive Retries" : 769 "Excessive Retries" :
770 ((error_bits & SABRE_PIOAFSR_PPERR) ? 770 ((error_bits & SABRE_PIOAFSR_PPERR) ?
771 "Parity Error" : "???")))))); 771 "Parity Error" : "???"))))));
772 printk("SABRE%d: bytemask[%04lx] was_block(%d)\n", 772 printk("%s: bytemask[%04lx] was_block(%d)\n",
773 p->index, 773 pbm->name,
774 (afsr & SABRE_PIOAFSR_BMSK) >> 32UL, 774 (afsr & SABRE_PIOAFSR_BMSK) >> 32UL,
775 (afsr & SABRE_PIOAFSR_BLK) ? 1 : 0); 775 (afsr & SABRE_PIOAFSR_BLK) ? 1 : 0);
776 printk("SABRE%d: PCI AFAR [%016lx]\n", p->index, afar); 776 printk("%s: PCI AFAR [%016lx]\n", pbm->name, afar);
777 printk("SABRE%d: PCI Secondary errors [", p->index); 777 printk("%s: PCI Secondary errors [", pbm->name);
778 reported = 0; 778 reported = 0;
779 if (afsr & SABRE_PIOAFSR_SMA) { 779 if (afsr & SABRE_PIOAFSR_SMA) {
780 reported++; 780 reported++;
@@ -806,11 +806,11 @@ static irqreturn_t sabre_pcierr_intr(int irq, void *dev_id)
806 * a bug in the IOMMU support code or a PCI device driver. 806 * a bug in the IOMMU support code or a PCI device driver.
807 */ 807 */
808 if (error_bits & (SABRE_PIOAFSR_PTA | SABRE_PIOAFSR_STA)) { 808 if (error_bits & (SABRE_PIOAFSR_PTA | SABRE_PIOAFSR_STA)) {
809 sabre_check_iommu_error(p, afsr, afar); 809 sabre_check_iommu_error(pbm, afsr, afar);
810 pci_scan_for_target_abort(p, &p->pbm_A, p->pbm_A.pci_bus); 810 pci_scan_for_target_abort(pbm, pbm->pci_bus);
811 } 811 }
812 if (error_bits & (SABRE_PIOAFSR_PMA | SABRE_PIOAFSR_SMA)) 812 if (error_bits & (SABRE_PIOAFSR_PMA | SABRE_PIOAFSR_SMA))
813 pci_scan_for_master_abort(p, &p->pbm_A, p->pbm_A.pci_bus); 813 pci_scan_for_master_abort(pbm, pbm->pci_bus);
814 814
815 /* For excessive retries, SABRE/PBM will abort the device 815 /* For excessive retries, SABRE/PBM will abort the device
816 * and there is no way to specifically check for excessive 816 * and there is no way to specifically check for excessive
@@ -820,18 +820,18 @@ static irqreturn_t sabre_pcierr_intr(int irq, void *dev_id)
820 */ 820 */
821 821
822 if (error_bits & (SABRE_PIOAFSR_PPERR | SABRE_PIOAFSR_SPERR)) 822 if (error_bits & (SABRE_PIOAFSR_PPERR | SABRE_PIOAFSR_SPERR))
823 pci_scan_for_parity_error(p, &p->pbm_A, p->pbm_A.pci_bus); 823 pci_scan_for_parity_error(pbm, pbm->pci_bus);
824 824
825 return IRQ_HANDLED; 825 return IRQ_HANDLED;
826} 826}
827 827
828static void sabre_register_error_handlers(struct pci_controller_info *p) 828static void sabre_register_error_handlers(struct pci_pbm_info *pbm)
829{ 829{
830 struct pci_pbm_info *pbm = &p->pbm_A; /* arbitrary */
831 struct device_node *dp = pbm->prom_node; 830 struct device_node *dp = pbm->prom_node;
832 struct of_device *op; 831 struct of_device *op;
833 unsigned long base = pbm->controller_regs; 832 unsigned long base = pbm->controller_regs;
834 u64 tmp; 833 u64 tmp;
834 int err;
835 835
836 if (pbm->chip_type == PBM_CHIP_TYPE_SABRE) 836 if (pbm->chip_type == PBM_CHIP_TYPE_SABRE)
837 dp = dp->parent; 837 dp = dp->parent;
@@ -858,22 +858,31 @@ static void sabre_register_error_handlers(struct pci_controller_info *p)
858 SABRE_UEAFSR_SDRD | SABRE_UEAFSR_SDWR | 858 SABRE_UEAFSR_SDRD | SABRE_UEAFSR_SDWR |
859 SABRE_UEAFSR_SDTE | SABRE_UEAFSR_PDTE)); 859 SABRE_UEAFSR_SDTE | SABRE_UEAFSR_PDTE));
860 860
861 request_irq(op->irqs[1], sabre_ue_intr, IRQF_SHARED, "SABRE UE", p); 861 err = request_irq(op->irqs[1], sabre_ue_intr, 0, "SABRE_UE", pbm);
862 if (err)
863 printk(KERN_WARNING "%s: Couldn't register UE, err=%d.\n",
864 pbm->name, err);
862 865
863 sabre_write(base + SABRE_CE_AFSR, 866 sabre_write(base + SABRE_CE_AFSR,
864 (SABRE_CEAFSR_PDRD | SABRE_CEAFSR_PDWR | 867 (SABRE_CEAFSR_PDRD | SABRE_CEAFSR_PDWR |
865 SABRE_CEAFSR_SDRD | SABRE_CEAFSR_SDWR)); 868 SABRE_CEAFSR_SDRD | SABRE_CEAFSR_SDWR));
866 869
867 request_irq(op->irqs[2], sabre_ce_intr, IRQF_SHARED, "SABRE CE", p); 870 err = request_irq(op->irqs[2], sabre_ce_intr, 0, "SABRE_CE", pbm);
868 request_irq(op->irqs[0], sabre_pcierr_intr, IRQF_SHARED, 871 if (err)
869 "SABRE PCIERR", p); 872 printk(KERN_WARNING "%s: Couldn't register CE, err=%d.\n",
873 pbm->name, err);
874 err = request_irq(op->irqs[0], sabre_pcierr_intr, 0,
875 "SABRE_PCIERR", pbm);
876 if (err)
877 printk(KERN_WARNING "%s: Couldn't register PCIERR, err=%d.\n",
878 pbm->name, err);
870 879
871 tmp = sabre_read(base + SABRE_PCICTRL); 880 tmp = sabre_read(base + SABRE_PCICTRL);
872 tmp |= SABRE_PCICTRL_ERREN; 881 tmp |= SABRE_PCICTRL_ERREN;
873 sabre_write(base + SABRE_PCICTRL, tmp); 882 sabre_write(base + SABRE_PCICTRL, tmp);
874} 883}
875 884
876static void apb_init(struct pci_controller_info *p, struct pci_bus *sabre_bus) 885static void apb_init(struct pci_bus *sabre_bus)
877{ 886{
878 struct pci_dev *pdev; 887 struct pci_dev *pdev;
879 888
@@ -909,7 +918,7 @@ static void apb_init(struct pci_controller_info *p, struct pci_bus *sabre_bus)
909 } 918 }
910} 919}
911 920
912static void sabre_scan_bus(struct pci_controller_info *p) 921static void sabre_scan_bus(struct pci_pbm_info *pbm)
913{ 922{
914 static int once; 923 static int once;
915 struct pci_bus *pbus; 924 struct pci_bus *pbus;
@@ -918,7 +927,7 @@ static void sabre_scan_bus(struct pci_controller_info *p)
918 * at 66Mhz, but the front side of APB runs at 33Mhz 927 * at 66Mhz, but the front side of APB runs at 33Mhz
919 * for both segments. 928 * for both segments.
920 */ 929 */
921 p->pbm_A.is_66mhz_capable = 0; 930 pbm->is_66mhz_capable = 0;
922 931
923 /* This driver has not been verified to handle 932 /* This driver has not been verified to handle
924 * multiple SABREs yet, so trap this. 933 * multiple SABREs yet, so trap this.
@@ -932,41 +941,41 @@ static void sabre_scan_bus(struct pci_controller_info *p)
932 } 941 }
933 once++; 942 once++;
934 943
935 pbus = pci_scan_one_pbm(&p->pbm_A); 944 pbus = pci_scan_one_pbm(pbm);
936 if (!pbus) 945 if (!pbus)
937 return; 946 return;
938 947
939 sabre_root_bus = pbus; 948 sabre_root_bus = pbus;
940 949
941 apb_init(p, pbus); 950 apb_init(pbus);
942 951
943 sabre_register_error_handlers(p); 952 sabre_register_error_handlers(pbm);
944} 953}
945 954
946static void sabre_iommu_init(struct pci_controller_info *p, 955static void sabre_iommu_init(struct pci_pbm_info *pbm,
947 int tsbsize, unsigned long dvma_offset, 956 int tsbsize, unsigned long dvma_offset,
948 u32 dma_mask) 957 u32 dma_mask)
949{ 958{
950 struct iommu *iommu = p->pbm_A.iommu; 959 struct iommu *iommu = pbm->iommu;
951 unsigned long i; 960 unsigned long i;
952 u64 control; 961 u64 control;
953 962
954 /* Register addresses. */ 963 /* Register addresses. */
955 iommu->iommu_control = p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL; 964 iommu->iommu_control = pbm->controller_regs + SABRE_IOMMU_CONTROL;
956 iommu->iommu_tsbbase = p->pbm_A.controller_regs + SABRE_IOMMU_TSBBASE; 965 iommu->iommu_tsbbase = pbm->controller_regs + SABRE_IOMMU_TSBBASE;
957 iommu->iommu_flush = p->pbm_A.controller_regs + SABRE_IOMMU_FLUSH; 966 iommu->iommu_flush = pbm->controller_regs + SABRE_IOMMU_FLUSH;
958 iommu->write_complete_reg = p->pbm_A.controller_regs + SABRE_WRSYNC; 967 iommu->write_complete_reg = pbm->controller_regs + SABRE_WRSYNC;
959 /* Sabre's IOMMU lacks ctx flushing. */ 968 /* Sabre's IOMMU lacks ctx flushing. */
960 iommu->iommu_ctxflush = 0; 969 iommu->iommu_ctxflush = 0;
961 970
962 /* Invalidate TLB Entries. */ 971 /* Invalidate TLB Entries. */
963 control = sabre_read(p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL); 972 control = sabre_read(pbm->controller_regs + SABRE_IOMMU_CONTROL);
964 control |= SABRE_IOMMUCTRL_DENAB; 973 control |= SABRE_IOMMUCTRL_DENAB;
965 sabre_write(p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL, control); 974 sabre_write(pbm->controller_regs + SABRE_IOMMU_CONTROL, control);
966 975
967 for(i = 0; i < 16; i++) { 976 for(i = 0; i < 16; i++) {
968 sabre_write(p->pbm_A.controller_regs + SABRE_IOMMU_TAG + (i * 8UL), 0); 977 sabre_write(pbm->controller_regs + SABRE_IOMMU_TAG + (i * 8UL), 0);
969 sabre_write(p->pbm_A.controller_regs + SABRE_IOMMU_DATA + (i * 8UL), 0); 978 sabre_write(pbm->controller_regs + SABRE_IOMMU_DATA + (i * 8UL), 0);
970 } 979 }
971 980
972 /* Leave diag mode enabled for full-flushing done 981 /* Leave diag mode enabled for full-flushing done
@@ -974,10 +983,10 @@ static void sabre_iommu_init(struct pci_controller_info *p,
974 */ 983 */
975 pci_iommu_table_init(iommu, tsbsize * 1024 * 8, dvma_offset, dma_mask); 984 pci_iommu_table_init(iommu, tsbsize * 1024 * 8, dvma_offset, dma_mask);
976 985
977 sabre_write(p->pbm_A.controller_regs + SABRE_IOMMU_TSBBASE, 986 sabre_write(pbm->controller_regs + SABRE_IOMMU_TSBBASE,
978 __pa(iommu->page_table)); 987 __pa(iommu->page_table));
979 988
980 control = sabre_read(p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL); 989 control = sabre_read(pbm->controller_regs + SABRE_IOMMU_CONTROL);
981 control &= ~(SABRE_IOMMUCTRL_TSBSZ | SABRE_IOMMUCTRL_TBWSZ); 990 control &= ~(SABRE_IOMMUCTRL_TSBSZ | SABRE_IOMMUCTRL_TBWSZ);
982 control |= SABRE_IOMMUCTRL_ENAB; 991 control |= SABRE_IOMMUCTRL_ENAB;
983 switch(tsbsize) { 992 switch(tsbsize) {
@@ -992,22 +1001,23 @@ static void sabre_iommu_init(struct pci_controller_info *p,
992 prom_halt(); 1001 prom_halt();
993 break; 1002 break;
994 } 1003 }
995 sabre_write(p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL, control); 1004 sabre_write(pbm->controller_regs + SABRE_IOMMU_CONTROL, control);
996} 1005}
997 1006
998static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp) 1007static void sabre_pbm_init(struct pci_controller_info *p, struct pci_pbm_info *pbm, struct device_node *dp)
999{ 1008{
1000 struct pci_pbm_info *pbm;
1001
1002 pbm = &p->pbm_A;
1003 pbm->name = dp->full_name; 1009 pbm->name = dp->full_name;
1004 printk("%s: SABRE PCI Bus Module\n", pbm->name); 1010 printk("%s: SABRE PCI Bus Module\n", pbm->name);
1005 1011
1012 pbm->scan_bus = sabre_scan_bus;
1013 pbm->pci_ops = &sabre_ops;
1014
1015 pbm->index = pci_num_pbms++;
1016
1006 pbm->chip_type = PBM_CHIP_TYPE_SABRE; 1017 pbm->chip_type = PBM_CHIP_TYPE_SABRE;
1007 pbm->parent = p; 1018 pbm->parent = p;
1008 pbm->prom_node = dp; 1019 pbm->prom_node = dp;
1009 pbm->pci_first_busno = p->pci_first_busno; 1020 pci_get_pbm_props(pbm);
1010 pbm->pci_last_busno = p->pci_last_busno;
1011 1021
1012 pci_determine_mem_io_space(pbm); 1022 pci_determine_mem_io_space(pbm);
1013} 1023}
@@ -1016,9 +1026,9 @@ void sabre_init(struct device_node *dp, char *model_name)
1016{ 1026{
1017 const struct linux_prom64_registers *pr_regs; 1027 const struct linux_prom64_registers *pr_regs;
1018 struct pci_controller_info *p; 1028 struct pci_controller_info *p;
1029 struct pci_pbm_info *pbm;
1019 struct iommu *iommu; 1030 struct iommu *iommu;
1020 int tsbsize; 1031 int tsbsize;
1021 const u32 *busrange;
1022 const u32 *vdma; 1032 const u32 *vdma;
1023 u32 upa_portid, dma_mask; 1033 u32 upa_portid, dma_mask;
1024 u64 clear_irq; 1034 u64 clear_irq;
@@ -1053,17 +1063,15 @@ void sabre_init(struct device_node *dp, char *model_name)
1053 prom_printf("SABRE: Error, kmalloc(pci_iommu) failed.\n"); 1063 prom_printf("SABRE: Error, kmalloc(pci_iommu) failed.\n");
1054 prom_halt(); 1064 prom_halt();
1055 } 1065 }
1056 p->pbm_A.iommu = iommu; 1066 pbm = &p->pbm_A;
1067 pbm->iommu = iommu;
1057 1068
1058 upa_portid = of_getintprop_default(dp, "upa-portid", 0xff); 1069 upa_portid = of_getintprop_default(dp, "upa-portid", 0xff);
1059 1070
1060 p->next = pci_controller_root; 1071 pbm->next = pci_pbm_root;
1061 pci_controller_root = p; 1072 pci_pbm_root = pbm;
1062 1073
1063 p->pbm_A.portid = upa_portid; 1074 pbm->portid = upa_portid;
1064 p->index = pci_num_controllers++;
1065 p->scan_bus = sabre_scan_bus;
1066 p->pci_ops = &sabre_ops;
1067 1075
1068 /* 1076 /*
1069 * Map in SABRE register set and report the presence of this SABRE. 1077 * Map in SABRE register set and report the presence of this SABRE.
@@ -1074,26 +1082,26 @@ void sabre_init(struct device_node *dp, char *model_name)
1074 /* 1082 /*
1075 * First REG in property is base of entire SABRE register space. 1083 * First REG in property is base of entire SABRE register space.
1076 */ 1084 */
1077 p->pbm_A.controller_regs = pr_regs[0].phys_addr; 1085 pbm->controller_regs = pr_regs[0].phys_addr;
1078 1086
1079 /* Clear interrupts */ 1087 /* Clear interrupts */
1080 1088
1081 /* PCI first */ 1089 /* PCI first */
1082 for (clear_irq = SABRE_ICLR_A_SLOT0; clear_irq < SABRE_ICLR_B_SLOT0 + 0x80; clear_irq += 8) 1090 for (clear_irq = SABRE_ICLR_A_SLOT0; clear_irq < SABRE_ICLR_B_SLOT0 + 0x80; clear_irq += 8)
1083 sabre_write(p->pbm_A.controller_regs + clear_irq, 0x0UL); 1091 sabre_write(pbm->controller_regs + clear_irq, 0x0UL);
1084 1092
1085 /* Then OBIO */ 1093 /* Then OBIO */
1086 for (clear_irq = SABRE_ICLR_SCSI; clear_irq < SABRE_ICLR_SCSI + 0x80; clear_irq += 8) 1094 for (clear_irq = SABRE_ICLR_SCSI; clear_irq < SABRE_ICLR_SCSI + 0x80; clear_irq += 8)
1087 sabre_write(p->pbm_A.controller_regs + clear_irq, 0x0UL); 1095 sabre_write(pbm->controller_regs + clear_irq, 0x0UL);
1088 1096
1089 /* Error interrupts are enabled later after the bus scan. */ 1097 /* Error interrupts are enabled later after the bus scan. */
1090 sabre_write(p->pbm_A.controller_regs + SABRE_PCICTRL, 1098 sabre_write(pbm->controller_regs + SABRE_PCICTRL,
1091 (SABRE_PCICTRL_MRLEN | SABRE_PCICTRL_SERR | 1099 (SABRE_PCICTRL_MRLEN | SABRE_PCICTRL_SERR |
1092 SABRE_PCICTRL_ARBPARK | SABRE_PCICTRL_AEN)); 1100 SABRE_PCICTRL_ARBPARK | SABRE_PCICTRL_AEN));
1093 1101
1094 /* Now map in PCI config space for entire SABRE. */ 1102 /* Now map in PCI config space for entire SABRE. */
1095 p->pbm_A.config_space = 1103 pbm->config_space =
1096 (p->pbm_A.controller_regs + SABRE_CONFIGSPACE); 1104 (pbm->controller_regs + SABRE_CONFIGSPACE);
1097 1105
1098 vdma = of_get_property(dp, "virtual-dma", NULL); 1106 vdma = of_get_property(dp, "virtual-dma", NULL);
1099 1107
@@ -1117,14 +1125,10 @@ void sabre_init(struct device_node *dp, char *model_name)
1117 prom_halt(); 1125 prom_halt();
1118 } 1126 }
1119 1127
1120 sabre_iommu_init(p, tsbsize, vdma[0], dma_mask); 1128 sabre_iommu_init(pbm, tsbsize, vdma[0], dma_mask);
1121
1122 busrange = of_get_property(dp, "bus-range", NULL);
1123 p->pci_first_busno = busrange[0];
1124 p->pci_last_busno = busrange[1];
1125 1129
1126 /* 1130 /*
1127 * Look for APB underneath. 1131 * Look for APB underneath.
1128 */ 1132 */
1129 sabre_pbm_init(p, dp); 1133 sabre_pbm_init(p, pbm, dp);
1130} 1134}