diff mbox series

hw/loongarch: Add virtio-mmio bus support

Message ID 20230906025000.3101766-1-zhaotianrui@loongson.cn (mailing list archive)
State New, archived
Headers show
Series hw/loongarch: Add virtio-mmio bus support | expand

Commit Message

zhaotianrui Sept. 6, 2023, 2:50 a.m. UTC
Add virtio-mmio bus support for LoongArch, so that devices
could be added in the virtio-mmio bus.

Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
---
 hw/loongarch/Kconfig | 1 +
 hw/loongarch/virt.c  | 3 +++
 2 files changed, 4 insertions(+)

Comments

Bibo Mao Sept. 6, 2023, 3:09 a.m. UTC | #1
在 2023/9/6 10:50, Tianrui Zhao 写道:
> Add virtio-mmio bus support for LoongArch, so that devices
> could be added in the virtio-mmio bus.
> 
> Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
> ---
>  hw/loongarch/Kconfig | 1 +
>  hw/loongarch/virt.c  | 3 +++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig
> index 1e7c5b43c5..01ab8ce8e7 100644
> --- a/hw/loongarch/Kconfig
> +++ b/hw/loongarch/Kconfig
> @@ -22,3 +22,4 @@ config LOONGARCH_VIRT
>      select DIMM
>      select PFLASH_CFI01
>      select ACPI_HMAT
> +    select VIRTIO_MMIO
> diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
> index 2629128aed..06f4bc3a5e 100644
> --- a/hw/loongarch/virt.c
> +++ b/hw/loongarch/virt.c
> @@ -560,6 +560,9 @@ static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineState *
>                           VIRT_RTC_IRQ - VIRT_GSI_BASE));
>      fdt_add_rtc_node(lams);
>  
> +    /* virtio-mmio device */
> +    sysbus_create_simple("virtio-mmio", 0x1e200000, qdev_get_gpio_in(pch_pic, 7));
It had better use macro rather than hardcoded value like 0x1e200000/7.

Another way multiple virtio-mmio devices should be added like other arches.
And there should be fdt/acpi table added for the device so that users can use it.

Regards
Bibo Mao
> +
>      pm_mem = g_new(MemoryRegion, 1);
>      memory_region_init_io(pm_mem, NULL, &loongarch_virt_pm_ops,
>                            NULL, "loongarch_virt_pm", PM_SIZE);
diff mbox series

Patch

diff --git a/hw/loongarch/Kconfig b/hw/loongarch/Kconfig
index 1e7c5b43c5..01ab8ce8e7 100644
--- a/hw/loongarch/Kconfig
+++ b/hw/loongarch/Kconfig
@@ -22,3 +22,4 @@  config LOONGARCH_VIRT
     select DIMM
     select PFLASH_CFI01
     select ACPI_HMAT
+    select VIRTIO_MMIO
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index 2629128aed..06f4bc3a5e 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -560,6 +560,9 @@  static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineState *
                          VIRT_RTC_IRQ - VIRT_GSI_BASE));
     fdt_add_rtc_node(lams);
 
+    /* virtio-mmio device */
+    sysbus_create_simple("virtio-mmio", 0x1e200000, qdev_get_gpio_in(pch_pic, 7));
+
     pm_mem = g_new(MemoryRegion, 1);
     memory_region_init_io(pm_mem, NULL, &loongarch_virt_pm_ops,
                           NULL, "loongarch_virt_pm", PM_SIZE);