File: micro_delay.c

package info (click to toggle)
arm-trusted-firmware 2.12.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie, trixie-proposed-updates, trixie-updates
  • size: 43,768 kB
  • sloc: ansic: 451,243; asm: 28,729; python: 2,703; makefile: 2,048; javascript: 139; sh: 33
file content (31 lines) | stat: -rw-r--r-- 639 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * Copyright (c) 2018-2020, Renesas Electronics Corporation. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <arch.h>
#include <arch_helpers.h>

#include "micro_delay.h"

#define RCAR_CONV_MICROSEC		1000000U

void
#if IMAGE_BL31
	__attribute__ ((section(".system_ram")))
#endif
	rcar_micro_delay(uint64_t micro_sec)
{
	uint64_t freq;
	uint64_t base_count;
	uint64_t get_count;
	uint64_t wait_time = 0U;

	freq = read_cntfrq_el0();
	base_count = read_cntpct_el0();
	while (micro_sec > wait_time) {
		get_count = read_cntpct_el0();
		wait_time = ((get_count - base_count) * RCAR_CONV_MICROSEC) / freq;
	}
}