Linux 6.13-rc4
[linux.git] / arch / sh / kernel / dma-coherent.c
blob6a44c0e7ba40eff1101877ed75d3e7fff19b2c1c
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>
10 void arch_dma_prep_coherent(struct page *page, size_t size)
12 __flush_purge_region(page_address(page), size);
15 void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
16 enum dma_data_direction dir)
18 void *addr = sh_cacheop_vaddr(phys_to_virt(paddr));
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();