X-Git-Url: https://git.librecmc.org/?p=oweals%2Fu-boot.git;a=blobdiff_plain;f=include%2Ftime.h;h=e99f9c8012701e7f0b62a37c0c71c12d2f4b8f87;hp=9fd0d73fb4e4342dc7650c1b4dcb114772b257ea;hb=1099b2abef35c3c887f6afac1a8ef18c7924d5d2;hpb=180e38ad2dbb3340cc71fb4fa335a68f2a4122ef diff --git a/include/time.h b/include/time.h index 9fd0d73fb4..e99f9c8012 100644 --- a/include/time.h +++ b/include/time.h @@ -4,6 +4,9 @@ #define _TIME_H #include +#include + +ulong get_tbclk(void); unsigned long get_timer(unsigned long base); @@ -12,6 +15,7 @@ unsigned long get_timer(unsigned long base); * Granularity may be larger than 1us if hardware does not support this. */ unsigned long timer_get_us(void); +uint64_t get_timer_us(uint64_t base); /* * timer_test_add_offset() @@ -21,6 +25,14 @@ unsigned long timer_get_us(void); */ void timer_test_add_offset(unsigned long offset); +/** + * usec_to_tick() - convert microseconds to clock ticks + * + * @usec: duration in microseconds + * Return: duration in clock ticks + */ +uint64_t usec_to_tick(unsigned long usec); + /* * These inlines deal with timer wrapping correctly. You are * strongly encouraged to use them @@ -60,4 +72,47 @@ void timer_test_add_offset(unsigned long offset); (time_after_eq(a,b) && \ time_before(a,c)) +/** + * usec2ticks() - Convert microseconds to internal ticks + * + * @usec: Value of microseconds to convert + * @return Corresponding internal ticks value, calculated using get_tbclk() + */ +ulong usec2ticks(unsigned long usec); + +/** + * ticks2usec() - Convert internal ticks to microseconds + * + * @ticks: Value of ticks to convert + * @return Corresponding microseconds value, calculated using get_tbclk() + */ +ulong ticks2usec(unsigned long ticks); + +/** + * wait_ticks() - waits a given number of ticks + * + * This is an internal function typically used to implement udelay() and + * similar. Normally you should use udelay() or mdelay() instead. + * + * @ticks: Number of ticks to wait + */ +void wait_ticks(unsigned long ticks); + +/** + * timer_get_us() - Get monotonic microsecond timer + * + * @return value of monotonic microsecond timer + */ +unsigned long timer_get_us(void); + +/** + * get_ticks() - Get the current tick value + * + * This is an internal value used by the timer on the system. Ticks increase + * monotonically at the rate given by get_tbclk(). + * + * @return current tick value + */ +uint64_t get_ticks(void); + #endif /* _TIME_H */