timer.c 681 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (C) 2016 Socionext Inc.
  3. * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <linux/bitops.h>
  8. #include <linux/io.h>
  9. #include <linux/sizes.h>
  10. #define CNT_CONTROL_BASE 0x60E00000
  11. #define CNTCR 0x000
  12. #define CNTCR_EN BIT(0)
  13. /* setup ARMv8 Generic Timer */
  14. int timer_init(void)
  15. {
  16. void __iomem *base;
  17. u32 tmp;
  18. base = ioremap(CNT_CONTROL_BASE, SZ_4K);
  19. /*
  20. * Note:
  21. * In a system that implements both Secure and Non-secure states,
  22. * this register is only writable in Secure state.
  23. */
  24. tmp = readl(base + CNTCR);
  25. tmp |= CNTCR_EN;
  26. writel(tmp, base + CNTCR);
  27. iounmap(base);
  28. return 0;
  29. }