1
2
3
4
5
6
7
8
9
10
11#ifndef QEMU_SSI_H
12#define QEMU_SSI_H
13
14#include "hw/qdev.h"
15
16typedef struct SSISlave SSISlave;
17
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
26#define SSI_GPIO_CS "ssi-gpio-cs"
27
28typedef enum {
29 SSI_CS_NONE = 0,
30 SSI_CS_LOW,
31 SSI_CS_HIGH,
32} SSICSMode;
33
34
35typedef struct SSISlaveClass {
36 DeviceClass parent_class;
37
38 int (*init)(SSISlave *dev);
39
40
41
42
43 uint32_t (*transfer)(SSISlave *dev, uint32_t val);
44
45
46
47
48 int (*set_cs)(SSISlave *dev, bool select);
49
50 SSICSMode cs_polarity;
51
52
53
54
55
56
57 uint32_t (*transfer_raw)(SSISlave *dev, uint32_t val);
58} SSISlaveClass;
59
60struct SSISlave {
61 DeviceState parent_obj;
62
63
64 bool cs;
65};
66
67#define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev)
68
69extern const VMStateDescription vmstate_ssi_slave;
70
71#define VMSTATE_SSI_SLAVE(_field, _state) { \
72 .name = (stringify(_field)), \
73 .size = sizeof(SSISlave), \
74 .vmsd = &vmstate_ssi_slave, \
75 .flags = VMS_STRUCT, \
76 .offset = vmstate_offset_value(_state, _field, SSISlave), \
77}
78
79DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
80DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
81
82
83SSIBus *ssi_create_bus(DeviceState *parent, const char *name);
84
85uint32_t ssi_transfer(SSIBus *bus, uint32_t val);
86
87
88void ssi_auto_connect_slaves(DeviceState *parent, qemu_irq *cs_lines,
89 SSIBus *bus);
90
91
92void max111x_set_input(DeviceState *dev, int line, uint8_t value);
93
94#endif
95