blob: d88e500c61b38975bcdc4633ab5a3c04dcab194c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/*
* Copyright (c) 2018, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <arch_helpers.h>
#include <tftf.h>
void waitus(uint64_t us)
{
uint64_t cntp_ct_val_base;
uint32_t cnt_frq;
uint64_t wait_cycles;
cnt_frq = read_cntfrq_el0();
cntp_ct_val_base = read_cntpct_el0();
/* Waitms in terms of counter freq */
wait_cycles = (us * cnt_frq) / 1000000;
while (read_cntpct_el0() - cntp_ct_val_base < wait_cycles)
;
}
void waitms(uint64_t ms)
{
while (ms > 0) {
waitus(1000);
ms--;
}
}
|