From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Andrew Jeffery" <andrew@aj.id.au>,
"Joaquin de Andres" <me@xcancerberox.com.ar>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Esteban Bosse" <estebanbosse@gmail.com>,
qemu-arm@nongnu.org, "Cédric Le Goater" <clg@kaod.org>,
"Joel Stanley" <joel@jms.id.au>
Subject: [PATCH v3 4/4] hw/misc/pca9552: Trace LED change events
Date: Fri, 19 Jun 2020 16:51:01 +0200 [thread overview]
Message-ID: <20200619145101.1637-5-f4bug@amsat.org> (raw)
In-Reply-To: <20200619145101.1637-1-f4bug@amsat.org>
Emit a trace event when a LED change its value.
Example booting obmc-phosphor-image:
$ qemu-system-arm -M witherspoon-bmc -trace pca9552_led_change
23367@1592575218.896117:pca9552_led_change 0x557cb6896d80 LED id:0 status: 0 -> 1
23367@1592575218.897072:pca9552_led_change 0x557cb6896d80 LED id:1 status: 0 -> 1
23367@1592575218.897487:pca9552_led_change 0x557cb6896d80 LED id:2 status: 0 -> 1
23367@1592575218.897855:pca9552_led_change 0x557cb6896d80 LED id:3 status: 0 -> 1
23367@1592575218.898256:pca9552_led_change 0x557cb6896d80 LED id:13 status: 0 -> 1
23367@1592575218.898663:pca9552_led_change 0x557cb6896d80 LED id:14 status: 0 -> 1
23367@1592575218.899138:pca9552_led_change 0x557cb6896d80 LED id:15 status: 0 -> 1
23367@1592575281.593379:pca9552_led_change 0x557cb6896d80 LED id:14 status: 1 -> 0
23367@1592575282.102994:pca9552_led_change 0x557cb6896d80 LED id:14 status: 0 -> 1
23367@1592575282.613558:pca9552_led_change 0x557cb6896d80 LED id:14 status: 1 -> 0
23367@1592575283.122774:pca9552_led_change 0x557cb6896d80 LED id:14 status: 0 -> 1
We notice the LED #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 50c149077d..096ec3112a 100644
--- a/hw/misc/pca9552.c
+++ b/hw/misc/pca9552.c
@@ -62,6 +62,16 @@ static void pca9552_update_pin_input(PCA9552State *s)
}
}
+static void pca9552_update_led(PCA9552State *s, unsigned id, unsigned new_state)
+{
+ /*
+ * 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_led_change(s, id, !new_state, new_state);
+}
+
static void pca9552_display_leds(PCA9552State *s)
{
uint16_t leds_status, led_changed;
@@ -86,6 +96,11 @@ static void pca9552_display_leds(PCA9552State *s)
buf[i] = '\0';
trace_pca9552_leds_status(s, buf);
}
+ for (i = 0; i < s->nr_leds; i++) {
+ if (extract32(led_changed, i, 1)) {
+ pca9552_update_led(s, i, extract32(leds_status, i, 1));
+ }
+ }
}
static uint8_t pca9552_read(PCA9552State *s, uint8_t reg)
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
index 5d9505ad0f..29892c8b28 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_leds_status(void *object, const char *buf) "%p LEDs 0-15 [%s]"
+pca9552_led_change(void *object, unsigned id, unsigned prev_state, unsigned current_state) "%p LED id:%u status: %u -> %u"
--
2.21.3
next prev parent reply other threads:[~2020-06-19 14:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 14:50 [PATCH v3 0/4] hw/misc/pca9552: Trace LED On/Off events Philippe Mathieu-Daudé
2020-06-19 14:50 ` [PATCH v3 1/4] hw/misc/pca9552: Replace magic value by PCA9552_LED_COUNT definition Philippe Mathieu-Daudé
2020-06-19 14:50 ` [PATCH v3 2/4] hw/misc/pca9552: Add a PCA955X_LED_MAX definition Philippe Mathieu-Daudé
2020-06-19 14:51 ` [PATCH v3 3/4] hw/misc/pca9552: Trace LED On/Off events Philippe Mathieu-Daudé
2020-06-19 14:51 ` Philippe Mathieu-Daudé [this message]
2020-06-20 11:49 ` [PATCH v3 0/4] " Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200619145101.1637-5-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=andrew@aj.id.au \
--cc=clg@kaod.org \
--cc=estebanbosse@gmail.com \
--cc=joel@jms.id.au \
--cc=me@xcancerberox.com.ar \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).