Lines Matching refs:ce

72 static void sun5i_clkevt_sync(struct sun5i_timer_clkevt *ce)  in sun5i_clkevt_sync()  argument
74 u32 old = readl(ce->timer.base + TIMER_CNTVAL_LO_REG(1)); in sun5i_clkevt_sync()
76 while ((old - readl(ce->timer.base + TIMER_CNTVAL_LO_REG(1))) < TIMER_SYNC_TICKS) in sun5i_clkevt_sync()
80 static void sun5i_clkevt_time_stop(struct sun5i_timer_clkevt *ce, u8 timer) in sun5i_clkevt_time_stop() argument
82 u32 val = readl(ce->timer.base + TIMER_CTL_REG(timer)); in sun5i_clkevt_time_stop()
83 writel(val & ~TIMER_CTL_ENABLE, ce->timer.base + TIMER_CTL_REG(timer)); in sun5i_clkevt_time_stop()
85 sun5i_clkevt_sync(ce); in sun5i_clkevt_time_stop()
88 static void sun5i_clkevt_time_setup(struct sun5i_timer_clkevt *ce, u8 timer, u32 delay) in sun5i_clkevt_time_setup() argument
90 writel(delay, ce->timer.base + TIMER_INTVAL_LO_REG(timer)); in sun5i_clkevt_time_setup()
93 static void sun5i_clkevt_time_start(struct sun5i_timer_clkevt *ce, u8 timer, bool periodic) in sun5i_clkevt_time_start() argument
95 u32 val = readl(ce->timer.base + TIMER_CTL_REG(timer)); in sun5i_clkevt_time_start()
103 ce->timer.base + TIMER_CTL_REG(timer)); in sun5i_clkevt_time_start()
108 struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt); in sun5i_clkevt_shutdown() local
110 sun5i_clkevt_time_stop(ce, 0); in sun5i_clkevt_shutdown()
116 struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt); in sun5i_clkevt_set_oneshot() local
118 sun5i_clkevt_time_stop(ce, 0); in sun5i_clkevt_set_oneshot()
119 sun5i_clkevt_time_start(ce, 0, false); in sun5i_clkevt_set_oneshot()
125 struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt); in sun5i_clkevt_set_periodic() local
127 sun5i_clkevt_time_stop(ce, 0); in sun5i_clkevt_set_periodic()
128 sun5i_clkevt_time_setup(ce, 0, ce->timer.ticks_per_jiffy); in sun5i_clkevt_set_periodic()
129 sun5i_clkevt_time_start(ce, 0, true); in sun5i_clkevt_set_periodic()
136 struct sun5i_timer_clkevt *ce = to_sun5i_timer_clkevt(clkevt); in sun5i_clkevt_next_event() local
138 sun5i_clkevt_time_stop(ce, 0); in sun5i_clkevt_next_event()
139 sun5i_clkevt_time_setup(ce, 0, evt - TIMER_SYNC_TICKS); in sun5i_clkevt_next_event()
140 sun5i_clkevt_time_start(ce, 0, false); in sun5i_clkevt_next_event()
147 struct sun5i_timer_clkevt *ce = (struct sun5i_timer_clkevt *)dev_id; in sun5i_timer_interrupt() local
149 writel(0x1, ce->timer.base + TIMER_IRQ_ST_REG); in sun5i_timer_interrupt()
150 ce->clkevt.event_handler(&ce->clkevt); in sun5i_timer_interrupt()
248 struct sun5i_timer_clkevt *ce = container_of(timer, struct sun5i_timer_clkevt, timer); in sun5i_rate_cb_clkevt() local
251 clockevents_update_freq(&ce->clkevt, ndata->new_rate); in sun5i_rate_cb_clkevt()
252 ce->timer.ticks_per_jiffy = DIV_ROUND_UP(ndata->new_rate, HZ); in sun5i_rate_cb_clkevt()
261 struct sun5i_timer_clkevt *ce; in sun5i_setup_clockevent() local
266 ce = kzalloc(sizeof(*ce), GFP_KERNEL); in sun5i_setup_clockevent()
267 if (!ce) in sun5i_setup_clockevent()
278 ce->timer.base = base; in sun5i_setup_clockevent()
279 ce->timer.ticks_per_jiffy = DIV_ROUND_UP(rate, HZ); in sun5i_setup_clockevent()
280 ce->timer.clk = clk; in sun5i_setup_clockevent()
281 ce->timer.clk_rate_cb.notifier_call = sun5i_rate_cb_clkevt; in sun5i_setup_clockevent()
282 ce->timer.clk_rate_cb.next = NULL; in sun5i_setup_clockevent()
284 ret = clk_notifier_register(clk, &ce->timer.clk_rate_cb); in sun5i_setup_clockevent()
290 ce->clkevt.name = node->name; in sun5i_setup_clockevent()
291 ce->clkevt.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; in sun5i_setup_clockevent()
292 ce->clkevt.set_next_event = sun5i_clkevt_next_event; in sun5i_setup_clockevent()
293 ce->clkevt.set_state_shutdown = sun5i_clkevt_shutdown; in sun5i_setup_clockevent()
294 ce->clkevt.set_state_periodic = sun5i_clkevt_set_periodic; in sun5i_setup_clockevent()
295 ce->clkevt.set_state_oneshot = sun5i_clkevt_set_oneshot; in sun5i_setup_clockevent()
296 ce->clkevt.tick_resume = sun5i_clkevt_shutdown; in sun5i_setup_clockevent()
297 ce->clkevt.rating = 340; in sun5i_setup_clockevent()
298 ce->clkevt.irq = irq; in sun5i_setup_clockevent()
299 ce->clkevt.cpumask = cpu_possible_mask; in sun5i_setup_clockevent()
305 clockevents_config_and_register(&ce->clkevt, rate, in sun5i_setup_clockevent()
309 "sun5i_timer0", ce); in sun5i_setup_clockevent()
318 clk_notifier_unregister(clk, &ce->timer.clk_rate_cb); in sun5i_setup_clockevent()
322 kfree(ce); in sun5i_setup_clockevent()