ramips: add support for kernel 5.10
[openwrt/openwrt.git] / target / linux / ramips / patches-5.10 / 311-MIPS-use-set_mode-to-enable-disable-the-cevt-r4k-irq.patch
1 From ce3d4a4111a5f7e6b4e74bceae5faa6ce388e8ec Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sun, 14 Jul 2013 23:08:11 +0200
4 Subject: [PATCH 05/53] MIPS: use set_mode() to enable/disable the cevt-r4k
5 irq
6
7 Signed-off-by: John Crispin <blogic@openwrt.org>
8 ---
9 arch/mips/ralink/Kconfig | 5 +++++
10 1 file changed, 5 insertions(+)
11
12 --- a/arch/mips/ralink/Kconfig
13 +++ b/arch/mips/ralink/Kconfig
14 @@ -1,12 +1,17 @@
15 # SPDX-License-Identifier: GPL-2.0
16 if RALINK
17
18 +config CEVT_SYSTICK_QUIRK
19 + bool
20 + default n
21 +
22 config CLKEVT_RT3352
23 bool
24 depends on SOC_RT305X || SOC_MT7620
25 default y
26 select TIMER_OF
27 select CLKSRC_MMIO
28 + select CEVT_SYSTICK_QUIRK
29
30 config RALINK_ILL_ACC
31 bool
32 --- a/arch/mips/kernel/cevt-r4k.c
33 +++ b/arch/mips/kernel/cevt-r4k.c
34 @@ -16,6 +16,31 @@
35 #include <asm/time.h>
36 #include <asm/cevt-r4k.h>
37
38 +#ifdef CONFIG_CEVT_SYSTICK_QUIRK
39 +static int mips_state_oneshot(struct clock_event_device *evt)
40 +{
41 + unsigned long flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED;
42 + if (!cp0_timer_irq_installed) {
43 + cp0_timer_irq_installed = 1;
44 + if (request_irq(evt->irq, c0_compare_interrupt, flags, "timer",
45 + c0_compare_interrupt))
46 + pr_err("Failed to request irq %d (timer)\n", evt->irq);
47 + }
48 +
49 + return 0;
50 +}
51 +
52 +static int mips_state_shutdown(struct clock_event_device *evt)
53 +{
54 + if (cp0_timer_irq_installed) {
55 + cp0_timer_irq_installed = 0;
56 + free_irq(evt->irq, NULL);
57 + }
58 +
59 + return 0;
60 +}
61 +#endif
62 +
63 static int mips_next_event(unsigned long delta,
64 struct clock_event_device *evt)
65 {
66 @@ -296,7 +321,9 @@ core_initcall(r4k_register_cpufreq_notif
67
68 int r4k_clockevent_init(void)
69 {
70 +#ifndef CONFIG_CEVT_SYSTICK_QUIRK
71 unsigned long flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED;
72 +#endif
73 unsigned int cpu = smp_processor_id();
74 struct clock_event_device *cd;
75 unsigned int irq, min_delta;
76 @@ -326,11 +353,16 @@ int r4k_clockevent_init(void)
77 cd->rating = 300;
78 cd->irq = irq;
79 cd->cpumask = cpumask_of(cpu);
80 +#ifdef CONFIG_CEVT_SYSTICK_QUIRK
81 + cd->set_state_shutdown = mips_state_shutdown;
82 + cd->set_state_oneshot = mips_state_oneshot;
83 +#endif
84 cd->set_next_event = mips_next_event;
85 cd->event_handler = mips_event_handler;
86
87 clockevents_config_and_register(cd, mips_hpt_frequency, min_delta, 0x7fffffff);
88
89 +#ifndef CONFIG_CEVT_SYSTICK_QUIRK
90 if (cp0_timer_irq_installed)
91 return 0;
92
93 @@ -339,6 +371,7 @@ int r4k_clockevent_init(void)
94 if (request_irq(irq, c0_compare_interrupt, flags, "timer",
95 c0_compare_interrupt))
96 pr_err("Failed to request irq %d (timer)\n", irq);
97 +#endif
98
99 return 0;
100 }