xref: /rk3399_ARM-atf/plat/imx/common/imx_sip_handler.c (revision 025514ba80f9bd51af460ff29c4a325904c1812c)
1 /*
2  * Copyright 2019 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <stdlib.h>
8 #include <stdint.h>
9 #include <std_svc.h>
10 #include <platform_def.h>
11 #include <common/debug.h>
12 #include <common/runtime_svc.h>
13 #include <imx_sip_svc.h>
14 #include <sci/sci.h>
15 
16 static int imx_srtc_set_time(uint32_t year_mon,
17 			unsigned long day_hour,
18 			unsigned long min_sec)
19 {
20 	return sc_timer_set_rtc_time(ipc_handle,
21 		year_mon >> 16, year_mon & 0xffff,
22 		day_hour >> 16, day_hour & 0xffff,
23 		min_sec >> 16, min_sec & 0xffff);
24 }
25 
26 int imx_srtc_handler(uint32_t smc_fid,
27 		    void *handle,
28 		    u_register_t x1,
29 		    u_register_t x2,
30 		    u_register_t x3,
31 		    u_register_t x4)
32 {
33 	int ret;
34 
35 	switch (x1) {
36 	case IMX_SIP_SRTC_SET_TIME:
37 		ret = imx_srtc_set_time(x2, x3, x4);
38 		break;
39 	default:
40 		ret = SMC_UNK;
41 	}
42 
43 	SMC_RET1(handle, ret);
44 }
45