mirror of
https://github.com/apache/nuttx.git
synced 2026-08-06 21:19:03 +00:00
board/qemu-armv7a: use fdt_virtio_mmio_devices_register() to register mmio devices
Use common implementation to register mmio device Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
parent
6e12b3d74b
commit
3caf47942e
1 changed files with 10 additions and 32 deletions
|
|
@ -28,13 +28,13 @@
|
|||
#include <syslog.h>
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/virtio/virtio-mmio.h>
|
||||
#include <nuttx/fdt.h>
|
||||
|
||||
#ifdef CONFIG_LIBC_FDT
|
||||
# include <libfdt.h>
|
||||
#endif
|
||||
|
||||
#include "chip.h"
|
||||
#include "qemu-armv7a.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
|
@ -50,36 +50,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_devices_from_fdt
|
||||
|
|
@ -88,6 +58,7 @@ static void register_virtio_devices_from_fdt(const void *fdt)
|
|||
static void register_devices_from_fdt(void)
|
||||
{
|
||||
const void *fdt = fdt_get();
|
||||
int ret;
|
||||
|
||||
if (fdt == NULL)
|
||||
{
|
||||
|
|
@ -95,8 +66,15 @@ 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
|
||||
|
||||
UNUSED(ret);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue