timer.c 553 B

123456789101112131415161718192021222324
  1. /*
  2. * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <asm/arcregs.h>
  7. #define NH_MODE (1 << 1) /* Disable timer if CPU is halted */
  8. int timer_init(void)
  9. {
  10. write_aux_reg(ARC_AUX_TIMER0_CTRL, NH_MODE);
  11. /* Set max value for counter/timer */
  12. write_aux_reg(ARC_AUX_TIMER0_LIMIT, 0xffffffff);
  13. /* Set initial count value and restart counter/timer */
  14. write_aux_reg(ARC_AUX_TIMER0_CNT, 0);
  15. return 0;
  16. }
  17. unsigned long timer_read_counter(void)
  18. {
  19. return read_aux_reg(ARC_AUX_TIMER0_CNT);
  20. }