xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/bifrost/mali_kbase_smc.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * (C) COPYRIGHT 2015, 2020-2022 ARM Limited. All rights reserved.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * This program is free software and is provided to you under the terms of the
7*4882a593Smuzhiyun  * GNU General Public License version 2 as published by the Free Software
8*4882a593Smuzhiyun  * Foundation, and any use by you of this program is subject to the terms
9*4882a593Smuzhiyun  * of such GNU license.
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * This program is distributed in the hope that it will be useful,
12*4882a593Smuzhiyun  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13*4882a593Smuzhiyun  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14*4882a593Smuzhiyun  * GNU General Public License for more details.
15*4882a593Smuzhiyun  *
16*4882a593Smuzhiyun  * You should have received a copy of the GNU General Public License
17*4882a593Smuzhiyun  * along with this program; if not, you can access it online at
18*4882a593Smuzhiyun  * http://www.gnu.org/licenses/gpl-2.0.html.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  */
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun #ifndef _KBASE_SMC_H_
23*4882a593Smuzhiyun #define _KBASE_SMC_H_
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_ARM64)
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #include <mali_kbase.h>
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun #define SMC_FAST_CALL (1 << 31)
30*4882a593Smuzhiyun #define SMC_64 (1 << 30)
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #define SMC_OEN_OFFSET 24
33*4882a593Smuzhiyun #define SMC_OEN_MASK (0x3F << SMC_OEN_OFFSET) /* 6 bits */
34*4882a593Smuzhiyun #define SMC_OEN_SIP (2 << SMC_OEN_OFFSET)
35*4882a593Smuzhiyun #define SMC_OEN_STD (4 << SMC_OEN_OFFSET)
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun /**
39*4882a593Smuzhiyun  * kbase_invoke_smc_fid - Perform a secure monitor call
40*4882a593Smuzhiyun  * @fid: The SMC function to call, see SMC Calling convention.
41*4882a593Smuzhiyun  * @arg0: First argument to the SMC.
42*4882a593Smuzhiyun  * @arg1: Second argument to the SMC.
43*4882a593Smuzhiyun  * @arg2: Third argument to the SMC.
44*4882a593Smuzhiyun  *
45*4882a593Smuzhiyun  * See SMC Calling Convention for details.
46*4882a593Smuzhiyun  *
47*4882a593Smuzhiyun  * Return: the return value from the SMC.
48*4882a593Smuzhiyun  */
49*4882a593Smuzhiyun u64 kbase_invoke_smc_fid(u32 fid, u64 arg0, u64 arg1, u64 arg2);
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun /**
52*4882a593Smuzhiyun  * kbase_invoke_smc - Perform a secure monitor call
53*4882a593Smuzhiyun  * @oen: Owning Entity number (SIP, STD etc).
54*4882a593Smuzhiyun  * @function_number: The function number within the OEN.
55*4882a593Smuzhiyun  * @smc64: use SMC64 calling convention instead of SMC32.
56*4882a593Smuzhiyun  * @arg0: First argument to the SMC.
57*4882a593Smuzhiyun  * @arg1: Second argument to the SMC.
58*4882a593Smuzhiyun  * @arg2: Third argument to the SMC.
59*4882a593Smuzhiyun  *
60*4882a593Smuzhiyun  * See SMC Calling Convention for details.
61*4882a593Smuzhiyun  *
62*4882a593Smuzhiyun  * Return: the return value from the SMC call.
63*4882a593Smuzhiyun  */
64*4882a593Smuzhiyun u64 kbase_invoke_smc(u32 oen, u16 function_number, bool smc64,
65*4882a593Smuzhiyun 		u64 arg0, u64 arg1, u64 arg2);
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun #endif /* CONFIG_ARM64 */
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun #endif /* _KBASE_SMC_H_ */
70