Skip to content

Commit

Permalink
xilinx_zynq: Added SPI controllers + flashes
Browse files Browse the repository at this point in the history
Added the two SPI controllers to the zynq machine model. Attached two SPI flash
devices to each controller.

Signed-off-by: Peter A. G. Crosthwaite <[email protected]>
Acked-by: Peter Maydell <[email protected]>
  • Loading branch information
pete128 committed Oct 10, 2012
1 parent 94befa4 commit 559d489
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions hw/xilinx_zynq.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include "flash.h"
#include "blockdev.h"
#include "loader.h"
#include "ssi.h"

#define NUM_SPI_FLASHES 4

#define FLASH_SIZE (64 * 1024 * 1024)
#define FLASH_SECTOR_SIZE (128 * 1024)
Expand All @@ -46,6 +49,34 @@ static void gem_init(NICInfo *nd, uint32_t base, qemu_irq irq)
sysbus_connect_irq(s, 0, irq);
}

static inline void zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq)
{
DeviceState *dev;
SysBusDevice *busdev;
SSIBus *spi;
int i;

dev = qdev_create(NULL, "xilinx,spips");
qdev_init_nofail(dev);
busdev = sysbus_from_qdev(dev);
sysbus_mmio_map(busdev, 0, base_addr);
sysbus_connect_irq(busdev, 0, irq);

spi = (SSIBus *)qdev_get_child_bus(dev, "spi");

for (i = 0; i < NUM_SPI_FLASHES; ++i) {
qemu_irq cs_line;

dev = ssi_create_slave_no_init(spi, "m25p80");
qdev_prop_set_string(dev, "partname", "n25q128");
qdev_init_nofail(dev);

cs_line = qdev_get_gpio_in(dev, 0);
sysbus_connect_irq(busdev, i+1, cs_line);
}

}

static void zynq_init(ram_addr_t ram_size, const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
Expand Down Expand Up @@ -113,6 +144,9 @@ static void zynq_init(ram_addr_t ram_size, const char *boot_device,
pic[n] = qdev_get_gpio_in(dev, n);
}

zynq_init_spi_flashes(0xE0006000, pic[58-IRQ_OFFSET]);
zynq_init_spi_flashes(0xE0007000, pic[81-IRQ_OFFSET]);

sysbus_create_simple("cadence_uart", 0xE0000000, pic[59-IRQ_OFFSET]);
sysbus_create_simple("cadence_uart", 0xE0001000, pic[82-IRQ_OFFSET]);

Expand Down

0 comments on commit 559d489

Please sign in to comment.