soc: Remove copyright notices
[coreboot.git] / src / soc / rockchip / rk3399 / timer.c
blobfaf8b551ae9ab021b1856a49d9d85bc6351db4c9
1 /*
2 * This file is part of the coreboot project.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <device/mmio.h>
16 #include <delay.h>
17 #include <soc/timer.h>
18 #include <stdint.h>
19 #include <timer.h>
21 static uint64_t timer_raw_value(void)
23 uint64_t value0;
24 uint64_t value1;
26 value0 = (uint64_t)read32(&timer0_ptr->timer_cur_value0);
27 value1 = (uint64_t)read32(&timer0_ptr->timer_cur_value1);
29 return value0 | value1<<32;
32 void timer_monotonic_get(struct mono_time *mt)
34 mono_time_set_usecs(mt, timer_raw_value() / clocks_per_usec);
37 void init_timer(void)
39 write32(&timer0_ptr->timer_load_count0, TIMER_LOAD_VAL);
40 write32(&timer0_ptr->timer_load_count1, TIMER_LOAD_VAL);
41 write32(&timer0_ptr->timer_load_count2, 0);
42 write32(&timer0_ptr->timer_load_count3, 0);
43 write32(&timer0_ptr->timer_ctrl_reg, 1);