timer.c 853 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * SH-Mobile Timer
  4. *
  5. * Copyright (C) 2010 Magnus Damm
  6. * Copyright (C) 2002 - 2009 Paul Mundt
  7. */
  8. #include <linux/platform_device.h>
  9. #include <linux/clocksource.h>
  10. #include <linux/delay.h>
  11. #include <linux/of_address.h>
  12. #include "common.h"
  13. void __init shmobile_init_delay(void)
  14. {
  15. struct device_node *np;
  16. u32 max_freq = 0;
  17. for_each_of_cpu_node(np) {
  18. u32 freq;
  19. if (!of_property_read_u32(np, "clock-frequency", &freq))
  20. max_freq = max(max_freq, freq);
  21. }
  22. if (!max_freq)
  23. return;
  24. /*
  25. * Calculate a worst-case loops-per-jiffy value
  26. * based on maximum cpu core hz setting and the
  27. * __delay() implementation in arch/arm/lib/delay.S.
  28. *
  29. * This will result in a longer delay than expected
  30. * when the cpu core runs on lower frequencies.
  31. */
  32. if (!preset_lpj)
  33. preset_lpj = max_freq / HZ;
  34. }