csrc-gic.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
  7. */
  8. #include <linux/init.h>
  9. #include <linux/time.h>
  10. #include <asm/gic.h>
  11. static cycle_t gic_hpt_read(struct clocksource *cs)
  12. {
  13. return gic_read_count();
  14. }
  15. static struct clocksource gic_clocksource = {
  16. .name = "GIC",
  17. .read = gic_hpt_read,
  18. .flags = CLOCK_SOURCE_IS_CONTINUOUS,
  19. };
  20. void __init gic_clocksource_init(unsigned int frequency)
  21. {
  22. unsigned int config, bits;
  23. /* Calculate the clocksource mask. */
  24. GICREAD(GIC_REG(SHARED, GIC_SH_CONFIG), config);
  25. bits = 32 + ((config & GIC_SH_CONFIG_COUNTBITS_MSK) >>
  26. (GIC_SH_CONFIG_COUNTBITS_SHF - 2));
  27. /* Set clocksource mask. */
  28. gic_clocksource.mask = CLOCKSOURCE_MASK(bits);
  29. /* Calculate a somewhat reasonable rating value. */
  30. gic_clocksource.rating = 200 + frequency / 10000000;
  31. clocksource_register_hz(&gic_clocksource, frequency);
  32. }