[PATCH 6/6] m68k: virt: Switch to generic goldfish-pic driver
From: Kuan-Wei Chiu
Date: Tue Sep 08 2026 - 05:52:37 EST
The m68k virt platform implements a custom irq_chip and chained handler
in arch/m68k/virt/ints.c to handle its 6 goldfish PIC instances.
Replace this custom implementation with calls to goldfish_pic_init() to
use the generic goldfish-pic driver, and select CONFIG_GOLDFISH_PIC for
CONFIG_VIRT.
Signed-off-by: Kuan-Wei Chiu <visitorckw@xxxxxxxxx>
---
arch/m68k/Kconfig.machine | 1 +
arch/m68k/virt/ints.c | 89 ++++-----------------------------------
2 files changed, 10 insertions(+), 80 deletions(-)
diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine
index cff990c319cb..7b15012ffb28 100644
--- a/arch/m68k/Kconfig.machine
+++ b/arch/m68k/Kconfig.machine
@@ -130,6 +130,7 @@ config VIRT
depends on MMU
select GENERIC_CLOCKEVENTS
select GOLDFISH
+ select GOLDFISH_PIC
select GOLDFISH_TIMER
select GOLDFISH_TTY
select M68040
diff --git a/arch/m68k/virt/ints.c b/arch/m68k/virt/ints.c
index 896aa6eb8bcc..54da6b1f5ce7 100644
--- a/arch/m68k/virt/ints.c
+++ b/arch/m68k/virt/ints.c
@@ -1,25 +1,14 @@
// SPDX-License-Identifier: GPL-2.0
-#include <linux/delay.h>
#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/sched/debug.h>
-#include <linux/types.h>
#include <linux/ioport.h>
+#include <linux/irqchip/irq-goldfish-pic.h>
-#include <asm/hwtest.h>
#include <asm/irq.h>
#include <asm/irq_regs.h>
#include <asm/processor.h>
#include <asm/virt.h>
-#define GFPIC_REG_IRQ_PENDING 0x04
-#define GFPIC_REG_IRQ_DISABLE_ALL 0x08
-#define GFPIC_REG_IRQ_DISABLE 0x0c
-#define GFPIC_REG_IRQ_ENABLE 0x10
-
static struct resource picres[6];
static const char *picname[6] = {
"goldfish_pic.0",
@@ -50,43 +39,6 @@ static const char *picname[6] = {
* CPU IRQ #7 -> NMI
*/
-static u32 gfpic_read(int pic, int reg)
-{
- void __iomem *base = (void __iomem *)(virt_bi_data.pic.mmio +
- pic * 0x1000);
-
- return ioread32be(base + reg);
-}
-
-static void gfpic_write(u32 value, int pic, int reg)
-{
- void __iomem *base = (void __iomem *)(virt_bi_data.pic.mmio +
- pic * 0x1000);
-
- iowrite32be(value, base + reg);
-}
-
-#define GF_PIC(irq) ((irq - IRQ_USER) / 32)
-#define GF_IRQ(irq) ((irq - IRQ_USER) % 32)
-
-static void virt_irq_enable(struct irq_data *data)
-{
- gfpic_write(BIT(GF_IRQ(data->irq)), GF_PIC(data->irq),
- GFPIC_REG_IRQ_ENABLE);
-}
-
-static void virt_irq_disable(struct irq_data *data)
-{
- gfpic_write(BIT(GF_IRQ(data->irq)), GF_PIC(data->irq),
- GFPIC_REG_IRQ_DISABLE);
-}
-
-static unsigned int virt_irq_startup(struct irq_data *data)
-{
- virt_irq_enable(data);
- return 0;
-}
-
static irqreturn_t virt_nmi_handler(int irq, void *dev_id)
{
static int in_nmi;
@@ -102,40 +54,12 @@ static irqreturn_t virt_nmi_handler(int irq, void *dev_id)
return IRQ_HANDLED;
}
-static struct irq_chip virt_irq_chip = {
- .name = "virt",
- .irq_enable = virt_irq_enable,
- .irq_disable = virt_irq_disable,
- .irq_startup = virt_irq_startup,
- .irq_shutdown = virt_irq_disable,
-};
-
-static void goldfish_pic_irq(struct irq_desc *desc)
-{
- u32 irq_pending;
- unsigned int irq_num;
- unsigned int pic = desc->irq_data.irq - 1;
-
- irq_pending = gfpic_read(pic, GFPIC_REG_IRQ_PENDING);
- irq_num = IRQ_USER + pic * 32;
-
- do {
- if (irq_pending & 1)
- generic_handle_irq(irq_num);
- ++irq_num;
- irq_pending >>= 1;
- } while (irq_pending);
-}
-
void __init virt_init_IRQ(void)
{
unsigned int i;
-
- m68k_setup_irq_controller(&virt_irq_chip, handle_simple_irq, IRQ_USER,
- NUM_VIRT_SOURCES - IRQ_USER);
+ int ret;
for (i = 0; i < 6; i++) {
-
picres[i] = (struct resource)
DEFINE_RES_MEM_NAMED(virt_bi_data.pic.mmio + i * 0x1000,
0x1000, picname[i]);
@@ -144,8 +68,13 @@ void __init virt_init_IRQ(void)
return;
}
- irq_set_chained_handler(virt_bi_data.pic.irq + i,
- goldfish_pic_irq);
+ ret = goldfish_pic_init((void __iomem *)(virt_bi_data.pic.mmio + i * 0x1000),
+ virt_bi_data.pic.irq + i,
+ IRQ_USER + i * 32, NULL);
+ if (ret) {
+ pr_err("Failed to initialize %s\n", picname[i]);
+ return;
+ }
}
if (request_irq(IRQ_AUTO_7, virt_nmi_handler, 0, "NMI",
--
2.55.0.979.g7e5102b832-goog