xref: /OK3568_Linux_fs/kernel/include/linux/sram_heap.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * SRAM DMA-Heap exporter && support alloc page and dmabuf on kernel
4  *
5  * Copyright (C) Rockchip Electronics Co., Ltd.
6  *
7  * Author: Huang Lee <Putin.li@rock-chips.com>
8  */
9 #ifndef _LINUX_SRAM_HEAP_H
10 #define _LINUX_SRAM_HEAP_H
11 
12 #include <linux/types.h>
13 #include <linux/dma-buf.h>
14 #include <linux/mm.h>
15 
16 #if IS_REACHABLE(CONFIG_DMABUF_HEAPS_SRAM)
17 struct dma_buf *sram_heap_alloc_dma_buf(size_t size);
18 struct page *sram_heap_alloc_pages(size_t size);
19 void sram_heap_free_pages(struct page *p);
20 void sram_heap_free_dma_buf(struct dma_buf *dmabuf);
21 void *sram_heap_get_vaddr(struct dma_buf *dmabuf);
22 phys_addr_t sram_heap_get_paddr(struct dma_buf *dmabuf);
23 
24 #else
sram_heap_alloc_dma_buf(size_t size)25 static inline struct dma_buf *sram_heap_alloc_dma_buf(size_t size)
26 {
27 	return NULL;
28 }
29 
sram_heap_alloc_pages(size_t size)30 static inline struct page *sram_heap_alloc_pages(size_t size)
31 {
32 	return NULL;
33 }
34 
sram_heap_free_pages(struct page * p)35 static inline void sram_heap_free_pages(struct page *p) {}
sram_heap_free_dma_buf(struct dma_buf * dmabuf)36 static inline void sram_heap_free_dma_buf(struct dma_buf *dmabuf) {}
37 
sram_heap_get_vaddr(struct dma_buf * dmabuf)38 static inline void *sram_heap_get_vaddr(struct dma_buf *dmabuf)
39 {
40 	return NULL;
41 }
42 
sram_heap_get_paddr(struct dma_buf * dmabuf)43 static inline phys_addr_t sram_heap_get_paddr(struct dma_buf *dmabuf)
44 {
45 	return 0;
46 }
47 #endif
48 
49 #endif
50