From: Laurent Vivier <laurent@vivier.eu>
To: linux-kernel@vger.kernel.org
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
linux-m68k@lists.linux-m68k.org,
Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
linux-rtc@vger.kernel.org, Laurent Vivier <laurent@vivier.eu>,
Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH v4 3/3] m68k: virt: Remove LEGACY_TIMER_TICK
Date: Wed, 12 Jan 2022 22:39:01 +0100 [thread overview]
Message-ID: <20220112213901.2178667-4-laurent@vivier.eu> (raw)
In-Reply-To: <20220112213901.2178667-1-laurent@vivier.eu>
Move virt machine to generic clockevents.
cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
arch/m68k/Kconfig.machine | 1 -
arch/m68k/virt/timer.c | 56 ++++++++++++++++++++++++++++++---------
2 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine
index 769c5b38fe16..74a2354bc226 100644
--- a/arch/m68k/Kconfig.machine
+++ b/arch/m68k/Kconfig.machine
@@ -152,7 +152,6 @@ config SUN3
config VIRT
bool "Virtual M68k Machine support"
depends on MMU
- select LEGACY_TIMER_TICK
select M68040
select MMU_MOTOROLA if MMU
select GOLDFISH
diff --git a/arch/m68k/virt/timer.c b/arch/m68k/virt/timer.c
index 843bf6ed7e1a..767b01f75abb 100644
--- a/arch/m68k/virt/timer.c
+++ b/arch/m68k/virt/timer.c
@@ -3,6 +3,7 @@
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/clocksource.h>
+#include <linux/clockchips.h>
#include <asm/virt.h>
struct goldfish_timer {
@@ -41,7 +42,25 @@ static struct clocksource goldfish_timer = {
.max_idle_ns = LONG_MAX,
};
-static irqreturn_t golfish_timer_handler(int irq, void *dev_id)
+static int goldfish_timer_set_oneshot(struct clock_event_device *evt)
+{
+ gf_timer->alarm_high = 0;
+ gf_timer->alarm_low = 0;
+
+ gf_timer->irq_enabled = 1;
+
+ return 0;
+}
+
+static int goldfish_timer_shutdown(struct clock_event_device *evt)
+{
+ gf_timer->irq_enabled = 0;
+
+ return 0;
+}
+
+static int goldfish_timer_next_event(unsigned long delta,
+ struct clock_event_device *evt)
{
u64 now;
@@ -49,19 +68,35 @@ static irqreturn_t golfish_timer_handler(int irq, void *dev_id)
now = goldfish_timer_read(NULL);
- legacy_timer_tick(1);
+ now += delta;
- now += NSEC_PER_SEC / HZ;
gf_timer->alarm_high = upper_32_bits(now);
gf_timer->alarm_low = lower_32_bits(now);
+ return 0;
+}
+
+struct clock_event_device goldfish_timer_clockevent = {
+ .name = "goldfish_timer",
+ .features = CLOCK_EVT_FEAT_ONESHOT,
+ .set_state_shutdown = goldfish_timer_shutdown,
+ .set_state_oneshot = goldfish_timer_set_oneshot,
+ .set_next_event = goldfish_timer_next_event,
+ .shift = 32,
+};
+
+static irqreturn_t golfish_timer_tick(int irq, void *dev_id)
+{
+ struct clock_event_device *evt = &goldfish_timer_clockevent;
+
+ evt->event_handler(evt);
+
return IRQ_HANDLED;
}
void __init virt_sched_init(void)
{
static struct resource sched_res;
- u64 now;
sched_res.name = "goldfish_timer";
sched_res.start = virt_bi_data.rtc.mmio;
@@ -72,19 +107,14 @@ void __init virt_sched_init(void)
return;
}
- if (request_irq(virt_bi_data.rtc.irq, golfish_timer_handler, IRQF_TIMER,
+ clockevents_config_and_register(&goldfish_timer_clockevent, NSEC_PER_SEC,
+ 1, 0xffffffff);
+
+ if (request_irq(virt_bi_data.rtc.irq, golfish_timer_tick, IRQF_TIMER,
"timer", NULL)) {
pr_err("Couldn't register timer interrupt\n");
return;
}
- now = goldfish_timer_read(NULL);
- now += NSEC_PER_SEC / HZ;
-
- gf_timer->clear_interrupt = 1;
- gf_timer->alarm_high = upper_32_bits(now);
- gf_timer->alarm_low = lower_32_bits(now);
- gf_timer->irq_enabled = 1;
-
clocksource_register_hz(&goldfish_timer, NSEC_PER_SEC);
}
--
2.34.1
prev parent reply other threads:[~2022-01-12 21:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-12 21:38 [PATCH v4 0/3] m68k: Add Virtual M68k Machine Laurent Vivier
2022-01-12 21:38 ` [PATCH v4 1/3] m68k: add asm/config.h Laurent Vivier
2022-01-12 21:39 ` [PATCH v4 2/3] m68k: introduce a virtual m68k machine Laurent Vivier
2022-01-12 21:39 ` Laurent Vivier [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220112213901.2178667-4-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=arnd@arndb.de \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-rtc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).