1 /* SPDX-License-Identifier: GPL-2.0-only */ 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 mct_raw_value(void)11static 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 init_timer(void)19void init_timer(void) 20 { 21 write32(&exynos_mct->g_tcon, read32(&exynos_mct->g_tcon) | (0x1 << 8)); 22 } 23 timer_monotonic_get(struct mono_time * mt)24void timer_monotonic_get(struct mono_time *mt) 25 { 26 /* We don't have to call mct_start() here 27 * because it was already called in the bootblock 28 */ 29 30 mono_time_set_usecs(mt, mct_raw_value() / clocks_per_usec); 31 } 32