blob: 6437bbf2c282895e6ec3c060d77c764a9a0418c9 [file] [log] [blame]
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +05301/*
Tejas Patel354fe572018-12-14 00:55:37 -08002 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +05303 *
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
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <common/debug.h>
10#include <common/runtime_svc.h>
11#include <tools_share/uuid.h>
Tejas Patel354fe572018-12-14 00:55:37 -080012#include "pm_svc_main.h"
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +053013
14/* SMC function IDs for SiP Service queries */
15#define VERSAL_SIP_SVC_CALL_COUNT 0x8200ff00
16#define VERSAL_SIP_SVC_UID 0x8200ff01
17#define VERSAL_SIP_SVC_VERSION 0x8200ff03
18
19/* SiP Service Calls version numbers */
20#define SIP_SVC_VERSION_MAJOR 0
21#define SIP_SVC_VERSION_MINOR 1
22
23/* These macros are used to identify PM calls from the SMC function ID */
24#define PM_FID_MASK 0xf000u
25#define PM_FID_VALUE 0u
26#define is_pm_fid(_fid) (((_fid) & PM_FID_MASK) == PM_FID_VALUE)
27
28/* SiP Service UUID */
29DEFINE_SVC_UUID2(versal_sip_uuid,
30 0x2ab9e4ec, 0x93b9, 0x11e7, 0xa0, 0x19,
31 0xdf, 0xe0, 0xdb, 0xad, 0x0a, 0xe0);
32
33/**
34 * sip_svc_setup() - Setup SiP Service
35 *
36 * Invokes PM setup
37 */
38static int32_t sip_svc_setup(void)
39{
Tejas Patel354fe572018-12-14 00:55:37 -080040 /* PM implementation as SiP Service */
41 pm_setup();
42
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +053043 return 0;
44}
45
46/**
47 * sip_svc_smc_handler() - Top-level SiP Service SMC handler
48 *
49 * Handler for all SiP SMC calls. Handles standard SIP requests
50 * and calls PM SMC handler if the call is for a PM-API function.
51 */
52uintptr_t sip_svc_smc_handler(uint32_t smc_fid,
53 u_register_t x1,
54 u_register_t x2,
55 u_register_t x3,
56 u_register_t x4,
57 void *cookie,
58 void *handle,
59 u_register_t flags)
60{
61 /* Let PM SMC handler deal with PM-related requests */
62 switch (smc_fid) {
63 case VERSAL_SIP_SVC_CALL_COUNT:
64 /* PM functions + default functions */
65 SMC_RET1(handle, 2);
66
67 case VERSAL_SIP_SVC_UID:
68 SMC_UUID_RET(handle, versal_sip_uuid);
69
70 case VERSAL_SIP_SVC_VERSION:
71 SMC_RET2(handle, SIP_SVC_VERSION_MAJOR, SIP_SVC_VERSION_MINOR);
72
73 default:
74 WARN("Unimplemented SiP Service Call: 0x%x\n", smc_fid);
75 SMC_RET1(handle, SMC_UNK);
76 }
77}
78
79/* Register PM Service Calls as runtime service */
80DECLARE_RT_SVC(
81 sip_svc,
82 OEN_SIP_START,
83 OEN_SIP_END,
84 SMC_TYPE_FAST,
85 sip_svc_setup,
86 sip_svc_smc_handler);