|
@@ -13,6 +13,7 @@
|
|
#include "qemu/main-loop.h"
|
|
#include "qemu/main-loop.h"
|
|
#include "block/aio.h"
|
|
#include "block/aio.h"
|
|
#include "hw/i2c/i2c.h"
|
|
#include "hw/i2c/i2c.h"
|
|
|
|
+#include "trace.h"
|
|
|
|
|
|
#define TYPE_I2C_ECHO "i2c-echo"
|
|
#define TYPE_I2C_ECHO "i2c-echo"
|
|
OBJECT_DECLARE_SIMPLE_TYPE(I2CEchoState, I2C_ECHO)
|
|
OBJECT_DECLARE_SIMPLE_TYPE(I2CEchoState, I2C_ECHO)
|
|
@@ -80,11 +81,13 @@ static int i2c_echo_event(I2CSlave *s, enum i2c_event event)
|
|
case I2C_START_RECV:
|
|
case I2C_START_RECV:
|
|
state->pos = 0;
|
|
state->pos = 0;
|
|
|
|
|
|
|
|
+ trace_i2c_echo_event(DEVICE(s)->canonical_path, "I2C_START_RECV");
|
|
break;
|
|
break;
|
|
|
|
|
|
case I2C_START_SEND:
|
|
case I2C_START_SEND:
|
|
state->pos = 0;
|
|
state->pos = 0;
|
|
|
|
|
|
|
|
+ trace_i2c_echo_event(DEVICE(s)->canonical_path, "I2C_START_SEND");
|
|
break;
|
|
break;
|
|
|
|
|
|
case I2C_FINISH:
|
|
case I2C_FINISH:
|
|
@@ -92,12 +95,15 @@ static int i2c_echo_event(I2CSlave *s, enum i2c_event event)
|
|
state->state = I2C_ECHO_STATE_START_SEND;
|
|
state->state = I2C_ECHO_STATE_START_SEND;
|
|
i2c_bus_master(state->bus, state->bh);
|
|
i2c_bus_master(state->bus, state->bh);
|
|
|
|
|
|
|
|
+ trace_i2c_echo_event(DEVICE(s)->canonical_path, "I2C_FINISH");
|
|
break;
|
|
break;
|
|
|
|
|
|
case I2C_NACK:
|
|
case I2C_NACK:
|
|
|
|
+ trace_i2c_echo_event(DEVICE(s)->canonical_path, "I2C_NACK");
|
|
break;
|
|
break;
|
|
|
|
|
|
default:
|
|
default:
|
|
|
|
+ trace_i2c_echo_event(DEVICE(s)->canonical_path, "UNHANDLED");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -112,6 +118,7 @@ static uint8_t i2c_echo_recv(I2CSlave *s)
|
|
return 0xff;
|
|
return 0xff;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ trace_i2c_echo_recv(DEVICE(s)->canonical_path, state->data[state->pos]);
|
|
return state->data[state->pos++];
|
|
return state->data[state->pos++];
|
|
}
|
|
}
|
|
|
|
|
|
@@ -119,6 +126,7 @@ static int i2c_echo_send(I2CSlave *s, uint8_t data)
|
|
{
|
|
{
|
|
I2CEchoState *state = I2C_ECHO(s);
|
|
I2CEchoState *state = I2C_ECHO(s);
|
|
|
|
|
|
|
|
+ trace_i2c_echo_send(DEVICE(s)->canonical_path, data);
|
|
if (state->pos > 2) {
|
|
if (state->pos > 2) {
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|