mb/google/fatcat: add pre-mem configuration based on fw_config
[coreboot.git] / src / soc / samsung / exynos5420 / timer.c
blob5e5d6484543eb0b23195ef1ab385ffba822d2a63
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/mmio.h>
4 #include <delay.h>
5 #include <soc/clk.h>
6 #include <stdint.h>
7 #include <timer.h>
9 static const uint32_t clocks_per_usec = MCT_HZ/1000000;
11 static uint64_t mct_raw_value(void)
13 uint64_t upper = read32(&exynos_mct->g_cnt_u);
14 uint64_t lower = read32(&exynos_mct->g_cnt_l);
16 return (upper << 32) | lower;
19 void init_timer(void)
21 write32(&exynos_mct->g_tcon, read32(&exynos_mct->g_tcon) | (0x1 << 8));
24 void timer_monotonic_get(struct mono_time *mt)
26 /* We don't have to call mct_start() here
27 * because it was already called in the bootblock
30 mono_time_set_usecs(mt, mct_raw_value() / clocks_per_usec);