Exemplo n.º 1
0
Arquivo: time.c Projeto: 274914765/C
/*
 * Should return useconds since last timer tick
 */
static unsigned long gettimeoffset(void)
{
    unsigned long offset;
    unsigned long clocks_per_jiffy;

    clocks_per_jiffy = bfin_read_TPERIOD();
    offset =
        (clocks_per_jiffy -
         bfin_read_TCOUNT()) / (((clocks_per_jiffy + 1) * HZ) /
                    USEC_PER_SEC);

    /* Check if we just wrapped the counters and maybe missed a tick */
    if ((bfin_read_ILAT() & (1 << IRQ_CORETMR))
        && (offset < (100000 / HZ / 2)))
        offset += (USEC_PER_SEC / HZ);

    return offset;
}
Exemplo n.º 2
0
/*
 * Should return useconds since last timer tick
 */
u32 arch_gettimeoffset(void)
{
	unsigned long offset;
	unsigned long clocks_per_jiffy;

#if defined(CONFIG_IPIPE)
	clocks_per_jiffy = bfin_read_TIMER0_PERIOD();
	offset = bfin_read_TIMER0_COUNTER() / \
		(((clocks_per_jiffy + 1) * HZ) / USEC_PER_SEC);

	if ((get_gptimer_status(0) & TIMER_STATUS_TIMIL0) && offset < (100000 / HZ / 2))
		offset += (USEC_PER_SEC / HZ);
#else
	clocks_per_jiffy = bfin_read_TPERIOD();
	offset = (clocks_per_jiffy - bfin_read_TCOUNT()) / \
		(((clocks_per_jiffy + 1) * HZ) / USEC_PER_SEC);

	/* Check if we just wrapped the counters and maybe missed a tick */
	if ((bfin_read_ILAT() & (1 << IRQ_CORETMR))
		&& (offset < (100000 / HZ / 2)))
		offset += (USEC_PER_SEC / HZ);
#endif
	return offset;
}