xref: /rk3399_rockchip-uboot/arch/arm/include/asm/arch-rockchip/rockchip_smccc.h (revision 70ad550d6f37befbc82a8e5e7c7753be83ff08b1)
1 /*
2  * (C) Copyright 2017 Rockchip Electronics Co., Ltd
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6 
7 #ifndef __ROCKCHIP_SMCCC_H__
8 #define __ROCKCHIP_SMCCC_H__
9 
10 #include <linux/arm-smccc.h>
11 
12 /* Rockchip platform SiP call ID */
13 #define SIP_ATF_VERSION			0x82000001
14 #define SIP_ACCESS_REG			0x82000002
15 #define SIP_SUSPEND_MODE		0x82000003
16 #define SIP_PENDING_CPUS		0x82000004
17 #define SIP_UARTDBG_CFG			0x82000005
18 #define SIP_UARTDBG_CFG64		0xc2000005
19 #define SIP_MCU_EL3FIQ_CFG		0x82000006
20 #define SIP_ACCESS_CHIP_STATE64		0xc2000006
21 #define SIP_SECURE_MEM_CONFIG		0x82000007
22 #define SIP_ACCESS_CHIP_EXTRA_STATE64	0xc2000007
23 #define SIP_DRAM_CONFIG			0x82000008
24 #define SIP_SHARE_MEM			0x82000009
25 #define SIP_SIP_VERSION			0x8200000a
26 #define SIP_REMOTECTL_CFG		0x8200000b
27 #define SIP_VPU_RESET			0x8200000c
28 #define SIP_SOC_BUS_DIV			0x8200000d
29 #define SIP_LAST_LOG			0x8200000e
30 #define SIP_AMP_CFG			0x82000022
31 #define SIP_HDCP_CONFIG			0x82000025
32 
33 #define ROCKCHIP_SIP_CONFIG_DRAM_INIT		0x00
34 #define ROCKCHIP_SIP_CONFIG_DRAM_SET_RATE	0x01
35 #define ROCKCHIP_SIP_CONFIG_DRAM_ROUND_RATE	0x02
36 #define ROCKCHIP_SIP_CONFIG_DRAM_SET_AT_SR	0x03
37 #define ROCKCHIP_SIP_CONFIG_DRAM_GET_BW		0x04
38 #define ROCKCHIP_SIP_CONFIG_DRAM_GET_RATE	0x05
39 #define ROCKCHIP_SIP_CONFIG_DRAM_CLR_IRQ	0x06
40 #define ROCKCHIP_SIP_CONFIG_DRAM_SET_PARAM	0x07
41 #define ROCKCHIP_SIP_CONFIG_DRAM_GET_VERSION	0x08
42 #define ROCKCHIP_SIP_CONFIG_DRAM_POST_SET_RATE	0x09
43 #define ROCKCHIP_SIP_CONFIG_DRAM_SET_NOC_RL	0x0a
44 #define ROCKCHIP_SIP_CONFIG_DRAM_DEBUG		0x0b
45 #define ROCKCHIP_SIP_CONFIG_DRAM_MCU_START	0x0c
46 #define ROCKCHIP_SIP_CONFIG_DRAM_ECC		0x0d
47 #define ROCKCHIP_SIP_CONFIG_DRAM_GET_FREQ_INFO	0x0e
48 #define ROCKCHIP_SIP_CONFIG_DRAM_FSP_INIT	0x0f
49 
50 /* Rockchip Sip version */
51 #define SIP_IMPLEMENT_V1                (1)
52 #define SIP_IMPLEMENT_V2                (2)
53 
54 /* Error return code */
55 #define IS_SIP_ERROR(x)			(!!(x))
56 
57 #define SIP_RET_SUCCESS			0
58 #define SIP_RET_SMC_UNKNOWN		-1
59 #define SIP_RET_NOT_SUPPORTED		-2
60 #define SIP_RET_INVALID_PARAMS		-3
61 #define SIP_RET_INVALID_ADDRESS		-4
62 #define SIP_RET_DENIED			-5
63 
64 /* SIP_ACCESS_REG: read or write */
65 #define SECURE_REG_RD			0x0
66 #define SECURE_REG_WR			0x1
67 
68 /* SIP_AMP_CFG */
69 #define AMP_PE_STATE			0x0
70 #define AMP_BOOT_ARG01			0x1
71 #define AMP_BOOT_ARG23			0x2
72 
73 /* Share mem page types */
74 typedef enum {
75 	SHARE_PAGE_TYPE_INVALID = 0,
76 	SHARE_PAGE_TYPE_UARTDBG,
77 	SHARE_PAGE_TYPE_DDR,
78 	SHARE_PAGE_TYPE_DDRDBG,
79 	SHARE_PAGE_TYPE_DDRECC,
80 	SHARE_PAGE_TYPE_DDRFSP,
81 	SHARE_PAGE_TYPE_DDR_ADDRMAP,
82 	SHARE_PAGE_TYPE_LAST_LOG,
83 	SHARE_PAGE_TYPE_HDCP,
84 	SHARE_PAGE_TYPE_MAX,
85 } share_page_type_t;
86 
87 /* hdcp config func */
88 typedef enum {
89 	HDCP_FUNC_STORAGE_ENCRYPT = 1,
90 	HDCP_FUNC_KEY_DECRYPT,
91 	HDCP_FUNC_KEY_LOAD,
92 	HDCP_FUNC_ENCRYPT_MODE
93 } sip_hdcp_func_t;
94 
95 /*
96  * sip_smc_set_suspend_mode() - Set U-Boot system suspend state before trap to trust.
97  *
98  * see kernel-4.4: drivers/soc/rockchip/rockchip_pm_config.c
99  */
100 int sip_smc_set_suspend_mode(unsigned long ctrl,
101 			     unsigned long config1,
102 			     unsigned long config2);
103 
104 int sip_smc_remotectl_config(unsigned long func, unsigned long data);
105 
106 /*
107  * sip_smc_amp_cfg() - config AMP
108  */
109 int sip_smc_amp_cfg(unsigned long func, unsigned long arg0, unsigned long arg1,
110 		    unsigned long arg2);
111 
112 /*
113  * sip_smc_dram() - Set dram configure for trust.
114  *
115  * see: ./drivers/ram/rockchip/rockchip_dmc.c
116  */
117 struct arm_smccc_res sip_smc_dram(unsigned long arg0,
118 				  unsigned long arg1,
119 				  unsigned long arg2);
120 
121 /*
122  * sip_smc_request_share_mem() - Request share memory from trust.
123  *
124  * @page_num:	page numbers
125  * @page_type:  page type, see: share_page_type_t
126  *
127  * @return arm_smccc_res structure, res.a0 equals 0 on success(res.a1 contains
128  *  share memory base address), otherwise failed.
129  */
130 struct arm_smccc_res sip_smc_request_share_mem(unsigned long page_num,
131 					       share_page_type_t page_type);
132 
133 /*
134  * sip_smc_secure_reg_read() - Read secure info(ddr/register...) from trust.
135  *
136  * @addr_phy:	address to read
137  *
138  * @return arm_smccc_res structure, res.a0 equals 0 on success(res.a1 contains
139  *  valid data), otherwise failed.
140  */
141 struct arm_smccc_res sip_smc_secure_reg_read(unsigned long addr_phy);
142 
143 /*
144  * sip_smc_secure_reg_write() - Write data to trust secure info(ddr/register...).
145  *
146  * @addr_phy:	address to write
147  * @val:	value to write
148  *
149  * @return 0 on success, otherwise failed.
150  */
151 int sip_smc_secure_reg_write(unsigned long addr_phy, unsigned long val);
152 
153 /*
154  * sip_smc_set_sip_version() - Set sip version to trust.
155  *
156  * @return 0 on success, otherwise failed.
157  */
158 int sip_smc_set_sip_version(unsigned long version);
159 
160 /*
161  * sip_smc_get_sip_version() - Get sip version to trust.
162  *
163  * @return arm_smccc_res structure, res.a0 equals 0 on success(res.a1 contains
164  *  sip version), otherwise failed.
165  */
166 struct arm_smccc_res sip_smc_get_sip_version(void);
167 
168 /*
169  * sip_smc_hdcp_config() - handle hdcp.
170  *
171  * @return  0 on success, otherwise failed.
172  */
173 int sip_smc_hdcp_config(unsigned long func,
174 			unsigned long arg1, unsigned long arg2);
175 
176 /*
177  * psci_cpu_on() - Standard ARM PSCI cpu on call.
178  *
179  * @cpuid:		cpu id
180  * @entry_point:	boot entry point
181  *
182  * @return 0 on success, otherwise failed.
183  */
184 int psci_cpu_on(unsigned long cpuid, unsigned long entry_point);
185 
186 #ifdef CONFIG_ARM_CPU_SUSPEND
187 /*
188  * psci_system_suspend() - Standard ARM PSCI system suspend call.
189  *
190  * @unused:		unused now, always 0 recommend
191  *
192  * @return 0 on success, otherwise failed.
193  */
194 int psci_system_suspend(unsigned long unused);
195 #endif
196 
197 #endif
198