1 /* 2 * Copyright (c) 2018-2020, Renesas Electronics Corporation. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <arch.h> 8 #include <arch_helpers.h> 9 10 #include "micro_delay.h" 11 12 #define RCAR_CONV_MICROSEC 1000000U 13 14 void 15 #if IMAGE_BL31 16 __attribute__ ((section(".system_ram"))) 17 #endif rcar_micro_delay(uint64_t micro_sec)18 rcar_micro_delay(uint64_t micro_sec) 19 { 20 uint64_t freq; 21 uint64_t base_count; 22 uint64_t get_count; 23 uint64_t wait_time = 0U; 24 25 freq = read_cntfrq_el0(); 26 base_count = read_cntpct_el0(); 27 while (micro_sec > wait_time) { 28 get_count = read_cntpct_el0(); 29 wait_time = ((get_count - base_count) * RCAR_CONV_MICROSEC) / freq; 30 } 31 } 32