blob: f6b29d1e8608098ce7a5b0d3ccac799029c1a9ce [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch_helpers.h>
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02008
9void waitus(uint64_t us)
10{
Sandrine Bailleuxba7695b2018-12-20 14:57:16 +010011 uint64_t start_count_val = syscounter_read();
12 uint64_t wait_cycles = (us * read_cntfrq_el0()) / 1000000;
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020013
Sandrine Bailleuxba7695b2018-12-20 14:57:16 +010014 while ((syscounter_read() - start_count_val) < wait_cycles)
15 /* Busy wait... */;
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020016}
17
18void waitms(uint64_t ms)
19{
20 while (ms > 0) {
21 waitus(1000);
22 ms--;
23 }
24}