aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/rockchip_timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/clocksource/rockchip_timer.c')
-rw-r--r--drivers/clocksource/rockchip_timer.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c
index d3c1742ded1a..8c77a529d0d4 100644
--- a/drivers/clocksource/rockchip_timer.c
+++ b/drivers/clocksource/rockchip_timer.c
@@ -17,16 +17,16 @@
17 17
18#define TIMER_NAME "rk_timer" 18#define TIMER_NAME "rk_timer"
19 19
20#define TIMER_LOAD_COUNT0 0x00 20#define TIMER_LOAD_COUNT0 0x00
21#define TIMER_LOAD_COUNT1 0x04 21#define TIMER_LOAD_COUNT1 0x04
22#define TIMER_CONTROL_REG 0x10 22#define TIMER_CONTROL_REG 0x10
23#define TIMER_INT_STATUS 0x18 23#define TIMER_INT_STATUS 0x18
24 24
25#define TIMER_DISABLE 0x0 25#define TIMER_DISABLE 0x0
26#define TIMER_ENABLE 0x1 26#define TIMER_ENABLE 0x1
27#define TIMER_MODE_FREE_RUNNING (0 << 1) 27#define TIMER_MODE_FREE_RUNNING (0 << 1)
28#define TIMER_MODE_USER_DEFINED_COUNT (1 << 1) 28#define TIMER_MODE_USER_DEFINED_COUNT (1 << 1)
29#define TIMER_INT_UNMASK (1 << 2) 29#define TIMER_INT_UNMASK (1 << 2)
30 30
31struct bc_timer { 31struct bc_timer {
32 struct clock_event_device ce; 32 struct clock_event_device ce;
@@ -49,14 +49,12 @@ static inline void __iomem *rk_base(struct clock_event_device *ce)
49static inline void rk_timer_disable(struct clock_event_device *ce) 49static inline void rk_timer_disable(struct clock_event_device *ce)
50{ 50{
51 writel_relaxed(TIMER_DISABLE, rk_base(ce) + TIMER_CONTROL_REG); 51 writel_relaxed(TIMER_DISABLE, rk_base(ce) + TIMER_CONTROL_REG);
52 dsb();
53} 52}
54 53
55static inline void rk_timer_enable(struct clock_event_device *ce, u32 flags) 54static inline void rk_timer_enable(struct clock_event_device *ce, u32 flags)
56{ 55{
57 writel_relaxed(TIMER_ENABLE | TIMER_INT_UNMASK | flags, 56 writel_relaxed(TIMER_ENABLE | TIMER_INT_UNMASK | flags,
58 rk_base(ce) + TIMER_CONTROL_REG); 57 rk_base(ce) + TIMER_CONTROL_REG);
59 dsb();
60} 58}
61 59
62static void rk_timer_update_counter(unsigned long cycles, 60static void rk_timer_update_counter(unsigned long cycles,
@@ -64,13 +62,11 @@ static void rk_timer_update_counter(unsigned long cycles,
64{ 62{
65 writel_relaxed(cycles, rk_base(ce) + TIMER_LOAD_COUNT0); 63 writel_relaxed(cycles, rk_base(ce) + TIMER_LOAD_COUNT0);
66 writel_relaxed(0, rk_base(ce) + TIMER_LOAD_COUNT1); 64 writel_relaxed(0, rk_base(ce) + TIMER_LOAD_COUNT1);
67 dsb();
68} 65}
69 66
70static void rk_timer_interrupt_clear(struct clock_event_device *ce) 67static void rk_timer_interrupt_clear(struct clock_event_device *ce)
71{ 68{
72 writel_relaxed(1, rk_base(ce) + TIMER_INT_STATUS); 69 writel_relaxed(1, rk_base(ce) + TIMER_INT_STATUS);
73 dsb();
74} 70}
75 71
76static inline int rk_timer_set_next_event(unsigned long cycles, 72static inline int rk_timer_set_next_event(unsigned long cycles,
@@ -173,4 +169,5 @@ static void __init rk_timer_init(struct device_node *np)
173 169
174 clockevents_config_and_register(ce, bc_timer.freq, 1, UINT_MAX); 170 clockevents_config_and_register(ce, bc_timer.freq, 1, UINT_MAX);
175} 171}
172
176CLOCKSOURCE_OF_DECLARE(rk_timer, "rockchip,rk3288-timer", rk_timer_init); 173CLOCKSOURCE_OF_DECLARE(rk_timer, "rockchip,rk3288-timer", rk_timer_init);