Ejemplo n.º 1
0
/*
 * Returns number of ms since last clock interrupt.  Note that interrupts
 * will have been disabled by do_gettimeoffset()
 */
static unsigned long versatile_gettimeoffset(void)
{
	unsigned long ticks1, ticks2, status;

	/*
	 * Get the current number of ticks.  Note that there is a race
	 * condition between us reading the timer and checking for
	 * an interrupt.  We get around this by ensuring that the
	 * counter has not reloaded between our two reads.
	 */
	ticks2 = readl(TIMER0_VA_BASE + TIMER_VALUE) & 0xffff;
	do {
		ticks1 = ticks2;
		status = __raw_readl(VA_IC_BASE + VIC_RAW_STATUS);
		ticks2 = readl(TIMER0_VA_BASE + TIMER_VALUE) & 0xffff;
	} while (ticks2 > ticks1);

	/*
	 * Number of ticks since last interrupt.
	 */
	ticks1 = TIMER_RELOAD - ticks2;

	/*
	 * Interrupt pending?  If so, we've reloaded once already.
	 *
	 * FIXME: Need to check this is effectively timer 0 that expires
	 */
	if (status & IRQMASK_TIMERINT0_1)
		ticks1 += TIMER_RELOAD;

	/*
	 * Convert the ticks to usecs
	 */
	return TICKS2USECS(ticks1);
}
/*
 * Returns number of ms since last clock interrupt.
 * Note that interrupts will have been disabled by do_gettimeoffset()
 */
static unsigned long ne1_gettimeoffset(void)
{
	unsigned long ticks1, ticks2, status;

	/*
	 * Get the current number of ticks.  Note that there is a race
	 * condition between us reading the timer and checking for
	 * an interrupt.  We get around this by ensuring that the
	 * counter has not reloaded between our two reads.
	 */
	ticks1 = readl(IO_ADDRESS(NE1_BASE_PTMR + TWD_TIMER_COUNTER));
	do {
		ticks2 = ticks1;
		status = readl(IO_ADDRESS(NE1_BASE_PTMR + TWD_TIMER_INTSTAT));
		ticks1 = readl(IO_ADDRESS(NE1_BASE_PTMR + TWD_TIMER_COUNTER));
	} while (ticks2 < ticks1);

	/*
	 * Interrupt pending?  If so, we've reloaded once already.
	 */
	if (status & INTSTAT_EVENT)
		ticks1 -= TIMER_RELOAD;

	/*
	 * Convert the ticks to usecs
	 */
	return TICKS2USECS(ticks1);
}
Ejemplo n.º 3
0
/*
 * Returns number of us since last clock interrupt.  Note that interrupts
 * will have been disabled by do_gettimeoffset()
 */
static unsigned long str8100_gettimeoffset(void)
{
	unsigned long ticks1, ticks2;
	unsigned long interrupt_status;

	/*
	 * Get the current number of ticks.  Note that there is a race
	 * condition between us reading the timer and checking for
	 * an interrupt.  We get around this by ensuring that the
	 * counter has not reloaded between our two reads.
	 */
	ticks2 = str8100_read_timer_counter();
	do {
		ticks1 = ticks2;
		interrupt_status = str8100_read_timer_interrupt_status();
		ticks2 = str8100_read_timer_counter();
	} while (ticks2 > ticks1);

	/*
	 * Number of ticks since last interrupt
	 */
	ticks1 = timer_counter_value - ticks2;

	/*
	 * Interrupt pending?  If so, we've reloaded once already.
	 */
	if (interrupt_status) {
		ticks1 += timer_counter_value;
	}

	/*
	 * Convert the ticks to usecs
	 */
	return TICKS2USECS(ticks1);
}
Ejemplo n.º 4
0
/*
 * Returns number of ms since last clock interrupt.  Note that interrupts
 * will have been disabled by do_gettimeoffset()
 */
static unsigned long integrator_gettimeoffset(void)
{
	volatile TimerStruct_t *timer1 = (TimerStruct_t *)TIMER1_VA_BASE;
	unsigned long ticks1, ticks2, status;

	/*
	 * Get the current number of ticks.  Note that there is a race
	 * condition between us reading the timer and checking for
	 * an interrupt.  We get around this by ensuring that the
	 * counter has not reloaded between our two reads.
	 */
	ticks2 = timer1->TimerValue & 0xffff;
	do {
		ticks1 = ticks2;
		status = __raw_readl(VA_IC_BASE + IRQ_RAW_STATUS);
		ticks2 = timer1->TimerValue & 0xffff;
	} while (ticks2 > ticks1);

	/*
	 * Number of ticks since last interrupt.
	 */
	ticks1 = timer_reload - ticks2;

	/*
	 * Interrupt pending?  If so, we've reloaded once already.
	 */
	if (status & (1 << IRQ_TIMERINT1))
		ticks1 += timer_reload;

	/*
	 * Convert the ticks to usecs
	 */
	return TICKS2USECS(ticks1);
}
Ejemplo n.º 5
0
/*
 * Returns number of ms since last clock interrupt.  Note that interrupts
 * will have been disabled by do_gettimeoffset()
 */
static unsigned long socle_gettimeoffset(void)
{
	volatile TimerStruct_t *timer1 = (TimerStruct_t *)TIMER1_VA_BASE;
	unsigned long ticks1, ticks2, status;

	/*
	 * Get the current number of ticks.  Note that there is a race
	 * condition between us reading the timer and checking for
	 * an interrupt.  We get around this by ensuring that the
	 * counter has not reloaded between our two reads.
	 */
	ticks2 = timer1->TimerValue;;
	status = timer1->TimerControl ;

	/*
	 * Number of ticks since last interrupt.
	 */
	ticks1 = TIMER_RELOAD - ticks2;
	/*
	 * Interrupt pending?  If so, we've reloaded once already.
	 *
	 * FIXME: Need to check this is effectively timer 0 that expires
	 */
	 /*
	if (status & (1<<2))  //timer's pending bit
	{
		ticks1 += TIMER_RELOAD;
	}
	*/

	return TICKS2USECS(ticks1);

}
Ejemplo n.º 6
0
static inline unsigned long timer_ticks_to_usec(unsigned long ticks)
{
	unsigned long res;

	res = TICKS2USECS(ticks);
	
	return res;
}
Ejemplo n.º 7
0
unsigned long integrator_gettimeoffset(void)
{
	unsigned long ticks1, ticks2, status;

	
	ticks2 = readl(TIMER1_VA_BASE + TIMER_VALUE) & 0xffff;
	do {
		ticks1 = ticks2;
		status = __raw_readl(VA_IC_BASE + IRQ_RAW_STATUS);
		ticks2 = readl(TIMER1_VA_BASE + TIMER_VALUE) & 0xffff;
	} while (ticks2 > ticks1);

	
	ticks1 = timer_reload - ticks2;

	
	if (status & (1 << IRQ_TIMERINT1))
		ticks1 += timer_reload;

	
	return TICKS2USECS(ticks1);
}
Ejemplo n.º 8
0
/*
 * Set up timer interrupt, and return the current time in seconds.
 */
void __init socle_init_timer(void)
{
	struct timespec tv;
	volatile TimerStruct_t *timer0 = (volatile TimerStruct_t *)TIMER0_VA_BASE;
	volatile TimerStruct_t *timer1 = (volatile TimerStruct_t *)TIMER1_VA_BASE;
	volatile TimerStruct_t *timer2 = (volatile TimerStruct_t *)TIMER2_VA_BASE;

	xtime.tv_nsec = 0;
	xtime.tv_sec  = 0;
	tv.tv_nsec = 0;
	tv.tv_sec  = 0;

	/*
	 * Initialise to a known state (all timers off)
	 */
	timer0->TimerControl = 0;
	timer1->TimerControl = 0;
	timer2->TimerControl = 0;

#ifdef CALCULATE_CPU_FREQ
	apb_clock = socle_scu_apb_clock_get();
	socle_scu_show_system_info();
	TIMER_RELOAD=apb_clock/HZ;
#endif

	timer1->TimerLoad = TIMER_RELOAD;
	tick_usec = TICKS2USECS(TIMER_RELOAD);
	/* 
	 * Make irqs happen for the system timer
	 */
	
	do_settimeofday(&tv);
	timer1->TimerControl = 0x182; /* periodic + IE ; prescale factor=1*/
	setup_irq(IRQ_TIMER1, &socle_timer_irq);

}
Ejemplo n.º 9
0
unsigned long __noinstrument machinecycles_to_usecs(unsigned long ticks)
{
	return TICKS2USECS(ticks);
}