diff options
author | Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com> | 2012-07-24 10:55:15 +1000 |
---|---|---|
committer | Peter Crosthwaite <peter.crosthwaite@xilinx.com> | 2012-10-10 11:13:31 +1000 |
commit | b4a76e84f4997392c9d2eb6f4373dc376d2ffd82 (patch) | |
tree | c86259bd728cddf0a9e67bc3b87802fe4981505e /hw/ssi.c | |
parent | 4bb26682f70a5f626cad3e0ac82bf4b6252ea7a4 (diff) | |
download | qemu-b4a76e84f4997392c9d2eb6f4373dc376d2ffd82.tar.gz qemu-b4a76e84f4997392c9d2eb6f4373dc376d2ffd82.tar.bz2 qemu-b4a76e84f4997392c9d2eb6f4373dc376d2ffd82.zip |
ssi: Support for multiple attached devices
Removed assertion that only one device is attached to the SSI bus.
When multiple devices are attached, all slaves have their transfer function
called for transfers. Each device is responsible for knowing whether or not its
CS is active, and if not returning 0. The returned data is the logical or of
all responses from the (mulitple) devices.
Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
Acked-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/ssi.c')
-rw-r--r-- | hw/ssi.c | 24 |
1 files changed, 9 insertions, 15 deletions
@@ -2,6 +2,8 @@ * QEMU Synchronous Serial Interface support * * Copyright (c) 2009 CodeSourcery. + * Copyright (c) 2012 Peter A.G. Crosthwaite (peter.crosthwaite@petalogix.com) + * Copyright (c) 2012 PetaLogix Pty Ltd. * Written by Paul Brook * * This code is licensed under the GNU GPL v2. @@ -29,14 +31,6 @@ static int ssi_slave_init(DeviceState *dev) { SSISlave *s = SSI_SLAVE(dev); SSISlaveClass *ssc = SSI_SLAVE_GET_CLASS(s); - SSIBus *bus; - BusChild *kid; - - bus = FROM_QBUS(SSIBus, qdev_get_parent_bus(dev)); - kid = QTAILQ_FIRST(&bus->qbus.children); - if (kid->child != dev || QTAILQ_NEXT(kid, sibling) != NULL) { - hw_error("Too many devices on SSI bus"); - } return ssc->init(s); } @@ -74,16 +68,16 @@ SSIBus *ssi_create_bus(DeviceState *parent, const char *name) uint32_t ssi_transfer(SSIBus *bus, uint32_t val) { BusChild *kid; - SSISlave *slave; SSISlaveClass *ssc; + uint32_t r = 0; - kid = QTAILQ_FIRST(&bus->qbus.children); - if (!kid) { - return 0; + QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) { + SSISlave *slave = SSI_SLAVE(kid->child); + ssc = SSI_SLAVE_GET_CLASS(slave); + r |= ssc->transfer(slave, val); } - slave = SSI_SLAVE(kid->child); - ssc = SSI_SLAVE_GET_CLASS(slave); - return ssc->transfer(slave, val); + + return r; } static void ssi_slave_register_types(void) |