timer.c 514 B

123456789101112131415161718192021222324
  1. /*
  2. * Copyright (C) 2012 Altera Corporation <www.altera.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <asm/io.h>
  8. #include <asm/arch/timer.h>
  9. #define TIMER_LOAD_VAL 0xFFFFFFFF
  10. static const struct socfpga_timer *timer_base = (void *)CONFIG_SYS_TIMERBASE;
  11. /*
  12. * Timer initialization
  13. */
  14. int timer_init(void)
  15. {
  16. writel(TIMER_LOAD_VAL, &timer_base->load_val);
  17. writel(TIMER_LOAD_VAL, &timer_base->curr_val);
  18. writel(readl(&timer_base->ctrl) | 0x3, &timer_base->ctrl);
  19. return 0;
  20. }