24 #include <asm/dma-mapping.h>
25 #include <linux/module.h>
52 static struct gen_pool *coherent_pool;
57 static void *hexagon_dma_alloc_coherent(
struct device *
dev,
size_t size,
63 if (coherent_pool ==
NULL) {
66 if (coherent_pool ==
NULL)
67 panic(
"Can't create %s() memory pool!", __func__);
69 gen_pool_add(coherent_pool,
85 static void hexagon_free_coherent(
struct device *dev,
size_t size,
void *
vaddr,
91 static int check_addr(
const char *
name,
struct device *hwdev,
97 "%s: overflow %Lx+%zu of device mask %Lx\n",
98 name, (
long long)bus, size,
119 s->dma_length = s->
length;
131 static inline void dma_sync(
void *
addr,
size_t size,
137 (
unsigned long) addr + size);
141 (
unsigned long) addr + size);
145 (
unsigned long) addr + size);
152 static inline void *dma_addr_to_virt(
dma_addr_t dma_addr)
177 unsigned long offset,
size_t size,
184 if (!check_addr(
"map_single", dev, bus, size))
187 dma_sync(dma_addr_to_virt(bus), size, dir);
192 static void hexagon_sync_single_for_cpu(
struct device *dev,
196 dma_sync(dma_addr_to_virt(dma_handle), size, dir);
199 static void hexagon_sync_single_for_device(
struct device *dev,
203 dma_sync(dma_addr_to_virt(dma_handle), size, dir);
207 .alloc = hexagon_dma_alloc_coherent,
208 .free = hexagon_free_coherent,
209 .map_sg = hexagon_map_sg,
210 .map_page = hexagon_map_page,
211 .sync_single_for_cpu = hexagon_sync_single_for_cpu,
212 .sync_single_for_device = hexagon_sync_single_for_device,