On 2025/11/12 上午11:26, Xianglai Li wrote:
In the loongarch virt fdt file, the interrupt trigger type directly
uses magic numbers. Now, refer to the definitions in the linux kernel and
use macro definitions.
Signed-off-by: Xianglai Li <[email protected]>
---
Cc: Bibo Mao <[email protected]>
Cc: Jiaxun Yang <[email protected]>
Cc: Song Gao <[email protected]>
hw/loongarch/virt-fdt-build.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/hw/loongarch/virt-fdt-build.c b/hw/loongarch/virt-fdt-build.c
index 1f0ba01f71..7333019cf7 100644
--- a/hw/loongarch/virt-fdt-build.c
+++ b/hw/loongarch/virt-fdt-build.c
@@ -16,6 +16,11 @@
#include "system/reset.h"
#include "target/loongarch/cpu.h"
+#define FDT_IRQ_TYPE_EDGE_RISING 1
+#define FDT_IRQ_TYPE_EDGE_FALLING 2
+#define FDT_IRQ_TYPE_LEVEL_HIGH 4
+#define FDT_IRQ_TYPE_LEVEL_LOW 8
+
static void create_fdt(LoongArchVirtMachineState *lvms)
{
MachineState *ms = MACHINE(lvms);
@@ -415,7 +420,8 @@ static void fdt_add_uart_node(LoongArchVirtMachineState
*lvms,
if (chosen) {
qemu_fdt_setprop_string(ms->fdt, "/chosen", "stdout-path", nodename);
}
- qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupts", irq, 0x4);
+ qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupts", irq,
+ FDT_IRQ_TYPE_LEVEL_HIGH);
qemu_fdt_setprop_cell(ms->fdt, nodename, "interrupt-parent",
*pch_pic_phandle);
g_free(nodename);
@@ -435,7 +441,8 @@ static void fdt_add_rtc_node(LoongArchVirtMachineState
*lvms,
"loongson,ls7a-rtc");
qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", 2, base, 2, size);
qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupts",
- VIRT_RTC_IRQ - VIRT_GSI_BASE , 0x4);
+ VIRT_RTC_IRQ - VIRT_GSI_BASE ,
+ FDT_IRQ_TYPE_LEVEL_HIGH);
qemu_fdt_setprop_cell(ms->fdt, nodename, "interrupt-parent",
*pch_pic_phandle);
g_free(nodename);
Reviewed-by: Bibo Mao <[email protected]>