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> |
| 8 | #include <tftf.h> |
| 9 | |
| 10 | void waitus(uint64_t us) |
| 11 | { |
| 12 | uint64_t cntp_ct_val_base; |
| 13 | uint32_t cnt_frq; |
| 14 | uint64_t wait_cycles; |
| 15 | |
| 16 | cnt_frq = read_cntfrq_el0(); |
| 17 | cntp_ct_val_base = read_cntpct_el0(); |
| 18 | |
| 19 | /* Waitms in terms of counter freq */ |
| 20 | wait_cycles = (us * cnt_frq) / 1000000; |
| 21 | |
| 22 | while (read_cntpct_el0() - cntp_ct_val_base < wait_cycles) |
| 23 | ; |
| 24 | } |
| 25 | |
| 26 | void waitms(uint64_t ms) |
| 27 | { |
| 28 | while (ms > 0) { |
| 29 | waitus(1000); |
| 30 | ms--; |
| 31 | } |
| 32 | } |