Merge branch 'android-4.4' of https://android.googlesource.com/kernel/common
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / ump / common / ump_uk_types.h
1 /*
2  * Copyright (C) 2010, 2012-2014 ARM Limited. All rights reserved.
3  * 
4  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6  * 
7  * A copy of the licence is included with the program, and can also be obtained from Free Software
8  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9  */
10
11 /**
12  * @file ump_uk_types.h
13  * Defines the types and constants used in the user-kernel interface
14  */
15
16 #ifndef __UMP_UK_TYPES_H__
17 #define __UMP_UK_TYPES_H__
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /* Helpers for API version handling */
24 #define MAKE_VERSION_ID(x) (((x) << 16UL) | (x))
25 #define IS_VERSION_ID(x) (((x) & 0xFFFF) == (((x) >> 16UL) & 0xFFFF))
26 #define GET_VERSION(x) (((x) >> 16UL) & 0xFFFF)
27 #define IS_API_MATCH(x, y) (IS_VERSION_ID((x)) && IS_VERSION_ID((y)) && (GET_VERSION((x)) == GET_VERSION((y))))
28
29 /**
30  * API version define.
31  * Indicates the version of the kernel API
32  * The version is a 16bit integer incremented on each API change.
33  * The 16bit integer is stored twice in a 32bit integer
34  * So for version 1 the value would be 0x00010001
35  */
36 #define UMP_IOCTL_API_VERSION MAKE_VERSION_ID(3)
37
38 typedef enum
39 {
40         _UMP_IOC_QUERY_API_VERSION = 1,
41         _UMP_IOC_ALLOCATE,
42         _UMP_IOC_RELEASE,
43         _UMP_IOC_SIZE_GET,
44         _UMP_IOC_MAP_MEM,    /* not used in Linux */
45         _UMP_IOC_UNMAP_MEM,  /* not used in Linux */
46         _UMP_IOC_MSYNC,
47         _UMP_IOC_CACHE_OPERATIONS_CONTROL,
48         _UMP_IOC_SWITCH_HW_USAGE,
49         _UMP_IOC_LOCK,
50         _UMP_IOC_UNLOCK,
51 } _ump_uk_functions;
52
53 typedef enum
54 {
55         UMP_REF_DRV_UK_CONSTRAINT_NONE = 0,
56         UMP_REF_DRV_UK_CONSTRAINT_PHYSICALLY_LINEAR = 1,
57         UMP_REF_DRV_UK_CONSTRAINT_USE_CACHE = 4,
58 } ump_uk_alloc_constraints;
59
60 typedef enum
61 {
62         _UMP_UK_MSYNC_CLEAN = 0,
63         _UMP_UK_MSYNC_CLEAN_AND_INVALIDATE = 1,
64         _UMP_UK_MSYNC_INVALIDATE = 2,
65         _UMP_UK_MSYNC_FLUSH_L1   = 3,
66         _UMP_UK_MSYNC_READOUT_CACHE_ENABLED = 128,
67 } ump_uk_msync_op;
68
69 typedef enum
70 {
71         _UMP_UK_CACHE_OP_START = 0,
72         _UMP_UK_CACHE_OP_FINISH  = 1,
73 } ump_uk_cache_op_control;
74
75 typedef enum
76 {
77         _UMP_UK_READ = 1,
78         _UMP_UK_READ_WRITE = 3,
79 } ump_uk_lock_usage;
80
81 typedef enum
82 {
83         _UMP_UK_USED_BY_CPU = 0,
84         _UMP_UK_USED_BY_MALI = 1,
85         _UMP_UK_USED_BY_UNKNOWN_DEVICE = 100,
86 } ump_uk_user;
87
88 /**
89  * Get API version ([in,out] u32 api_version, [out] u32 compatible)
90  */
91 typedef struct _ump_uk_api_version_s
92 {
93         void *ctx;      /**< [in,out] user-kernel context (trashed on output) */
94         u32 version;    /**< Set to the user space version on entry, stores the device driver version on exit */
95         u32 compatible; /**< Non-null if the device is compatible with the client */
96 } _ump_uk_api_version_s;
97
98 /**
99  * ALLOCATE ([out] u32 secure_id, [in,out] u32 size,  [in] contraints)
100  */
101 typedef struct _ump_uk_allocate_s
102 {
103         void *ctx;                              /**< [in,out] user-kernel context (trashed on output) */
104         u32 secure_id;                          /**< Return value from DD to Userdriver */
105         u32 size;                               /**< Input and output. Requested size; input. Returned size; output */
106         ump_uk_alloc_constraints constraints;   /**< Only input to Devicedriver */
107 } _ump_uk_allocate_s;
108
109 /**
110  * SIZE_GET ([in] u32 secure_id, [out]size )
111  */
112 typedef struct _ump_uk_size_get_s
113 {
114         void *ctx;                              /**< [in,out] user-kernel context (trashed on output) */
115         u32 secure_id;                          /**< Input to DD */
116         u32 size;                               /**< Returned size; output */
117 } _ump_uk_size_get_s;
118
119 /**
120  * Release ([in] u32 secure_id)
121  */
122 typedef struct _ump_uk_release_s
123 {
124         void *ctx;                              /**< [in,out] user-kernel context (trashed on output) */
125         u32 secure_id;                          /**< Input to DD */
126 } _ump_uk_release_s;
127
128 typedef struct _ump_uk_map_mem_s
129 {
130         void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
131         void *mapping;                  /**< [out] Returns user-space virtual address for the mapping */
132         void *phys_addr;                /**< [in] physical address */
133         unsigned long size;             /**< [in] size */
134         u32 secure_id;                  /**< [in] secure_id to assign to mapping */
135         void *_ukk_private;             /**< Only used inside linux port between kernel frontend and common part to store vma */
136         u32 cookie;
137         u32 is_cached;            /**< [in,out] caching of CPU mappings */
138 } _ump_uk_map_mem_s;
139
140 typedef struct _ump_uk_unmap_mem_s
141 {
142         void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
143         void *mapping;
144         u32 size;
145         void *_ukk_private;
146         u32 cookie;
147 } _ump_uk_unmap_mem_s;
148
149 typedef struct _ump_uk_msync_s
150 {
151         void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
152         void *mapping;        /**< [in] mapping addr */
153         void *address;        /**< [in] flush start addr */
154         u32 size;             /**< [in] size to flush */
155         ump_uk_msync_op op;   /**< [in] flush operation */
156         u32 cookie;           /**< [in] cookie stored with reference to the kernel mapping internals */
157         u32 secure_id;        /**< [in] secure_id that identifies the ump buffer */
158         u32 is_cached;        /**< [out] caching of CPU mappings */
159 } _ump_uk_msync_s;
160
161 typedef struct _ump_uk_cache_operations_control_s
162 {
163         void *ctx;                   /**< [in,out] user-kernel context (trashed on output) */
164         ump_uk_cache_op_control op;  /**< [in] cache operations start/stop */
165 } _ump_uk_cache_operations_control_s;
166
167
168 typedef struct _ump_uk_switch_hw_usage_s
169 {
170         void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
171         u32 secure_id;        /**< [in] secure_id that identifies the ump buffer */
172         ump_uk_user new_user;         /**< [in] cookie stored with reference to the kernel mapping internals */
173
174 } _ump_uk_switch_hw_usage_s;
175
176 typedef struct _ump_uk_lock_s
177 {
178         void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
179         u32 secure_id;        /**< [in] secure_id that identifies the ump buffer */
180         ump_uk_lock_usage lock_usage;
181 } _ump_uk_lock_s;
182
183 typedef struct _ump_uk_unlock_s
184 {
185         void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
186         u32 secure_id;        /**< [in] secure_id that identifies the ump buffer */
187 } _ump_uk_unlock_s;
188
189 #ifdef __cplusplus
190 }
191 #endif
192
193 #endif /* __UMP_UK_TYPES_H__ */