hw/i2c: Add trace events
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-id: 20180606191801.6331-1-f4bug@amsat.org Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
da969774af
commit
08bb9b347b
|
@ -213,6 +213,7 @@ trace-events-subdirs += hw/char
|
||||||
trace-events-subdirs += hw/display
|
trace-events-subdirs += hw/display
|
||||||
trace-events-subdirs += hw/dma
|
trace-events-subdirs += hw/dma
|
||||||
trace-events-subdirs += hw/hppa
|
trace-events-subdirs += hw/hppa
|
||||||
|
trace-events-subdirs += hw/i2c
|
||||||
trace-events-subdirs += hw/i386
|
trace-events-subdirs += hw/i386
|
||||||
trace-events-subdirs += hw/i386/xen
|
trace-events-subdirs += hw/i386/xen
|
||||||
trace-events-subdirs += hw/ide
|
trace-events-subdirs += hw/ide
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "hw/i2c/i2c.h"
|
#include "hw/i2c/i2c.h"
|
||||||
|
#include "trace.h"
|
||||||
|
|
||||||
#define I2C_BROADCAST 0x00
|
#define I2C_BROADCAST 0x00
|
||||||
|
|
||||||
|
@ -130,14 +131,16 @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv)
|
||||||
}
|
}
|
||||||
|
|
||||||
QLIST_FOREACH(node, &bus->current_devs, next) {
|
QLIST_FOREACH(node, &bus->current_devs, next) {
|
||||||
|
I2CSlave *s = node->elt;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
sc = I2C_SLAVE_GET_CLASS(node->elt);
|
sc = I2C_SLAVE_GET_CLASS(s);
|
||||||
/* If the bus is already busy, assume this is a repeated
|
/* If the bus is already busy, assume this is a repeated
|
||||||
start condition. */
|
start condition. */
|
||||||
|
|
||||||
if (sc->event) {
|
if (sc->event) {
|
||||||
rv = sc->event(node->elt, recv ? I2C_START_RECV : I2C_START_SEND);
|
trace_i2c_event("start", s->address);
|
||||||
|
rv = sc->event(s, recv ? I2C_START_RECV : I2C_START_SEND);
|
||||||
if (rv && !bus->broadcast) {
|
if (rv && !bus->broadcast) {
|
||||||
if (bus_scanned) {
|
if (bus_scanned) {
|
||||||
/* First call, terminate the transfer. */
|
/* First call, terminate the transfer. */
|
||||||
|
@ -156,9 +159,11 @@ void i2c_end_transfer(I2CBus *bus)
|
||||||
I2CNode *node, *next;
|
I2CNode *node, *next;
|
||||||
|
|
||||||
QLIST_FOREACH_SAFE(node, &bus->current_devs, next, next) {
|
QLIST_FOREACH_SAFE(node, &bus->current_devs, next, next) {
|
||||||
sc = I2C_SLAVE_GET_CLASS(node->elt);
|
I2CSlave *s = node->elt;
|
||||||
|
sc = I2C_SLAVE_GET_CLASS(s);
|
||||||
if (sc->event) {
|
if (sc->event) {
|
||||||
sc->event(node->elt, I2C_FINISH);
|
trace_i2c_event("finish", s->address);
|
||||||
|
sc->event(s, I2C_FINISH);
|
||||||
}
|
}
|
||||||
QLIST_REMOVE(node, next);
|
QLIST_REMOVE(node, next);
|
||||||
g_free(node);
|
g_free(node);
|
||||||
|
@ -169,14 +174,17 @@ void i2c_end_transfer(I2CBus *bus)
|
||||||
int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send)
|
int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send)
|
||||||
{
|
{
|
||||||
I2CSlaveClass *sc;
|
I2CSlaveClass *sc;
|
||||||
|
I2CSlave *s;
|
||||||
I2CNode *node;
|
I2CNode *node;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (send) {
|
if (send) {
|
||||||
QLIST_FOREACH(node, &bus->current_devs, next) {
|
QLIST_FOREACH(node, &bus->current_devs, next) {
|
||||||
sc = I2C_SLAVE_GET_CLASS(node->elt);
|
s = node->elt;
|
||||||
|
sc = I2C_SLAVE_GET_CLASS(s);
|
||||||
if (sc->send) {
|
if (sc->send) {
|
||||||
ret = ret || sc->send(node->elt, *data);
|
trace_i2c_send(s->address, *data);
|
||||||
|
ret = ret || sc->send(s, *data);
|
||||||
} else {
|
} else {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +197,9 @@ int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send)
|
||||||
|
|
||||||
sc = I2C_SLAVE_GET_CLASS(QLIST_FIRST(&bus->current_devs)->elt);
|
sc = I2C_SLAVE_GET_CLASS(QLIST_FIRST(&bus->current_devs)->elt);
|
||||||
if (sc->recv) {
|
if (sc->recv) {
|
||||||
ret = sc->recv(QLIST_FIRST(&bus->current_devs)->elt);
|
s = QLIST_FIRST(&bus->current_devs)->elt;
|
||||||
|
ret = sc->recv(s);
|
||||||
|
trace_i2c_recv(s->address, ret);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
|
@ -226,6 +236,7 @@ void i2c_nack(I2CBus *bus)
|
||||||
QLIST_FOREACH(node, &bus->current_devs, next) {
|
QLIST_FOREACH(node, &bus->current_devs, next) {
|
||||||
sc = I2C_SLAVE_GET_CLASS(node->elt);
|
sc = I2C_SLAVE_GET_CLASS(node->elt);
|
||||||
if (sc->event) {
|
if (sc->event) {
|
||||||
|
trace_i2c_event("nack", node->elt->address);
|
||||||
sc->event(node->elt, I2C_NACK);
|
sc->event(node->elt, I2C_NACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
# See docs/devel/tracing.txt for syntax documentation.
|
||||||
|
|
||||||
|
# hw/i2c/core.c
|
||||||
|
|
||||||
|
i2c_event(const char *event, uint8_t address) "%s(addr:0x%02x)"
|
||||||
|
i2c_send(uint8_t address, uint8_t data) "send(addr:0x%02x) data:0x%02x"
|
||||||
|
i2c_recv(uint8_t address, uint8_t data) "recv(addr:0x%02x) data:0x%02x"
|
Loading…
Reference in New Issue