blob: d232d7e067c3a01b6aea8dfe6ee43bc9b8bfaa71 [file] [log] [blame]
Stephen Warren45b8ae62012-08-05 16:07:21 +00001/*
2 * (C) Copyright 2012 Stephen Warren
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <common.h>
18#include <asm/io.h>
19#include <asm/arch/timer.h>
20
21int timer_init(void)
22{
23 return 0;
24}
25
26ulong get_timer(ulong base)
27{
28 struct bcm2835_timer_regs *regs =
29 (struct bcm2835_timer_regs *)BCM2835_TIMER_PHYSADDR;
30
31 return readl(&regs->clo) - base;
32}
33
34unsigned long long get_ticks(void)
35{
36 return get_timer(0);
37}
38
39ulong get_tbclk(void)
40{
41 return CONFIG_SYS_HZ;
42}
43
44void __udelay(unsigned long usec)
45{
46 ulong endtime;
47 signed long diff;
48
49 endtime = get_timer(0) + usec;
50
51 do {
52 ulong now = get_timer(0);
53 diff = endtime - now;
54 } while (diff >= 0);
55}