1 /* 2 * Copyright (c) 2022, Intel Corporation. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <assert.h> 8 #include <common/debug.h> 9 #include <common/runtime_svc.h> 10 #include <lib/mmio.h> 11 12 #include "socfpga_sip_svc.h" 13 14 uintptr_t sip_smc_handler_v2(uint32_t smc_fid, 15 u_register_t x1, 16 u_register_t x2, 17 u_register_t x3, 18 u_register_t x4, 19 void *cookie, 20 void *handle, 21 u_register_t flags) 22 { 23 uint32_t retval = 0; 24 int status = INTEL_SIP_SMC_STATUS_OK; 25 26 switch (smc_fid) { 27 case INTEL_SIP_SMC_V2_GET_SVC_VERSION: 28 SMC_RET4(handle, INTEL_SIP_SMC_STATUS_OK, x1, 29 SIP_SVC_VERSION_MAJOR, 30 SIP_SVC_VERSION_MINOR); 31 32 case INTEL_SIP_SMC_V2_REG_READ: 33 status = intel_secure_reg_read(x2, &retval); 34 SMC_RET4(handle, status, x1, retval, x2); 35 36 case INTEL_SIP_SMC_V2_REG_WRITE: 37 status = intel_secure_reg_write(x2, (uint32_t)x3, &retval); 38 SMC_RET4(handle, status, x1, retval, x2); 39 40 case INTEL_SIP_SMC_V2_REG_UPDATE: 41 status = intel_secure_reg_update(x2, (uint32_t)x3, 42 (uint32_t)x4, &retval); 43 SMC_RET4(handle, status, x1, retval, x2); 44 45 case INTEL_SIP_SMC_V2_HPS_SET_BRIDGES: 46 status = intel_hps_set_bridges(x2, x3); 47 SMC_RET2(handle, status, x1); 48 49 default: 50 ERROR("%s: unhandled SMC V2 (0x%x)\n", __func__, smc_fid); 51 SMC_RET1(handle, SMC_UNK); 52 } 53 } 54