blob: aced5891a8cb891dcc0b70472aad46bc5e3e4443 [file] [log] [blame]
Marek Vasut1778b412018-12-26 15:57:08 +01001/*
2 * Copyright (c) 2018, 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#include "micro_delay.h"
10
11#define RCAR_CONV_MICROSEC 1000000U
12
13void
14#if IMAGE_BL31
15 __attribute__ ((section (".system_ram")))
16#endif
17 rcar_micro_delay(uint64_t micro_sec)
18{
19 uint64_t freq;
20 uint64_t base_count;
21 uint64_t get_count;
22 uint64_t wait_time = 0U;
23
24 freq = read_cntfrq_el0();
25 base_count = read_cntpct_el0();
26 while (micro_sec > wait_time) {
27 get_count = read_cntpct_el0();
28 wait_time = ((get_count - base_count) * RCAR_CONV_MICROSEC) / freq;
29 }
30}