summaryrefslogtreecommitdiffstats
path: root/hw/misc/mps2-scc.c
diff options
context:
space:
mode:
authorPeter Maydell2020-10-28 00:43:53 +0100
committerPeter Maydell2020-10-28 00:43:53 +0100
commitcddfbe07749a44f83d0f8241fff7ca96a6631882 (patch)
tree8a299cef18894f323de9976c1609ba8c7f14a18d /hw/misc/mps2-scc.c
parentMerge remote-tracking branch 'remotes/philmd-gitlab/tags/acceptance-testing-2... (diff)
parenthw/arm/tosa: Replace fprintf() calls by LED devices (diff)
downloadqemu-cddfbe07749a44f83d0f8241fff7ca96a6631882.tar.gz
qemu-cddfbe07749a44f83d0f8241fff7ca96a6631882.tar.xz
qemu-cddfbe07749a44f83d0f8241fff7ca96a6631882.zip
Merge remote-tracking branch 'remotes/philmd-gitlab/tags/led-api-20201026' into staging
API to model LED. CI jobs results: . https://cirrus-ci.com/build/4879251751043072 . https://gitlab.com/philmd/qemu/-/pipelines/207661784 . https://travis-ci.org/github/philmd/qemu/builds/738958191 . https://app.shippable.com/github/philmd/qemu/runs/891/summary/console # gpg: Signature made Mon 26 Oct 2020 22:03:59 GMT # gpg: using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE # gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full] # Primary key fingerprint: FAAB E75E 1291 7221 DCFD 6BB2 E3E3 2C2C DEAD C0DE * remotes/philmd-gitlab/tags/led-api-20201026: hw/arm/tosa: Replace fprintf() calls by LED devices hw/misc/mps2-scc: Use the LED device hw/misc/mps2-fpgaio: Use the LED device hw/arm/aspeed: Add the 3 front LEDs drived by the PCA9552 #1 hw/misc/led: Emit a trace event when LED intensity has changed hw/misc/led: Allow connecting from GPIO output hw/misc/led: Add a LED device Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/misc/mps2-scc.c')
-rw-r--r--hw/misc/mps2-scc.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
index 9d0909e7b3..ce1dfe9356 100644
--- a/hw/misc/mps2-scc.c
+++ b/hw/misc/mps2-scc.c
@@ -20,11 +20,13 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/module.h"
+#include "qemu/bitops.h"
#include "trace.h"
#include "hw/sysbus.h"
#include "migration/vmstate.h"
#include "hw/registerfields.h"
#include "hw/misc/mps2-scc.h"
+#include "hw/misc/led.h"
#include "hw/qdev-properties.h"
REG32(CFG0, 0)
@@ -152,18 +154,10 @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value,
s->cfg0 = value;
break;
case A_CFG1:
- /* CFG1 bits [7:0] control the board LEDs. We don't currently have
- * a mechanism for displaying this graphically, so use a trace event.
- */
- trace_mps2_scc_leds(value & 0x80 ? '*' : '.',
- value & 0x40 ? '*' : '.',
- value & 0x20 ? '*' : '.',
- value & 0x10 ? '*' : '.',
- value & 0x08 ? '*' : '.',
- value & 0x04 ? '*' : '.',
- value & 0x02 ? '*' : '.',
- value & 0x01 ? '*' : '.');
s->cfg1 = value;
+ for (size_t i = 0; i < ARRAY_SIZE(s->led); i++) {
+ led_set_state(s->led[i], extract32(value, i, 1));
+ }
break;
case A_CFGDATA_OUT:
s->cfgdata_out = value;
@@ -236,6 +230,9 @@ static void mps2_scc_reset(DeviceState *dev)
for (i = 0; i < NUM_OSCCLK; i++) {
s->oscclk[i] = s->oscclk_reset[i];
}
+ for (i = 0; i < ARRAY_SIZE(s->led); i++) {
+ device_cold_reset(DEVICE(s->led[i]));
+ }
}
static void mps2_scc_init(Object *obj)
@@ -249,6 +246,14 @@ static void mps2_scc_init(Object *obj)
static void mps2_scc_realize(DeviceState *dev, Error **errp)
{
+ MPS2SCC *s = MPS2_SCC(dev);
+
+ for (size_t i = 0; i < ARRAY_SIZE(s->led); i++) {
+ char *name = g_strdup_printf("SCC LED%zu", i);
+ s->led[i] = led_create_simple(OBJECT(dev), GPIO_POLARITY_ACTIVE_HIGH,
+ LED_COLOR_GREEN, name);
+ g_free(name);
+ }
}
static const VMStateDescription mps2_scc_vmstate = {