2 * QEMU Synchronous Serial Interface support
4 * Copyright (c) 2009 CodeSourcery.
5 * Written by Paul Brook
7 * This code is licenced under the GNU GPL v2.
16 static void ssi_slave_init(DeviceState
*dev
, DeviceInfo
*base_info
)
18 SSISlaveInfo
*info
= container_of(base_info
, SSISlaveInfo
, qdev
);
19 SSISlave
*s
= SSI_SLAVE_FROM_QDEV(dev
);
22 bus
= FROM_QBUS(SSIBus
, qdev_get_parent_bus(dev
));
23 if (LIST_FIRST(&bus
->qbus
.children
) != dev
24 || LIST_NEXT(dev
, sibling
) != NULL
) {
25 hw_error("Too many devices on SSI bus");
32 void ssi_register_slave(const char *name
, int size
, SSISlaveInfo
*info
)
34 assert(size
>= sizeof(SSISlave
));
35 info
->qdev
.init
= ssi_slave_init
;
36 info
->qdev
.bus_type
= BUS_TYPE_SSI
;
37 qdev_register(name
, size
, &info
->qdev
);
40 DeviceState
*ssi_create_slave(SSIBus
*bus
, const char *name
)
43 dev
= qdev_create(&bus
->qbus
, name
);
48 SSIBus
*ssi_create_bus(DeviceState
*parent
, const char *name
)
51 bus
= qbus_create(BUS_TYPE_SSI
, sizeof(SSIBus
), parent
, name
);
52 return FROM_QBUS(SSIBus
, bus
);
55 uint32_t ssi_transfer(SSIBus
*bus
, uint32_t val
)
59 dev
= LIST_FIRST(&bus
->qbus
.children
);
63 slave
= SSI_SLAVE_FROM_QDEV(dev
);
64 return slave
->info
->transfer(slave
, val
);