Skip to content

Commit

Permalink
hw/gpio/imx_gpio: Turn DPRINTF() into trace events
Browse files Browse the repository at this point in the history
While at it add a trace event for input GPIO events.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Bernhard Beschow <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
  • Loading branch information
shentok authored and philmd committed Jan 13, 2025
1 parent e589c0e commit e3778c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
18 changes: 7 additions & 11 deletions hw/gpio/imx_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "migration/vmstate.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "trace.h"

#ifndef DEBUG_IMX_GPIO
#define DEBUG_IMX_GPIO 0
Expand All @@ -34,14 +35,6 @@ typedef enum IMXGPIOLevel {
IMX_GPIO_LEVEL_HIGH = 1,
} IMXGPIOLevel;

#define DPRINTF(fmt, args...) \
do { \
if (DEBUG_IMX_GPIO) { \
fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX_GPIO, \
__func__, ##args); \
} \
} while (0)

static const char *imx_gpio_reg_name(uint32_t reg)
{
switch (reg) {
Expand Down Expand Up @@ -111,6 +104,8 @@ static void imx_gpio_set(void *opaque, int line, int level)
IMXGPIOState *s = IMX_GPIO(opaque);
IMXGPIOLevel imx_level = level ? IMX_GPIO_LEVEL_HIGH : IMX_GPIO_LEVEL_LOW;

trace_imx_gpio_set(DEVICE(s)->canonical_path, line, imx_level);

imx_gpio_set_int_line(s, line, imx_level);

/* this is an input signal, so set PSR */
Expand Down Expand Up @@ -200,7 +195,8 @@ static uint64_t imx_gpio_read(void *opaque, hwaddr offset, unsigned size)
break;
}

DPRINTF("(%s) = 0x%" PRIx32 "\n", imx_gpio_reg_name(offset), reg_value);
trace_imx_gpio_read(DEVICE(s)->canonical_path, imx_gpio_reg_name(offset),
reg_value);

return reg_value;
}
Expand All @@ -210,8 +206,8 @@ static void imx_gpio_write(void *opaque, hwaddr offset, uint64_t value,
{
IMXGPIOState *s = IMX_GPIO(opaque);

DPRINTF("(%s, value = 0x%" PRIx32 ")\n", imx_gpio_reg_name(offset),
(uint32_t)value);
trace_imx_gpio_write(DEVICE(s)->canonical_path, imx_gpio_reg_name(offset),
value);

switch (offset) {
case DR_ADDR:
Expand Down
5 changes: 5 additions & 0 deletions hw/gpio/trace-events
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# See docs/devel/tracing.rst for syntax documentation.

# imx_gpio.c
imx_gpio_read(const char *id, const char *reg, uint32_t value) "%s:[%s] -> 0x%" PRIx32
imx_gpio_write(const char *id, const char *reg, uint32_t value) "%s:[%s] <- 0x%" PRIx32
imx_gpio_set(const char *id, int line, int level) "%s:[%d] <- %d"

# npcm7xx_gpio.c
npcm7xx_gpio_read(const char *id, uint64_t offset, uint64_t value) " %s offset: 0x%04" PRIx64 " value 0x%08" PRIx64
npcm7xx_gpio_write(const char *id, uint64_t offset, uint64_t value) "%s offset: 0x%04" PRIx64 " value 0x%08" PRIx64
Expand Down

0 comments on commit e3778c8

Please sign in to comment.