Paul Brook | 90d3723 | 2009-05-14 22:35:09 +0100 | [diff] [blame] | 1 | /* QEMU Synchronous Serial Interface support. */ |
| 2 | |
| 3 | /* In principle SSI is a point-point interface. As such the qemu |
| 4 | implementation has a single slave device on a "bus". |
| 5 | However it is fairly common for boards to have multiple slaves |
| 6 | connected to a single master, and select devices with an external |
| 7 | chip select. This is implemented in qemu by having an explicit mux device. |
| 8 | It is assumed that master and slave are both using the same transfer width. |
| 9 | */ |
| 10 | |
| 11 | #ifndef QEMU_SSI_H |
| 12 | #define QEMU_SSI_H |
| 13 | |
| 14 | #include "qdev.h" |
| 15 | |
| 16 | typedef struct SSISlave SSISlave; |
| 17 | |
Anthony Liguori | cd6c4cf | 2011-12-16 13:36:39 -0600 | [diff] [blame] | 18 | #define TYPE_SSI_SLAVE "ssi-slave" |
| 19 | #define SSI_SLAVE(obj) \ |
| 20 | OBJECT_CHECK(SSISlave, (obj), TYPE_SSI_SLAVE) |
| 21 | #define SSI_SLAVE_CLASS(klass) \ |
| 22 | OBJECT_CLASS_CHECK(SSISlaveClass, (klass), TYPE_SSI_SLAVE) |
| 23 | #define SSI_SLAVE_GET_CLASS(obj) \ |
| 24 | OBJECT_GET_CLASS(SSISlaveClass, (obj), TYPE_SSI_SLAVE) |
| 25 | |
Paul Brook | 90d3723 | 2009-05-14 22:35:09 +0100 | [diff] [blame] | 26 | /* Slave devices. */ |
Anthony Liguori | cd6c4cf | 2011-12-16 13:36:39 -0600 | [diff] [blame] | 27 | typedef struct SSISlaveClass { |
| 28 | DeviceClass parent_class; |
| 29 | |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 30 | int (*init)(SSISlave *dev); |
Paul Brook | 90d3723 | 2009-05-14 22:35:09 +0100 | [diff] [blame] | 31 | uint32_t (*transfer)(SSISlave *dev, uint32_t val); |
Anthony Liguori | cd6c4cf | 2011-12-16 13:36:39 -0600 | [diff] [blame] | 32 | } SSISlaveClass; |
Paul Brook | 90d3723 | 2009-05-14 22:35:09 +0100 | [diff] [blame] | 33 | |
| 34 | struct SSISlave { |
| 35 | DeviceState qdev; |
Paul Brook | 90d3723 | 2009-05-14 22:35:09 +0100 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | #define SSI_SLAVE_FROM_QDEV(dev) DO_UPCAST(SSISlave, qdev, dev) |
| 39 | #define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev) |
| 40 | |
Paul Brook | 90d3723 | 2009-05-14 22:35:09 +0100 | [diff] [blame] | 41 | DeviceState *ssi_create_slave(SSIBus *bus, const char *name); |
| 42 | |
| 43 | /* Master interface. */ |
Paul Brook | 02e2da4 | 2009-05-23 00:05:19 +0100 | [diff] [blame] | 44 | SSIBus *ssi_create_bus(DeviceState *parent, const char *name); |
Paul Brook | 90d3723 | 2009-05-14 22:35:09 +0100 | [diff] [blame] | 45 | |
| 46 | uint32_t ssi_transfer(SSIBus *bus, uint32_t val); |
| 47 | |
Paul Brook | a984a69 | 2009-05-14 22:35:09 +0100 | [diff] [blame] | 48 | /* max111x.c */ |
| 49 | void max111x_set_input(DeviceState *dev, int line, uint8_t value); |
| 50 | |
Paul Brook | 90d3723 | 2009-05-14 22:35:09 +0100 | [diff] [blame] | 51 | #endif |