23 #include <linux/types.h>
25 #include <linux/pci.h>
26 #include <asm/iommu.h>
27 #include <asm/machdep.h>
30 #define IOBMAP_PAGE_SHIFT 12
31 #define IOBMAP_PAGE_SIZE (1 << IOBMAP_PAGE_SHIFT)
32 #define IOBMAP_PAGE_MASK (IOBMAP_PAGE_SIZE - 1)
34 #define IOB_BASE 0xe0000000
35 #define IOB_SIZE 0x3000
37 #define IOBCAP_REG 0x40
38 #define IOBCOM_REG 0x100
40 #define IOBCOM_ATEN 0x00000100
43 #define IOB_AD_REG 0x14c
45 #define IOB_AD_VGPRT 0x00000e00
46 #define IOB_AD_VGAEN 0x00000100
48 #define IOB_AD_MPSEL_MASK 0x00000030
49 #define IOB_AD_MPSEL_B38 0x00000000
50 #define IOB_AD_MPSEL_B40 0x00000010
51 #define IOB_AD_MPSEL_B42 0x00000020
53 #define IOB_AD_TRNG_MASK 0x00000003
54 #define IOB_AD_TRNG_256M 0x00000000
55 #define IOB_AD_TRNG_2G 0x00000001
56 #define IOB_AD_TRNG_128G 0x00000003
58 #define IOB_TABLEBASE_REG 0x154
61 #define IOB_XLT_L1_REGBASE 0x2b00
64 #define IOB_AT_INVAL_TLB_REG 0x2d00
67 #define IOBMAP_L1E_V 0x40000000
68 #define IOBMAP_L1E_V_B 0x80000000
71 #define IOBMAP_L1E_BIG_CACHED 0x00000002
72 #define IOBMAP_L1E_BIG_PRIORITY 0x00000001
75 #define IOBMAP_L2E_V 0x80000000
76 #define IOBMAP_L2E_V_CACHED 0xc0000000
79 static u32 iob_l1_emptyval;
80 static u32 iob_l2_emptyval;
81 static u32 *iob_l2_base;
84 static int iommu_table_iobmap_inited;
87 long npages,
unsigned long uaddr,
95 pr_debug(
"iobmap: build at: %lx, %lx, addr: %lx\n", index, npages, uaddr);
115 static void iobmap_free(
struct iommu_table *tbl,
long index,
119 unsigned long bus_addr;
121 pr_debug(
"iobmap: free at: %lx, %lx\n", index, npages);
128 *(ip++) = iob_l2_emptyval;
136 static void iommu_table_iobmap_setup(
void)
139 iommu_table_iobmap.it_busno = 0;
140 iommu_table_iobmap.it_offset = 0;
145 iommu_table_iobmap.it_base = (
unsigned long)iob_l2_base;
146 iommu_table_iobmap.it_index = 0;
150 iommu_table_iobmap.it_blocksize = 4;
157 static void pci_dma_bus_setup_pasemi(
struct pci_bus *
bus)
159 pr_debug(
"pci_dma_bus_setup, bus %p, bus->self %p\n", bus, bus->
self);
161 if (!iommu_table_iobmap_inited) {
162 iommu_table_iobmap_inited = 1;
163 iommu_table_iobmap_setup();
168 static void pci_dma_dev_setup_pasemi(
struct pci_dev *
dev)
170 pr_debug(
"pci_dma_dev_setup, dev %p (%s)\n", dev, pci_name(dev));
172 #if !defined(CONFIG_PPC_PASEMI_IOMMU_DMA_FORCE)
178 !firmware_has_feature(FW_FEATURE_LPAR)) {
184 set_iommu_table_base(&dev->
dev, &iommu_table_iobmap);
198 panic(
"IOBMAP: Cannot allocate spare page!");
206 panic(
"IOBMAP: Cannot map registers!");
209 for (i = 0; i < 64; i++) {
237 #ifndef CONFIG_PPC_PASEMI_IOMMU
248 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_pasemi;
249 ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_pasemi;
250 ppc_md.tce_build = iobmap_build;
251 ppc_md.tce_free = iobmap_free;
257 #ifndef CONFIG_PPC_PASEMI_IOMMU