i.MX: Standardize i.MX I2C debug
The goal is to have debug code always compiled during build. We standardize all debug output on the following format: [QOM_TYPE_NAME]reporting_function: debug message The qemu_log_mask() output is following the same format as the above debug. Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> Message-id: 328acfe6fc09a5afdbfbfd5220e0869fd5082660.1445781957.git.jcd@tribudubois.net Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
5641112574
commit
3afcbb01bc
@ -21,13 +21,17 @@
|
|||||||
#include "hw/i2c/imx_i2c.h"
|
#include "hw/i2c/imx_i2c.h"
|
||||||
#include "hw/i2c/i2c.h"
|
#include "hw/i2c/i2c.h"
|
||||||
|
|
||||||
#ifndef IMX_I2C_DEBUG
|
#ifndef DEBUG_IMX_I2C
|
||||||
#define IMX_I2C_DEBUG 0
|
#define DEBUG_IMX_I2C 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IMX_I2C_DEBUG
|
#define DPRINTF(fmt, args...) \
|
||||||
#define DPRINT(fmt, args...) \
|
do { \
|
||||||
do { fprintf(stderr, "%s: "fmt, __func__, ## args); } while (0)
|
if (DEBUG_IMX_I2C) { \
|
||||||
|
fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX_I2C, \
|
||||||
|
__func__, ##args); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
static const char *imx_i2c_get_regname(unsigned offset)
|
static const char *imx_i2c_get_regname(unsigned offset)
|
||||||
{
|
{
|
||||||
@ -46,9 +50,6 @@ static const char *imx_i2c_get_regname(unsigned offset)
|
|||||||
return "[?]";
|
return "[?]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#define DPRINT(fmt, args...) do { } while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool imx_i2c_is_enabled(IMXI2CState *s)
|
static inline bool imx_i2c_is_enabled(IMXI2CState *s)
|
||||||
{
|
{
|
||||||
@ -121,11 +122,11 @@ static uint64_t imx_i2c_read(void *opaque, hwaddr offset,
|
|||||||
|
|
||||||
if (s->address == ADDR_RESET) {
|
if (s->address == ADDR_RESET) {
|
||||||
/* something is wrong as the address is not set */
|
/* something is wrong as the address is not set */
|
||||||
qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Trying to read "
|
qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Trying to read "
|
||||||
"without specifying the slave address\n",
|
"without specifying the slave address\n",
|
||||||
TYPE_IMX_I2C, __func__);
|
TYPE_IMX_I2C, __func__);
|
||||||
} else if (s->i2cr & I2CR_MTX) {
|
} else if (s->i2cr & I2CR_MTX) {
|
||||||
qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Trying to read "
|
qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Trying to read "
|
||||||
"but MTX is set\n", TYPE_IMX_I2C, __func__);
|
"but MTX is set\n", TYPE_IMX_I2C, __func__);
|
||||||
} else {
|
} else {
|
||||||
/* get the next byte */
|
/* get the next byte */
|
||||||
@ -134,7 +135,7 @@ static uint64_t imx_i2c_read(void *opaque, hwaddr offset,
|
|||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
imx_i2c_raise_interrupt(s);
|
imx_i2c_raise_interrupt(s);
|
||||||
} else {
|
} else {
|
||||||
qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: read failed "
|
qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: read failed "
|
||||||
"for device 0x%02x\n", TYPE_IMX_I2C,
|
"for device 0x%02x\n", TYPE_IMX_I2C,
|
||||||
__func__, s->address);
|
__func__, s->address);
|
||||||
ret = 0xff;
|
ret = 0xff;
|
||||||
@ -143,19 +144,19 @@ static uint64_t imx_i2c_read(void *opaque, hwaddr offset,
|
|||||||
|
|
||||||
s->i2dr_read = ret;
|
s->i2dr_read = ret;
|
||||||
} else {
|
} else {
|
||||||
qemu_log_mask(LOG_UNIMP, "%s[%s]: slave mode not implemented\n",
|
qemu_log_mask(LOG_UNIMP, "[%s]%s: slave mode not implemented\n",
|
||||||
TYPE_IMX_I2C, __func__);
|
TYPE_IMX_I2C, __func__);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Bad address at offset %d\n",
|
qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad address at offset 0x%"
|
||||||
TYPE_IMX_I2C, __func__, s->address);
|
HWADDR_PRIx "\n", TYPE_IMX_I2C, __func__, offset);
|
||||||
value = 0;
|
value = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("read %s [0x%02x] -> 0x%02x\n", imx_i2c_get_regname(offset),
|
DPRINTF("read %s [0x%" HWADDR_PRIx "] -> 0x%02x\n",
|
||||||
(unsigned int)offset, value);
|
imx_i2c_get_regname(offset), offset, value);
|
||||||
|
|
||||||
return (uint64_t)value;
|
return (uint64_t)value;
|
||||||
}
|
}
|
||||||
@ -165,8 +166,8 @@ static void imx_i2c_write(void *opaque, hwaddr offset,
|
|||||||
{
|
{
|
||||||
IMXI2CState *s = IMX_I2C(opaque);
|
IMXI2CState *s = IMX_I2C(opaque);
|
||||||
|
|
||||||
DPRINT("write %s [0x%02x] <- 0x%02x\n", imx_i2c_get_regname(offset),
|
DPRINTF("write %s [0x%" HWADDR_PRIx "] <- 0x%02x\n",
|
||||||
(unsigned int)offset, (int)value);
|
imx_i2c_get_regname(offset), offset, (int)value);
|
||||||
|
|
||||||
value &= 0xff;
|
value &= 0xff;
|
||||||
|
|
||||||
@ -264,13 +265,13 @@ static void imx_i2c_write(void *opaque, hwaddr offset,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qemu_log_mask(LOG_UNIMP, "%s[%s]: slave mode not implemented\n",
|
qemu_log_mask(LOG_UNIMP, "[%s]%s: slave mode not implemented\n",
|
||||||
TYPE_IMX_I2C, __func__);
|
TYPE_IMX_I2C, __func__);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qemu_log_mask(LOG_GUEST_ERROR, "%s[%s]: Bad address at offset %d\n",
|
qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad address at offset 0x%"
|
||||||
TYPE_IMX_I2C, __func__, s->address);
|
HWADDR_PRIx "\n", TYPE_IMX_I2C, __func__, offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user