mb/qemu/riscv: Intialize PCI root bus

Allocate resources to devices on the bus.
This booted to the fedora disk image using nvme with the CrabEFI payload.

Change-Id: I898b38fd4fa94f7d1a73132d6f821ff7c9e201dd
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/91881
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
This commit is contained in:
Arthur Heymans 2026-03-25 23:12:58 +01:00 committed by Matt DeVillier
commit f1e95c5536
4 changed files with 53 additions and 5 deletions

View file

@ -2,4 +2,9 @@
chip mainboard/emulation/qemu-riscv
device cpu_cluster 0 on end
device domain 0 on
ops qemu_riscv_pci_domain_ops
device pci 00.0 on end
end
end

View file

@ -1,9 +1,16 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#define QEMU_VIRT_CLINT 0x02000000
#define QEMU_VIRT_PCIE_PIO 0x03000000
#define QEMU_VIRT_PLIC 0x0c000000
#define QEMU_VIRT_UART0 0x10000000
#define QEMU_VIRT_VIRTIO 0x10001000
#define QEMU_VIRT_FW_CFG 0x10100000
#define QEMU_VIRT_FLASH 0x20000000
#define QEMU_VIRT_PCIE_ECAM 0x30000000
#define QEMU_VIRT_PCIE_ECAM_SIZE 0x10000000
#define QEMU_VIRT_PCIE_MMIO_BASE 0x40000000
#define QEMU_VIRT_PCIE_MMIO_LIMIT 0x7fffffff
#define QEMU_VIRT_DRAM 0x80000000
#define QEMU_VIRT_PCIE_MMIO_HIGH_BASE 0x300000000ULL
#define QEMU_VIRT_PCIE_MMIO_HIGH_LIMIT 0x3ffffffffULL

View file

@ -2,16 +2,52 @@
#include <console/console.h>
#include <device/device.h>
#include <device/pci.h>
#include <symbols.h>
#include <cbmem.h>
#include <mainboard/addressmap.h>
static void qemu_riscv_domain_read_resources(struct device *dev)
{
struct resource *res;
int index = 0;
/* PCI I/O port window */
res = new_resource(dev, index++);
res->limit = 0xffff;
res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED;
/* 32-bit PCI MMIO window */
res = new_resource(dev, index++);
res->base = QEMU_VIRT_PCIE_MMIO_BASE;
res->limit = QEMU_VIRT_PCIE_MMIO_LIMIT;
res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED;
/*
* NOTE: 64-bit MMIO window (0x300000000-0x3ffffffff) is omitted
* because OpenSBI 1.1 (bundled with coreboot) does not add PMP
* entries for it, causing S-mode load access faults. All BARs
* will be assigned in the 32-bit window which is plenty for the
* QEMU virt machine's typical device set.
*/
/* ECAM config space (fixed MMIO) */
mmio_range(dev, index++, QEMU_VIRT_PCIE_ECAM, QEMU_VIRT_PCIE_ECAM_SIZE);
/* DRAM */
ram_from_to(dev, index++, (uintptr_t)_dram, cbmem_top());
}
struct device_operations qemu_riscv_pci_domain_ops = {
.read_resources = qemu_riscv_domain_read_resources,
.set_resources = pci_domain_set_resources,
.scan_bus = pci_host_bridge_scan_bus,
};
static void mainboard_enable(struct device *dev)
{
if (!dev) {
if (!dev)
die("No dev0; die\n");
}
ram_from_to(dev, 0, (uintptr_t)_dram, cbmem_top());
}
struct chip_operations mainboard_ops = {

View file

@ -3,4 +3,4 @@
#include <types.h>
#include <mainboard/addressmap.h>
uintptr_t io_port_mmio_base = QEMU_VIRT_FW_CFG;
uintptr_t io_port_mmio_base = QEMU_VIRT_PCIE_PIO;