import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-mt8127 / include / mach / m4u.h
1 #ifndef __M4U_H__
2 #define __M4U_H__
3 #include <linux/ioctl.h>
4 #include <linux/fs.h>
5 #include <mach/m4u_port.h>
6 #include <linux/scatterlist.h>
7
8 typedef int M4U_PORT_ID_ENUM;
9 typedef int M4U_MODULE_ID_ENUM;
10
11 typedef enum
12 {
13 RT_RANGE_HIGH_PRIORITY=0,
14 SEQ_RANGE_LOW_PRIORITY=1
15 } M4U_RANGE_PRIORITY_ENUM;
16
17
18 // port related: virtuality, security, distance
19 typedef struct _M4U_PORT
20 {
21 M4U_PORT_ID_ENUM ePortID; //hardware port ID, defined in M4U_PORT_ID_ENUM
22 unsigned int Virtuality;
23 unsigned int Security;
24 unsigned int domain; //domain : 0 1 2 3
25 unsigned int Distance;
26 unsigned int Direction; //0:- 1:+
27 }M4U_PORT_STRUCT;
28
29 typedef enum
30 {
31 ROTATE_0=0,
32 ROTATE_90,
33 ROTATE_180,
34 ROTATE_270,
35 ROTATE_HFLIP_0,
36 ROTATE_HFLIP_90,
37 ROTATE_HFLIP_180,
38 ROTATE_HFLIP_270
39 } M4U_ROTATOR_ENUM;
40
41 typedef struct _M4U_PORT_ROTATOR
42 {
43 M4U_PORT_ID_ENUM ePortID; // hardware port ID, defined in M4U_PORT_ID_ENUM
44 unsigned int Virtuality;
45 unsigned int Security;
46 // unsigned int Distance; // will be caculated actomatically inside M4U driver
47 // unsigned int Direction;
48 unsigned int MVAStart;
49 unsigned int BufAddr;
50 unsigned int BufSize;
51 M4U_ROTATOR_ENUM angle;
52 }M4U_PORT_STRUCT_ROTATOR;
53
54 typedef enum
55 {
56 M4U_CACHE_FLUSH_BEFORE_HW_READ_MEM = 0, // optimized, recommand to use
57 M4U_CACHE_FLUSH_BEFORE_HW_WRITE_MEM = 1, // optimized, recommand to use
58 M4U_CACHE_CLEAN_BEFORE_HW_READ_MEM = 2,
59 M4U_CACHE_INVALID_AFTER_HW_WRITE_MEM = 3,
60 M4U_NONE_OP = 4,
61 } M4U_CACHE_SYNC_ENUM;
62
63
64 // for kernel direct call --------------------------------------------
65 int m4u_dump_reg(int m4u_index);
66 int m4u_dump_info(int m4u_index);
67 int m4u_power_on(int m4u_index);
68 int m4u_power_off(int m4u_index);
69
70 int m4u_alloc_mva(M4U_MODULE_ID_ENUM eModuleID,
71 const unsigned int BufAddr,
72 const unsigned int BufSize,
73 int security,
74 int cache_coherent,
75 unsigned int *pRetMVABuf);
76
77 int m4u_alloc_mva_sg(M4U_MODULE_ID_ENUM eModuleID,
78 struct sg_table *sg_table,
79 const unsigned int BufSize,
80 int security,
81 int cache_coherent,
82 unsigned int *pRetMVABuf);
83
84
85 int m4u_dealloc_mva(M4U_MODULE_ID_ENUM eModuleID,
86 const unsigned int BufAddr,
87 const unsigned int BufSize,
88 const unsigned int MVA);
89
90 int m4u_dealloc_mva_sg(M4U_MODULE_ID_ENUM eModuleID,
91 struct sg_table* sg_table,
92 const unsigned int BufSize,
93 const unsigned int MVA);
94
95 int m4u_insert_wrapped_range(M4U_MODULE_ID_ENUM eModuleID,
96 M4U_PORT_ID_ENUM portID,
97 unsigned int MVAStart,
98 unsigned int MVAEnd);
99
100 int m4u_invalid_wrapped_range(M4U_MODULE_ID_ENUM eModuleID,
101 M4U_PORT_ID_ENUM portID,
102 unsigned int MVAStart,
103 unsigned int MVAEnd);
104
105 int m4u_insert_seq_range(M4U_MODULE_ID_ENUM eModuleID,
106 unsigned int MVAStart,
107 unsigned int MVAEnd,
108 M4U_RANGE_PRIORITY_ENUM ePriority,
109 unsigned int entryCount); //0:disable multi-entry, 1,2,4,8,16: enable multi-entry
110
111 int m4u_invalid_seq_range(M4U_MODULE_ID_ENUM eModuleID,
112 unsigned int MVAStart,
113 unsigned int MVAEnd);
114
115 int m4u_config_port_rotator(M4U_PORT_STRUCT_ROTATOR *pM4uPort);
116
117 int m4u_config_port(M4U_PORT_STRUCT* pM4uPort); //native
118 //int m4u_config_port_rotator(M4U_PORT_STRUCT_ROTATOR *pM4uPort);
119 int m4u_monitor_start(int m4u_id);
120 int m4u_monitor_stop(int m4u_id);
121
122
123 int m4u_dma_cache_maint(M4U_MODULE_ID_ENUM eModuleID,
124 const void *va,
125 size_t size,
126 int direction);
127
128 int m4u_mau_check_pagetable(unsigned int start_addr, unsigned int end_addr);
129 int m4u_mau_get_physical_port(unsigned int* engineMask);
130
131 // used for those looply used buffer
132 // will check link list for mva rather than re-build pagetable by get_user_pages()
133 // if can not find the VA in link list, will call m4u_alloc_mva() internally
134 int m4u_query_mva(M4U_MODULE_ID_ENUM eModuleID,
135 const unsigned int BufAddr,
136 const unsigned int BufSize,
137 unsigned int *pRetMVABuf,
138 struct file * a_pstFile);
139
140 int m4u_log_on(void);
141 int m4u_log_off(void);
142 int m4u_debug_command(unsigned int command);
143 int m4u_mva_map_kernel(unsigned int mva, unsigned int size, int sec,
144 unsigned int* map_va, unsigned int* map_size);
145 int m4u_mva_unmap_kernel(unsigned int mva, unsigned int size, unsigned int va);
146 int m4u_fill_linear_pagetable(unsigned int pa, unsigned int size);
147 // m4u driver internal use ---------------------------------------------------
148 //
149 /*TEE
150 *only for ovl 4 layger (sync nonsec pt 2 sec pt)
151 *if ovl config port NonSec to Sec, and also want to use a nonsec memory,
152 * please call this function before you use it.
153 * return : 0 : successful
154 * -1: failed
155 */
156 int m4u_sync_nonsec_sec_pgtable(unsigned int mva,
157 unsigned int size,
158 int port);
159
160 #endif
161