1 /*
2  * Copyright (c) 2019-2022, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include "timer_cmsdk_drv.h"
9 #include "tfm_plat_defs.h"
10 #include "tfm_plat_test.h"
11 #include "device_definition.h"
12 
13 #define TIMER_RELOAD_VALUE          (16*1024*1024)
14 
tfm_plat_test_secure_timer_start(void)15 void tfm_plat_test_secure_timer_start(void)
16 {
17     if (!timer_cmsdk_is_initialized(&CMSDK_TIMER0_DEV_S)) {
18         timer_cmsdk_init(&CMSDK_TIMER0_DEV_S);
19     }
20     timer_cmsdk_set_reload_value(&CMSDK_TIMER0_DEV_S, TIMER_RELOAD_VALUE);
21     timer_cmsdk_enable(&CMSDK_TIMER0_DEV_S);
22     timer_cmsdk_enable_interrupt(&CMSDK_TIMER0_DEV_S);
23 }
24 
tfm_plat_test_secure_timer_stop(void)25 void tfm_plat_test_secure_timer_stop(void)
26 {
27     timer_cmsdk_disable(&CMSDK_TIMER0_DEV_S);
28     timer_cmsdk_disable_interrupt(&CMSDK_TIMER0_DEV_S);
29     timer_cmsdk_clear_interrupt(&CMSDK_TIMER0_DEV_S);
30 }
31 
tfm_plat_test_non_secure_timer_start(void)32 void tfm_plat_test_non_secure_timer_start(void)
33 {
34     if (!timer_cmsdk_is_initialized(&CMSDK_TIMER1_DEV_NS)) {
35         timer_cmsdk_init(&CMSDK_TIMER1_DEV_NS);
36     }
37     timer_cmsdk_set_reload_value(&CMSDK_TIMER1_DEV_NS, TIMER_RELOAD_VALUE);
38     timer_cmsdk_enable(&CMSDK_TIMER1_DEV_NS);
39     timer_cmsdk_enable_interrupt(&CMSDK_TIMER1_DEV_NS);
40 }
41 
tfm_plat_test_non_secure_timer_stop(void)42 void tfm_plat_test_non_secure_timer_stop(void)
43 {
44     timer_cmsdk_disable(&CMSDK_TIMER1_DEV_NS);
45     timer_cmsdk_disable_interrupt(&CMSDK_TIMER1_DEV_NS);
46     timer_cmsdk_clear_interrupt(&CMSDK_TIMER1_DEV_NS);
47 }
48