hw/i2c/bitbang_i2c: Convert DPRINTF() to trace events

Convert the remaining DPRINTF debug macro uses to tracepoints.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Corey Minyard <cminyard@mvista.com>
Message-id: 20230111085016.44551-6-philmd@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Philippe Mathieu-Daudé 2023-01-11 09:50:16 +01:00 committed by Peter Maydell
parent 1e5b1899cc
commit c166e592a7
2 changed files with 10 additions and 12 deletions

View File

@ -18,14 +18,6 @@
#include "qom/object.h" #include "qom/object.h"
#include "trace.h" #include "trace.h"
//#define DEBUG_BITBANG_I2C
#ifdef DEBUG_BITBANG_I2C
#define DPRINTF(fmt, ...) \
do { printf("bitbang_i2c: " fmt , ## __VA_ARGS__); } while (0)
#else
#define DPRINTF(fmt, ...) do {} while(0)
#endif
/* bitbang_i2c_state enum to name */ /* bitbang_i2c_state enum to name */
static const char * const sname[] = { static const char * const sname[] = {
@ -71,8 +63,10 @@ static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c)
/* Set device data pin. */ /* Set device data pin. */
static int bitbang_i2c_ret(bitbang_i2c_interface *i2c, int level) static int bitbang_i2c_ret(bitbang_i2c_interface *i2c, int level)
{ {
trace_bitbang_i2c_data(i2c->last_clock, i2c->last_data,
i2c->device_out, level);
i2c->device_out = level; i2c->device_out = level;
//DPRINTF("%d %d %d\n", i2c->last_clock, i2c->last_data, i2c->device_out);
return level & i2c->last_data; return level & i2c->last_data;
} }
@ -137,11 +131,11 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
if (i2c->current_addr < 0) { if (i2c->current_addr < 0) {
i2c->current_addr = i2c->buffer; i2c->current_addr = i2c->buffer;
DPRINTF("Address 0x%02x\n", i2c->current_addr); trace_bitbang_i2c_addr(i2c->current_addr);
ret = i2c_start_transfer(i2c->bus, i2c->current_addr >> 1, ret = i2c_start_transfer(i2c->bus, i2c->current_addr >> 1,
i2c->current_addr & 1); i2c->current_addr & 1);
} else { } else {
DPRINTF("Sent 0x%02x\n", i2c->buffer); trace_bitbang_i2c_send(i2c->buffer);
ret = i2c_send(i2c->bus, i2c->buffer); ret = i2c_send(i2c->bus, i2c->buffer);
} }
if (ret) { if (ret) {
@ -161,7 +155,7 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level)
} }
case RECEIVING_BIT7: case RECEIVING_BIT7:
i2c->buffer = i2c_recv(i2c->bus); i2c->buffer = i2c_recv(i2c->bus);
DPRINTF("RX byte 0x%02x\n", i2c->buffer); trace_bitbang_i2c_recv(i2c->buffer);
/* Fall through... */ /* Fall through... */
case RECEIVING_BIT6 ... RECEIVING_BIT0: case RECEIVING_BIT6 ... RECEIVING_BIT0:
data = i2c->buffer >> 7; data = i2c->buffer >> 7;

View File

@ -2,6 +2,10 @@
# bitbang_i2c.c # bitbang_i2c.c
bitbang_i2c_state(const char *old_state, const char *new_state) "state %s -> %s" bitbang_i2c_state(const char *old_state, const char *new_state) "state %s -> %s"
bitbang_i2c_addr(uint8_t addr) "Address 0x%02x"
bitbang_i2c_send(uint8_t byte) "TX byte 0x%02x"
bitbang_i2c_recv(uint8_t byte) "RX byte 0x%02x"
bitbang_i2c_data(unsigned dat, unsigned clk, unsigned old_out, unsigned new_out) "dat %u clk %u out %u -> %u"
# core.c # core.c