/* GPTCNT is now supposed to tick 1 by 1 us. */ void udelay(unsigned long usec) { unsigned long now, start, tmo; setup_gpt(); tmo = usec * (CONFIG_MX53_CLK32 / 1000) / 1000; if (!tmo) tmo = 1; now = start = GPTCNT; while ((now - start) < tmo) now = GPTCNT; }
/* GPTCNT is now supposed to tick 1 by 1 us. */ void udelay(unsigned long usec) { ulong tmp; setup_gpt(); tmp = get_timer_masked(); /* get current timestamp */ /* if setting this forward will roll time stamp */ if ((usec + tmp + 1) < tmp) { /* reset "advancing" timestamp to 0, set lastinc value */ reset_timer_masked(); } else { /* else, set advancing stamp wake up time */ tmp += usec; } while (get_timer_masked() < tmp) /* loop till event */ /*NOP*/; }
int timer_init(void) { setup_gpt(); return 0; }