xlxn-axi-gpio: Add and connect the Xilnx AXI GPIO
cover xlxn-axi-gpio: Add and connect the Xilnx AXI GPIO
This patch series adds and connects the Xilnx AXI GPIO device.
Datasheet:
http://www.xilinx.com/support/documentation/ip_documentation/xps_gpio.pdf
Alistair Francis (2):
xlnx-axi-gpio: Add the Xilinx AXI GPIO device
xlnx-ep108: Connect the AXI GPIO device
hw/arm/xlnx-ep108.c | 26 ++++ hw/gpio/Makefile.objs | 1 + hw/gpio/xlnx-axi-gpio.c | 269 ++++++++++++++++++++++++++++++++++++++++ include/hw/gpio/xlnx-axi-gpio.h | 65 ++++++++++ 4 files changed, 361 insertions(+) create mode 100644 hw/gpio/xlnx-axi-gpio.c create mode 100644 include/hw/gpio/xlnx-axi-gpio.h
Signature · 1 line
2.7.4
PATCH 1/2 xlnx-axi-gpio: Add the Xilinx AXI GPIO device
Add the Xilinx AXI GPIO device. This is a commonly used device that lives in the programmable logic (PL) in Xilinx chips.
---
hw/gpio/Makefile.objs | 1 + hw/gpio/xlnx-axi-gpio.c | 269 ++++++++++++++++++++++++++++++++++++++++ include/hw/gpio/xlnx-axi-gpio.h | 65 ++++++++++ 3 files changed, 335 insertions(+) create mode 100644 hw/gpio/xlnx-axi-gpio.c create mode 100644 include/hw/gpio/xlnx-axi-gpio.h
hw/gpio/Makefile.objs +1 -0
@@ -7,3 +7,4 @@ common-obj-$(CONFIG_GPIO_KEY) += gpio_key.o obj-$(CONFIG_OMAP) += omap_gpio.o obj-$(CONFIG_IMX) += imx_gpio.o +obj-y += xlnx-axi-gpio.o
hw/gpio/xlnx-axi-gpio.c new file +269 -0
269 lines not on this page · raw message
include/hw/gpio/xlnx-axi-gpio.h new file +65 -0
65 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 2/2 xlnx-ep108: Connect the AXI GPIO device
In reply to Alistair FrancisConnect the new Xilinx AXI GPIO devices based on the defaults used in the ZCU102 reference board design.
---
hw/arm/xlnx-ep108.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
hw/arm/xlnx-ep108.c +26 -0
@@ -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;
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v1 2/2] xlnx-ep108: Connect the AXI GPIO device
Quoted 2 lines · Alistair Francis
Connect the new Xilinx AXI GPIO devices based on the defaults used in the ZCU102 reference board design.
Quoted 62 lines
Signed-off-by Alistair Francis <[email protected]>---
hw/arm/xlnx-ep108.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)hw/arm/xlnx-ep108.c +26
-0@@ -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;Signature · 1 line
2.7.4