19055c7d1SRyan Harkin /* 2a6485b2bSAbhi.Singh * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. 30711ee5cSLionel Debieve * Copyright (c) 2019, Linaro Limited 49055c7d1SRyan Harkin * 582cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 69055c7d1SRyan Harkin */ 79055c7d1SRyan Harkin 8c3cf06f1SAntonio Nino Diaz #ifndef DELAY_TIMER_H 9c3cf06f1SAntonio Nino Diaz #define DELAY_TIMER_H 109055c7d1SRyan Harkin 110711ee5cSLionel Debieve #include <stdbool.h> 129055c7d1SRyan Harkin #include <stdint.h> 139055c7d1SRyan Harkin 140711ee5cSLionel Debieve #include <arch_helpers.h> 150711ee5cSLionel Debieve 169055c7d1SRyan Harkin /******************************************************************** 179055c7d1SRyan Harkin * A simple timer driver providing synchronous delay functionality. 189055c7d1SRyan Harkin * The driver must be initialized with a structure that provides a 199055c7d1SRyan Harkin * function pointer to return the timer value and a clock 209055c7d1SRyan Harkin * multiplier/divider. The ratio of the multiplier and the divider is 21540a5ba8SJuan Castillo * the clock period in microseconds. 229055c7d1SRyan Harkin ********************************************************************/ 239055c7d1SRyan Harkin 24*472cccb5SMaheedhar Bollapalli typedef struct timer_operation { 259055c7d1SRyan Harkin uint32_t (*get_timer_value)(void); 269055c7d1SRyan Harkin uint32_t clk_mult; 279055c7d1SRyan Harkin uint32_t clk_div; 28a6485b2bSAbhi.Singh uint64_t (*timeout_init_us)(uint32_t usec); 29a6485b2bSAbhi.Singh bool (*timeout_elapsed)(uint64_t cnt); 309055c7d1SRyan Harkin } timer_ops_t; 319055c7d1SRyan Harkin 32a6485b2bSAbhi.Singh uint64_t timeout_init_us(uint32_t usec); 33a6485b2bSAbhi.Singh bool timeout_elapsed(uint64_t cnt); 349055c7d1SRyan Harkin void mdelay(uint32_t msec); 359055c7d1SRyan Harkin void udelay(uint32_t usec); 369fb8af33SRoberto Vargas void timer_init(const timer_ops_t *ops_ptr); 379055c7d1SRyan Harkin 38c3cf06f1SAntonio Nino Diaz #endif /* DELAY_TIMER_H */ 39