aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-nomadik
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/plat-nomadik')
-rw-r--r--arch/arm/plat-nomadik/include/plat/mtu.h47
-rw-r--r--arch/arm/plat-nomadik/timer.c50
2 files changed, 49 insertions, 48 deletions
diff --git a/arch/arm/plat-nomadik/include/plat/mtu.h b/arch/arm/plat-nomadik/include/plat/mtu.h
index 65704a3d4241..6508e7694a4b 100644
--- a/arch/arm/plat-nomadik/include/plat/mtu.h
+++ b/arch/arm/plat-nomadik/include/plat/mtu.h
@@ -1,54 +1,11 @@
1#ifndef __PLAT_MTU_H 1#ifndef __PLAT_MTU_H
2#define __PLAT_MTU_H 2#define __PLAT_MTU_H
3 3
4/*
5 * Guaranteed runtime conversion range in seconds for
6 * the clocksource and clockevent.
7 */
8#define MTU_MIN_RANGE 4
9
10/* should be set by the platform code */ 4/* should be set by the platform code */
11extern void __iomem *mtu_base; 5extern void __iomem *mtu_base;
12 6
13/* 7void nmdk_clkevt_reset(void);
14 * The MTU device hosts four different counters, with 4 set of 8void nmdk_clksrc_reset(void);
15 * registers. These are register names.
16 */
17
18#define MTU_IMSC 0x00 /* Interrupt mask set/clear */
19#define MTU_RIS 0x04 /* Raw interrupt status */
20#define MTU_MIS 0x08 /* Masked interrupt status */
21#define MTU_ICR 0x0C /* Interrupt clear register */
22
23/* per-timer registers take 0..3 as argument */
24#define MTU_LR(x) (0x10 + 0x10 * (x) + 0x00) /* Load value */
25#define MTU_VAL(x) (0x10 + 0x10 * (x) + 0x04) /* Current value */
26#define MTU_CR(x) (0x10 + 0x10 * (x) + 0x08) /* Control reg */
27#define MTU_BGLR(x) (0x10 + 0x10 * (x) + 0x0c) /* At next overflow */
28
29/* bits for the control register */
30#define MTU_CRn_ENA 0x80
31#define MTU_CRn_PERIODIC 0x40 /* if 0 = free-running */
32#define MTU_CRn_PRESCALE_MASK 0x0c
33#define MTU_CRn_PRESCALE_1 0x00
34#define MTU_CRn_PRESCALE_16 0x04
35#define MTU_CRn_PRESCALE_256 0x08
36#define MTU_CRn_32BITS 0x02
37#define MTU_CRn_ONESHOT 0x01 /* if 0 = wraps reloading from BGLR*/
38
39/* Other registers are usual amba/primecell registers, currently not used */
40#define MTU_ITCR 0xff0
41#define MTU_ITOP 0xff4
42
43#define MTU_PERIPH_ID0 0xfe0
44#define MTU_PERIPH_ID1 0xfe4
45#define MTU_PERIPH_ID2 0xfe8
46#define MTU_PERIPH_ID3 0xfeC
47
48#define MTU_PCELL0 0xff0
49#define MTU_PCELL1 0xff4
50#define MTU_PCELL2 0xff8
51#define MTU_PCELL3 0xffC
52 9
53#endif /* __PLAT_MTU_H */ 10#endif /* __PLAT_MTU_H */
54 11
diff --git a/arch/arm/plat-nomadik/timer.c b/arch/arm/plat-nomadik/timer.c
index a04b5215b6d8..30b6433d910d 100644
--- a/arch/arm/plat-nomadik/timer.c
+++ b/arch/arm/plat-nomadik/timer.c
@@ -21,7 +21,51 @@
21#include <asm/mach/time.h> 21#include <asm/mach/time.h>
22#include <asm/sched_clock.h> 22#include <asm/sched_clock.h>
23 23
24#include <plat/mtu.h> 24/*
25 * Guaranteed runtime conversion range in seconds for
26 * the clocksource and clockevent.
27 */
28#define MTU_MIN_RANGE 4
29
30/*
31 * The MTU device hosts four different counters, with 4 set of
32 * registers. These are register names.
33 */
34
35#define MTU_IMSC 0x00 /* Interrupt mask set/clear */
36#define MTU_RIS 0x04 /* Raw interrupt status */
37#define MTU_MIS 0x08 /* Masked interrupt status */
38#define MTU_ICR 0x0C /* Interrupt clear register */
39
40/* per-timer registers take 0..3 as argument */
41#define MTU_LR(x) (0x10 + 0x10 * (x) + 0x00) /* Load value */
42#define MTU_VAL(x) (0x10 + 0x10 * (x) + 0x04) /* Current value */
43#define MTU_CR(x) (0x10 + 0x10 * (x) + 0x08) /* Control reg */
44#define MTU_BGLR(x) (0x10 + 0x10 * (x) + 0x0c) /* At next overflow */
45
46/* bits for the control register */
47#define MTU_CRn_ENA 0x80
48#define MTU_CRn_PERIODIC 0x40 /* if 0 = free-running */
49#define MTU_CRn_PRESCALE_MASK 0x0c
50#define MTU_CRn_PRESCALE_1 0x00
51#define MTU_CRn_PRESCALE_16 0x04
52#define MTU_CRn_PRESCALE_256 0x08
53#define MTU_CRn_32BITS 0x02
54#define MTU_CRn_ONESHOT 0x01 /* if 0 = wraps reloading from BGLR*/
55
56/* Other registers are usual amba/primecell registers, currently not used */
57#define MTU_ITCR 0xff0
58#define MTU_ITOP 0xff4
59
60#define MTU_PERIPH_ID0 0xfe0
61#define MTU_PERIPH_ID1 0xfe4
62#define MTU_PERIPH_ID2 0xfe8
63#define MTU_PERIPH_ID3 0xfeC
64
65#define MTU_PCELL0 0xff0
66#define MTU_PCELL1 0xff4
67#define MTU_PCELL2 0xff8
68#define MTU_PCELL3 0xffC
25 69
26static bool clkevt_periodic; 70static bool clkevt_periodic;
27static u32 clk_prescale; 71static u32 clk_prescale;
@@ -68,7 +112,7 @@ static int nmdk_clkevt_next(unsigned long evt, struct clock_event_device *ev)
68 return 0; 112 return 0;
69} 113}
70 114
71static void nmdk_clkevt_reset(void) 115void nmdk_clkevt_reset(void)
72{ 116{
73 if (clkevt_periodic) { 117 if (clkevt_periodic) {
74 118
@@ -138,7 +182,7 @@ static struct irqaction nmdk_timer_irq = {
138 .dev_id = &nmdk_clkevt, 182 .dev_id = &nmdk_clkevt,
139}; 183};
140 184
141static void nmdk_clksrc_reset(void) 185void nmdk_clksrc_reset(void)
142{ 186{
143 /* Disable */ 187 /* Disable */
144 writel(0, mtu_base + MTU_CR(0)); 188 writel(0, mtu_base + MTU_CR(0));