@@ -1165,10 +1165,13 @@ static int ot_i2c_target_event(I2CSlave *target, enum i2c_event event)
11651165 }
11661166
11671167 switch (event ) {
1168+ case I2C_START_SEND :
11681169 case I2C_START_SEND_ASYNC :
11691170 /* Set the first byte to the target address + RW bit as 0. */
11701171 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+ }
11721175 break ;
11731176 case I2C_START_RECV :
11741177 /* 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)
12261229 return data ;
12271230}
12281231
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+
12291244static void ot_i2c_target_send_async (I2CSlave * target , uint8_t data )
12301245{
12311246 BusState * abus = qdev_get_parent_bus (DEVICE (target ));
@@ -1246,6 +1261,7 @@ static void ot_i2c_target_class_init(ObjectClass *klass, void *data)
12461261
12471262 dc -> desc = "OpenTitan I2C Target" ;
12481263 sc -> event = & ot_i2c_target_event ;
1264+ sc -> send = & ot_i2c_target_send ;
12491265 sc -> send_async = & ot_i2c_target_send_async ;
12501266 sc -> recv = & ot_i2c_target_recv ;
12511267}
0 commit comments