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;
17typedef struct SSISlaveClass SSISlaveClass;
18typedef enum SSICSMode SSICSMode;
19
20#define TYPE_SSI_SLAVE "ssi-slave"
21#define SSI_SLAVE(obj) \
22 OBJECT_CHECK(SSISlave, (obj), TYPE_SSI_SLAVE)
23#define SSI_SLAVE_CLASS(klass) \
24 OBJECT_CLASS_CHECK(SSISlaveClass, (klass), TYPE_SSI_SLAVE)
25#define SSI_SLAVE_GET_CLASS(obj) \
26 OBJECT_GET_CLASS(SSISlaveClass, (obj), TYPE_SSI_SLAVE)
27
28#define SSI_GPIO_CS "ssi-gpio-cs"
29
30enum SSICSMode {
31 SSI_CS_NONE = 0,
32 SSI_CS_LOW,
33 SSI_CS_HIGH,
34};
35
36
37struct SSISlaveClass {
38 DeviceClass parent_class;
39
40 int (*init)(SSISlave *dev);
41
42
43
44
45 uint32_t (*transfer)(SSISlave *dev, uint32_t val);
46
47
48
49
50 int (*set_cs)(SSISlave *dev, bool select);
51
52 SSICSMode cs_polarity;
53
54
55
56
57
58
59 uint32_t (*transfer_raw)(SSISlave *dev, uint32_t val);
60};
61
62struct SSISlave {
63 DeviceState parent_obj;
64
65
66 bool cs;
67};
68
69#define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev)
70
71extern const VMStateDescription vmstate_ssi_slave;
72
73#define VMSTATE_SSI_SLAVE(_field, _state) { \
74 .name = (stringify(_field)), \
75 .size = sizeof(SSISlave), \
76 .vmsd = &vmstate_ssi_slave, \
77 .flags = VMS_STRUCT, \
78 .offset = vmstate_offset_value(_state, _field, SSISlave), \
79}
80
81DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
82DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
83
84
85SSIBus *ssi_create_bus(DeviceState *parent, const char *name);
86
87uint32_t ssi_transfer(SSIBus *bus, uint32_t val);
88
89
90void ssi_auto_connect_slaves(DeviceState *parent, qemu_irq *cs_lines,
91 SSIBus *bus);
92
93
94void max111x_set_input(DeviceState *dev, int line, uint8_t value);
95
96#endif
97