timer.c 689 B

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2010-2011 Calxeda, Inc.
  4. *
  5. * Based on arm926ejs/mx27/timer.c
  6. */
  7. #include <common.h>
  8. #include <asm/io.h>
  9. #include <asm/arch-armv7/systimer.h>
  10. #undef SYSTIMER_BASE
  11. #define SYSTIMER_BASE 0xFFF34000 /* Timer 0 and 1 base */
  12. static struct systimer *systimer_base = (struct systimer *)SYSTIMER_BASE;
  13. /*
  14. * Start the timer
  15. */
  16. int timer_init(void)
  17. {
  18. /*
  19. * Setup timer0
  20. */
  21. writel(0, &systimer_base->timer0control);
  22. writel(SYSTIMER_RELOAD, &systimer_base->timer0load);
  23. writel(SYSTIMER_RELOAD, &systimer_base->timer0value);
  24. writel(SYSTIMER_EN | SYSTIMER_32BIT | SYSTIMER_PRESC_256,
  25. &systimer_base->timer0control);
  26. return 0;
  27. }