sc->event = smbus_i2c_event; sc->recv = smbus_i2c_recv; sc->send = smbus_i2c_send; } bool smbus_vmstate_needed(SMBusDevice *dev) { return dev->mode != SMBUS_IDLE; } const VMStateDescription vmstate_smbus_device = { .name = TYPE_SMBUS_DEVICE, .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField[]) { VMSTATE_I2C_SLAVE(i2c, SMBusDevice), VMSTATE_INT32(mode, SMBusDevice), VMSTATE_INT32(data_len, SMBusDevice), VMSTATE_UINT8_ARRAY(data_buf, SMBusDevice, SMBUS_DATA_MAX_LEN), VMSTATE_END_OF_LIST() } }; static const TypeInfo smbus_device_type_info = { .name = TYPE_SMBUS_DEVICE, .parent = TYPE_I2C_SLAVE, .instance_size = sizeof(SMBusDevice), .abstract = true, .class_size = sizeof(SMBusDeviceClass), .class_init = smbus_device_class_init, };
snprintf(bus_name, sizeof(bus_name), "i2c@%d", i); s->busses[i] = i2c_init_bus(DEVICE(s), bus_name); } } static void pca954x_realize(DeviceState *dev, Error **errp) { /* Dummy */ } static const VMStateDescription vmstate_PCA954X = { .name = "pca954x", .version_id = 1, .fields = (VMStateField[]) { VMSTATE_I2C_SLAVE(i2c, PCA954XState), VMSTATE_UINT8(control_reg, PCA954XState), VMSTATE_BOOL(control_decoded, PCA954XState), VMSTATE_UINT8(active_lanes, PCA954XState), VMSTATE_UINT8(lanes, PCA954XState), VMSTATE_BOOL(mux, PCA954XState), VMSTATE_END_OF_LIST() } }; static Property pca954x_properties[] = { /* These could be GPIOs, but the application is rare, just let machine model * tie them with props */ DEFINE_PROP_UINT8("chip-enable", PCA954XState, chip_enable, 0), DEFINE_PROP_END_OF_LIST(),