Ryan Harkin | 32539fc | 2015-03-17 14:50:05 +0000 | [diff] [blame] | 1 | /* |
Abhi.Singh | ce66811 | 2024-08-21 12:55:38 -0500 | [diff] [blame] | 2 | * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. |
Lionel Debieve | 94a552f | 2019-09-24 16:59:56 +0200 | [diff] [blame] | 3 | * Copyright (c) 2019, Linaro Limited |
Ryan Harkin | 32539fc | 2015-03-17 14:50:05 +0000 | [diff] [blame] | 4 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 5 | * SPDX-License-Identifier: BSD-3-Clause |
Ryan Harkin | 32539fc | 2015-03-17 14:50:05 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 8 | #ifndef DELAY_TIMER_H |
| 9 | #define DELAY_TIMER_H |
Ryan Harkin | 32539fc | 2015-03-17 14:50:05 +0000 | [diff] [blame] | 10 | |
Lionel Debieve | 94a552f | 2019-09-24 16:59:56 +0200 | [diff] [blame] | 11 | #include <stdbool.h> |
Ryan Harkin | 32539fc | 2015-03-17 14:50:05 +0000 | [diff] [blame] | 12 | #include <stdint.h> |
| 13 | |
Lionel Debieve | 94a552f | 2019-09-24 16:59:56 +0200 | [diff] [blame] | 14 | #include <arch_helpers.h> |
| 15 | |
Ryan Harkin | 32539fc | 2015-03-17 14:50:05 +0000 | [diff] [blame] | 16 | /******************************************************************** |
| 17 | * A simple timer driver providing synchronous delay functionality. |
| 18 | * The driver must be initialized with a structure that provides a |
| 19 | * function pointer to return the timer value and a clock |
| 20 | * multiplier/divider. The ratio of the multiplier and the divider is |
Juan Castillo | fd383b4 | 2015-12-01 16:10:15 +0000 | [diff] [blame] | 21 | * the clock period in microseconds. |
Ryan Harkin | 32539fc | 2015-03-17 14:50:05 +0000 | [diff] [blame] | 22 | ********************************************************************/ |
| 23 | |
| 24 | typedef struct timer_ops { |
| 25 | uint32_t (*get_timer_value)(void); |
| 26 | uint32_t clk_mult; |
| 27 | uint32_t clk_div; |
Abhi.Singh | ce66811 | 2024-08-21 12:55:38 -0500 | [diff] [blame] | 28 | uint64_t (*timeout_init_us)(uint32_t usec); |
| 29 | bool (*timeout_elapsed)(uint64_t cnt); |
Ryan Harkin | 32539fc | 2015-03-17 14:50:05 +0000 | [diff] [blame] | 30 | } timer_ops_t; |
| 31 | |
Abhi.Singh | ce66811 | 2024-08-21 12:55:38 -0500 | [diff] [blame] | 32 | uint64_t timeout_init_us(uint32_t usec); |
| 33 | bool timeout_elapsed(uint64_t cnt); |
Ryan Harkin | 32539fc | 2015-03-17 14:50:05 +0000 | [diff] [blame] | 34 | void mdelay(uint32_t msec); |
| 35 | void udelay(uint32_t usec); |
Roberto Vargas | 777dd43 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 36 | void timer_init(const timer_ops_t *ops_ptr); |
Ryan Harkin | 32539fc | 2015-03-17 14:50:05 +0000 | [diff] [blame] | 37 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 38 | #endif /* DELAY_TIMER_H */ |