1 /*
2 * include/linux/amlogic/tee.h
3 *
4 * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 */
17
18 #ifndef __TEE_H__
19 #define __TEE_H__
20
21 /* memory type used by tee_protect_mem_by_type() */
22 #define TEE_MEM_TYPE_GPU 0x6
23 #define TEE_MEM_TYPE_VDIN 0x7
24 #define TEE_MEM_TYPE_HCODEC 0x8
25 #define TEE_MEM_TYPE_GE2D 0x9
26 #define TEE_MEM_TYPE_DEMUX 0xa
27
28 /* device ID used by tee_config_device_state() */
29 #define DMC_DEV_ID_GPU 1
30 #define DMC_DEV_ID_HEVC 4
31 #define DMC_DEV_ID_PARSER 7
32 #define DMC_DEV_ID_VPU 8
33 #define DMC_DEV_ID_VDIN 9
34 #define DMC_DEV_ID_VDEC 13
35 #define DMC_DEV_ID_HCODEC 14
36 #define DMC_DEV_ID_GE2D 15
37
38 #ifndef CONFIG_AMLOGIC_TEE
tee_enabled(void)39 static inline bool tee_enabled(void)
40 {
41 return false;
42 }
43
tee_protect_tvp_mem(uint32_t start,uint32_t size,uint32_t * handle)44 static inline uint32_t tee_protect_tvp_mem(uint32_t start, uint32_t size,
45 uint32_t *handle)
46 {
47 return 0xFFFFFFFF;
48 }
49
is_secload_get(void)50 static inline int is_secload_get(void)
51 {
52 return 0;
53 }
54
tee_unprotect_tvp_mem(uint32_t handle)55 static inline void tee_unprotect_tvp_mem(uint32_t handle)
56 {
57 }
58
tee_load_video_fw_swap(uint32_t index,uint32_t vdec,bool is_swap)59 static inline int tee_load_video_fw_swap(uint32_t index, uint32_t vdec, bool is_swap)
60 {
61 return -1;
62 }
63
tee_load_video_fw(uint32_t index,uint32_t vdec)64 static inline int tee_load_video_fw(uint32_t index, uint32_t vdec)
65 {
66 return -1;
67 }
68 #else
69 extern bool tee_enabled(void);
70 extern int is_secload_get(void);
71 extern int tee_load_video_fw(uint32_t index, uint32_t vdec);
72 extern int tee_load_video_fw_swap(uint32_t index, uint32_t vdec, bool is_swap);
73 extern uint32_t tee_protect_tvp_mem(uint32_t start, uint32_t size,
74 uint32_t *handle);
75 extern void tee_unprotect_tvp_mem(uint32_t handle);
76 extern uint32_t tee_protect_mem_by_type(uint32_t type,
77 uint32_t start, uint32_t size,
78 uint32_t *handle);
79 extern void tee_unprotect_mem(uint32_t handle);
80
81 extern int tee_config_device_state(int dev_id, int secure);
82
83 #endif
84
85
86 #endif /* __TEE_H__ */
87
88