From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: geert@linux-m68k.org, sre@kernel.org
Cc: jserv@ccns.ncku.edu.tw, eleanor15x@gmail.com,
linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org,
linux-pm@vger.kernel.org, Kuan-Wei Chiu <visitorckw@gmail.com>
Subject: [PATCH 2/2] m68k: virt: Switch to qemu-virt-ctrl driver
Date: Mon, 12 Jan 2026 18:22:57 +0000 [thread overview]
Message-ID: <20260112182258.1851769-3-visitorckw@gmail.com> (raw)
In-Reply-To: <20260112182258.1851769-1-visitorckw@gmail.com>
Register the "qemu-virt-ctrl" platform device during board
initialization to utilize the new generic power/reset driver.
Consequently, remove the legacy reset and power-off implementations
specific to the virt machine. The platform's mach_reset callback is
updated to call do_kernel_restart(), bridging the legacy m68k reboot
path to the generic kernel restart handler framework for this machine.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
arch/m68k/virt/config.c | 42 +--------------------------------------
arch/m68k/virt/platform.c | 20 ++++++++++++++++---
2 files changed, 18 insertions(+), 44 deletions(-)
diff --git a/arch/m68k/virt/config.c b/arch/m68k/virt/config.c
index 632ba200ad42..b338e2a8da6a 100644
--- a/arch/m68k/virt/config.c
+++ b/arch/m68k/virt/config.c
@@ -13,18 +13,6 @@
struct virt_booter_data virt_bi_data;
-#define VIRT_CTRL_REG_FEATURES 0x00
-#define VIRT_CTRL_REG_CMD 0x04
-
-static struct resource ctrlres;
-
-enum {
- CMD_NOOP,
- CMD_RESET,
- CMD_HALT,
- CMD_PANIC,
-};
-
static void virt_get_model(char *str)
{
/* str is 80 characters long */
@@ -33,25 +21,9 @@ static void virt_get_model(char *str)
(u8)(virt_bi_data.qemu_version >> 16),
(u8)(virt_bi_data.qemu_version >> 8));
}
-
-static void virt_halt(void)
-{
- void __iomem *base = (void __iomem *)virt_bi_data.ctrl.mmio;
-
- iowrite32be(CMD_HALT, base + VIRT_CTRL_REG_CMD);
- local_irq_disable();
- while (1)
- ;
-}
-
static void virt_reset(void)
{
- void __iomem *base = (void __iomem *)virt_bi_data.ctrl.mmio;
-
- iowrite32be(CMD_RESET, base + VIRT_CTRL_REG_CMD);
- local_irq_disable();
- while (1)
- ;
+ do_kernel_restart(NULL);
}
/*
@@ -113,20 +85,8 @@ void __init config_virt(void)
virt_bi_data.tty.mmio);
setup_earlycon(earlycon);
- ctrlres = (struct resource)
- DEFINE_RES_MEM_NAMED(virt_bi_data.ctrl.mmio, 0x100,
- "virtctrl");
-
- if (request_resource(&iomem_resource, &ctrlres)) {
- pr_err("Cannot allocate virt controller resource\n");
- return;
- }
-
mach_init_IRQ = virt_init_IRQ;
mach_sched_init = virt_sched_init;
mach_get_model = virt_get_model;
mach_reset = virt_reset;
- mach_halt = virt_halt;
-
- register_platform_power_off(virt_halt);
}
diff --git a/arch/m68k/virt/platform.c b/arch/m68k/virt/platform.c
index 1560c4140ab9..764f556b4b32 100644
--- a/arch/m68k/virt/platform.c
+++ b/arch/m68k/virt/platform.c
@@ -30,7 +30,10 @@ static int __init virt_platform_init(void)
DEFINE_RES_MEM(virt_bi_data.rtc.mmio + 0x1000, 0x1000),
DEFINE_RES_IRQ(virt_bi_data.rtc.irq + 1),
};
- struct platform_device *pdev1, *pdev2;
+ const struct resource virt_ctrl_res[] = {
+ DEFINE_RES_MEM(virt_bi_data.ctrl.mmio, 0x100),
+ };
+ struct platform_device *pdev1, *pdev2, *pdev3;
struct platform_device *pdevs[VIRTIO_BUS_NB];
unsigned int i;
int ret = 0;
@@ -57,19 +60,30 @@ static int __init virt_platform_init(void)
goto err_unregister_tty;
}
+ pdev3 = platform_device_register_simple("qemu-virt-ctrl",
+ PLATFORM_DEVID_NONE,
+ virt_ctrl_res,
+ ARRAY_SIZE(virt_ctrl_res));
+ if (IS_ERR(pdev3)) {
+ ret = PTR_ERR(pdev3);
+ goto err_unregister_rtc;
+ }
+
for (i = 0; i < VIRTIO_BUS_NB; i++) {
pdevs[i] = virt_virtio_init(i);
if (IS_ERR(pdevs[i])) {
ret = PTR_ERR(pdevs[i]);
- goto err_unregister_rtc_virtio;
+ goto err_unregister_virtio;
}
}
return 0;
-err_unregister_rtc_virtio:
+err_unregister_virtio:
while (i > 0)
platform_device_unregister(pdevs[--i]);
+ platform_device_unregister(pdev3);
+err_unregister_rtc:
platform_device_unregister(pdev2);
err_unregister_tty:
platform_device_unregister(pdev1);
--
2.52.0.457.g6b5491de43-goog
prev parent reply other threads:[~2026-01-12 18:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 18:22 [PATCH 0/2] Add QEMU virt-ctrl driver and update m68k virt Kuan-Wei Chiu
2026-01-12 18:22 ` [PATCH 1/2] power: reset: Add QEMU virt-ctrl driver Kuan-Wei Chiu
2026-01-14 10:01 ` Daniel Palmer
2026-01-15 6:15 ` Kuan-Wei Chiu
2026-01-15 13:29 ` Daniel Palmer
2026-01-15 15:21 ` Kuan-Wei Chiu
2026-01-30 21:55 ` Sebastian Reichel
2026-01-12 18:22 ` Kuan-Wei Chiu [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=20260112182258.1851769-3-visitorckw@gmail.com \
--to=visitorckw@gmail.com \
--cc=eleanor15x@gmail.com \
--cc=geert@linux-m68k.org \
--cc=jserv@ccns.ncku.edu.tw \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@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