This patch allocates Virtio MMIO params (IRQ and memory region) and pass them to the backend, also update Guest device-tree.
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- tools/libs/light/libxl_arm.c | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index ea633d6f91df..89e5a1e5780d 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -135,6 +135,26 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, i2c->irq, i2c->base); }
+ for (i = 0; i < d_config->num_gpios; i++) { + libxl_device_gpio *gpio = &d_config->gpios[i]; + + gpio->base = alloc_virtio_mmio_base(gc); + if (!gpio->base) + return ERROR_FAIL; + + gpio->irq = alloc_virtio_mmio_irq(gc); + if (!gpio->irq) + return ERROR_FAIL; + + if (virtio_irq < gpio->irq) + virtio_irq = gpio->irq; + + virtio_enabled = true; + + LOG(DEBUG, "Allocate Virtio MMIO params for GPIO: IRQ %u BASE 0x%"PRIx64, + gpio->irq, gpio->base); + } + if (virtio_enabled) nr_spis += (virtio_irq - 32) + 1;
@@ -954,6 +974,41 @@ static int make_virtio_mmio_node_i2c(libxl__gc *gc, void *fdt, return 0; }
+static int make_virtio_mmio_node_gpio(libxl__gc *gc, void *fdt, + uint64_t base, uint32_t irq) +{ + int res; + + res = _make_virtio_mmio_node(gc, fdt, base, irq); + if (res) return res; + + res = fdt_begin_node(fdt, "gpio"); + if (res) return res; + + res = fdt_property_compat(gc, fdt, 1, "virtio,device29"); + if (res) return res; + + res = fdt_property(fdt, "gpio-controller", NULL, 0); + if (res) return res; + + res = fdt_property_cell(fdt, "#gpio-cells", 2); + if (res) return res; + + res = fdt_property(fdt, "interrupt-controller", NULL, 0); + if (res) return res; + + res = fdt_property_cell(fdt, "#interrupt-cells", 2); + if (res) return res; + + res = fdt_end_node(fdt); + if (res) return res; + + res = fdt_end_node(fdt); + if (res) return res; + + return 0; +} + static const struct arch_info *get_arch_info(libxl__gc *gc, const struct xc_dom_image *dom) { @@ -1269,6 +1324,11 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_config *d_config, FDT( make_virtio_mmio_node(gc, fdt, disk->base, disk->irq) ); }
+ for (i = 0; i < d_config->num_gpios; i++) { + libxl_device_gpio *gpio = &d_config->gpios[i]; + FDT( make_virtio_mmio_node_gpio(gc, fdt, gpio->base, gpio->irq) ); + } + for (i = 0; i < d_config->num_i2cs; i++) { libxl_device_i2c *i2c = &d_config->i2cs[i]; FDT( make_virtio_mmio_node_i2c(gc, fdt, i2c->base, i2c->irq) );