tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / soc / rockchip / rk3288 / timer.c
blob0b07eda525cef47f242d43597dd5595cf446feed
1 /*
2 * This file is part of the coreboot project.
4 * Copyright 2014 Rockchip Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #include <arch/io.h>
17 #include <delay.h>
18 #include <soc/timer.h>
19 #include <stdint.h>
20 #include <timer.h>
22 static uint64_t timer_raw_value(void)
24 uint64_t value0;
25 uint64_t value1;
27 value0 = (uint64_t)read32(&timer7_ptr->timer_curr_value0);
28 value1 = (uint64_t)read32(&timer7_ptr->timer_curr_value1);
29 value0 = value0 | value1<<32;
30 return value0;
33 void timer_monotonic_get(struct mono_time *mt)
35 mono_time_set_usecs(mt, timer_raw_value() / clocks_per_usec);
38 void init_timer(void)
40 write32(&timer7_ptr->timer_load_count0, TIMER_LOAD_VAL);
41 write32(&timer7_ptr->timer_load_count1, TIMER_LOAD_VAL);
42 write32(&timer7_ptr->timer_ctrl_reg, 1);