ion_sunxi.h 2.95 KB
Newer Older
Jens Kuske's avatar
Jens Kuske committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
 * include/linux/ion_sunxi.h
 *
 * Copyright(c) 2013-2015 Allwinnertech Co., Ltd.
 *      http://www.allwinnertech.com
 *
 * Author: liugang <liugang@allwinnertech.com>
 *
 * sunxi ion header file
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#ifndef __ION_SUNXI_H
#define __ION_SUNXI_H

#define ION_HEAP_TYPE_SUNXI_START (ION_HEAP_TYPE_CUSTOM + 1)
#define ION_HEAP_TYPE_SECURE	  (ION_HEAP_TYPE_SUNXI_START)

typedef struct {
	long 	start;
	long 	end;
}sunxi_cache_range;

typedef struct {
	void *handle;
	unsigned long phys_addr;
	unsigned long size;
}sunxi_phys_data;

#define DMA_BUF_MAXCNT 	8

typedef struct {
	unsigned int src_va;
	unsigned int src_pa;
	unsigned int dst_va;
	unsigned int dst_pa;
	unsigned int size;
}dma_buf_item;

typedef struct {
	int multi_dma;
	unsigned int cnt;
	dma_buf_item item[DMA_BUF_MAXCNT];
}dma_buf_group;

#define ION_IOC_SUNXI_FLUSH_RANGE           5
#define ION_IOC_SUNXI_FLUSH_ALL             6
#define ION_IOC_SUNXI_PHYS_ADDR             7
#define ION_IOC_SUNXI_DMA_COPY              8
#define ION_IOC_SUNXI_DUMP                  9

#ifdef __KERNEL__

int flush_clean_user_range(long start, long end);
int flush_user_range(long start, long end);
void flush_dcache_all(void);

/**
 * sunxi_buf_alloc - alloc phys contigous memory in SUNXI platform.
 * @size: size in bytes to allocate.
 * @paddr: store the start phys address allocated.
 *
 * return the start virtual address, or 0 if failed.
 */
void *sunxi_buf_alloc(unsigned int size, unsigned int *paddr);
/**
 * sunxi_buf_free - free buffer allocated by sunxi_buf_alloc.
 * @vaddr: the kernel virt addr of the area.
 * @paddr: the start phys addr of the area.
 * @size: size in bytes of the area.
 */
void sunxi_buf_free(void *vaddr, unsigned int paddr, unsigned int size);
/**
 * sunxi_alloc_phys - alloc phys contigous memory in SUNXI platform.
 * @size: size in bytes to allocate.
 *
 * return the start phys addr, or 0 if failed.
 */
u32 sunxi_alloc_phys(size_t size);
/**
 * sunxi_free_phys - free phys contigous memory allocted by sunxi_alloc_phys.
 * @paddr: the start phys addr of the area.
 * @size: size in bytes of the area.
 */
void sunxi_free_phys(u32 paddr, size_t size);
/**
 * sunxi_map_kernel - map phys contigous memory to kernel virtual space.
 * @paddr: the start phys addr of the area.
 * @size: size in bytes of the area.
 *
 * return the start virt addr which is in vmalloc space, or NULL if failed.
 */
void *sunxi_map_kernel(unsigned int paddr, unsigned int size);
/**
 * sunxi_unmap_kernel - unmap phys contigous memory from kernel space.
 * @vaddr: the kernel virt addr of the area.
 * @paddr: the start phys addr of the area.
 * @size: size in bytes of the area.
 */
void sunxi_unmap_kernel(void *vaddr, unsigned int paddr, unsigned int size);

#endif /* __KERNEL__ */

#endif