diff options
author | David S. Miller <davem@davemloft.net> | 2008-09-10 06:07:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-09-11 02:11:56 -0400 |
commit | a21cff3e5e39c087b5a4c5efb20f1744475c556e (patch) | |
tree | 1438e43c4d7b2d4042f074afc887fe2e7c30e7ad /arch/sparc64/kernel/pci_sabre.c | |
parent | 22fecbae4446ad470b9237ee9b79f80f343b3838 (diff) |
sparc64: Start commonizing code common between SABRE and PSYCHO.
These are very similar chips, in fact they are identical in some
macro blocks.
So start commonizing code which they can share. We begin with
the IOMMU initialization sequence.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/pci_sabre.c')
-rw-r--r-- | arch/sparc64/kernel/pci_sabre.c | 63 |
1 files changed, 2 insertions, 61 deletions
diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c index 196049bb14b2..a3a276de75ab 100644 --- a/arch/sparc64/kernel/pci_sabre.c +++ b/arch/sparc64/kernel/pci_sabre.c | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include "pci_impl.h" | 21 | #include "pci_impl.h" |
22 | #include "iommu_common.h" | 22 | #include "iommu_common.h" |
23 | #include "psycho_common.h" | ||
23 | 24 | ||
24 | #define DRIVER_NAME "sabre" | 25 | #define DRIVER_NAME "sabre" |
25 | #define PFX DRIVER_NAME ": " | 26 | #define PFX DRIVER_NAME ": " |
@@ -674,66 +675,6 @@ static void __init sabre_scan_bus(struct pci_pbm_info *pbm, | |||
674 | sabre_register_error_handlers(pbm); | 675 | sabre_register_error_handlers(pbm); |
675 | } | 676 | } |
676 | 677 | ||
677 | static int sabre_iommu_init(struct pci_pbm_info *pbm, | ||
678 | int tsbsize, unsigned long dvma_offset, | ||
679 | u32 dma_mask) | ||
680 | { | ||
681 | struct iommu *iommu = pbm->iommu; | ||
682 | unsigned long i; | ||
683 | u64 control; | ||
684 | int err; | ||
685 | |||
686 | /* Register addresses. */ | ||
687 | iommu->iommu_control = pbm->controller_regs + SABRE_IOMMU_CONTROL; | ||
688 | iommu->iommu_tsbbase = pbm->controller_regs + SABRE_IOMMU_TSBBASE; | ||
689 | iommu->iommu_flush = pbm->controller_regs + SABRE_IOMMU_FLUSH; | ||
690 | iommu->iommu_tags = iommu->iommu_flush + (0xa580UL - 0x0210UL); | ||
691 | iommu->write_complete_reg = pbm->controller_regs + SABRE_WRSYNC; | ||
692 | /* Sabre's IOMMU lacks ctx flushing. */ | ||
693 | iommu->iommu_ctxflush = 0; | ||
694 | |||
695 | /* Invalidate TLB Entries. */ | ||
696 | control = sabre_read(pbm->controller_regs + SABRE_IOMMU_CONTROL); | ||
697 | control |= SABRE_IOMMUCTRL_DENAB; | ||
698 | sabre_write(pbm->controller_regs + SABRE_IOMMU_CONTROL, control); | ||
699 | |||
700 | for(i = 0; i < 16; i++) { | ||
701 | sabre_write(pbm->controller_regs + SABRE_IOMMU_TAG + (i * 8UL), 0); | ||
702 | sabre_write(pbm->controller_regs + SABRE_IOMMU_DATA + (i * 8UL), 0); | ||
703 | } | ||
704 | |||
705 | /* Leave diag mode enabled for full-flushing done | ||
706 | * in pci_iommu.c | ||
707 | */ | ||
708 | err = iommu_table_init(iommu, tsbsize * 1024 * 8, | ||
709 | dvma_offset, dma_mask, pbm->numa_node); | ||
710 | if (err) { | ||
711 | printk(KERN_ERR PFX "iommu_table_init() failed\n"); | ||
712 | return err; | ||
713 | } | ||
714 | |||
715 | sabre_write(pbm->controller_regs + SABRE_IOMMU_TSBBASE, | ||
716 | __pa(iommu->page_table)); | ||
717 | |||
718 | control = sabre_read(pbm->controller_regs + SABRE_IOMMU_CONTROL); | ||
719 | control &= ~(SABRE_IOMMUCTRL_TSBSZ | SABRE_IOMMUCTRL_TBWSZ); | ||
720 | control |= SABRE_IOMMUCTRL_ENAB; | ||
721 | switch(tsbsize) { | ||
722 | case 64: | ||
723 | control |= SABRE_IOMMU_TSBSZ_64K; | ||
724 | break; | ||
725 | case 128: | ||
726 | control |= SABRE_IOMMU_TSBSZ_128K; | ||
727 | break; | ||
728 | default: | ||
729 | printk(KERN_ERR PFX "Illegal TSB size %d\n", tsbsize); | ||
730 | return -EINVAL; | ||
731 | } | ||
732 | sabre_write(pbm->controller_regs + SABRE_IOMMU_CONTROL, control); | ||
733 | |||
734 | return 0; | ||
735 | } | ||
736 | |||
737 | static void __init sabre_pbm_init(struct pci_pbm_info *pbm, | 678 | static void __init sabre_pbm_init(struct pci_pbm_info *pbm, |
738 | struct of_device *op) | 679 | struct of_device *op) |
739 | { | 680 | { |
@@ -862,7 +803,7 @@ static int __devinit sabre_probe(struct of_device *op, | |||
862 | goto out_free_iommu; | 803 | goto out_free_iommu; |
863 | } | 804 | } |
864 | 805 | ||
865 | err = sabre_iommu_init(pbm, tsbsize, vdma[0], dma_mask); | 806 | err = psycho_iommu_init(pbm, tsbsize, vdma[0], dma_mask, SABRE_WRSYNC); |
866 | if (err) | 807 | if (err) |
867 | goto out_free_iommu; | 808 | goto out_free_iommu; |
868 | 809 | ||