diff options
author | Peter Crosthwaite <peter.crosthwaite@xilinx.com> | 2012-10-01 12:34:37 +1000 |
---|---|---|
committer | Peter Crosthwaite <peter.crosthwaite@xilinx.com> | 2012-10-10 11:13:32 +1000 |
commit | b4ae3cfa57b8c1bdbbd7b7d420971e9171203ade (patch) | |
tree | 08fc675a0ce8db85b5096792f85d3bfc01daaade /hw/xilinx_spi.c | |
parent | fcb5629d3eb208d84c0fe9aa1ef64a6af7de0139 (diff) |
ssi: Add slave autoconnect helper
Added helper function to automatically connect SPI slaves based on the QOM child
nodes of a device. A SSI master device can call this routine to automatically
hook-up all child nodes to its SPI bus.
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Acked-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/xilinx_spi.c')
-rw-r--r-- | hw/xilinx_spi.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/hw/xilinx_spi.c b/hw/xilinx_spi.c index 7db47877e2..5cdf967c20 100644 --- a/hw/xilinx_spi.c +++ b/hw/xilinx_spi.c @@ -320,8 +320,12 @@ static int xilinx_spi_init(SysBusDevice *dev) XilinxSPI *s = FROM_SYSBUS(typeof(*s), dev); DB_PRINT("\n"); + + s->spi = ssi_create_bus(&dev->qdev, "spi"); + sysbus_init_irq(dev, &s->irq); s->cs_lines = g_new(qemu_irq, s->num_cs); + ssi_auto_connect_slaves(DEVICE(s), s->cs_lines, s->spi); for (i = 0; i < s->num_cs; ++i) { sysbus_init_irq(dev, &s->cs_lines[i]); } @@ -331,8 +335,6 @@ static int xilinx_spi_init(SysBusDevice *dev) s->irqline = -1; - s->spi = ssi_create_bus(&dev->qdev, "spi"); - fifo8_create(&s->tx_fifo, FIFO_CAPACITY); fifo8_create(&s->rx_fifo, FIFO_CAPACITY); |