OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [libdev/] [timer/] [sp804/] [timer.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * SP804 Primecell Timer offsets
3
 *
4
 * Copyright (C) 2007 Bahadir Balban
5
 *
6
 */
7
#ifndef __SP804_TIMER_H__
8
#define __SP804_TIMER_H__
9
 
10
#include <libdev/io.h>
11
 
12
/* Register offsets */
13
#define SP804_LOAD                      0x0
14
#define SP804_VALUE                     0x4
15
#define SP804_CTRL                      0x8
16
#define SP804_INTCLR                    0xC
17
#define SP804_RIS                       0x10
18
#define SP804_MIS                       0x14
19
#define SP804_BGLOAD                    0x18
20
 
21
#define SP804_ENABLE                    (1 << 7)
22
#define SP804_PERIODIC                  (1 << 6)
23
#define SP804_IRQEN                     (1 << 5)
24
#define SP804_32BIT                     (1 << 1)
25
#define SP804_ONESHOT                   (1 << 0)
26
 
27
/* Timer prescaling */
28
#define SP804_SCALE_SHIFT               2
29
#define SP804_SCALE_DIV16               1
30
#define SP804_SCALE_DIV256              2
31
 
32
/* Wrapping = 0, Oneshot = 1 */
33
#define SP804_ONESHOT                   (1 << 0)
34
 
35
static inline __attribute__ ((always_inline))
36
void sp804_load(unsigned long timer_base, u32 val)
37
{
38
        write(val, timer_base + SP804_LOAD);
39
}
40
 
41
static inline __attribute__ ((always_inline))
42
void sp804_irq_clear(unsigned long timer_base)
43
{
44
        write(1, timer_base + SP804_INTCLR);
45
}
46
 
47
static inline __attribute__ ((always_inline))
48
void sp804_enable(unsigned long timer_base)
49
{
50
        volatile u32 reg = read(timer_base + SP804_CTRL);
51
 
52
        write(reg | SP804_ENABLE, timer_base + SP804_CTRL);
53
}
54
 
55
void timer_start(unsigned long timer_base);
56
void timer_load(u32 loadval, unsigned long timer_base);
57
u32 timer_read(unsigned long timer_base);
58
void timer_stop(unsigned long timer_base);
59
void timer_init_periodic(unsigned long timer_base, u32 load_value);
60
void timer_init_oneshot(unsigned long timer_base);
61
void timer_init(unsigned long timer_base, u32 load_value);
62
 
63
#endif /* __SP804_TIMER_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.