timer.c 707 B

12345678910111213141516171819202122232425262728293031323334
  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 <init.h>
  9. #include <asm/io.h>
  10. #include <asm/arch-armv7/systimer.h>
  11. #undef SYSTIMER_BASE
  12. #define SYSTIMER_BASE 0xFFF34000 /* Timer 0 and 1 base */
  13. static struct systimer *systimer_base = (struct systimer *)SYSTIMER_BASE;
  14. /*
  15. * Start the timer
  16. */
  17. int timer_init(void)
  18. {
  19. /*
  20. * Setup timer0
  21. */
  22. writel(0, &systimer_base->timer0control);
  23. writel(SYSTIMER_RELOAD, &systimer_base->timer0load);
  24. writel(SYSTIMER_RELOAD, &systimer_base->timer0value);
  25. writel(SYSTIMER_EN | SYSTIMER_32BIT | SYSTIMER_PRESC_256,
  26. &systimer_base->timer0control);
  27. return 0;
  28. }