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