1 /*
2  * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include "platform_retarget.h"
9 #include "platform_retarget_dev.h"
10 #include "timer_cmsdk.h"
11 #include "tfm_plat_test.h"
12 
13 #include "smm_mps2.h"
14 
15 #define TIMER_RELOAD_VALUE (16*1024*1024)
16 
tfm_plat_test_secure_timer_start(void)17 void tfm_plat_test_secure_timer_start(void)
18 {
19     if (!cmsdk_timer_is_initialized(&CMSDK_TIMER0_DEV_S)) {
20         cmsdk_timer_init(&CMSDK_TIMER0_DEV_S);
21     }
22     cmsdk_timer_set_reload_value(&CMSDK_TIMER0_DEV_S, TIMER_RELOAD_VALUE);
23     cmsdk_timer_enable(&CMSDK_TIMER0_DEV_S);
24     cmsdk_timer_enable_interrupt(&CMSDK_TIMER0_DEV_S);
25 }
26 
tfm_plat_test_secure_timer_stop(void)27 void tfm_plat_test_secure_timer_stop(void)
28 {
29     cmsdk_timer_disable(&CMSDK_TIMER0_DEV_S);
30     cmsdk_timer_disable_interrupt(&CMSDK_TIMER0_DEV_S);
31     cmsdk_timer_clear_interrupt(&CMSDK_TIMER0_DEV_S);
32 }
33 
tfm_plat_test_secure_timer_clear_intr(void)34 void tfm_plat_test_secure_timer_clear_intr(void) {
35     cmsdk_timer_clear_interrupt(&CMSDK_TIMER0_DEV_S);
36 }
37 
tfm_plat_test_non_secure_timer_start(void)38 void tfm_plat_test_non_secure_timer_start(void)
39 {
40     if (!cmsdk_timer_is_initialized(&CMSDK_TIMER1_DEV_NS)) {
41         cmsdk_timer_init(&CMSDK_TIMER1_DEV_NS);
42     }
43     cmsdk_timer_set_reload_value(&CMSDK_TIMER1_DEV_NS, TIMER_RELOAD_VALUE);
44     cmsdk_timer_enable(&CMSDK_TIMER1_DEV_NS);
45     cmsdk_timer_enable_interrupt(&CMSDK_TIMER1_DEV_NS);
46 }
47 
tfm_plat_test_non_secure_timer_stop(void)48 void tfm_plat_test_non_secure_timer_stop(void)
49 {
50     cmsdk_timer_disable(&CMSDK_TIMER1_DEV_NS);
51     cmsdk_timer_disable_interrupt(&CMSDK_TIMER1_DEV_NS);
52     cmsdk_timer_clear_interrupt(&CMSDK_TIMER1_DEV_NS);
53 }
54