Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

m68k: virt: Switch to qemu-virt-ctrl driver

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.

To prevent any regressions in reboot or power-off functionality when
the driver is not built-in, explicitly select POWER_RESET and
POWER_RESET_QEMU_VIRT_CTRL for the VIRT machine in Kconfig.machine.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://patch.msgid.link/20260412211952.3564033-3-visitorckw@gmail.com
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

authored by

Kuan-Wei Chiu and committed by
Geert Uytterhoeven
56f29585 ad9d2cd0

+20 -44
+2
arch/m68k/Kconfig.machine
··· 133 133 select GOLDFISH_TIMER 134 134 select GOLDFISH_TTY 135 135 select M68040 136 + select POWER_RESET 137 + select POWER_RESET_QEMU_VIRT_CTRL 136 138 select RTC_CLASS 137 139 select RTC_DRV_GOLDFISH 138 140 select TTY
+1 -41
arch/m68k/virt/config.c
··· 13 13 14 14 struct virt_booter_data virt_bi_data; 15 15 16 - #define VIRT_CTRL_REG_FEATURES 0x00 17 - #define VIRT_CTRL_REG_CMD 0x04 18 - 19 - static struct resource ctrlres; 20 - 21 - enum { 22 - CMD_NOOP, 23 - CMD_RESET, 24 - CMD_HALT, 25 - CMD_PANIC, 26 - }; 27 - 28 16 static void virt_get_model(char *str) 29 17 { 30 18 /* str is 80 characters long */ ··· 21 33 (u8)(virt_bi_data.qemu_version >> 16), 22 34 (u8)(virt_bi_data.qemu_version >> 8)); 23 35 } 24 - 25 - static void virt_halt(void) 26 - { 27 - void __iomem *base = (void __iomem *)virt_bi_data.ctrl.mmio; 28 - 29 - iowrite32be(CMD_HALT, base + VIRT_CTRL_REG_CMD); 30 - local_irq_disable(); 31 - while (1) 32 - ; 33 - } 34 - 35 36 static void virt_reset(void) 36 37 { 37 - void __iomem *base = (void __iomem *)virt_bi_data.ctrl.mmio; 38 - 39 - iowrite32be(CMD_RESET, base + VIRT_CTRL_REG_CMD); 40 - local_irq_disable(); 41 - while (1) 42 - ; 38 + do_kernel_restart(NULL); 43 39 } 44 40 45 41 /* ··· 85 113 virt_bi_data.tty.mmio); 86 114 setup_earlycon(earlycon); 87 115 88 - ctrlres = (struct resource) 89 - DEFINE_RES_MEM_NAMED(virt_bi_data.ctrl.mmio, 0x100, 90 - "virtctrl"); 91 - 92 - if (request_resource(&iomem_resource, &ctrlres)) { 93 - pr_err("Cannot allocate virt controller resource\n"); 94 - return; 95 - } 96 - 97 116 mach_init_IRQ = virt_init_IRQ; 98 117 mach_sched_init = virt_sched_init; 99 118 mach_get_model = virt_get_model; 100 119 mach_reset = virt_reset; 101 - mach_halt = virt_halt; 102 - 103 - register_platform_power_off(virt_halt); 104 120 }
+17 -3
arch/m68k/virt/platform.c
··· 30 30 DEFINE_RES_MEM(virt_bi_data.rtc.mmio + 0x1000, 0x1000), 31 31 DEFINE_RES_IRQ(virt_bi_data.rtc.irq + 1), 32 32 }; 33 - struct platform_device *pdev1, *pdev2; 33 + const struct resource virt_ctrl_res[] = { 34 + DEFINE_RES_MEM(virt_bi_data.ctrl.mmio, 0x100), 35 + }; 36 + struct platform_device *pdev1, *pdev2, *pdev3; 34 37 struct platform_device *pdevs[VIRTIO_BUS_NB]; 35 38 unsigned int i; 36 39 int ret = 0; ··· 60 57 goto err_unregister_tty; 61 58 } 62 59 60 + pdev3 = platform_device_register_simple("qemu-virt-ctrl", 61 + PLATFORM_DEVID_NONE, 62 + virt_ctrl_res, 63 + ARRAY_SIZE(virt_ctrl_res)); 64 + if (IS_ERR(pdev3)) { 65 + ret = PTR_ERR(pdev3); 66 + goto err_unregister_rtc; 67 + } 68 + 63 69 for (i = 0; i < VIRTIO_BUS_NB; i++) { 64 70 pdevs[i] = virt_virtio_init(i); 65 71 if (IS_ERR(pdevs[i])) { 66 72 ret = PTR_ERR(pdevs[i]); 67 - goto err_unregister_rtc_virtio; 73 + goto err_unregister_virtio; 68 74 } 69 75 } 70 76 71 77 return 0; 72 78 73 - err_unregister_rtc_virtio: 79 + err_unregister_virtio: 74 80 while (i > 0) 75 81 platform_device_unregister(pdevs[--i]); 82 + platform_device_unregister(pdev3); 83 + err_unregister_rtc: 76 84 platform_device_unregister(pdev2); 77 85 err_unregister_tty: 78 86 platform_device_unregister(pdev1);