blob: 15953af099574764b6400899c730af29418ccfb2 [file] [log] [blame]
Vincent Guittot492acec2017-06-07 10:12:05 +02001/*
2 * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <hisi_sip_svc.h>
8#include <debug.h>
9#include <pmf.h>
10#include <runtime_svc.h>
11#include <stdint.h>
12#include <uuid.h>
13
14
15/* Hisi SiP Service UUID */
16DEFINE_SVC_UUID(hisi_sip_svc_uid,
17 0xe599df74, 0x7682, 0x40aa, 0x9f, 0xf8,
18 0xc0, 0x85, 0x52, 0xbc, 0x39, 0x3f);
19
20static int hisi_sip_setup(void)
21{
22 if (pmf_setup() != 0)
23 return 1;
24 return 0;
25}
26
27/*
28 * This function handles Hisi defined SiP Calls
29 */
30static uintptr_t hisi_sip_handler(unsigned int smc_fid,
31 u_register_t x1,
32 u_register_t x2,
33 u_register_t x3,
34 u_register_t x4,
35 void *cookie,
36 void *handle,
37 u_register_t flags)
38{
39 int call_count = 0;
40
41 /*
42 * Dispatch PMF calls to PMF SMC handler and return its return
43 * value
44 */
45 if (is_pmf_fid(smc_fid)) {
46 return pmf_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
47 handle, flags);
48 }
49
50 switch (smc_fid) {
51 case HISI_SIP_SVC_CALL_COUNT:
52 /* PMF calls */
53 call_count += PMF_NUM_SMC_CALLS;
54
55 /* State switch call */
56 call_count += 1;
57
58 SMC_RET1(handle, call_count);
59
60 case HISI_SIP_SVC_UID:
61 /* Return UID to the caller */
62 SMC_UUID_RET(handle, hisi_sip_svc_uid);
63
64 case HISI_SIP_SVC_VERSION:
65 /* Return the version of current implementation */
66 SMC_RET2(handle, HISI_SIP_SVC_VERSION_MAJOR, HISI_SIP_SVC_VERSION_MINOR);
67
68 default:
69 WARN("Unimplemented HISI SiP Service Call: 0x%x \n", smc_fid);
70 SMC_RET1(handle, SMC_UNK);
71 }
72
73}
74
75
76/* Define a runtime service descriptor for fast SMC calls */
77DECLARE_RT_SVC(
78 hisi_sip_svc,
79 OEN_SIP_START,
80 OEN_SIP_END,
81 SMC_TYPE_FAST,
82 hisi_sip_setup,
83 hisi_sip_handler
84);