This patch allocates Virtio MMIO params (IRQ and memory region) and pass them to the backend, also update Guest device-tree based on Virtio I2C DT bindings [1].
[1] https://www.kernel.org/doc/Documentation/devicetree/bindings/i2c/i2c-virtio....
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- tools/libs/light/libxl_arm.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 3a038d388cf0..d085c7cf4dbd 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -110,6 +110,15 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, } }
+ for (i = 0; i < d_config->num_i2cs; i++) { + libxl_device_i2c *i2c = &d_config->i2cs[i]; + + int rc = alloc_virtio_mmio_params(gc, &i2c->base, &i2c->irq, + &virtio_mmio_base, &virtio_mmio_irq); + if (rc) + return rc; + } + if (virtio_mmio_irq != GUEST_VIRTIO_MMIO_SPI_FIRST) { virtio_irq = virtio_mmio_irq - 1; nr_spis += (virtio_irq - 32) + 1; @@ -909,6 +918,26 @@ static int make_virtio_mmio_node_simple(libxl__gc *gc, void *fdt, uint64_t base, return fdt_end_node(fdt); }
+static int make_virtio_mmio_node_i2c(libxl__gc *gc, void *fdt, + uint64_t base, uint32_t irq) +{ + int res; + + res = make_virtio_mmio_node_common(gc, fdt, base, irq); + if (res) return res; + + res = fdt_begin_node(fdt, "i2c"); + if (res) return res; + + res = fdt_property_compat(gc, fdt, 1, "virtio,device22"); + if (res) return res; + + res = fdt_end_node(fdt); + if (res) return res; + + return fdt_end_node(fdt); +} + static const struct arch_info *get_arch_info(libxl__gc *gc, const struct xc_dom_image *dom) { @@ -1224,6 +1253,11 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_config *d_config, FDT( make_virtio_mmio_node_simple(gc, fdt, disk->base, disk->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) ); + } + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) );