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