1 /* 2 * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /* Top level SMC handler for SiP calls. Dispatch PM calls to PM SMC handler. */ 8 9 #include <runtime_svc.h> 10 #include <uuid.h> 11 #include "pm_svc_main.h" 12 13 /* SMC function IDs for SiP Service queries */ 14 #define ZYNQMP_SIP_SVC_CALL_COUNT 0x8200ff00 15 #define ZYNQMP_SIP_SVC_UID 0x8200ff01 16 #define ZYNQMP_SIP_SVC_VERSION 0x8200ff03 17 18 /* SiP Service Calls version numbers */ 19 #define SIP_SVC_VERSION_MAJOR 0 20 #define SIP_SVC_VERSION_MINOR 1 21 22 /* These macros are used to identify PM calls from the SMC function ID */ 23 #define PM_FID_MASK 0xf000u 24 #define PM_FID_VALUE 0u 25 #define is_pm_fid(_fid) (((_fid) & PM_FID_MASK) == PM_FID_VALUE) 26 27 /* SiP Service UUID */ 28 DEFINE_SVC_UUID(zynqmp_sip_uuid, 29 0x2a1d9b5c, 0x8605, 0x4023, 0xa6, 0x1b, 30 0xb9, 0x25, 0x82, 0x2d, 0xe3, 0xa5); 31 32 /** 33 * sip_svc_setup() - Setup SiP Service 34 * 35 * Invokes PM setup 36 */ 37 static int32_t sip_svc_setup(void) 38 { 39 /* PM implementation as SiP Service */ 40 pm_setup(); 41 42 return 0; 43 } 44 45 /** 46 * sip_svc_smc_handler() - Top-level SiP Service SMC handler 47 * 48 * Handler for all SiP SMC calls. Handles standard SIP requests 49 * and calls PM SMC handler if the call is for a PM-API function. 50 */ 51 uint64_t sip_svc_smc_handler(uint32_t smc_fid, 52 uint64_t x1, 53 uint64_t x2, 54 uint64_t x3, 55 uint64_t x4, 56 void *cookie, 57 void *handle, 58 uint64_t flags) 59 { 60 /* Let PM SMC handler deal with PM-related requests */ 61 if (is_pm_fid(smc_fid)) { 62 return pm_smc_handler(smc_fid, x1, x2, x3, x4, cookie, handle, 63 flags); 64 } 65 66 switch (smc_fid) { 67 case ZYNQMP_SIP_SVC_CALL_COUNT: 68 /* PM functions + default functions */ 69 SMC_RET1(handle, PM_API_MAX + 2); 70 71 case ZYNQMP_SIP_SVC_UID: 72 SMC_UUID_RET(handle, zynqmp_sip_uuid); 73 74 case ZYNQMP_SIP_SVC_VERSION: 75 SMC_RET2(handle, SIP_SVC_VERSION_MAJOR, SIP_SVC_VERSION_MINOR); 76 77 default: 78 WARN("Unimplemented SiP Service Call: 0x%x\n", smc_fid); 79 SMC_RET1(handle, SMC_UNK); 80 } 81 } 82 83 /* Register PM Service Calls as runtime service */ 84 DECLARE_RT_SVC( 85 sip_svc, 86 OEN_SIP_START, 87 OEN_SIP_END, 88 SMC_TYPE_FAST, 89 sip_svc_setup, 90 sip_svc_smc_handler); 91