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