Merge tag 'v3.10.55' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-mt8127 / include / mach / mt_secure_api.h
1 /*
2 */
3
4 #ifndef _MT_SECURE_API_H_
5 #define _MT_SECURE_API_H_
6
7 /* Use the arch_extension sec pseudo op before switching to secure world */
8 #if defined(__GNUC__) && \
9 defined(__GNUC_MINOR__) && \
10 defined(__GNUC_PATCHLEVEL__) && \
11 ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)) \
12 >= 40502
13 #define MC_ARCH_EXTENSION_SEC
14 #endif
15
16
17 /*
18 * return code for fastcalls
19 */
20 #define MC_FC_RET_OK 0
21 #define MC_FC_RET_ERR_INVALID 1
22
23
24
25 /* t-base fastcall */
26 /*
27 * Command to inform SW that we will enter in Power Sleep (Dormant).
28 * Parameters:
29 * - param0, the NW wakeup addr (phys).
30 * - param1, the cpuID who will sleep
31 * - param2, unused.
32 * Return:
33 * - Cannot fail, always MC_FC_RET_OK.
34 */
35 #define MC_FC_SLEEP -3
36 /*
37 * Command to write NW reset addr for Slave cpus.
38 * Parameters:
39 * - param0, the NW reset addr (phys).
40 * - param1, the cpuID.
41 * - param2, unused.
42 * Return:
43 * - Cannot fail, always MC_FC_RET_OK.
44 */
45 #define MC_FC_SET_RESET_VECTOR -301
46 /*
47 * Command to switch off BootRom.
48 * Parameters:
49 * - param0, unused.
50 * - param1, unsued.
51 * - param2, unused.
52 * Return:
53 * - Cannot fail, always MC_FC_RET_OK.
54 */
55 #define MC_FC_TURN_OFF_BOOTROM -302
56 /*
57 * Command to cancel a sleep command in case of Dormant abort.
58 * Parameters:
59 * - param0, unused.
60 * - param1, unsued.
61 * - param2, unused.
62 * Return:
63 * - Cannot fail, always MC_FC_RET_OK.
64 */
65 #define MC_FC_SLEEP_CANCELLED -302
66
67
68
69 /*
70 * mt_secure_call
71 * Parameters:
72 * - cmd, the command we want to execute.
73 * - param0, param1, param2: the parameters used for this command.
74 * Return:
75 * - Error code of the command (MC_FC_RET_OK in case of success).
76 */
77 static inline int mt_secure_call(uint32_t cmd, uint32_t param0, uint32_t param1, uint32_t param2)
78 {
79 /* SMC expect values in r0-r3 */
80 register u32 reg0 __asm__("r0") = cmd;
81 register u32 reg1 __asm__("r1") = param0;
82 register u32 reg2 __asm__("r2") = param1;
83 register u32 reg3 __asm__("r3") = param2;
84 int ret = 0;
85
86 __asm__ volatile (
87 #ifdef MC_ARCH_EXTENSION_SEC
88 /* This pseudo op is supported and required from
89 * binutils 2.21 on */
90 ".arch_extension sec\n"
91 #endif
92 "smc 0\n"
93 : "+r"(reg0), "+r"(reg1), "+r"(reg2), "+r"(reg3)
94 );
95
96 /* set response */
97 ret = reg0;
98 return ret;
99 }
100
101
102 #endif /* _MT_SECURE_API_H_ */