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