fix error return value while loading environment
[barebox-mini2440.git] / include / clock.h
blob278f6e87b230b56870ab188e31806a4b7df48a7c
1 #include <types.h>
3 #ifndef CLOCK_H
4 #define CLOCK_H
6 struct clocksource {
7 uint32_t shift;
8 uint32_t mult;
9 uint64_t (*read)(void);
10 uint64_t cycle_last;
11 uint64_t mask;
15 static inline uint32_t cyc2ns(struct clocksource *cs, uint64_t cycles)
17 uint64_t ret = cycles;
18 ret = (ret * cs->mult) >> cs->shift;
19 return ret;
22 int init_clock(struct clocksource *);
24 uint64_t get_time_ns(void);
26 uint32_t clocksource_hz2mult(uint32_t hz, uint32_t shift_constant);
28 int is_timeout(uint64_t start_ns, uint64_t time_offset_ns);
30 // void udelay(unsigned long usecs);
32 void ndelay(unsigned long nsecs);
33 void mdelay(unsigned long msecs);
35 #define SECOND ((uint64_t)(1000 * 1000 * 1000))
36 #define MSECOND ((uint64_t)(1000 * 1000))
37 #define USECOND ((uint64_t)(1000))
39 #endif /* CLOCK_H */