blob: 3cd1bd0921ea55a42824e6190d160b1f90081000 [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
Vincent Guittot492acec2017-06-07 10:12:05 +02007#include <stdint.h>
Vincent Guittot492acec2017-06-07 10:12:05 +02008
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <common/debug.h>
10#include <common/runtime_svc.h>
11#include <lib/pmf/pmf.h>
12#include <tools_share/uuid.h>
13
14#include <hisi_sip_svc.h>
Vincent Guittot492acec2017-06-07 10:12:05 +020015
16/* Hisi SiP Service UUID */
Roberto Vargaseace8f12018-04-26 13:36:53 +010017DEFINE_SVC_UUID2(hisi_sip_svc_uid,
18 0x74df99e5, 0x8276, 0xaa40, 0x9f, 0xf8,
19 0xc0, 0x85, 0x52, 0xbc, 0x39, 0x3f);
Vincent Guittot492acec2017-06-07 10:12:05 +020020
21static int hisi_sip_setup(void)
22{
23 if (pmf_setup() != 0)
24 return 1;
25 return 0;
26}
27
28/*
29 * This function handles Hisi defined SiP Calls
30 */
31static uintptr_t hisi_sip_handler(unsigned int smc_fid,
32 u_register_t x1,
33 u_register_t x2,
34 u_register_t x3,
35 u_register_t x4,
36 void *cookie,
37 void *handle,
38 u_register_t flags)
39{
40 int call_count = 0;
41
42 /*
43 * Dispatch PMF calls to PMF SMC handler and return its return
44 * value
45 */
46 if (is_pmf_fid(smc_fid)) {
47 return pmf_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
48 handle, flags);
49 }
50
51 switch (smc_fid) {
52 case HISI_SIP_SVC_CALL_COUNT:
53 /* PMF calls */
54 call_count += PMF_NUM_SMC_CALLS;
55
56 /* State switch call */
57 call_count += 1;
58
59 SMC_RET1(handle, call_count);
60
61 case HISI_SIP_SVC_UID:
62 /* Return UID to the caller */
63 SMC_UUID_RET(handle, hisi_sip_svc_uid);
64
65 case HISI_SIP_SVC_VERSION:
66 /* Return the version of current implementation */
67 SMC_RET2(handle, HISI_SIP_SVC_VERSION_MAJOR, HISI_SIP_SVC_VERSION_MINOR);
68
69 default:
70 WARN("Unimplemented HISI SiP Service Call: 0x%x \n", smc_fid);
71 SMC_RET1(handle, SMC_UNK);
72 }
73
74}
75
76
77/* Define a runtime service descriptor for fast SMC calls */
78DECLARE_RT_SVC(
79 hisi_sip_svc,
80 OEN_SIP_START,
81 OEN_SIP_END,
82 SMC_TYPE_FAST,
83 hisi_sip_setup,
84 hisi_sip_handler
85);