Exemple #1
0
/* The counter may wrap */
void udelay (unsigned long usec)
{
	u64 target, elapsed;
	u32 last_count = get_timer_raw();	/* get current timestamp */
	u32 now;
	u32 remainder;

	/* Convert usecs to timer frequency */
	target   = (u64)usec * (u64)CONFIG_SYS_HZ_CLOCK;

	// Use the kernel macro to avoid errors
	// __udivdi3 is NOT available
	// target /= (1000000L);
	// target /= div_clock;

	remainder = do_div(target, (u32)1000000);
     	remainder = do_div(target, div_clock);

	if(target){

		elapsed = 0;
		now = last_count = get_timer_raw();

		while (elapsed < target){
			if(now > last_count) {
				/* Must have wrapped */
				elapsed += last_count + TIMER_LOAD_VAL + 1 - now;
			} else {
				elapsed += last_count - now;
			}
			last_count = now;
			now = get_timer_raw();
		}
	} /* else usec too small.... */
}
Exemple #2
0
void udelay_masked(unsigned long usec)
{
	u32 tmo;
	u32 endtime;
	signed long diff;

	tmo = CONFIG_SYS_HZ_CLOCK / 1000;
	tmo *= usec;
	tmo /= 1000;

	endtime = get_timer_raw() + tmo;

	do {
		u32 now = get_timer_raw();
		diff = endtime - now;
	} while (diff >= 0);
}
Exemple #3
0
void udelay(unsigned long usec)
{
	ulong tmo;
	ulong endtime;
	signed long diff;

	tmo = CONFIG_SYS_HZ_CLOCK / 1000;
	tmo *= usec;
	tmo /= (1000 * TIM_CLK_DIV);

	endtime = get_timer_raw() + tmo;

	do {
		ulong now = get_timer_raw();
		diff = endtime - now;
	} while (diff >= 0);
}
Exemple #4
0
void udelay_masked(unsigned long usec)
{
	ulong tmo;
	ulong endtime;
	signed long diff;

	tmo = CFG_HZ_CLOCK / 1000;
	tmo *= usec;
	tmo /= 1000;

	endtime = get_timer_raw() + tmo;

	do {
		ulong now = get_timer_raw();
		diff = endtime - now;
	} while (diff >= 0);
}
Exemple #5
0
void udelay_masked (unsigned long usec)
{
	ulong tmo;

#if 0 /* doesn't work for usec < 1000 */
	tmo = usec / 1000;
	tmo *= CFG_HZ_CLOCK;
#else
	tmo = CFG_HZ_CLOCK / 1000;
	tmo *= usec;
#endif
	tmo /= 1000;

	reset_timer_masked ();

	while (get_timer_raw () < tmo)
		/*NOP*/;
}
Exemple #6
0
ulong get_timer_masked(void)
{
	return get_timer_raw()/TIMER_LOAD_VAL;
}
ulong get_timer_masked(void)
{
	return TICKS_TO_USEC(get_timer_raw());

}
Exemple #8
0
ulong get_timer(ulong base)
{
	return((get_timer_raw() / (TIMER_LOAD_VAL / TIM_CLK_DIV)) - base);
}
Exemple #9
0
ulong get_timer_masked(void)
{
	return(get_timer_raw() / DIV(TIMER_LOAD_VAL));
}