[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 7/8] hw/misc/pca9552: Trace GPIO change events
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v4 7/8] hw/misc/pca9552: Trace GPIO change events |
Date: |
Sun, 21 Jun 2020 00:58:53 +0200 |
Emit a trace event when a GPIO change its state.
Example booting obmc-phosphor-image:
$ qemu-system-arm -M witherspoon-bmc -trace pca9552_gpio_change
1592690552.687372:pca9552_gpio_change pca1 GPIO id:0 status: 0 -> 1
1592690552.690169:pca9552_gpio_change pca1 GPIO id:1 status: 0 -> 1
1592690552.691673:pca9552_gpio_change pca1 GPIO id:2 status: 0 -> 1
1592690552.696886:pca9552_gpio_change pca1 GPIO id:3 status: 0 -> 1
1592690552.698614:pca9552_gpio_change pca1 GPIO id:13 status: 0 -> 1
1592690552.699833:pca9552_gpio_change pca1 GPIO id:14 status: 0 -> 1
1592690552.700842:pca9552_gpio_change pca1 GPIO id:15 status: 0 -> 1
1592690683.841921:pca9552_gpio_change pca1 GPIO id:14 status: 1 -> 0
1592690683.861660:pca9552_gpio_change pca1 GPIO id:14 status: 0 -> 1
1592690684.371460:pca9552_gpio_change pca1 GPIO id:14 status: 1 -> 0
1592690684.882115:pca9552_gpio_change pca1 GPIO id:14 status: 0 -> 1
1592690685.391411:pca9552_gpio_change pca1 GPIO id:14 status: 1 -> 0
1592690685.901391:pca9552_gpio_change pca1 GPIO id:14 status: 0 -> 1
1592690686.411678:pca9552_gpio_change pca1 GPIO id:14 status: 1 -> 0
1592690686.921279:pca9552_gpio_change pca1 GPIO id:14 status: 0 -> 1
We notice the GPIO #14 (front-power LED) starts to blink.
This LED is described in the witherspoon device-tree [*]:
front-power {
retain-state-shutdown;
default-state = "keep";
gpios = <&pca0 14 GPIO_ACTIVE_LOW>;
};
[*]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts?id=b1f9be9392f0#n140
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/misc/pca9552.c | 15 +++++++++++++++
hw/misc/trace-events | 1 +
2 files changed, 16 insertions(+)
diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c
index f0d435e310..85557b78d9 100644
--- a/hw/misc/pca9552.c
+++ b/hw/misc/pca9552.c
@@ -60,6 +60,21 @@ static void pca9552_display_pins_status(PCA9552State *s)
buf[i] = '\0';
trace_pca9552_gpio_status(s->description, buf);
}
+ if (trace_event_get_state_backends(TRACE_PCA9552_GPIO_CHANGE)) {
+ for (i = 0; i < s->nr_leds; i++) {
+ if (extract32(pins_changed, i, 1)) {
+ unsigned new_state = extract32(pins_status, i, 1);
+
+ /*
+ * We display the state using the PCA logic ("active-high").
+ * This is not the state of the LED, which signal might be
+ * wired "active-low" on the board.
+ */
+ trace_pca9552_gpio_change(s->description, i,
+ !new_state, new_state);
+ }
+ }
+ }
}
static void pca9552_update_pin_input(PCA9552State *s)
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
index 7630e59652..805d2110e0 100644
--- a/hw/misc/trace-events
+++ b/hw/misc/trace-events
@@ -209,3 +209,4 @@ grlib_apb_pnp_read(uint64_t addr, uint32_t value) "APB PnP
read addr:0x%03"PRIx6
# pca9552.c
pca9552_gpio_status(const char *description, const char *buf) "%s GPIOs 0-15
[%s]"
+pca9552_gpio_change(const char *description, unsigned id, unsigned prev_state,
unsigned current_state) "%s GPIO id:%u status: %u -> %u"
--
2.21.3
- Re: [PATCH v4 4/8] hw/misc/pca9552: Add a 'description' property for debugging purpose, (continued)
[PATCH v4 5/8] hw/misc/pca9552: Trace GPIO High/Low events, Philippe Mathieu-Daudé, 2020/06/20
[PATCH v4 6/8] hw/arm/aspeed: Describe each PCA9552 device, Philippe Mathieu-Daudé, 2020/06/20
[PATCH v4 7/8] hw/misc/pca9552: Trace GPIO change events,
Philippe Mathieu-Daudé <=
[PATCH v4 8/8] hw/misc/pca9552: Model qdev output GPIOs, Philippe Mathieu-Daudé, 2020/06/20