2023-05-26 16:50:15 +00:00
|
|
|
From: John Crispin <blogic@openwrt.org>
|
|
|
|
Date: Sun, 14 Jul 2013 23:08:11 +0200
|
2024-11-03 04:30:21 +00:00
|
|
|
Subject: [PATCH 1/2] MIPS: use set_mode() to enable/disable the cevt-r4k irq
|
2023-05-26 16:50:15 +00:00
|
|
|
|
|
|
|
Signed-off-by: John Crispin <blogic@openwrt.org>
|
|
|
|
---
|
2024-09-12 11:14:13 +00:00
|
|
|
arch/mips/kernel/cevt-r4k.c | 43 +++++++++++++++++++++++++++++++++++++
|
2024-11-03 04:30:21 +00:00
|
|
|
drivers/clocksource/Kconfig | 5 +++++
|
2024-09-12 11:14:13 +00:00
|
|
|
2 files changed, 48 insertions(+)
|
2023-05-26 16:50:15 +00:00
|
|
|
|
|
|
|
--- a/arch/mips/kernel/cevt-r4k.c
|
|
|
|
+++ b/arch/mips/kernel/cevt-r4k.c
|
|
|
|
@@ -16,6 +16,31 @@
|
|
|
|
#include <asm/time.h>
|
|
|
|
#include <asm/cevt-r4k.h>
|
|
|
|
|
|
|
|
+#ifdef CONFIG_CEVT_SYSTICK_QUIRK
|
|
|
|
+static int mips_state_oneshot(struct clock_event_device *evt)
|
|
|
|
+{
|
|
|
|
+ unsigned long flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED;
|
|
|
|
+ if (!cp0_timer_irq_installed) {
|
|
|
|
+ cp0_timer_irq_installed = 1;
|
|
|
|
+ if (request_irq(evt->irq, c0_compare_interrupt, flags, "timer",
|
|
|
|
+ c0_compare_interrupt))
|
|
|
|
+ pr_err("Failed to request irq %d (timer)\n", evt->irq);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int mips_state_shutdown(struct clock_event_device *evt)
|
|
|
|
+{
|
|
|
|
+ if (cp0_timer_irq_installed) {
|
|
|
|
+ cp0_timer_irq_installed = 0;
|
|
|
|
+ free_irq(evt->irq, NULL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
static int mips_next_event(unsigned long delta,
|
|
|
|
struct clock_event_device *evt)
|
|
|
|
{
|
|
|
|
@@ -292,7 +317,9 @@ core_initcall(r4k_register_cpufreq_notif
|
|
|
|
|
|
|
|
int r4k_clockevent_init(void)
|
|
|
|
{
|
|
|
|
+#ifndef CONFIG_CEVT_SYSTICK_QUIRK
|
|
|
|
unsigned long flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED;
|
|
|
|
+#endif
|
|
|
|
unsigned int cpu = smp_processor_id();
|
|
|
|
struct clock_event_device *cd;
|
|
|
|
unsigned int irq, min_delta;
|
2024-09-12 11:14:13 +00:00
|
|
|
@@ -303,6 +330,15 @@ int r4k_clockevent_init(void)
|
|
|
|
if (!c0_compare_int_usable())
|
|
|
|
return -ENXIO;
|
|
|
|
|
|
|
|
+#ifdef CONFIG_CEVT_SYSTICK_QUIRK
|
|
|
|
+ /*
|
|
|
|
+ * With vectored interrupts things are getting platform specific.
|
|
|
|
+ * get_c0_compare_int is a hook to allow a platform to return the
|
|
|
|
+ * interrupt number of its liking.
|
|
|
|
+ */
|
|
|
|
+ irq = get_c0_compare_int();
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
cd = &per_cpu(mips_clockevent_device, cpu);
|
|
|
|
|
|
|
|
cd->name = "MIPS";
|
|
|
|
@@ -314,11 +350,17 @@ int r4k_clockevent_init(void)
|
|
|
|
|
2023-05-26 16:50:15 +00:00
|
|
|
cd->rating = 300;
|
|
|
|
cd->cpumask = cpumask_of(cpu);
|
|
|
|
+#ifdef CONFIG_CEVT_SYSTICK_QUIRK
|
2024-09-12 11:14:13 +00:00
|
|
|
+ cd->irq = irq;
|
2023-05-26 16:50:15 +00:00
|
|
|
+ cd->set_state_shutdown = mips_state_shutdown;
|
|
|
|
+ cd->set_state_oneshot = mips_state_oneshot;
|
|
|
|
+#endif
|
|
|
|
cd->set_next_event = mips_next_event;
|
|
|
|
cd->event_handler = mips_event_handler;
|
|
|
|
|
|
|
|
clockevents_config_and_register(cd, mips_hpt_frequency, min_delta, 0x7fffffff);
|
|
|
|
|
|
|
|
+#ifndef CONFIG_CEVT_SYSTICK_QUIRK
|
|
|
|
if (cp0_timer_irq_installed)
|
|
|
|
return 0;
|
|
|
|
|
2024-09-12 11:14:13 +00:00
|
|
|
@@ -334,6 +376,7 @@ int r4k_clockevent_init(void)
|
2023-05-26 16:50:15 +00:00
|
|
|
if (request_irq(irq, c0_compare_interrupt, flags, "timer",
|
|
|
|
c0_compare_interrupt))
|
|
|
|
pr_err("Failed to request irq %d (timer)\n", irq);
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2024-11-03 04:30:21 +00:00
|
|
|
--- a/drivers/clocksource/Kconfig
|
|
|
|
+++ b/drivers/clocksource/Kconfig
|
2024-12-09 23:19:18 +00:00
|
|
|
@@ -732,10 +732,15 @@ config GOLDFISH_TIMER
|
2024-11-03 04:30:21 +00:00
|
|
|
depends on RTC_DRV_GOLDFISH
|
|
|
|
help
|
|
|
|
Support for the timer/counter of goldfish-rtc
|
|
|
|
+
|
2024-09-12 11:14:13 +00:00
|
|
|
+config CEVT_SYSTICK_QUIRK
|
|
|
|
+ bool
|
|
|
|
+ default n
|
|
|
|
|
2024-11-03 04:30:21 +00:00
|
|
|
config RALINK_TIMER
|
|
|
|
bool "Ralink System Tick Counter"
|
|
|
|
depends on SOC_RT305X || SOC_MT7620 || COMPILE_TEST
|
|
|
|
+ select CEVT_SYSTICK_QUIRK
|
|
|
|
select CLKSRC_MMIO
|
|
|
|
select TIMER_OF
|
|
|
|
help
|