| 1 |
|
| 2 |
|
| 3 |
#include <device/mmio.h> |
| 4 |
#include <delay.h> |
| 5 |
#include <soc/clk.h> |
| 6 |
#include <stdint.h> |
| 7 |
#include <timer.h> |
| 8 |
|
| 9 |
static const uint32_t clocks_per_usec = MCT_HZ/1000000; |
| 10 |
|
| 11 |
static uint64_t mct_raw_value(void) |
| 12 |
{ |
| 13 |
uint64_t upper = read32(&exynos_mct->g_cnt_u); |
| 14 |
uint64_t lower = read32(&exynos_mct->g_cnt_l); |
| 15 |
|
| 16 |
return (upper << 32) | lower; |
| 17 |
} |
| 18 |
|
| 19 |
void init_timer(void) |
| 20 |
{ |
| 21 |
write32(&exynos_mct->g_tcon, read32(&exynos_mct->g_tcon) | (0x1 << 8)); |
| 22 |
} |
| 23 |
|
| 24 |
void timer_monotonic_get(struct mono_time *mt) |
| 25 |
{ |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
mono_time_set_usecs(mt, mct_raw_value() / clocks_per_usec); |
| 31 |
} |