1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (C) 2004 - 2007 Paul Mundt 4 */ 5 #include <linux/mm.h> 6 #include <linux/dma-map-ops.h> 7 #include <asm/cacheflush.h> 8 #include <asm/addrspace.h> 9 10 void arch_dma_prep_coherent(struct page *page, size_t size) 11 { 12 __flush_purge_region(page_address(page), size); 13 } 14 15 void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, 16 enum dma_data_direction dir) 17 { 18 void *addr = sh_cacheop_vaddr(phys_to_virt(paddr)); 19 20 switch (dir) { 21 case DMA_FROM_DEVICE: /* invalidate only */ 22 __flush_invalidate_region(addr, size); 23 break; 24 case DMA_TO_DEVICE: /* writeback only */ 25 __flush_wback_region(addr, size); 26 break; 27 case DMA_BIDIRECTIONAL: /* writeback and invalidate */ 28 __flush_purge_region(addr, size); 29 break; 30 default: 31 BUG(); 32 } 33 } 34