sparc32: Update defconfig.
[safe/jmp/linux-2.6] / arch / sparc / mm / io-unit.c
index 0f97ab3..005e758 100644 (file)
 #include <linux/highmem.h>     /* pte_offset_map => kmap_atomic */
 #include <linux/bitops.h>
 #include <linux/scatterlist.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
-#include <asm/sbus.h>
 #include <asm/io.h>
 #include <asm/io-unit.h>
 #include <asm/mxcc.h>
 #define IOPERM        (IOUPTE_CACHE | IOUPTE_WRITE | IOUPTE_VALID)
 #define MKIOPTE(phys) __iopte((((phys)>>4) & IOUPTE_PAGE) | IOPERM)
 
-void __init iounit_init(struct sbus_bus *sbus)
+static void __init iounit_iommu_init(struct of_device *op)
 {
-       struct device_node *dp = sbus->ofdev.node;
        struct iounit_struct *iounit;
        iopte_t *xpt, *xptend;
-       struct of_device *op;
-
-       op = of_find_device_by_node(dp);
-       if (!op) {
-               prom_printf("SUN4D: Cannot find SBI of_device.\n");
-               prom_halt();
-       }
 
        iounit = kzalloc(sizeof(struct iounit_struct), GFP_ATOMIC);
        if (!iounit) {
@@ -66,7 +59,6 @@ void __init iounit_init(struct sbus_bus *sbus)
                prom_halt();
        }
        
-       sbus->ofdev.dev.archdata.iommu = iounit;
        op->dev.archdata.iommu = iounit;
        iounit->page_table = xpt;
        spin_lock_init(&iounit->lock);
@@ -76,6 +68,25 @@ void __init iounit_init(struct sbus_bus *sbus)
                iopte_val(*xpt++) = 0;
 }
 
+static int __init iounit_init(void)
+{
+       extern void sun4d_init_sbi_irq(void);
+       struct device_node *dp;
+
+       for_each_node_by_name(dp, "sbi") {
+               struct of_device *op = of_find_device_by_node(dp);
+
+               iounit_iommu_init(op);
+               of_propagate_archdata(op);
+       }
+
+       sun4d_init_sbi_irq();
+
+       return 0;
+}
+
+subsys_initcall(iounit_init);
+
 /* One has to hold iounit->lock to call this */
 static unsigned long iounit_get_area(struct iounit_struct *iounit, unsigned long vaddr, int size)
 {
@@ -145,8 +156,8 @@ static void iounit_get_scsi_sgl(struct device *dev, struct scatterlist *sg, int
        spin_lock_irqsave(&iounit->lock, flags);
        while (sz != 0) {
                --sz;
-               sg->dvma_address = iounit_get_area(iounit, (unsigned long) sg_virt(sg), sg->length);
-               sg->dvma_length = sg->length;
+               sg->dma_address = iounit_get_area(iounit, (unsigned long) sg_virt(sg), sg->length);
+               sg->dma_length = sg->length;
                sg = sg_next(sg);
        }
        spin_unlock_irqrestore(&iounit->lock, flags);
@@ -175,8 +186,8 @@ static void iounit_release_scsi_sgl(struct device *dev, struct scatterlist *sg,
        spin_lock_irqsave(&iounit->lock, flags);
        while (sz != 0) {
                --sz;
-               len = ((sg->dvma_address & ~PAGE_MASK) + sg->length + (PAGE_SIZE-1)) >> PAGE_SHIFT;
-               vaddr = (sg->dvma_address - IOUNIT_DMA_BASE) >> PAGE_SHIFT;
+               len = ((sg->dma_address & ~PAGE_MASK) + sg->length + (PAGE_SIZE-1)) >> PAGE_SHIFT;
+               vaddr = (sg->dma_address - IOUNIT_DMA_BASE) >> PAGE_SHIFT;
                IOD(("iounit_release %08lx-%08lx\n", (long)vaddr, (long)len+vaddr));
                for (len += vaddr; vaddr < len; vaddr++)
                        clear_bit(vaddr, iounit->bmap);
@@ -257,51 +268,3 @@ void __init ld_mmu_iounit(void)
        BTFIXUPSET_CALL(mmu_unmap_dma_area, iounit_unmap_dma_area, BTFIXUPCALL_NORM);
 #endif
 }
-
-__u32 iounit_map_dma_init(struct sbus_bus *sbus, int size)
-{
-       int i, j, k, npages;
-       unsigned long rotor, scan, limit;
-       unsigned long flags;
-       __u32 ret;
-       struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
-
-        npages = (size + (PAGE_SIZE-1)) >> PAGE_SHIFT;
-       i = 0x0213;
-       spin_lock_irqsave(&iounit->lock, flags);
-next:  j = (i & 15);
-       rotor = iounit->rotor[j - 1];
-       limit = iounit->limit[j];
-       scan = rotor;
-nexti: scan = find_next_zero_bit(iounit->bmap, limit, scan);
-       if (scan + npages > limit) {
-               if (limit != rotor) {
-                       limit = rotor;
-                       scan = iounit->limit[j - 1];
-                       goto nexti;
-               }
-               i >>= 4;
-               if (!(i & 15))
-                       panic("iounit_map_dma_init: Couldn't find free iopte slots for %d bytes\n", size);
-               goto next;
-       }
-       for (k = 1, scan++; k < npages; k++)
-               if (test_bit(scan++, iounit->bmap))
-                       goto nexti;
-       iounit->rotor[j - 1] = (scan < limit) ? scan : iounit->limit[j - 1];
-       scan -= npages;
-       ret = IOUNIT_DMA_BASE + (scan << PAGE_SHIFT);
-       for (k = 0; k < npages; k++, scan++)
-               set_bit(scan, iounit->bmap);
-       spin_unlock_irqrestore(&iounit->lock, flags);
-       return ret;
-}
-
-__u32 iounit_map_dma_page(__u32 vaddr, void *addr, struct sbus_bus *sbus)
-{
-       int scan = (vaddr - IOUNIT_DMA_BASE) >> PAGE_SHIFT;
-       struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
-       
-       iounit->page_table[scan] = MKIOPTE(__pa(((unsigned long)addr) & PAGE_MASK));
-       return vaddr + (((unsigned long)addr) & ~PAGE_MASK);
-}