csrc-r4k.c 1021 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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) 2007 by Ralf Baechle
  7. */
  8. #include <linux/clocksource.h>
  9. #include <linux/init.h>
  10. #include <linux/sched_clock.h>
  11. #include <asm/time.h>
  12. static cycle_t c0_hpt_read(struct clocksource *cs)
  13. {
  14. return read_c0_count();
  15. }
  16. static struct clocksource clocksource_mips = {
  17. .name = "MIPS",
  18. .read = c0_hpt_read,
  19. .mask = CLOCKSOURCE_MASK(32),
  20. .flags = CLOCK_SOURCE_IS_CONTINUOUS,
  21. };
  22. static u64 notrace r4k_read_sched_clock(void)
  23. {
  24. return read_c0_count();
  25. }
  26. int __init init_r4k_clocksource(void)
  27. {
  28. if (!cpu_has_counter || !mips_hpt_frequency)
  29. return -ENXIO;
  30. /* Calculate a somewhat reasonable rating value */
  31. clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
  32. clocksource_register_hz(&clocksource_mips, mips_hpt_frequency);
  33. sched_clock_register(r4k_read_sched_clock, 32, mips_hpt_frequency);
  34. return 0;
  35. }