Merge tag 'lsk-v3.10-15.05-android' into develop-3.10
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard / mali_uk.h
1 /*
2  *
3  * (C) COPYRIGHT ARM Limited. All rights reserved.
4  *
5  * This program is free software and is provided to you under the terms of the
6  * GNU General Public License version 2 as published by the Free Software
7  * Foundation, and any use by you of this program is subject to the terms
8  * of such GNU licence.
9  *
10  * A copy of the licence is included with the program, and can also be obtained
11  * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12  * Boston, MA  02110-1301, USA.
13  *
14  */
15
16
17
18
19
20 /**
21  * @file mali_uk.h
22  * Types and definitions that are common across OSs for both the user
23  * and kernel side of the User-Kernel interface.
24  */
25
26 #ifndef _UK_H_
27 #define _UK_H_
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif                          /* __cplusplus */
32
33 #include <malisw/mali_stdtypes.h>
34
35 /**
36  * @addtogroup base_api
37  * @{
38  */
39
40 /**
41  * @defgroup uk_api User-Kernel Interface API
42  *
43  * The User-Kernel Interface abstracts the communication mechanism between the user and kernel-side code of device
44  * drivers developed as part of the Midgard DDK. Currently that includes the Base driver and the UMP driver.
45  *
46  * It exposes an OS independent API to user-side code (UKU) which routes functions calls to an OS-independent
47  * kernel-side API (UKK) via an OS-specific communication mechanism.
48  *
49  * This API is internal to the Midgard DDK and is not exposed to any applications.
50  *
51  * @{
52  */
53
54 /**
55  * These are identifiers for kernel-side drivers implementing a UK interface, aka UKK clients. The
56  * UK module maps this to an OS specific device name, e.g. "gpu_base" -> "GPU0:". Specify this
57  * identifier to select a UKK client to the uku_open() function.
58  *
59  * When a new UKK client driver is created a new identifier needs to be added to the uk_client_id
60  * enumeration and the uku_open() implemenation for the various OS ports need to be updated to
61  * provide a mapping of the identifier to the OS specific device name.
62  *
63  */
64 enum uk_client_id {
65         /**
66          * Value used to identify the Base driver UK client.
67          */
68         UK_CLIENT_MALI_T600_BASE,
69
70         /** The number of uk clients supported. This must be the last member of the enum */
71         UK_CLIENT_COUNT
72 };
73
74 /**
75  * Each function callable through the UK interface has a unique number.
76  * Functions provided by UK clients start from number UK_FUNC_ID.
77  * Numbers below UK_FUNC_ID are used for internal UK functions.
78  */
79 enum uk_func {
80         UKP_FUNC_ID_CHECK_VERSION,   /**< UKK Core internal function */
81         /**
82          * Each UK client numbers the functions they provide starting from
83          * number UK_FUNC_ID. This number is then eventually assigned to the
84          * id field of the union uk_header structure when preparing to make a
85          * UK call. See your UK client for a list of their function numbers.
86          */
87         UK_FUNC_ID = 512
88 };
89
90 /**
91  * Arguments for a UK call are stored in a structure. This structure consists
92  * of a fixed size header and a payload. The header carries a 32-bit number
93  * identifying the UK function to be called (see uk_func). When the UKK client
94  * receives this header and executed the requested UK function, it will use
95  * the same header to store the result of the function in the form of a
96  * mali_error return code. The size of this structure is such that the
97  * first member of the payload following the header can be accessed efficiently
98  * on a 32 and 64-bit kernel and the structure has the same size regardless
99  * of a 32 or 64-bit kernel. The uk_kernel_size_type type should be defined
100  * accordingly in the OS specific mali_uk_os.h header file.
101  */
102 union uk_header {
103         /**
104          * 32-bit number identifying the UK function to be called.
105          * Also see uk_func.
106          */
107         u32 id;
108         /**
109          * The mali_error return code returned by the called UK function.
110          * See the specification of the particular UK function you are
111          * calling for the meaning of the error codes returned. All
112          * UK functions return MALI_ERROR_NONE on success.
113          */
114         u32 ret;
115         /*
116          * Used to ensure 64-bit alignment of this union. Do not remove.
117          * This field is used for padding and does not need to be initialized.
118          */
119         u64 sizer;
120 };
121
122 /**
123  * This structure carries a 16-bit major and minor number and is sent along with an internal UK call
124  * used during uku_open to identify the versions of the UK module in use by the user-side and kernel-side.
125  */
126 struct uku_version_check_args {
127         union uk_header header;
128                   /**< UK call header */
129         u16 major;
130            /**< This field carries the user-side major version on input and the kernel-side major version on output */
131         u16 minor;
132            /**< This field carries the user-side minor version on input and the kernel-side minor version on output. */
133         u8 padding[4];
134 };
135
136 /** @} end group uk_api */
137
138 /** @} *//* end group base_api */
139
140 #ifdef __cplusplus
141 }
142 #endif                          /* __cplusplus */
143 #endif                          /* _UK_H_ */