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 #define SIP_MCU_CFG 0x82000028 33 34 #define ROCKCHIP_SIP_CONFIG_DRAM_INIT 0x00 35 #define ROCKCHIP_SIP_CONFIG_DRAM_SET_RATE 0x01 36 #define ROCKCHIP_SIP_CONFIG_DRAM_ROUND_RATE 0x02 37 #define ROCKCHIP_SIP_CONFIG_DRAM_SET_AT_SR 0x03 38 #define ROCKCHIP_SIP_CONFIG_DRAM_GET_BW 0x04 39 #define ROCKCHIP_SIP_CONFIG_DRAM_GET_RATE 0x05 40 #define ROCKCHIP_SIP_CONFIG_DRAM_CLR_IRQ 0x06 41 #define ROCKCHIP_SIP_CONFIG_DRAM_SET_PARAM 0x07 42 #define ROCKCHIP_SIP_CONFIG_DRAM_GET_VERSION 0x08 43 #define ROCKCHIP_SIP_CONFIG_DRAM_POST_SET_RATE 0x09 44 #define ROCKCHIP_SIP_CONFIG_DRAM_SET_NOC_RL 0x0a 45 #define ROCKCHIP_SIP_CONFIG_DRAM_DEBUG 0x0b 46 #define ROCKCHIP_SIP_CONFIG_DRAM_MCU_START 0x0c 47 #define ROCKCHIP_SIP_CONFIG_DRAM_ECC 0x0d 48 #define ROCKCHIP_SIP_CONFIG_DRAM_GET_FREQ_INFO 0x0e 49 #define ROCKCHIP_SIP_CONFIG_DRAM_FSP_INIT 0x0f 50 51 /* RK_SIP_MCU_CFG child configs, MCU ID */ 52 #define ROCKCHIP_SIP_CONFIG_BUSMCU_0_ID 0x00 53 #define ROCKCHIP_SIP_CONFIG_BUSMCU_1_ID 0x01 54 #define ROCKCHIP_SIP_CONFIG_PMUMCU_0_ID 0x10 55 #define ROCKCHIP_SIP_CONFIG_DDRMCU_0_ID 0x20 56 #define ROCKCHIP_SIP_CONFIG_NPUMCU_0_ID 0x30 57 58 /* RK_SIP_MCU_CFG child configs */ 59 #define ROCKCHIP_SIP_CONFIG_MCU_CODE_START_ADDR 0x01 60 #define ROCKCHIP_SIP_CONFIG_MCU_EXPERI_START_ADDR 0x02 61 #define ROCKCHIP_SIP_CONFIG_MCU_SRAM_START_ADDR 0x03 62 #define ROCKCHIP_SIP_CONFIG_MCU_EXSRAM_START_ADDR 0x04 63 64 /* Rockchip Sip version */ 65 #define SIP_IMPLEMENT_V1 (1) 66 #define SIP_IMPLEMENT_V2 (2) 67 68 /* Error return code */ 69 #define IS_SIP_ERROR(x) (!!(x)) 70 71 #define SIP_RET_SUCCESS 0 72 #define SIP_RET_SMC_UNKNOWN -1 73 #define SIP_RET_NOT_SUPPORTED -2 74 #define SIP_RET_INVALID_PARAMS -3 75 #define SIP_RET_INVALID_ADDRESS -4 76 #define SIP_RET_DENIED -5 77 78 /* SIP_ACCESS_REG: read or write */ 79 #define SECURE_REG_RD 0x0 80 #define SECURE_REG_WR 0x1 81 82 /* SIP_AMP_CFG */ 83 #define AMP_PE_STATE 0x0 84 #define AMP_BOOT_ARG01 0x1 85 #define AMP_BOOT_ARG23 0x2 86 87 /* Share mem page types */ 88 typedef enum { 89 SHARE_PAGE_TYPE_INVALID = 0, 90 SHARE_PAGE_TYPE_UARTDBG, 91 SHARE_PAGE_TYPE_DDR, 92 SHARE_PAGE_TYPE_DDRDBG, 93 SHARE_PAGE_TYPE_DDRECC, 94 SHARE_PAGE_TYPE_DDRFSP, 95 SHARE_PAGE_TYPE_DDR_ADDRMAP, 96 SHARE_PAGE_TYPE_LAST_LOG, 97 SHARE_PAGE_TYPE_HDCP, 98 SHARE_PAGE_TYPE_SLEEP, 99 SHARE_PAGE_TYPE_MAX, 100 } share_page_type_t; 101 102 /* hdcp config func */ 103 typedef enum { 104 HDCP_FUNC_STORAGE_ENCRYPT = 1, 105 HDCP_FUNC_KEY_DECRYPT, 106 HDCP_FUNC_KEY_LOAD, 107 HDCP_FUNC_ENCRYPT_MODE 108 } sip_hdcp_func_t; 109 110 /* 111 * sip_smc_set_suspend_mode() - Set U-Boot system suspend state before trap to trust. 112 * 113 * see kernel-4.4: drivers/soc/rockchip/rockchip_pm_config.c 114 */ 115 int sip_smc_set_suspend_mode(unsigned long ctrl, 116 unsigned long config1, 117 unsigned long config2); 118 119 int sip_smc_remotectl_config(unsigned long func, unsigned long data); 120 121 /* 122 * sip_smc_amp_cfg() - config AMP 123 */ 124 int sip_smc_amp_cfg(unsigned long func, unsigned long arg0, unsigned long arg1, 125 unsigned long arg2); 126 127 /* 128 * sip_smc_dram() - Set dram configure for trust. 129 * 130 * see: ./drivers/ram/rockchip/rockchip_dmc.c 131 */ 132 struct arm_smccc_res sip_smc_dram(unsigned long arg0, 133 unsigned long arg1, 134 unsigned long arg2); 135 136 /* 137 * sip_smc_request_share_mem() - Request share memory from trust. 138 * 139 * @page_num: page numbers 140 * @page_type: page type, see: share_page_type_t 141 * 142 * @return arm_smccc_res structure, res.a0 equals 0 on success(res.a1 contains 143 * share memory base address), otherwise failed. 144 */ 145 struct arm_smccc_res sip_smc_request_share_mem(unsigned long page_num, 146 share_page_type_t page_type); 147 148 /* 149 * sip_smc_secure_reg_read() - Read secure info(ddr/register...) from trust. 150 * 151 * @addr_phy: address to read 152 * 153 * @return arm_smccc_res structure, res.a0 equals 0 on success(res.a1 contains 154 * valid data), otherwise failed. 155 */ 156 struct arm_smccc_res sip_smc_secure_reg_read(unsigned long addr_phy); 157 158 /* 159 * sip_smc_secure_reg_write() - Write data to trust secure info(ddr/register...). 160 * 161 * @addr_phy: address to write 162 * @val: value to write 163 * 164 * @return 0 on success, otherwise failed. 165 */ 166 int sip_smc_secure_reg_write(unsigned long addr_phy, unsigned long val); 167 168 /* 169 * sip_smc_set_sip_version() - Set sip version to trust. 170 * 171 * @return 0 on success, otherwise failed. 172 */ 173 int sip_smc_set_sip_version(unsigned long version); 174 175 /* 176 * sip_smc_get_sip_version() - Get sip version to trust. 177 * 178 * @return arm_smccc_res structure, res.a0 equals 0 on success(res.a1 contains 179 * sip version), otherwise failed. 180 */ 181 struct arm_smccc_res sip_smc_get_sip_version(void); 182 183 /* 184 * sip_smc_hdcp_config() - handle hdcp. 185 * 186 * @return 0 on success, otherwise failed. 187 */ 188 int sip_smc_hdcp_config(unsigned long func, 189 unsigned long arg1, unsigned long arg2); 190 191 /* 192 * sip_smc_mcu_config() - handle mcu. 193 * 194 * @return 0 on success, otherwise failed. 195 */ 196 int sip_smc_mcu_config(unsigned long mcu_id, unsigned long func, unsigned long arg2); 197 198 /* 199 * psci_cpu_on() - Standard ARM PSCI cpu on call. 200 * 201 * @cpuid: cpu id 202 * @entry_point: boot entry point 203 * 204 * @return 0 on success, otherwise failed. 205 */ 206 int psci_cpu_on(unsigned long cpuid, unsigned long entry_point); 207 208 /* 209 * psci_cpu_off() - Standard ARM PSCI cpu off call. 210 * 211 * @state: dummy, set 0 by default. 212 * 213 * @return 0 on success, otherwise failed. 214 */ 215 int psci_cpu_off(uint32_t state); 216 217 #ifdef CONFIG_ARM_CPU_SUSPEND 218 /* 219 * psci_system_suspend() - Standard ARM PSCI system suspend call. 220 * 221 * @unused: unused now, always 0 recommend 222 * 223 * @return 0 on success, otherwise failed. 224 */ 225 int psci_system_suspend(unsigned long unused); 226 #endif 227 228 #endif 229