@@ -1165,10 +1165,13 @@ static int ot_i2c_target_event(I2CSlave *target, enum i2c_event event)
1165
1165
}
1166
1166
1167
1167
switch (event ) {
1168
+ case I2C_START_SEND :
1168
1169
case I2C_START_SEND_ASYNC :
1169
1170
/* Set the first byte to the target address + RW bit as 0. */
1170
1171
ot_i2c_target_set_acqdata (s , target -> address << 1u , SIGNAL_START );
1171
- i2c_ack (s -> bus );
1172
+ if (event == I2C_START_SEND_ASYNC ) {
1173
+ i2c_ack (s -> bus );
1174
+ }
1172
1175
break ;
1173
1176
case I2C_START_RECV :
1174
1177
/* Set the first byte to the target address + RW bit as 1. */
@@ -1226,6 +1229,18 @@ static uint8_t ot_i2c_target_recv(I2CSlave *target)
1226
1229
return data ;
1227
1230
}
1228
1231
1232
+ static int ot_i2c_target_send (I2CSlave * target , uint8_t data )
1233
+ {
1234
+ BusState * abus = qdev_get_parent_bus (DEVICE (target ));
1235
+ OtI2CState * s = OT_I2C (abus -> parent );
1236
+ if (!ot_i2c_target_enabled (s )) {
1237
+ return -1 ;
1238
+ }
1239
+
1240
+ ot_i2c_target_set_acqdata (s , data , SIGNAL_NONE );
1241
+ return 0 ;
1242
+ }
1243
+
1229
1244
static void ot_i2c_target_send_async (I2CSlave * target , uint8_t data )
1230
1245
{
1231
1246
BusState * abus = qdev_get_parent_bus (DEVICE (target ));
@@ -1246,6 +1261,7 @@ static void ot_i2c_target_class_init(ObjectClass *klass, void *data)
1246
1261
1247
1262
dc -> desc = "OpenTitan I2C Target" ;
1248
1263
sc -> event = & ot_i2c_target_event ;
1264
+ sc -> send = & ot_i2c_target_send ;
1249
1265
sc -> send_async = & ot_i2c_target_send_async ;
1250
1266
sc -> recv = & ot_i2c_target_recv ;
1251
1267
}
0 commit comments