blob: dfc77c7fef6d66b4df3aee7656fa225cf51a2fd5 [file] [log] [blame]
Konstantin Porotchkinf69ec582018-06-07 18:31:14 +03001/*
2 * Copyright (C) 2018 Marvell International Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 * https://spdx.org/licenses
6 */
7
8#include <arch_helpers.h>
9#include <delay_timer.h>
10#include <mvebu_def.h>
11
12#define SYS_COUNTER_FREQ_IN_MHZ (COUNTER_FREQUENCY/1000000)
13
14static uint32_t plat_get_timer_value(void)
15{
16 /*
17 * Generic delay timer implementation expects the timer to be a down
18 * counter. We apply bitwise NOT operator to the tick values returned
19 * by read_cntpct_el0() to simulate the down counter.
20 */
21 return (uint32_t)(~read_cntpct_el0());
22}
23
24static const timer_ops_t plat_timer_ops = {
25 .get_timer_value = plat_get_timer_value,
26 .clk_mult = 1,
27 .clk_div = SYS_COUNTER_FREQ_IN_MHZ
28};
29
30void plat_delay_timer_init(void)
31{
32 timer_init(&plat_timer_ops);
33}