void __init setup_system_timer0(void)
{
	/* Power down the core timer, just to play safe. */
	bfin_write_TCNTL(0);

	disable_gptimers(TIMER0bit);
	set_gptimer_status(0, TIMER_STATUS_TRUN0);
	while (get_gptimer_status(0) & TIMER_STATUS_TRUN0)
		udelay(10);

	set_gptimer_config(0, 0x59); /* IRQ enable, periodic, PWM_OUT, SCLKed, OUT PAD disabled */
	set_gptimer_period(TIMER0_id, get_sclk() / HZ);
	set_gptimer_pwidth(TIMER0_id, 1);
	SSYNC();
	enable_gptimers(TIMER0bit);
}
Exemple #2
0
irqreturn_t timer_interrupt(int irq, void *dummy)
{
	/* last time the cmos clock got updated */
	static long last_rtc_update;

	write_seqlock(&xtime_lock);
#if defined(CONFIG_TICK_SOURCE_SYSTMR0) && !defined(CONFIG_IPIPE)
	/*
	 * TIMIL0 is latched in __ipipe_grab_irq() when the I-Pipe is
	 * enabled.
	 */
	if (get_gptimer_status(0) & TIMER_STATUS_TIMIL0) {
#endif
		do_timer(1);

		/*
		 * If we have an externally synchronized Linux clock, then update
		 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
		 * called as close as possible to 500 ms before the new second starts.
		 */
		if (ntp_synced() &&
		    xtime.tv_sec > last_rtc_update + 660 &&
		    (xtime.tv_nsec / NSEC_PER_USEC) >=
		    500000 - ((unsigned)TICK_SIZE) / 2
		    && (xtime.tv_nsec / NSEC_PER_USEC) <=
		    500000 + ((unsigned)TICK_SIZE) / 2) {
			if (set_rtc_mmss(xtime.tv_sec) == 0)
				last_rtc_update = xtime.tv_sec;
			else
				/* Do it again in 60s. */
				last_rtc_update = xtime.tv_sec - 600;
		}
#if defined(CONFIG_TICK_SOURCE_SYSTMR0) && !defined(CONFIG_IPIPE)
		set_gptimer_status(0, TIMER_STATUS_TIMIL0);
	}
#endif
	write_sequnlock(&xtime_lock);

#ifdef CONFIG_IPIPE
	update_root_process_times(get_irq_regs());
#else
	update_process_times(user_mode(get_irq_regs()));
#endif
	profile_tick(CPU_PROFILING);

	return IRQ_HANDLED;
}
Exemple #3
0
static void bfin_timer_ack(void)
{
	set_gptimer_status(TIMER_GROUP1, TIMER_STATUS_TIMIL0);
}