19f505cc2SVincent Guittot /* 29f505cc2SVincent Guittot * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. 39f505cc2SVincent Guittot * 49f505cc2SVincent Guittot * SPDX-License-Identifier: BSD-3-Clause 59f505cc2SVincent Guittot */ 69f505cc2SVincent Guittot 79f505cc2SVincent Guittot #include <debug.h> 8ee1ebbd1SIsla Mitchell #include <hisi_sip_svc.h> 99f505cc2SVincent Guittot #include <pmf.h> 109f505cc2SVincent Guittot #include <runtime_svc.h> 119f505cc2SVincent Guittot #include <stdint.h> 129f505cc2SVincent Guittot #include <uuid.h> 139f505cc2SVincent Guittot 149f505cc2SVincent Guittot 159f505cc2SVincent Guittot /* Hisi SiP Service UUID */ 16*03364865SRoberto Vargas DEFINE_SVC_UUID2(hisi_sip_svc_uid, 17*03364865SRoberto Vargas 0x74df99e5, 0x8276, 0xaa40, 0x9f, 0xf8, 189f505cc2SVincent Guittot 0xc0, 0x85, 0x52, 0xbc, 0x39, 0x3f); 199f505cc2SVincent Guittot 209f505cc2SVincent Guittot static int hisi_sip_setup(void) 219f505cc2SVincent Guittot { 229f505cc2SVincent Guittot if (pmf_setup() != 0) 239f505cc2SVincent Guittot return 1; 249f505cc2SVincent Guittot return 0; 259f505cc2SVincent Guittot } 269f505cc2SVincent Guittot 279f505cc2SVincent Guittot /* 289f505cc2SVincent Guittot * This function handles Hisi defined SiP Calls 299f505cc2SVincent Guittot */ 309f505cc2SVincent Guittot static uintptr_t hisi_sip_handler(unsigned int smc_fid, 319f505cc2SVincent Guittot u_register_t x1, 329f505cc2SVincent Guittot u_register_t x2, 339f505cc2SVincent Guittot u_register_t x3, 349f505cc2SVincent Guittot u_register_t x4, 359f505cc2SVincent Guittot void *cookie, 369f505cc2SVincent Guittot void *handle, 379f505cc2SVincent Guittot u_register_t flags) 389f505cc2SVincent Guittot { 399f505cc2SVincent Guittot int call_count = 0; 409f505cc2SVincent Guittot 419f505cc2SVincent Guittot /* 429f505cc2SVincent Guittot * Dispatch PMF calls to PMF SMC handler and return its return 439f505cc2SVincent Guittot * value 449f505cc2SVincent Guittot */ 459f505cc2SVincent Guittot if (is_pmf_fid(smc_fid)) { 469f505cc2SVincent Guittot return pmf_smc_handler(smc_fid, x1, x2, x3, x4, cookie, 479f505cc2SVincent Guittot handle, flags); 489f505cc2SVincent Guittot } 499f505cc2SVincent Guittot 509f505cc2SVincent Guittot switch (smc_fid) { 519f505cc2SVincent Guittot case HISI_SIP_SVC_CALL_COUNT: 529f505cc2SVincent Guittot /* PMF calls */ 539f505cc2SVincent Guittot call_count += PMF_NUM_SMC_CALLS; 549f505cc2SVincent Guittot 559f505cc2SVincent Guittot /* State switch call */ 569f505cc2SVincent Guittot call_count += 1; 579f505cc2SVincent Guittot 589f505cc2SVincent Guittot SMC_RET1(handle, call_count); 599f505cc2SVincent Guittot 609f505cc2SVincent Guittot case HISI_SIP_SVC_UID: 619f505cc2SVincent Guittot /* Return UID to the caller */ 629f505cc2SVincent Guittot SMC_UUID_RET(handle, hisi_sip_svc_uid); 639f505cc2SVincent Guittot 649f505cc2SVincent Guittot case HISI_SIP_SVC_VERSION: 659f505cc2SVincent Guittot /* Return the version of current implementation */ 669f505cc2SVincent Guittot SMC_RET2(handle, HISI_SIP_SVC_VERSION_MAJOR, HISI_SIP_SVC_VERSION_MINOR); 679f505cc2SVincent Guittot 689f505cc2SVincent Guittot default: 699f505cc2SVincent Guittot WARN("Unimplemented HISI SiP Service Call: 0x%x \n", smc_fid); 709f505cc2SVincent Guittot SMC_RET1(handle, SMC_UNK); 719f505cc2SVincent Guittot } 729f505cc2SVincent Guittot 739f505cc2SVincent Guittot } 749f505cc2SVincent Guittot 759f505cc2SVincent Guittot 769f505cc2SVincent Guittot /* Define a runtime service descriptor for fast SMC calls */ 779f505cc2SVincent Guittot DECLARE_RT_SVC( 789f505cc2SVincent Guittot hisi_sip_svc, 799f505cc2SVincent Guittot OEN_SIP_START, 809f505cc2SVincent Guittot OEN_SIP_END, 819f505cc2SVincent Guittot SMC_TYPE_FAST, 829f505cc2SVincent Guittot hisi_sip_setup, 839f505cc2SVincent Guittot hisi_sip_handler 849f505cc2SVincent Guittot ); 85