delay_timer.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2019, Linaro Limited
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef DELAY_TIMER_H
  8. #define DELAY_TIMER_H
  9. #include <stdbool.h>
  10. #include <stdint.h>
  11. #include <arch_helpers.h>
  12. /********************************************************************
  13. * A simple timer driver providing synchronous delay functionality.
  14. * The driver must be initialized with a structure that provides a
  15. * function pointer to return the timer value and a clock
  16. * multiplier/divider. The ratio of the multiplier and the divider is
  17. * the clock period in microseconds.
  18. ********************************************************************/
  19. typedef struct timer_ops {
  20. uint32_t (*get_timer_value)(void);
  21. uint32_t clk_mult;
  22. uint32_t clk_div;
  23. uint64_t (*timeout_init_us)(uint32_t usec);
  24. bool (*timeout_elapsed)(uint64_t cnt);
  25. } timer_ops_t;
  26. uint64_t timeout_init_us(uint32_t usec);
  27. bool timeout_elapsed(uint64_t cnt);
  28. void mdelay(uint32_t msec);
  29. void udelay(uint32_t usec);
  30. void timer_init(const timer_ops_t *ops_ptr);
  31. #endif /* DELAY_TIMER_H */