Merge tag 'rproc-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc...
[linux.git] / arch / hexagon / kernel / dma.c
blob882680e81a30fea3901b6af48c1600a5f56ac99c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * DMA implementation for Hexagon
5 * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
6 */
8 #include <linux/dma-map-ops.h>
9 #include <linux/memblock.h>
10 #include <asm/page.h>
12 void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
13 enum dma_data_direction dir)
15 void *addr = phys_to_virt(paddr);
17 switch (dir) {
18 case DMA_TO_DEVICE:
19 hexagon_clean_dcache_range((unsigned long) addr,
20 (unsigned long) addr + size);
21 break;
22 case DMA_FROM_DEVICE:
23 hexagon_inv_dcache_range((unsigned long) addr,
24 (unsigned long) addr + size);
25 break;
26 case DMA_BIDIRECTIONAL:
27 flush_dcache_range((unsigned long) addr,
28 (unsigned long) addr + size);
29 break;
30 default:
31 BUG();
36 * Our max_low_pfn should have been backed off by 16MB in mm/init.c to create
37 * DMA coherent space. Use that for the pool.
39 static int __init hexagon_dma_init(void)
41 return dma_init_global_coherent(PFN_PHYS(max_low_pfn),
42 hexagon_coherent_pool_size);
44 core_initcall(hexagon_dma_init);