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 /* Rockchip platform SiP call ID */ 11 #define SIP_ATF_VERSION 0x82000001 12 #define SIP_ACCESS_REG 0x82000002 13 #define SIP_SUSPEND_MODE 0x82000003 14 #define SIP_PENDING_CPUS 0x82000004 15 #define SIP_UARTDBG_CFG 0x82000005 16 #define SIP_UARTDBG_CFG64 0xc2000005 17 #define SIP_MCU_EL3FIQ_CFG 0x82000006 18 #define SIP_ACCESS_CHIP_STATE64 0xc2000006 19 #define SIP_SECURE_MEM_CONFIG 0x82000007 20 #define SIP_ACCESS_CHIP_EXTRA_STATE64 0xc2000007 21 #define SIP_DRAM_CONFIG 0x82000008 22 #define SIP_SHARE_MEM 0x82000009 23 #define SIP_SIP_VERSION 0x8200000a 24 #define SIP_REMOTECTL_CFG 0x8200000b 25 #define PSCI_SIP_VPU_RESET 0x8200000c 26 27 #define ROCKCHIP_SIP_CONFIG_DRAM_INIT 0x00 28 #define ROCKCHIP_SIP_CONFIG_DRAM_SET_RATE 0x01 29 #define ROCKCHIP_SIP_CONFIG_DRAM_ROUND_RATE 0x02 30 #define ROCKCHIP_SIP_CONFIG_DRAM_SET_AT_SR 0x03 31 #define ROCKCHIP_SIP_CONFIG_DRAM_GET_BW 0x04 32 #define ROCKCHIP_SIP_CONFIG_DRAM_GET_RATE 0x05 33 #define ROCKCHIP_SIP_CONFIG_DRAM_CLR_IRQ 0x06 34 #define ROCKCHIP_SIP_CONFIG_DRAM_SET_PARAM 0x07 35 #define ROCKCHIP_SIP_CONFIG_DRAM_GET_VERSION 0x08 36 37 /* Rockchip Sip version */ 38 #define SIP_IMPLEMENT_V1 (1) 39 #define SIP_IMPLEMENT_V2 (2) 40 41 /* Error return code */ 42 #define IS_SIP_ERROR(x) (!!(x)) 43 44 #define SIP_RET_SUCCESS 0 45 #define SIP_RET_SMC_UNKNOWN -1 46 #define SIP_RET_NOT_SUPPORTED -2 47 #define SIP_RET_INVALID_PARAMS -3 48 #define SIP_RET_INVALID_ADDRESS -4 49 #define SIP_RET_DENIED -5 50 51 /* SIP_ACCESS_REG: read or write */ 52 #define SECURE_REG_RD 0x0 53 #define SECURE_REG_WR 0x1 54 55 /* Share mem page types */ 56 typedef enum { 57 SHARE_PAGE_TYPE_INVALID = 0, 58 SHARE_PAGE_TYPE_UARTDBG, 59 SHARE_PAGE_TYPE_DDR, 60 SHARE_PAGE_TYPE_MAX, 61 } share_page_type_t; 62 63 /* 64 * sip_smc_set_suspend_mode() - Set U-Boot system suspend state before trap to trust. 65 * 66 * see kernel-4.4: drivers/soc/rockchip/rockchip_pm_config.c 67 */ 68 int sip_smc_set_suspend_mode(unsigned long ctrl, 69 unsigned long config1, 70 unsigned long config2); 71 72 /* 73 * sip_smc_dram() - Set dram configure for trust. 74 * 75 * see: ./drivers/ram/rockchip/rockchip_dmc.c 76 */ 77 struct arm_smccc_res sip_smc_dram(unsigned long arg0, 78 unsigned long arg1, 79 unsigned long arg2); 80 81 /* 82 * sip_smc_request_share_mem() - Request share memory from trust. 83 * 84 * @page_num: page numbers 85 * @page_type: page type, see: share_page_type_t 86 * 87 * @return arm_smccc_res structure, res.a0 equals 0 on success(res.a1 contains 88 * share memory base address), otherwise failed. 89 */ 90 struct arm_smccc_res sip_smc_request_share_mem(unsigned long page_num, 91 share_page_type_t page_type); 92 93 /* 94 * sip_smc_secure_reg_read() - Read secure info(ddr/register...) from trust. 95 * 96 * @addr_phy: address to read 97 * 98 * @return arm_smccc_res structure, res.a0 equals 0 on success(res.a1 contains 99 * valid data), otherwise failed. 100 */ 101 struct arm_smccc_res sip_smc_secure_reg_read(unsigned long addr_phy); 102 103 /* 104 * sip_smc_secure_reg_write() - Write data to trust secure info(ddr/register...). 105 * 106 * @addr_phy: address to write 107 * @val: value to write 108 * 109 * @return 0 on success, otherwise failed. 110 */ 111 int sip_smc_secure_reg_write(unsigned long addr_phy, unsigned long val); 112 113 /* 114 * sip_smc_set_sip_version() - Set sip version to trust. 115 * 116 * @return 0 on success, otherwise failed. 117 */ 118 int sip_smc_set_sip_version(unsigned long version); 119 120 /* 121 * sip_smc_get_sip_version() - Get sip version to trust. 122 * 123 * @return arm_smccc_res structure, res.a0 equals 0 on success(res.a1 contains 124 * sip version), otherwise failed. 125 */ 126 struct arm_smccc_res sip_smc_get_sip_version(void); 127 128 /* 129 * psci_cpu_on() - Standard ARM PSCI cpu on call. 130 * 131 * @cpuid: cpu id 132 * @entry_point: boot entry point 133 * 134 * @return 0 on success, otherwise failed. 135 */ 136 int psci_cpu_on(unsigned long cpuid, unsigned long entry_point); 137 138 /* 139 * psci_system_suspend() - Standard ARM PSCI system suspend call. 140 * 141 * @unused: unused now, always 0 recommend 142 * 143 * @return 0 on success, otherwise failed. 144 */ 145 int psci_system_suspend(unsigned long unused); 146 147 #endif 148