16 #include <linux/export.h>
18 #include <linux/types.h>
22 #include <asm/bootinfo.h>
49 if (paddr >= 0x410000000ull && paddr < 0x420000000ull)
50 paddr -= 0x400000000ull;
51 return octeon_hole_phys_to_dma(paddr);
56 daddr = octeon_hole_dma_to_phys(daddr);
58 if (daddr >= 0x10000000ull && daddr < 0x20000000ull)
59 daddr += 0x400000000ull;
66 return octeon_hole_phys_to_dma(paddr);
71 return octeon_hole_dma_to_phys(daddr);
76 if (paddr >= 0x410000000ull && paddr < 0x420000000ull)
77 paddr -= 0x400000000ull;
80 if (paddr >= 0xf0000000ull)
91 if (daddr >= 0x10000000ull && daddr < 0x20000000ull)
92 daddr += 0x400000000ull;
99 if (paddr >= 0x410000000ull && paddr < 0x420000000ull)
100 paddr -= 0x400000000ull;
119 if (daddr >= 0x10000000ull && daddr < 0x20000000ull)
120 daddr += 0x400000000ull;
145 static void octeon_dma_sync_single_for_device(
struct device *dev,
152 static void octeon_dma_sync_sg_for_device(
struct device *dev,
159 static void *octeon_dma_alloc_coherent(
struct device *dev,
size_t size,
170 #ifdef CONFIG_ZONE_DMA
177 #ifdef CONFIG_ZONE_DMA32
194 static void octeon_dma_free_coherent(
struct device *dev,
size_t size,
243 .alloc = octeon_dma_alloc_coherent,
244 .free = octeon_dma_free_coherent,
245 .map_page = octeon_dma_map_page,
247 .map_sg = octeon_dma_map_sg,
250 .sync_single_for_device = octeon_dma_sync_single_for_device,
252 .sync_sg_for_device = octeon_dma_sync_sg_for_device,
256 .phys_to_dma = octeon_unity_phys_to_dma,
257 .dma_to_phys = octeon_unity_dma_to_phys
268 unsigned long swiotlb_nslabs;
282 addr_size += e->size;
284 if (max_addr < e->
addr + e->size)
285 max_addr = e->addr + e->size;
298 swiotlbsize = addr_size / 4;
299 if (swiotlbsize > 64 * (1<<20))
300 swiotlbsize = 64 * (1<<20);
301 }
else if (max_addr > 0xf0000000ul) {
306 swiotlbsize = 64 * (1<<20);
309 #ifdef CONFIG_USB_OCTEON_OHCI
312 swiotlbsize = 64 * (1<<20);
328 .alloc = octeon_dma_alloc_coherent,
329 .free = octeon_dma_free_coherent,
330 .map_page = octeon_dma_map_page,
332 .map_sg = octeon_dma_map_sg,
335 .sync_single_for_device = octeon_dma_sync_single_for_device,
337 .sync_sg_for_device = octeon_dma_sync_sg_for_device,
349 _octeon_pci_dma_map_ops.
phys_to_dma = octeon_gen2_phys_to_dma;
350 _octeon_pci_dma_map_ops.
dma_to_phys = octeon_gen2_dma_to_phys;
353 _octeon_pci_dma_map_ops.
phys_to_dma = octeon_gen1_phys_to_dma;
354 _octeon_pci_dma_map_ops.
dma_to_phys = octeon_gen1_dma_to_phys;
357 _octeon_pci_dma_map_ops.
phys_to_dma = octeon_big_phys_to_dma;
358 _octeon_pci_dma_map_ops.
dma_to_phys = octeon_big_dma_to_phys;
361 _octeon_pci_dma_map_ops.
phys_to_dma = octeon_small_phys_to_dma;
362 _octeon_pci_dma_map_ops.
dma_to_phys = octeon_small_dma_to_phys;
367 octeon_pci_dma_map_ops = &_octeon_pci_dma_map_ops.
dma_map_ops;