Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/agpgart
[sfrench/cifs-2.6.git] / arch / powerpc / platforms / cell / iommu.c
index 46e7cb9c3e648ec0fc7cde3b19f30406728b8b75..aca4c3db0dde3431b3ff96eb0567442641a42f65 100644 (file)
@@ -289,7 +289,7 @@ static void cell_do_map_iommu(struct cell_iommu *iommu,
        ioc_base = iommu->mapped_base;
        ioc_mmio_base = iommu->mapped_mmio_base;
 
-       for (real_address = 0, io_address = 0;
+       for (real_address = 0, io_address = map_start;
             io_address <= map_start + map_size;
             real_address += io_page_size, io_address += io_page_size) {
                ioste = get_iost_entry(fake_iopt, io_address, io_page_size);
@@ -302,21 +302,22 @@ static void cell_do_map_iommu(struct cell_iommu *iommu,
                set_iopt_cache(ioc_mmio_base,
                        get_ioc_hash_1way(ioste, io_address),
                        get_ioc_tag(ioste, io_address),
-                       get_iopt_entry(real_address-map_start, ioid, IOPT_PROT_RW));
+                       get_iopt_entry(real_address, ioid, IOPT_PROT_RW));
        }
 }
 
 static void iommu_devnode_setup(struct device_node *d)
 {
-       unsigned int *ioid;
-       unsigned long *dma_window, map_start, map_size, token;
+       const unsigned int *ioid;
+       unsigned long map_start, map_size, token;
+       const unsigned long *dma_window;
        struct cell_iommu *iommu;
 
-       ioid = (unsigned int *)get_property(d, "ioid", NULL);
+       ioid = get_property(d, "ioid", NULL);
        if (!ioid)
                pr_debug("No ioid entry found !\n");
 
-       dma_window = (unsigned long *)get_property(d, "ibm,dma-window", NULL);
+       dma_window = get_property(d, "ibm,dma-window", NULL);
        if (!dma_window)
                pr_debug("No ibm,dma-window entry found !\n");
 
@@ -344,8 +345,8 @@ static int cell_map_iommu_hardcoded(int num_nodes)
 
        /* node 0 */
        iommu = &cell_iommus[0];
-       iommu->mapped_base = __ioremap(0x20000511000, 0x1000, _PAGE_NO_CACHE);
-       iommu->mapped_mmio_base = __ioremap(0x20000510000, 0x1000, _PAGE_NO_CACHE);
+       iommu->mapped_base = ioremap(0x20000511000ul, 0x1000);
+       iommu->mapped_mmio_base = ioremap(0x20000510000ul, 0x1000);
 
        enable_mapping(iommu->mapped_base, iommu->mapped_mmio_base);
 
@@ -357,8 +358,8 @@ static int cell_map_iommu_hardcoded(int num_nodes)
 
        /* node 1 */
        iommu = &cell_iommus[1];
-       iommu->mapped_base = __ioremap(0x30000511000, 0x1000, _PAGE_NO_CACHE);
-       iommu->mapped_mmio_base = __ioremap(0x30000510000, 0x1000, _PAGE_NO_CACHE);
+       iommu->mapped_base = ioremap(0x30000511000ul, 0x1000);
+       iommu->mapped_mmio_base = ioremap(0x30000510000ul, 0x1000);
 
        enable_mapping(iommu->mapped_base, iommu->mapped_mmio_base);
 
@@ -371,8 +372,9 @@ static int cell_map_iommu_hardcoded(int num_nodes)
 
 static int cell_map_iommu(void)
 {
-       unsigned int num_nodes = 0, *node_id;
-       unsigned long *base, *mmio_base;
+       unsigned int num_nodes = 0;
+       const unsigned int *node_id;
+       const unsigned long *base, *mmio_base;
        struct device_node *dn;
        struct cell_iommu *iommu = NULL;
 
@@ -381,7 +383,7 @@ static int cell_map_iommu(void)
        for(dn = of_find_node_by_type(NULL, "cpu");
            dn;
            dn = of_find_node_by_type(dn, "cpu")) {
-               node_id = (unsigned int *)get_property(dn, "node-id", NULL);
+               node_id = get_property(dn, "node-id", NULL);
 
                if (num_nodes < *node_id)
                        num_nodes = *node_id;
@@ -396,9 +398,9 @@ static int cell_map_iommu(void)
            dn;
            dn = of_find_node_by_type(dn, "cpu")) {
 
-               node_id = (unsigned int *)get_property(dn, "node-id", NULL);
-               base = (unsigned long *)get_property(dn, "ioc-cache", NULL);
-               mmio_base = (unsigned long *)get_property(dn, "ioc-translation", NULL);
+               node_id = get_property(dn, "node-id", NULL);
+               base = get_property(dn, "ioc-cache", NULL);
+               mmio_base = get_property(dn, "ioc-translation", NULL);
 
                if (!base || !mmio_base || !node_id)
                        return cell_map_iommu_hardcoded(num_nodes);
@@ -407,8 +409,8 @@ static int cell_map_iommu(void)
                iommu->base = *base;
                iommu->mmio_base = *mmio_base;
 
-               iommu->mapped_base = __ioremap(*base, 0x1000, _PAGE_NO_CACHE);
-               iommu->mapped_mmio_base = __ioremap(*mmio_base, 0x1000, _PAGE_NO_CACHE);
+               iommu->mapped_base = ioremap(*base, 0x1000);
+               iommu->mapped_mmio_base = ioremap(*mmio_base, 0x1000);
 
                enable_mapping(iommu->mapped_base,
                               iommu->mapped_mmio_base);
@@ -473,6 +475,16 @@ static int cell_dma_supported(struct device *dev, u64 mask)
        return mask < 0x100000000ull;
 }
 
+static struct dma_mapping_ops cell_iommu_ops = {
+       .alloc_coherent = cell_alloc_coherent,
+       .free_coherent = cell_free_coherent,
+       .map_single = cell_map_single,
+       .unmap_single = cell_unmap_single,
+       .map_sg = cell_map_sg,
+       .unmap_sg = cell_unmap_sg,
+       .dma_supported = cell_dma_supported,
+};
+
 void cell_init_iommu(void)
 {
        int setup_bus = 0;
@@ -498,11 +510,5 @@ void cell_init_iommu(void)
                }
        }
 
-       pci_dma_ops.alloc_coherent = cell_alloc_coherent;
-       pci_dma_ops.free_coherent = cell_free_coherent;
-       pci_dma_ops.map_single = cell_map_single;
-       pci_dma_ops.unmap_single = cell_unmap_single;
-       pci_dma_ops.map_sg = cell_map_sg;
-       pci_dma_ops.unmap_sg = cell_unmap_sg;
-       pci_dma_ops.dma_supported = cell_dma_supported;
+       pci_dma_ops = cell_iommu_ops;
 }