Connect a PCIe host and graphics support to RISC-V
Subsystems (2)
v4 cover Connect a PCIe host and graphics support to RISC-V
V4:
- Fix the spike device tree
- Don't use stdvga device
V3:
- Remove Makefile config changes
- Connect a network adapter to the virt device
V2:
- Use the gpex PCIe host for virt
- Add support for SiFive U PCIe
Alistair Francis (7):
hw/riscv/virtio: Set the soc device tree node as a simple-bus hw/riscv/spike: Set the soc device tree node as a simple-bus hw/riscv/virt: Increase the number of interrupts hw/riscv/virt: Connect the gpex PCIe
riscv: Enable VGA and PCIE_VGA
hw/riscv/sifive_u: Connect the Xilinx PCIe hw/riscv/virt: Connect a VirtIO net PCIe device
default-configs/riscv32-softmmu.mak | 8 ++++ default-configs/riscv64-softmmu.mak | 8 ++++ hw/riscv/sifive_u.c | 64 +++++++++++++++++++++++++ hw/riscv/spike.c | 2 +- hw/riscv/virt.c | 74 ++++++++++++++++++++++++++++- include/hw/riscv/sifive_u.h | 4 +- include/hw/riscv/virt.h | 6 ++- 7 files changed, 161 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
PATCH v4 1/7 hw/riscv/virtio: Set the soc device tree node as a simple-bus
To allow Linux to enumerate devices on the /soc/ node set it as a "simple-bus".
--- hw/riscv/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/virt.c +1 -1
@@ -121,7 +121,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,qemu_fdt_add_subnode (fdt,"/soc" );qemu_fdt_setprop (fdt,"/soc" ,"ranges" ,NULL ,0 ); -qemu_fdt_setprop_string (fdt,"/soc" ,"compatible" ,"riscv-virtio-soc" ); +qemu_fdt_setprop_string (fdt,"/soc" ,"compatible" ,"simple-bus" );qemu_fdt_setprop_cell (fdt,"/soc" ,"#size-cells" ,0x2 );qemu_fdt_setprop_cell (fdt,"/soc" ,"#address-cells" ,0x2 );
Signature · 1 line
2.17.1
PATCH v4 2/7 hw/riscv/spike: Set the soc device tree node as a simple-bus
In reply to Alistair FrancisTo allow Linux to enumerate devices on the /soc/ node set it as a "simple-bus".
--- hw/riscv/spike.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/spike.c +1 -1
@@ -90,7 +90,7 @@ static void create_fdt(SpikeState *s, const struct MemmapEntry *memmap,qemu_fdt_add_subnode (fdt,"/soc" );qemu_fdt_setprop (fdt,"/soc" ,"ranges" ,NULL ,0 ); -qemu_fdt_setprop_string (fdt,"/soc" ,"compatible" ,"ucbbar,spike-bare-soc" ); +qemu_fdt_setprop_string (fdt,"/soc" ,"compatible" ,"simple-bus" );qemu_fdt_setprop_cell (fdt,"/soc" ,"#size-cells" ,0x2 );qemu_fdt_setprop_cell (fdt,"/soc" ,"#address-cells" ,0x2 );
Signature · 1 line
2.17.1
PATCH v4 3/7 hw/riscv/virt: Increase the number of interrupts
In reply to Alistair FrancisIncrease the number of interrupts to match the HiFive Unleashed board.
--- include/hw/riscv/virt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/riscv/virt.h +1 -1
@@ -45,7 +45,7 @@ enum {UART0_IRQ =10 ,VIRTIO_IRQ =1 ,/* 1 to 8 */ VIRTIO_COUNT =8 , -VIRTIO_NDEV =10 +VIRTIO_NDEV =0x35 }; enum {
Signature · 1 line
2.17.1
PATCH v4 4/7 hw/riscv/virt: Connect the gpex PCIe
In reply to Alistair FrancisConnect the gpex PCIe device based on the device tree included in the HiFive Unleashed ROM.
--- default-configs/riscv32-softmmu.mak | 3 ++ default-configs/riscv64-softmmu.mak | 3 ++ hw/riscv/virt.c | 58 +++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 4 +- 4 files changed, 67 insertions(+), 1 deletion(-)
default-configs/riscv32-softmmu.mak +3 -0
@@ -5,3 +5,6 @@ CONFIG_VIRTIO_MMIO=y include virtio.mak CONFIG_CADENCE=y + +CONFIG_PCI=y +CONFIG_PCI_GENERIC=y
default-configs/riscv64-softmmu.mak +3 -0
@@ -5,3 +5,6 @@ CONFIG_VIRTIO_MMIO=y include virtio.mak CONFIG_CADENCE=y + +CONFIG_PCI=y +CONFIG_PCI_GENERIC=y
hw/riscv/virt.c +58 -0
88 lines not on this page · raw message
include/hw/riscv/virt.h +3 -1
@@ -38,13 +38,15 @@ enum {VIRT_PLIC ,VIRT_UART0 ,VIRT_VIRTIO , - VIRT_DRAM +VIRT_DRAM , + VIRT_PCIE };enum {UART0_IRQ =10 ,VIRTIO_IRQ =1 ,/* 1 to 8 */ VIRTIO_COUNT =8 , +PCIE_IRQ =0x20 ,VIRTIO_NDEV =0x35 };
Signature · 1 line
2.17.1
PATCH v4 5/7 riscv: Enable VGA and PCIE_VGA
In reply to Alistair FrancisEnable compile support for VGA devices. This allows the user to conenct a display by adding '-device bochs-display -display sdl' to their command line argument.
--- default-configs/riscv32-softmmu.mak | 3 +++ default-configs/riscv64-softmmu.mak | 3 +++ hw/riscv/virt.c | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-)
default-configs/riscv32-softmmu.mak +3 -0
@@ -8,3 +8,6 @@ CONFIG_CADENCE=y CONFIG_PCI=y CONFIG_PCI_GENERIC=y + +CONFIG_VGA=y +CONFIG_VGA_PCI=y
default-configs/riscv64-softmmu.mak +3 -0
@@ -8,3 +8,6 @@ CONFIG_CADENCE=y CONFIG_PCI=y CONFIG_PCI_GENERIC=y + +CONFIG_VGA=y +CONFIG_VGA_PCI=y
hw/riscv/virt.c +2 -2
@@ -437,8 +437,8 @@ static void riscv_virt_board_init(MachineState *machine) }gpex_pcie_init (system_memory,0 , memmap[VIRT_PCIE ].base, - memmap[VIRT_PCIE ].size,0x40000000 ,0x20000000 , -qdev_get_gpio_in (DEVICE (s->plic),PCIE_IRQ ), true); + memmap[VIRT_PCIE ].size,0x40000000 ,0x20000000 , +qdev_get_gpio_in (DEVICE (s->plic),PCIE_IRQ ), true); serial_mm_init(system_memory, memmap[VIRT_UART0].base, 0, qdev_get_gpio_in(DEVICE(s->plic), UART0_IRQ), 399193,
Signature · 1 line
2.17.1
PATCH v4 6/7 hw/riscv/sifive_u: Connect the Xilinx PCIe
In reply to Alistair FrancisConnect the Xilinx PCIe device based on the information in the device tree stored in the ROM of the HiFish Unleashed board.
--- default-configs/riscv32-softmmu.mak | 1 + default-configs/riscv64-softmmu.mak | 1 + hw/riscv/sifive_u.c | 64 +++++++++++++++++++++++++++++ include/hw/riscv/sifive_u.h | 4 +- 4 files changed, 69 insertions(+), 1 deletion(-)
default-configs/riscv32-softmmu.mak +1 -0
@@ -8,6 +8,7 @@ CONFIG_CADENCE=y CONFIG_PCI=y CONFIG_PCI_GENERIC=y +CONFIG_PCI_XILINX=y CONFIG_VGA=y CONFIG_VGA_PCI=y
default-configs/riscv64-softmmu.mak +1 -0
@@ -8,6 +8,7 @@ CONFIG_CADENCE=y CONFIG_PCI=y CONFIG_PCI_GENERIC=y +CONFIG_PCI_XILINX=y CONFIG_VGA=y CONFIG_VGA_PCI=y
hw/riscv/sifive_u.c +64 -0
94 lines not on this page · raw message
include/hw/riscv/sifive_u.h +3 -1
@@ -53,12 +53,14 @@ enum {SIFIVE_U_UART0 ,SIFIVE_U_UART1 ,SIFIVE_U_DRAM , - SIFIVE_U_GEM +SIFIVE_U_GEM , + SIFIVE_U_PCIE };enum {SIFIVE_U_UART0_IRQ =3 ,SIFIVE_U_UART1_IRQ =4 , +SIFIVE_U_PCIE_IRQ =0x20 ,SIFIVE_U_GEM_IRQ =0x35 };
Signature · 1 line
2.17.1
PATCH v4 7/7 hw/riscv/virt: Connect a VirtIO net PCIe device
In reply to Alistair Francis--- default-configs/riscv32-softmmu.mak | 1 + default-configs/riscv64-softmmu.mak | 1 + hw/riscv/virt.c | 20 +++++++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-)
default-configs/riscv32-softmmu.mak +1 -0
@@ -9,6 +9,7 @@ CONFIG_CADENCE=y CONFIG_PCI=y CONFIG_PCI_GENERIC=y CONFIG_PCI_XILINX=y +CONFIG_VIRTIO_PCI=y CONFIG_VGA=y CONFIG_VGA_PCI=y
default-configs/riscv64-softmmu.mak +1 -0
@@ -9,6 +9,7 @@ CONFIG_CADENCE=y CONFIG_PCI=y CONFIG_PCI_GENERIC=y CONFIG_PCI_XILINX=y +CONFIG_VIRTIO_PCI=y CONFIG_VGA=y CONFIG_VGA_PCI=y
hw/riscv/virt.c +17 -3
@@ -36,6 +36,7 @@#include "hw/riscv/sifive_test.h" #include "hw/riscv/virt.h" #include "chardev/char.h" +#include "net/net.h" #include "sysemu/arch_init.h" #include "sysemu/device_tree.h" #include "exec/address-spaces.h"
@@ -322,6 +323,8 @@ static void riscv_virt_board_init(MachineState *machine)MemoryRegion *system_memory =get_system_memory ();MemoryRegion *main_mem =g_new (MemoryRegion,1 );MemoryRegion *mask_rom =g_new (MemoryRegion,1 ); +DeviceState *dev; +PCIBus *pci_bus;char *plic_hart_config;size_t plic_hart_config_len;int i;
@@ -436,9 +439,20 @@ static void riscv_virt_board_init(MachineState *machine) qdev_get_gpio_in(DEVICE(s->plic), VIRTIO_IRQ + i)); } -gpex_pcie_init (system_memory,0 , memmap[VIRT_PCIE ].base, - memmap[VIRT_PCIE ].size,0x40000000 ,0x20000000 , -qdev_get_gpio_in (DEVICE (s->plic),PCIE_IRQ ), true); + dev =gpex_pcie_init (system_memory,0 , memmap[VIRT_PCIE ].base, + memmap[VIRT_PCIE ].size,0x40000000 ,0x20000000 , +qdev_get_gpio_in (DEVICE (s->plic),PCIE_IRQ ), true); + pci_bus =PCI_HOST_BRIDGE (dev)->bus; + +for (i =0 ; i < nb_nics; i++) { +NICInfo *nd = &nd_table[i]; + +if (!nd->model) { + nd->model =g_strdup ("virtio" ); + } + +pci_nic_init_nofail (nd, pci_bus, nd->model,NULL ); + } serial_mm_init(system_memory, memmap[VIRT_UART0].base, 0, qdev_get_gpio_in(DEVICE(s->plic), UART0_IRQ), 399193,
Signature · 1 line
2.17.1