arm64/qemu/fdt: remove duplicate mmio parser code
reuse fdt_virtio_mmio_devices_register() to avoid duplicate Signed-off-by: chao an <anchao.archer@bytedance.com>
This commit is contained in:
parent
ef469bac7f
commit
e50b5773de
1 changed files with 10 additions and 31 deletions
|
|
@ -59,36 +59,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_LIBC_FDT) && defined(CONFIG_DEVICE_TREE)
|
||||
#ifdef CONFIG_DRIVERS_VIRTIO_MMIO
|
||||
|
||||
/****************************************************************************
|
||||
* Name: register_virtio_devices_from_fdt
|
||||
****************************************************************************/
|
||||
|
||||
static void register_virtio_devices_from_fdt(const void *fdt)
|
||||
{
|
||||
uintptr_t addr;
|
||||
int offset = -1;
|
||||
int irqnum;
|
||||
|
||||
for (; ; )
|
||||
{
|
||||
offset = fdt_node_offset_by_compatible(fdt, offset, "virtio,mmio");
|
||||
if (offset == -FDT_ERR_NOTFOUND)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
addr = fdt_get_reg_base(fdt, offset, 0);
|
||||
irqnum = fdt_get_irq(fdt, offset, 1, QEMU_SPI_IRQ_BASE);
|
||||
if (addr > 0 && irqnum >= 0)
|
||||
{
|
||||
virtio_register_mmio_device((void *)addr, irqnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: register_pci_host_from_fdt
|
||||
|
|
@ -181,6 +151,7 @@ static void register_pci_host_from_fdt(const void *fdt)
|
|||
static void register_devices_from_fdt(void)
|
||||
{
|
||||
const void *fdt = fdt_get();
|
||||
int ret;
|
||||
|
||||
if (fdt == NULL)
|
||||
{
|
||||
|
|
@ -188,12 +159,20 @@ static void register_devices_from_fdt(void)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_DRIVERS_VIRTIO_MMIO
|
||||
register_virtio_devices_from_fdt(fdt);
|
||||
|
||||
ret = fdt_virtio_mmio_devices_register(fdt, QEMU_SPI_IRQ_BASE);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "fdt_virtio_mmio_devices_register failed, ret=%d\n",
|
||||
ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
register_pci_host_from_fdt(fdt);
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue