Skip to content

Commit

Permalink
petalogix-ml605: added SPI controller with n25q128
Browse files Browse the repository at this point in the history
Added SPI controller to the reference design, with two n25q128 spi-flashes
connected.

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 929d1b5 commit acd3b6b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions hw/petalogix_ml605_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "blockdev.h"
#include "pc.h"
#include "exec-memory.h"
#include "ssi.h"

#include "microblaze_boot.h"
#include "microblaze_pic_cpu.h"
Expand All @@ -47,6 +48,8 @@

#define BINARY_DEVICE_TREE_FILE "petalogix-ml605.dtb"

#define NUM_SPI_FLASHES 4

#define MEMORY_BASEADDR 0x50000000
#define FLASH_BASEADDR 0x86000000
#define INTC_BASEADDR 0x81800000
Expand Down Expand Up @@ -79,6 +82,7 @@ petalogix_ml605_init(ram_addr_t ram_size,
MemoryRegion *address_space_mem = get_system_memory();
DeviceState *dev, *dma, *eth0;
MicroBlazeCPU *cpu;
SysBusDevice *busdev;
CPUMBState *env;
DriveInfo *dinfo;
int i;
Expand Down Expand Up @@ -139,6 +143,29 @@ petalogix_ml605_init(ram_addr_t ram_size,
xilinx_axiethernetdma_init(dma, STREAM_SLAVE(eth0),
0x84600000, irq[1], irq[0], 100 * 1000000);

{
SSIBus *spi;

dev = qdev_create(NULL, "xlnx.xps-spi");
qdev_prop_set_uint8(dev, "num-ss-bits", NUM_SPI_FLASHES);
qdev_init_nofail(dev);
busdev = sysbus_from_qdev(dev);
sysbus_mmio_map(busdev, 0, 0x40a00000);
sysbus_connect_irq(busdev, 0, irq[4]);

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);
}
}

microblaze_load_kernel(cpu, ddr_base, ram_size, BINARY_DEVICE_TREE_FILE,
machine_cpu_reset);

Expand Down

0 comments on commit acd3b6b

Please sign in to comment.