[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 5/7] hw/misc/mps2-fpgaio: Use the LED device
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v3 5/7] hw/misc/mps2-fpgaio: Use the LED device |
Date: |
Sun, 21 Jun 2020 01:07:17 +0200 |
Per the 'ARM MPS2 and MPS2+ FPGA Prototyping Boards Technical
Reference Manual' (100112_0200_07_en):
2.1 Overview of the MPS2 and MPS2+ hardware
The MPS2 and MPS2+ FPGA Prototyping Boards contain the
following components and interfaces:
* User switches and user LEDs:
- Two green LEDs and two push buttons that connect to
the FPGA.
- Eight green LEDs and one 8-way dip switch that connect
to the MCC.
Add the 2 LEDs connected to the FPGA.
This remplaces the 'mps2_fpgaio_leds' trace events by the generic
'led_set_intensity' event.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/misc/mps2-fpgaio.h | 1 +
hw/misc/mps2-fpgaio.c | 13 ++++++++-----
hw/misc/Kconfig | 1 +
hw/misc/trace-events | 1 -
4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/include/hw/misc/mps2-fpgaio.h b/include/hw/misc/mps2-fpgaio.h
index 69e265cd4b..228b813fd3 100644
--- a/include/hw/misc/mps2-fpgaio.h
+++ b/include/hw/misc/mps2-fpgaio.h
@@ -32,6 +32,7 @@ typedef struct {
/*< public >*/
MemoryRegion iomem;
+ DeviceState *led[2];
uint32_t led0;
uint32_t prescale;
diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c
index 2f3fbeef34..65488f8634 100644
--- a/hw/misc/mps2-fpgaio.c
+++ b/hw/misc/mps2-fpgaio.c
@@ -24,6 +24,7 @@
#include "migration/vmstate.h"
#include "hw/registerfields.h"
#include "hw/misc/mps2-fpgaio.h"
+#include "hw/misc/led.h"
#include "hw/qdev-properties.h"
#include "qemu/timer.h"
@@ -176,12 +177,9 @@ static void mps2_fpgaio_write(void *opaque, hwaddr offset,
uint64_t value,
switch (offset) {
case A_LED0:
- /* LED bits [1:0] control board LEDs. We don't currently have
- * a mechanism for displaying this graphically, so use a trace event.
- */
- trace_mps2_fpgaio_leds(value & 0x02 ? '*' : '.',
- value & 0x01 ? '*' : '.');
s->led0 = value & 0x3;
+ led_set_state(LED(s->led[0]), value & 0x01);
+ led_set_state(LED(s->led[1]), value & 0x02);
break;
case A_PRESCALE:
resync_counter(s);
@@ -249,6 +247,11 @@ static void mps2_fpgaio_init(Object *obj)
memory_region_init_io(&s->iomem, obj, &mps2_fpgaio_ops, s,
"mps2-fpgaio", 0x1000);
sysbus_init_mmio(sbd, &s->iomem);
+
+ s->led[0] = create_led(obj, LED_COLOR_GREEN,
+ "USERLED0", LED_RESET_INTENSITY_ACTIVE_HIGH);
+ s->led[1] = create_led(obj, LED_COLOR_GREEN,
+ "USERLED1", LED_RESET_INTENSITY_ACTIVE_HIGH);
}
static bool mps2_fpgaio_counters_needed(void *opaque)
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
index f60dce694d..889757731b 100644
--- a/hw/misc/Kconfig
+++ b/hw/misc/Kconfig
@@ -93,6 +93,7 @@ config MIPS_ITU
config MPS2_FPGAIO
bool
+ select LED
config MPS2_SCC
bool
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
index 57d39bf9b9..8bc7a675e8 100644
--- a/hw/misc/trace-events
+++ b/hw/misc/trace-events
@@ -89,7 +89,6 @@ mps2_scc_cfg_read(unsigned function, unsigned device,
uint32_t value) "MPS2 SCC
mps2_fpgaio_read(uint64_t offset, uint64_t data, unsigned size) "MPS2 FPGAIO
read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
mps2_fpgaio_write(uint64_t offset, uint64_t data, unsigned size) "MPS2 FPGAIO
write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
mps2_fpgaio_reset(void) "MPS2 FPGAIO: reset"
-mps2_fpgaio_leds(char led1, char led0) "MPS2 FPGAIO LEDs: %c%c"
# msf2-sysreg.c
msf2_sysreg_write(uint64_t offset, uint32_t val, uint32_t prev) "msf2-sysreg
write: addr 0x%08" PRIx64 " data 0x%" PRIx32 " prev 0x%" PRIx32
--
2.21.3
- [PATCH v3 1/7] hw/misc: Add a LED device, (continued)
- [PATCH v3 2/7] hw/misc/led: Add helper to connect LED to GPIO output, Philippe Mathieu-Daudé, 2020/06/20
- [PATCH v3 3/7] hw/misc/led: Emit a trace event when LED intensity has changed, Philippe Mathieu-Daudé, 2020/06/20
- [PATCH v3 4/7] hw/arm/aspeed: Add the 3 front LEDs drived by the PCA9552 #1, Philippe Mathieu-Daudé, 2020/06/20
- [PATCH v3 5/7] hw/misc/mps2-fpgaio: Use the LED device,
Philippe Mathieu-Daudé <=
- [PATCH v3 6/7] hw/misc/mps2-scc: Use the LED device, Philippe Mathieu-Daudé, 2020/06/20
- [PATCH v3 7/7] hw/arm/tosa: Replace fprintf() calls by LED devices, Philippe Mathieu-Daudé, 2020/06/20
- Re: [PATCH v3 0/7] hw/misc: Add LED device, no-reply, 2020/06/20