Lines Matching full:timer
3 * Rockchip timer support
44 struct rk_timer timer; member
52 return &container_of(ce, struct rk_clkevt, ce)->timer; in rk_timer()
55 static inline void rk_timer_disable(struct rk_timer *timer) in rk_timer_disable() argument
57 writel_relaxed(TIMER_DISABLE, timer->ctrl); in rk_timer_disable()
60 static inline void rk_timer_enable(struct rk_timer *timer, u32 flags) in rk_timer_enable() argument
62 writel_relaxed(TIMER_ENABLE | flags, timer->ctrl); in rk_timer_enable()
66 struct rk_timer *timer) in rk_timer_update_counter() argument
68 writel_relaxed(cycles, timer->base + TIMER_LOAD_COUNT0); in rk_timer_update_counter()
69 writel_relaxed(0, timer->base + TIMER_LOAD_COUNT1); in rk_timer_update_counter()
72 static void rk_timer_interrupt_clear(struct rk_timer *timer) in rk_timer_interrupt_clear() argument
74 writel_relaxed(1, timer->base + TIMER_INT_STATUS); in rk_timer_interrupt_clear()
80 struct rk_timer *timer = rk_timer(ce); in rk_timer_set_next_event() local
82 rk_timer_disable(timer); in rk_timer_set_next_event()
83 rk_timer_update_counter(cycles, timer); in rk_timer_set_next_event()
84 rk_timer_enable(timer, TIMER_MODE_USER_DEFINED_COUNT | in rk_timer_set_next_event()
91 struct rk_timer *timer = rk_timer(ce); in rk_timer_shutdown() local
93 rk_timer_disable(timer); in rk_timer_shutdown()
99 struct rk_timer *timer = rk_timer(ce); in rk_timer_set_periodic() local
101 rk_timer_disable(timer); in rk_timer_set_periodic()
102 rk_timer_update_counter(timer->freq / HZ - 1, timer); in rk_timer_set_periodic()
103 rk_timer_enable(timer, TIMER_MODE_FREE_RUNNING | TIMER_INT_UNMASK); in rk_timer_set_periodic()
110 struct rk_timer *timer = rk_timer(ce); in rk_timer_interrupt() local
112 rk_timer_interrupt_clear(timer); in rk_timer_interrupt()
115 rk_timer_disable(timer); in rk_timer_interrupt()
128 rk_timer_probe(struct rk_timer *timer, struct device_node *np) in rk_timer_probe() argument
135 timer->base = of_iomap(np, 0); in rk_timer_probe()
136 if (!timer->base) { in rk_timer_probe()
141 if (of_device_is_compatible(np, "rockchip,rk3399-timer")) in rk_timer_probe()
144 timer->ctrl = timer->base + ctrl_reg; in rk_timer_probe()
158 timer->pclk = pclk; in rk_timer_probe()
160 timer_clk = of_clk_get_by_name(np, "timer"); in rk_timer_probe()
163 pr_err("Failed to get timer clock for '%s'\n", TIMER_NAME); in rk_timer_probe()
169 pr_err("Failed to enable timer clock\n"); in rk_timer_probe()
172 timer->clk = timer_clk; in rk_timer_probe()
174 timer->freq = clk_get_rate(timer_clk); in rk_timer_probe()
182 timer->irq = irq; in rk_timer_probe()
184 rk_timer_interrupt_clear(timer); in rk_timer_probe()
185 rk_timer_disable(timer); in rk_timer_probe()
193 iounmap(timer->base); in rk_timer_probe()
198 static void __init rk_timer_cleanup(struct rk_timer *timer) in rk_timer_cleanup() argument
200 clk_disable_unprepare(timer->clk); in rk_timer_cleanup()
201 clk_disable_unprepare(timer->pclk); in rk_timer_cleanup()
202 iounmap(timer->base); in rk_timer_cleanup()
216 ret = rk_timer_probe(&rk_clkevt->timer, np); in rk_clkevt_init()
227 ce->irq = rk_clkevt->timer.irq; in rk_clkevt_init()
231 ret = request_irq(rk_clkevt->timer.irq, rk_timer_interrupt, IRQF_TIMER, in rk_clkevt_init()
240 rk_clkevt->timer.freq, 1, UINT_MAX); in rk_clkevt_init()
244 rk_timer_cleanup(&rk_clkevt->timer); in rk_clkevt_init()
299 pr_err("Too many timer definitions for '%s'\n", TIMER_NAME); in rk_timer_init()
303 TIMER_OF_DECLARE(rk3288_timer, "rockchip,rk3288-timer", rk_timer_init);
304 TIMER_OF_DECLARE(rk3399_timer, "rockchip,rk3399-timer", rk_timer_init);