diff mbox

[v1,2/2] xlnx-ep108: Connect the AXI GPIO device

Message ID 8430dea044fb614e7e2a2efbb5861c57ab5e7d2a.1478907354.git.alistair.francis@xilinx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alistair Francis Nov. 11, 2016, 11:42 p.m. UTC
Connect the new Xilinx AXI GPIO devices based on the defaults used in
the ZCU102 reference board design.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---

 hw/arm/xlnx-ep108.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Edgar E. Iglesias Nov. 12, 2016, 4:12 a.m. UTC | #1
On Fri, Nov 11, 2016 at 03:42:31PM -0800, Alistair Francis wrote:
> Connect the new Xilinx AXI GPIO devices based on the defaults used in
> the ZCU102 reference board design.

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>


> 
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
> ---
> 
>  hw/arm/xlnx-ep108.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/hw/arm/xlnx-ep108.c b/hw/arm/xlnx-ep108.c
> index 4ec590a..23b3d6e 100644
> --- a/hw/arm/xlnx-ep108.c
> +++ b/hw/arm/xlnx-ep108.c
> @@ -20,14 +20,27 @@
>  #include "qemu-common.h"
>  #include "cpu.h"
>  #include "hw/arm/xlnx-zynqmp.h"
> +#include "hw/gpio/xlnx-axi-gpio.h"
>  #include "hw/boards.h"
>  #include "qemu/error-report.h"
>  #include "exec/address-spaces.h"
>  #include "qemu/log.h"
>  
> +#define XLNX_EP108_NUM_AXI_GPIOS 7
> +
> +/* These can always be changed, but these seven are the default in the reference
> + * board design.
> + */
> +static const uint64_t axi_gpio_addr[XLNX_EP108_NUM_AXI_GPIOS] = {
> +    0xa1000000, 0x401000000, 0x1001000000, 0xb1000000, 0x501000000,
> +    0x4801000000, 0x81000000,
> +};
> +
>  typedef struct XlnxEP108 {
>      XlnxZynqMPState soc;
>      MemoryRegion ddr_ram;
> +
> +    XlnxAXIGPIO axi_gpio[XLNX_EP108_NUM_AXI_GPIOS];
>  } XlnxEP108;
>  
>  static struct arm_boot_info xlnx_ep108_binfo;
> @@ -106,6 +119,19 @@ static void xlnx_ep108_init(MachineState *machine)
>          sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[i]), 1, cs_line);
>      }
>  
> +    /* Connect the GPIO devices. These aren't on the board, but they are in
> +     * the PL, so we connect them here instead of in the SoC.
> +     */
> +    for (i = 0; i < XLNX_EP108_NUM_AXI_GPIOS; i++) {
> +        object_initialize(&s->axi_gpio[i], sizeof(s->axi_gpio[i]),
> +                          TYPE_XLNX_AXI_GPIO);
> +        qdev_set_parent_bus(DEVICE(&s->axi_gpio[i]), sysbus_get_default());
> +
> +        object_property_set_bool(OBJECT(&s->axi_gpio[i]), true, "realized", &error_fatal);
> +        sysbus_mmio_map(SYS_BUS_DEVICE(&s->axi_gpio[i]), 0, axi_gpio_addr[i]);
> +        /* The device supports interrupts, but they aren't connected */
> +    }
> +
>      xlnx_ep108_binfo.ram_size = ram_size;
>      xlnx_ep108_binfo.kernel_filename = machine->kernel_filename;
>      xlnx_ep108_binfo.kernel_cmdline = machine->kernel_cmdline;
> -- 
> 2.7.4
>
diff mbox

Patch

diff --git a/hw/arm/xlnx-ep108.c b/hw/arm/xlnx-ep108.c
index 4ec590a..23b3d6e 100644
--- a/hw/arm/xlnx-ep108.c
+++ b/hw/arm/xlnx-ep108.c
@@ -20,14 +20,27 @@ 
 #include "qemu-common.h"
 #include "cpu.h"
 #include "hw/arm/xlnx-zynqmp.h"
+#include "hw/gpio/xlnx-axi-gpio.h"
 #include "hw/boards.h"
 #include "qemu/error-report.h"
 #include "exec/address-spaces.h"
 #include "qemu/log.h"
 
+#define XLNX_EP108_NUM_AXI_GPIOS 7
+
+/* These can always be changed, but these seven are the default in the reference
+ * board design.
+ */
+static const uint64_t axi_gpio_addr[XLNX_EP108_NUM_AXI_GPIOS] = {
+    0xa1000000, 0x401000000, 0x1001000000, 0xb1000000, 0x501000000,
+    0x4801000000, 0x81000000,
+};
+
 typedef struct XlnxEP108 {
     XlnxZynqMPState soc;
     MemoryRegion ddr_ram;
+
+    XlnxAXIGPIO axi_gpio[XLNX_EP108_NUM_AXI_GPIOS];
 } XlnxEP108;
 
 static struct arm_boot_info xlnx_ep108_binfo;
@@ -106,6 +119,19 @@  static void xlnx_ep108_init(MachineState *machine)
         sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[i]), 1, cs_line);
     }
 
+    /* Connect the GPIO devices. These aren't on the board, but they are in
+     * the PL, so we connect them here instead of in the SoC.
+     */
+    for (i = 0; i < XLNX_EP108_NUM_AXI_GPIOS; i++) {
+        object_initialize(&s->axi_gpio[i], sizeof(s->axi_gpio[i]),
+                          TYPE_XLNX_AXI_GPIO);
+        qdev_set_parent_bus(DEVICE(&s->axi_gpio[i]), sysbus_get_default());
+
+        object_property_set_bool(OBJECT(&s->axi_gpio[i]), true, "realized", &error_fatal);
+        sysbus_mmio_map(SYS_BUS_DEVICE(&s->axi_gpio[i]), 0, axi_gpio_addr[i]);
+        /* The device supports interrupts, but they aren't connected */
+    }
+
     xlnx_ep108_binfo.ram_size = ram_size;
     xlnx_ep108_binfo.kernel_filename = machine->kernel_filename;
     xlnx_ep108_binfo.kernel_cmdline = machine->kernel_cmdline;