diff mbox

[v3,5/5] xlnx-ep108: Connect the SPI Flash

Message ID 6ba7b1cc766cbd622b1f0a1049a5d84ec70120b9.1445995187.git.alistair.francis@xilinx.com
State New
Headers show

Commit Message

Alistair Francis Oct. 28, 2015, 5:32 p.m. UTC
Connect the sst25wf080 SPI flash to the EP108 board.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---
V3:
 - Don't reach into the SoC
V2:
 - Use sst25wf080 instead of m25p80

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

Comments

Peter Crosthwaite Oct. 29, 2015, 2:06 a.m. UTC | #1
On Wed, Oct 28, 2015 at 10:32 AM, Alistair Francis <
alistair.francis@xilinx.com> wrote:

> Connect the sst25wf080 SPI flash to the EP108 board.
>
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
> ---
> V3:
>  - Don't reach into the SoC
> V2:
>  - Use sst25wf080 instead of m25p80
>
>  hw/arm/xlnx-ep108.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/hw/arm/xlnx-ep108.c b/hw/arm/xlnx-ep108.c
> index 2899698..9ac6e6f 100644
> --- a/hw/arm/xlnx-ep108.c
> +++ b/hw/arm/xlnx-ep108.c
> @@ -33,6 +33,7 @@ static struct arm_boot_info xlnx_ep108_binfo;
>  static void xlnx_ep108_init(MachineState *machine)
>  {
>      XlnxEP108 *s = g_new0(XlnxEP108, 1);
> +    int i, j;
>      Error *err = NULL;
>
>      object_initialize(&s->soc, sizeof(s->soc), TYPE_XLNX_ZYNQMP);
> @@ -60,6 +61,24 @@ static void xlnx_ep108_init(MachineState *machine)
>                                           machine->ram_size);
>      memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram);
>
> +    for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
> +        SSIBus *spi_bus;
> +        char bus_name[6];
> +
> +        snprintf(bus_name, 6, "spi%d", i);
> +        spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc), bus_name);
> +
> +        for (j = 0; j < XLNX_ZYNQMP_NUM_SPI_FLASHES; ++j) {
>


So this fully-populated 2X4 arrangement of SPI flashes is a QEMU-specific
concept that was invented before we attempted to accurately model real
boards. That is, xilinx-zynq-a9 is really a virt-only machine model with no
equivalent board (although a 702 dts goes a long way). So in the absence of
a concrete board definition, I opted for this fully-populated scheme. It
was done for software testing with multiple devs and controllers as no real
boards had multiple SPI flash chips. I don't think that should carry over
to EP108 as-is.

Regards,
Peter


> +            DeviceState *flash_dev = ssi_create_slave(spi_bus,
> "sst25wf080");
> +            qemu_irq cs_line = qdev_get_gpio_in_named(flash_dev,
> +                                                      SSI_GPIO_CS, 0);
> +
> +            sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[i]),
> +                               i * XLNX_ZYNQMP_NUM_SPI_FLASHES + j,
> +                               cs_line);
> +        }
> +    }
> +
>      xlnx_ep108_binfo.ram_size = machine->ram_size;
>      xlnx_ep108_binfo.kernel_filename = machine->kernel_filename;
>      xlnx_ep108_binfo.kernel_cmdline = machine->kernel_cmdline;
> --
> 2.5.0
>
>
Alistair Francis Nov. 23, 2015, 5:24 a.m. UTC | #2
On Thu, Oct 29, 2015 at 7:36 AM, Peter Crosthwaite
<crosthwaitepeter@gmail.com> wrote:
>
>
> On Wed, Oct 28, 2015 at 10:32 AM, Alistair Francis
> <alistair.francis@xilinx.com> wrote:
>>
>> Connect the sst25wf080 SPI flash to the EP108 board.
>>
>> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
>> ---
>> V3:
>>  - Don't reach into the SoC
>> V2:
>>  - Use sst25wf080 instead of m25p80
>>
>>  hw/arm/xlnx-ep108.c | 19 +++++++++++++++++++
>>  1 file changed, 19 insertions(+)
>>
>> diff --git a/hw/arm/xlnx-ep108.c b/hw/arm/xlnx-ep108.c
>> index 2899698..9ac6e6f 100644
>> --- a/hw/arm/xlnx-ep108.c
>> +++ b/hw/arm/xlnx-ep108.c
>> @@ -33,6 +33,7 @@ static struct arm_boot_info xlnx_ep108_binfo;
>>  static void xlnx_ep108_init(MachineState *machine)
>>  {
>>      XlnxEP108 *s = g_new0(XlnxEP108, 1);
>> +    int i, j;
>>      Error *err = NULL;
>>
>>      object_initialize(&s->soc, sizeof(s->soc), TYPE_XLNX_ZYNQMP);
>> @@ -60,6 +61,24 @@ static void xlnx_ep108_init(MachineState *machine)
>>                                           machine->ram_size);
>>      memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram);
>>
>> +    for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
>> +        SSIBus *spi_bus;
>> +        char bus_name[6];
>> +
>> +        snprintf(bus_name, 6, "spi%d", i);
>> +        spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc),
>> bus_name);
>> +
>> +        for (j = 0; j < XLNX_ZYNQMP_NUM_SPI_FLASHES; ++j) {
>
>
>
> So this fully-populated 2X4 arrangement of SPI flashes is a QEMU-specific
> concept that was invented before we attempted to accurately model real
> boards. That is, xilinx-zynq-a9 is really a virt-only machine model with no
> equivalent board (although a 702 dts goes a long way). So in the absence of
> a concrete board definition, I opted for this fully-populated scheme. It was
> done for software testing with multiple devs and controllers as no real
> boards had multiple SPI flash chips. I don't think that should carry over to
> EP108 as-is.

Ok, I had a deeper look and it looks like there is only one SPI flash device per
I2C device, so I have fixed that.

Thanks,

Alistair

>
> Regards,
> Peter
>
>>
>> +            DeviceState *flash_dev = ssi_create_slave(spi_bus,
>> "sst25wf080");
>> +            qemu_irq cs_line = qdev_get_gpio_in_named(flash_dev,
>> +                                                      SSI_GPIO_CS, 0);
>> +
>> +            sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[i]),
>> +                               i * XLNX_ZYNQMP_NUM_SPI_FLASHES + j,
>> +                               cs_line);
>> +        }
>> +    }
>> +
>>      xlnx_ep108_binfo.ram_size = machine->ram_size;
>>      xlnx_ep108_binfo.kernel_filename = machine->kernel_filename;
>>      xlnx_ep108_binfo.kernel_cmdline = machine->kernel_cmdline;
>> --
>> 2.5.0
>>
>
diff mbox

Patch

diff --git a/hw/arm/xlnx-ep108.c b/hw/arm/xlnx-ep108.c
index 2899698..9ac6e6f 100644
--- a/hw/arm/xlnx-ep108.c
+++ b/hw/arm/xlnx-ep108.c
@@ -33,6 +33,7 @@  static struct arm_boot_info xlnx_ep108_binfo;
 static void xlnx_ep108_init(MachineState *machine)
 {
     XlnxEP108 *s = g_new0(XlnxEP108, 1);
+    int i, j;
     Error *err = NULL;
 
     object_initialize(&s->soc, sizeof(s->soc), TYPE_XLNX_ZYNQMP);
@@ -60,6 +61,24 @@  static void xlnx_ep108_init(MachineState *machine)
                                          machine->ram_size);
     memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram);
 
+    for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
+        SSIBus *spi_bus;
+        char bus_name[6];
+
+        snprintf(bus_name, 6, "spi%d", i);
+        spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc), bus_name);
+
+        for (j = 0; j < XLNX_ZYNQMP_NUM_SPI_FLASHES; ++j) {
+            DeviceState *flash_dev = ssi_create_slave(spi_bus, "sst25wf080");
+            qemu_irq cs_line = qdev_get_gpio_in_named(flash_dev,
+                                                      SSI_GPIO_CS, 0);
+
+            sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[i]),
+                               i * XLNX_ZYNQMP_NUM_SPI_FLASHES + j,
+                               cs_line);
+        }
+    }
+
     xlnx_ep108_binfo.ram_size = machine->ram_size;
     xlnx_ep108_binfo.kernel_filename = machine->kernel_filename;
     xlnx_ep108_binfo.kernel_cmdline = machine->kernel_cmdline;