Commit 5ff55390ed80da2570fbeab51bdd2d2a43d4901a

Authored by Simon Glass
Committed by Wolfgang Denk
1 parent aacc8c16ee

bootstage: Define an optional microsecond timer

Define timer_get_boot_us() which returns the number of microseconds
since boot. If undefined then we use get_timer() * 1000.

We can fit this in a 32-bit register which keeps everyone happy on
the efficiency side. It will wrap around after about an hour. If we
are still looking at it after an hour then we had better not be
timing the boot.

Signed-off-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 24 additions and 0 deletions Side-by-side Diff

... ... @@ -207,6 +207,13 @@
207 207 #endif /* CONFIG_SERIAL_MULTI */
208 208  
209 209 /*
  210 + * Return the time since boot in microseconds, This is needed for bootstage
  211 + * and should be defined in CPU- or board-specific code. If undefined then
  212 + * millisecond resolution will be used (the standard get_timer()).
  213 + */
  214 +ulong timer_get_boot_us(void);
  215 +
  216 +/*
210 217 * General Purpose Utilities
211 218 */
212 219 #define min(X, Y) \
... ... @@ -47,4 +47,21 @@
47 47 while (msec--)
48 48 udelay(1000);
49 49 }
  50 +
  51 +ulong __timer_get_boot_us(void)
  52 +{
  53 + static ulong base_time;
  54 +
  55 + /*
  56 + * We can't implement this properly. Return 0 on the first call and
  57 + * larger values after that.
  58 + */
  59 + if (base_time)
  60 + return get_timer(base_time) * 1000;
  61 + base_time = get_timer(0);
  62 + return 0;
  63 +}
  64 +
  65 +ulong timer_get_boot_us(void)
  66 + __attribute__((weak, alias("__timer_get_boot_us")));