1*1d333e69SMichal Simek /* 2*1d333e69SMichal Simek * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. 3*1d333e69SMichal Simek * Copyright (c) 2018-2022, Xilinx, Inc. All rights reserved. 4*1d333e69SMichal Simek * Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved. 5*1d333e69SMichal Simek * 6*1d333e69SMichal Simek * SPDX-License-Identifier: BSD-3-Clause 7*1d333e69SMichal Simek */ 8*1d333e69SMichal Simek 9*1d333e69SMichal Simek /* Top level SMC handler for SiP calls. Dispatch PM calls to PM SMC handler. */ 10*1d333e69SMichal Simek 11*1d333e69SMichal Simek #include <common/debug.h> 12*1d333e69SMichal Simek #include <common/runtime_svc.h> 13*1d333e69SMichal Simek #include <tools_share/uuid.h> 14*1d333e69SMichal Simek 15*1d333e69SMichal Simek /* SMC function IDs for SiP Service queries */ 16*1d333e69SMichal Simek #define VERSAL_NET_SIP_SVC_CALL_COUNT (0x8200ff00U) 17*1d333e69SMichal Simek #define VERSAL_NET_SIP_SVC_UID (0x8200ff01U) 18*1d333e69SMichal Simek #define VERSAL_NET_SIP_SVC_VERSION (0x8200ff03U) 19*1d333e69SMichal Simek 20*1d333e69SMichal Simek /* SiP Service Calls version numbers */ 21*1d333e69SMichal Simek #define SIP_SVC_VERSION_MAJOR (0U) 22*1d333e69SMichal Simek #define SIP_SVC_VERSION_MINOR (1U) 23*1d333e69SMichal Simek 24*1d333e69SMichal Simek /* SiP Service UUID */ 25*1d333e69SMichal Simek DEFINE_SVC_UUID2(versal_net_sip_uuid, 26*1d333e69SMichal Simek 0x80d4c25a, 0xebaf, 0x11eb, 0x94, 0x68, 27*1d333e69SMichal Simek 0x0b, 0x4e, 0x3b, 0x8f, 0xc3, 0x60); 28*1d333e69SMichal Simek 29*1d333e69SMichal Simek /** 30*1d333e69SMichal Simek * sip_svc_setup() - Setup SiP Service 31*1d333e69SMichal Simek */ 32*1d333e69SMichal Simek static int32_t sip_svc_setup(void) 33*1d333e69SMichal Simek { 34*1d333e69SMichal Simek return 0; 35*1d333e69SMichal Simek } 36*1d333e69SMichal Simek 37*1d333e69SMichal Simek /* 38*1d333e69SMichal Simek * sip_svc_smc_handler() - Top-level SiP Service SMC handler 39*1d333e69SMichal Simek * 40*1d333e69SMichal Simek * Handler for all SiP SMC calls. Handles standard SIP requests 41*1d333e69SMichal Simek * and calls PM SMC handler if the call is for a PM-API function. 42*1d333e69SMichal Simek */ 43*1d333e69SMichal Simek static uintptr_t sip_svc_smc_handler(uint32_t smc_fid, 44*1d333e69SMichal Simek u_register_t x1, 45*1d333e69SMichal Simek u_register_t x2, 46*1d333e69SMichal Simek u_register_t x3, 47*1d333e69SMichal Simek u_register_t x4, 48*1d333e69SMichal Simek void *cookie, 49*1d333e69SMichal Simek void *handle, 50*1d333e69SMichal Simek u_register_t flags) 51*1d333e69SMichal Simek { 52*1d333e69SMichal Simek /* Let PM SMC handler deal with PM-related requests */ 53*1d333e69SMichal Simek switch (smc_fid) { 54*1d333e69SMichal Simek case VERSAL_NET_SIP_SVC_CALL_COUNT: 55*1d333e69SMichal Simek /* PM functions + default functions */ 56*1d333e69SMichal Simek SMC_RET1(handle, 2); 57*1d333e69SMichal Simek 58*1d333e69SMichal Simek case VERSAL_NET_SIP_SVC_UID: 59*1d333e69SMichal Simek SMC_UUID_RET(handle, versal_net_sip_uuid); 60*1d333e69SMichal Simek 61*1d333e69SMichal Simek case VERSAL_NET_SIP_SVC_VERSION: 62*1d333e69SMichal Simek SMC_RET2(handle, SIP_SVC_VERSION_MAJOR, SIP_SVC_VERSION_MINOR); 63*1d333e69SMichal Simek 64*1d333e69SMichal Simek default: 65*1d333e69SMichal Simek WARN("Unimplemented SiP Service Call: 0x%x\n", smc_fid); 66*1d333e69SMichal Simek SMC_RET1(handle, SMC_UNK); 67*1d333e69SMichal Simek } 68*1d333e69SMichal Simek } 69*1d333e69SMichal Simek 70*1d333e69SMichal Simek /* Register PM Service Calls as runtime service */ 71*1d333e69SMichal Simek DECLARE_RT_SVC( 72*1d333e69SMichal Simek sip_svc, 73*1d333e69SMichal Simek OEN_SIP_START, 74*1d333e69SMichal Simek OEN_SIP_END, 75*1d333e69SMichal Simek SMC_TYPE_FAST, 76*1d333e69SMichal Simek sip_svc_setup, 77*1d333e69SMichal Simek sip_svc_smc_handler); 78