Konstantin Porotchkin | f69ec58 | 2018-06-07 18:31:14 +0300 | [diff] [blame] | 1 | /* |
| 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 | |
| 14 | static 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 | |
| 24 | static 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 | |
| 30 | void plat_delay_timer_init(void) |
| 31 | { |
| 32 | timer_init(&plat_timer_ops); |
| 33 | } |