blob: e9fdfb785e6726123be7165889df63d1dfaea307 [file] [log] [blame]
Ryan Harkin32539fc2015-03-17 14:50:05 +00001/*
Abhi.Singhce668112024-08-21 12:55:38 -05002 * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.
Lionel Debieve94a552f2019-09-24 16:59:56 +02003 * Copyright (c) 2019, Linaro Limited
Ryan Harkin32539fc2015-03-17 14:50:05 +00004 *
dp-armfa3cf0b2017-05-03 09:38:09 +01005 * SPDX-License-Identifier: BSD-3-Clause
Ryan Harkin32539fc2015-03-17 14:50:05 +00006 */
7
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00008#ifndef DELAY_TIMER_H
9#define DELAY_TIMER_H
Ryan Harkin32539fc2015-03-17 14:50:05 +000010
Lionel Debieve94a552f2019-09-24 16:59:56 +020011#include <stdbool.h>
Ryan Harkin32539fc2015-03-17 14:50:05 +000012#include <stdint.h>
13
Lionel Debieve94a552f2019-09-24 16:59:56 +020014#include <arch_helpers.h>
15
Ryan Harkin32539fc2015-03-17 14:50:05 +000016/********************************************************************
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 Castillofd383b42015-12-01 16:10:15 +000021 * the clock period in microseconds.
Ryan Harkin32539fc2015-03-17 14:50:05 +000022 ********************************************************************/
23
24typedef struct timer_ops {
25 uint32_t (*get_timer_value)(void);
26 uint32_t clk_mult;
27 uint32_t clk_div;
Abhi.Singhce668112024-08-21 12:55:38 -050028 uint64_t (*timeout_init_us)(uint32_t usec);
29 bool (*timeout_elapsed)(uint64_t cnt);
Ryan Harkin32539fc2015-03-17 14:50:05 +000030} timer_ops_t;
31
Abhi.Singhce668112024-08-21 12:55:38 -050032uint64_t timeout_init_us(uint32_t usec);
33bool timeout_elapsed(uint64_t cnt);
Ryan Harkin32539fc2015-03-17 14:50:05 +000034void mdelay(uint32_t msec);
35void udelay(uint32_t usec);
Roberto Vargas777dd432018-02-12 12:36:17 +000036void timer_init(const timer_ops_t *ops_ptr);
Ryan Harkin32539fc2015-03-17 14:50:05 +000037
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000038#endif /* DELAY_TIMER_H */