[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 6/7] hw/arm/virt: add new add_fdt_xxx_node function
From: |
Eric Auger |
Subject: |
[Qemu-devel] [RFC v2 6/7] hw/arm/virt: add new add_fdt_xxx_node functions |
Date: |
Fri, 8 Aug 2014 16:03:48 +0100 |
Create new functions:
- add_fdt_uart_node
- add_fdt_rtc_node
- add_fdt_virtio_nodes
They will be used for dynamic sysbus instantiation.
Signed-off-by: Eric Auger <address@hidden>
---
hw/arm/virt.c | 67 +++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 44 insertions(+), 23 deletions(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 66103c2..1a18a5a 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -337,18 +337,15 @@ static void create_gic(const VirtBoardInfo *vbi, qemu_irq
*pic)
fdt_add_gic_node(vbi);
}
-static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic)
+static void fdt_add_uart_node(const VirtBoardInfo *vbi)
{
- char *nodename;
hwaddr base = vbi->memmap[VIRT_UART].base;
hwaddr size = vbi->memmap[VIRT_UART].size;
int irq = vbi->irqmap[VIRT_UART];
const char compat[] = "arm,pl011\0arm,primecell";
const char clocknames[] = "uartclk\0apb_pclk";
+ char *nodename = g_strdup_printf("/address@hidden" PRIx64, base);
- sysbus_create_simple("pl011", base, pic[irq]);
-
- nodename = g_strdup_printf("/address@hidden" PRIx64, base);
qemu_fdt_add_subnode(vbi->fdt, nodename);
/* Note that we can't use setprop_string because of the embedded NUL */
qemu_fdt_setprop(vbi->fdt, nodename, "compatible",
@@ -365,17 +362,23 @@ static void create_uart(const VirtBoardInfo *vbi,
qemu_irq *pic)
g_free(nodename);
}
-static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic)
+static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic)
+{
+ hwaddr base = vbi->memmap[VIRT_UART].base;
+ int irq = vbi->irqmap[VIRT_UART];
+
+ sysbus_create_simple("pl011", base, pic[irq]);
+ fdt_add_uart_node(vbi);
+}
+
+static void fdt_add_rtc_node(const VirtBoardInfo *vbi)
{
- char *nodename;
hwaddr base = vbi->memmap[VIRT_RTC].base;
hwaddr size = vbi->memmap[VIRT_RTC].size;
int irq = vbi->irqmap[VIRT_RTC];
const char compat[] = "arm,pl031\0arm,primecell";
+ char *nodename = g_strdup_printf("/address@hidden" PRIx64, base);
- sysbus_create_simple("pl031", base, pic[irq]);
-
- nodename = g_strdup_printf("/address@hidden" PRIx64, base);
qemu_fdt_add_subnode(vbi->fdt, nodename);
qemu_fdt_setprop(vbi->fdt, nodename, "compatible", compat, sizeof(compat));
qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg",
@@ -388,22 +391,20 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq
*pic)
g_free(nodename);
}
-static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic)
+static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic)
{
- int i;
- hwaddr size = vbi->memmap[VIRT_MMIO].size;
+ hwaddr base = vbi->memmap[VIRT_RTC].base;
+ int irq = vbi->irqmap[VIRT_RTC];
- /* Note that we have to create the transports in forwards order
- * so that command line devices are inserted lowest address first,
- * and then add dtb nodes in reverse order so that they appear in
- * the finished device tree lowest address first.
- */
- for (i = 0; i < NUM_VIRTIO_TRANSPORTS; i++) {
- int irq = vbi->irqmap[VIRT_MMIO] + i;
- hwaddr base = vbi->memmap[VIRT_MMIO].base + i * size;
+ sysbus_create_simple("pl031", base, pic[irq]);
- sysbus_create_simple("virtio-mmio", base, pic[irq]);
- }
+ fdt_add_rtc_node(vbi);
+}
+
+static void fdt_add_virtio_nodes(const VirtBoardInfo *vbi)
+{
+ int i;
+ hwaddr size = vbi->memmap[VIRT_MMIO].size;
for (i = NUM_VIRTIO_TRANSPORTS - 1; i >= 0; i--) {
char *nodename;
@@ -423,6 +424,26 @@ static void create_virtio_devices(const VirtBoardInfo
*vbi, qemu_irq *pic)
}
}
+static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic)
+{
+ int i;
+ hwaddr size = vbi->memmap[VIRT_MMIO].size;
+
+ /* Note that we have to create the transports in forwards order
+ * so that command line devices are inserted lowest address first,
+ * and then add dtb nodes in reverse order so that they appear in
+ * the finished device tree lowest address first.
+ */
+ for (i = 0; i < NUM_VIRTIO_TRANSPORTS; i++) {
+ int irq = vbi->irqmap[VIRT_MMIO] + i;
+ hwaddr base = vbi->memmap[VIRT_MMIO].base + i * size;
+
+ sysbus_create_simple("virtio-mmio", base, pic[irq]);
+ }
+
+ fdt_add_virtio_nodes(vbi);
+}
+
static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)
{
const VirtBoardInfo *board = (const VirtBoardInfo *)binfo;
--
1.8.3.2
- Re: [Qemu-devel] [RFC v2 1/7] hw/misc/dyn_sysbus_binding: helpers for sysbus device dynamic binding, (continued)
- [Qemu-devel] [RFC v2 3/7] PPC: e500: Support dynamically spawned sysbus devices, Eric Auger, 2014/08/08
- [Qemu-devel] [RFC v2 2/7] hw/arm/dyn_sysbus_devtree: helpers for sysbus device dynamic dt node generation, Eric Auger, 2014/08/08
- [Qemu-devel] [RFC v2 4/7] e500: Add support for eTSEC in device tree, Eric Auger, 2014/08/08
- [Qemu-devel] [RFC v2 5/7] hw/arm/boot: load_dtb becomes non static, Eric Auger, 2014/08/08
- [Qemu-devel] [RFC v2 6/7] hw/arm/virt: add new add_fdt_xxx_node functions,
Eric Auger <=
- [Qemu-devel] [RFC v2 7/7] hw/arm/virt: Support dynamically spawned sysbus devices, Eric Auger, 2014/08/08