302-clocksource-add-otto-driver.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From 3cc8011171186d906c547bc6f0c1f8e350edc7cf Mon Sep 17 00:00:00 2001
  2. From: Markus Stockhausen <[email protected]>
  3. Date: Mon, 3 Oct 2022 14:45:21 +0200
  4. Subject: [PATCH] realtek: resurrect timer driver
  5. Now that we provide a clock driver for the Reltek SOCs the CPU frequency might
  6. change on demand. This has direct visible effects during operation
  7. - the CEVT 4K timer is no longer a stable clocksource
  8. - after CPU frequencies changes time calculation works wrong
  9. - sched_clock falls back to kernel default interval (100 Hz)
  10. - timestamps in dmesg have only 2 digits left
  11. [ 0.000000] sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps ...
  12. [ 0.060000] pid_max: default: 32768 minimum: 301
  13. [ 0.070000] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
  14. [ 0.070000] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
  15. [ 0.080000] dyndbg: Ignore empty _ddebug table in a CONFIG_DYNAMIC_DEBUG_CORE build
  16. [ 0.090000] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, ...
  17. Looking around where we can start the CEVT timer for RTL930X is a good basis.
  18. Initially it was developed as a clocksource driver for the broken timer in that
  19. specific SOC series. Afterwards it was shifted around to the CEVT location,
  20. got SMP enablement and lost its clocksource feature. So we at least have
  21. something to copy from. As the timers on these devices are well understood
  22. the implementation follows this way:
  23. - leave the RTL930X implementation as is
  24. - provide a new driver for RTL83XX devices only
  25. - swap RTL930X driver at a later time
  26. Like the clock driver this patch contains a self contained module that is SOC
  27. independet and already provides full support for the RTL838X, RTL839X and
  28. RTL930X devices. Some of the new (or reestablished) features are:
  29. - simplified initialization routines
  30. - SMP setup with CPU hotplug framework
  31. - derived from LXB clock speed
  32. - supplied clocksource
  33. - dedicated register functions for better readability
  34. - documentation about some caveats
  35. Signed-off-by: Markus Stockhausen <[email protected]>
  36. [remove unused header includes, remove old CONFIG_MIPS dependency, add
  37. REALTEK_ prefix to driver symbol]
  38. Signed-off-by: Sander Vanheule <[email protected]>
  39. ---
  40. drivers/clocksource/Kconfig | 12 +++
  41. drivers/clocksource/Makefile | 1 +
  42. include/linux/cpuhotplug.h | 1 +
  43. 3 files changed, 14 insertions(+)
  44. --- a/drivers/clocksource/Kconfig
  45. +++ b/drivers/clocksource/Kconfig
  46. @@ -127,6 +127,17 @@ config RDA_TIMER
  47. help
  48. Enables the support for the RDA Micro timer driver.
  49. +config REALTEK_OTTO_TIMER
  50. + bool "Clocksource/timer for the Realtek Otto platform"
  51. + select COMMON_CLK
  52. + select TIMER_OF
  53. + help
  54. + This driver adds support for the timers found in the Realtek RTL83xx
  55. + and RTL93xx SoCs series. This includes chips such as RTL8380, RTL8381
  56. + and RTL832, as well as chips from the RTL839x series, such as RTL8390
  57. + RT8391, RTL8392, RTL8393 and RTL8396 and chips of the RTL930x series
  58. + such as RTL9301, RTL9302 or RTL9303.
  59. +
  60. config SUN4I_TIMER
  61. bool "Sun4i timer driver" if COMPILE_TEST
  62. depends on HAS_IOMEM
  63. --- a/drivers/clocksource/Makefile
  64. +++ b/drivers/clocksource/Makefile
  65. @@ -58,6 +58,7 @@ obj-$(CONFIG_MILBEAUT_TIMER) += timer-mi
  66. obj-$(CONFIG_SPRD_TIMER) += timer-sprd.o
  67. obj-$(CONFIG_NPCM7XX_TIMER) += timer-npcm7xx.o
  68. obj-$(CONFIG_RDA_TIMER) += timer-rda.o
  69. +obj-$(CONFIG_REALTEK_OTTO_TIMER) += timer-rtl-otto.o
  70. obj-$(CONFIG_ARC_TIMERS) += arc_timer.o
  71. obj-$(CONFIG_ARM_ARCH_TIMER) += arm_arch_timer.o
  72. --- a/include/linux/cpuhotplug.h
  73. +++ b/include/linux/cpuhotplug.h
  74. @@ -176,6 +176,7 @@ enum cpuhp_state {
  75. CPUHP_AP_MARCO_TIMER_STARTING,
  76. CPUHP_AP_MIPS_GIC_TIMER_STARTING,
  77. CPUHP_AP_ARC_TIMER_STARTING,
  78. + CPUHP_AP_REALTEK_TIMER_STARTING,
  79. CPUHP_AP_RISCV_TIMER_STARTING,
  80. CPUHP_AP_CLINT_TIMER_STARTING,
  81. CPUHP_AP_CSKY_TIMER_STARTING,