Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | /* |
| 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 Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 8 | |
| 9 | void waitus(uint64_t us) |
| 10 | { |
Sandrine Bailleux | ba7695b | 2018-12-20 14:57:16 +0100 | [diff] [blame] | 11 | uint64_t start_count_val = syscounter_read(); |
| 12 | uint64_t wait_cycles = (us * read_cntfrq_el0()) / 1000000; |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 13 | |
Sandrine Bailleux | ba7695b | 2018-12-20 14:57:16 +0100 | [diff] [blame] | 14 | while ((syscounter_read() - start_count_val) < wait_cycles) |
| 15 | /* Busy wait... */; |
Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | void waitms(uint64_t ms) |
| 19 | { |
| 20 | while (ms > 0) { |
| 21 | waitus(1000); |
| 22 | ms--; |
| 23 | } |
| 24 | } |