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 8 LEDs connected to the MCC.
This remplaces the 'mps2_scc_leds' trace events by the generic
'led_set_intensity' event.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
https://youtu.be/l9kD70uPchk?t=288
---
include/hw/misc/mps2-scc.h | 1 +
hw/misc/mps2-scc.c | 23 ++++++++++++-----------
hw/misc/Kconfig | 1 +
hw/misc/trace-events | 1 -
4 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h
index 7045473788..29e12b832b 100644
--- a/include/hw/misc/mps2-scc.h
+++ b/include/hw/misc/mps2-scc.h
@@ -25,6 +25,7 @@ typedef struct {
/*< public >*/
MemoryRegion iomem;
+ DeviceState *led[8];
uint32_t cfg0;
uint32_t cfg1;
diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
index 9d0909e7b3..2e59a382ec 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(LED(s->led[i]), !!extract32(value, i, 1));
+ }
break;
case A_CFGDATA_OUT:
s->cfgdata_out = value;
@@ -245,6 +239,13 @@ static void mps2_scc_init(Object *obj)
memory_region_init_io(&s->iomem, obj, &mps2_scc_ops, s, "mps2-scc", 0x1000);
sysbus_init_mmio(sbd, &s->iomem);
+
+ for (size_t i = 0; i < ARRAY_SIZE(s->led); i++) {
+ char *name = g_strdup_printf("SCC LED%zu", i);
+ s->led[i] = create_led(obj, LED_COLOR_GREEN,
+ name, LED_RESET_INTENSITY_ACTIVE_HIGH);
+ g_free(name);
+ }
}
static void mps2_scc_realize(DeviceState *dev, Error **errp)
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
index 889757731b..f278f7f354 100644
--- a/hw/misc/Kconfig
+++ b/hw/misc/Kconfig
@@ -97,6 +97,7 @@ config MPS2_FPGAIO
config MPS2_SCC
bool
+ select LED
config TZ_MPC
bool
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
index 8bc7a675e8..490a0f341a 100644
--- a/hw/misc/trace-events
+++ b/hw/misc/trace-events
@@ -81,7 +81,6 @@ aspeed_scu_write(uint64_t offset, unsigned size, uint32_t data) "To 0x%" PRIx64
mps2_scc_read(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
mps2_scc_write(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
mps2_scc_reset(void) "MPS2 SCC: reset"
-mps2_scc_leds(char led7, char led6, char led5, char led4, char led3, char led2, char led1, char led0) "MPS2 SCC LEDs: %c%c%c%c%c%c%c%c"
mps2_scc_cfg_write(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config write: function %d device %d data 0x%" PRIx32
mps2_scc_cfg_read(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config read: function %d device %d data 0x%" PRIx32
--
2.21.3
On 6/20/20 4:07 PM, Philippe Mathieu-Daudé wrote:
> @@ -25,6 +25,7 @@ typedef struct {
>
> /*< public >*/
> MemoryRegion iomem;
> + DeviceState *led[8];
LEDState?
> + for (size_t i = 0; i < ARRAY_SIZE(s->led); i++) {
> + led_set_state(LED(s->led[i]), !!extract32(value, i, 1));
> + }
No need for !!.
r~
On 6/21/20 1:07 AM, Philippe Mathieu-Daudé wrote:
> 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 8 LEDs connected to the MCC.
>
> This remplaces the 'mps2_scc_leds' trace events by the generic
> 'led_set_intensity' event.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> https://youtu.be/l9kD70uPchk?t=288
> ---
> include/hw/misc/mps2-scc.h | 1 +
> hw/misc/mps2-scc.c | 23 ++++++++++++-----------
> hw/misc/Kconfig | 1 +
> hw/misc/trace-events | 1 -
> 4 files changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h
> index 7045473788..29e12b832b 100644
> --- a/include/hw/misc/mps2-scc.h
> +++ b/include/hw/misc/mps2-scc.h
> @@ -25,6 +25,7 @@ typedef struct {
>
> /*< public >*/
> MemoryRegion iomem;
> + DeviceState *led[8];
>
> uint32_t cfg0;
> uint32_t cfg1;
> diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
> index 9d0909e7b3..2e59a382ec 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(LED(s->led[i]), !!extract32(value, i, 1));
> + }
> break;
> case A_CFGDATA_OUT:
> s->cfgdata_out = value;
> @@ -245,6 +239,13 @@ static void mps2_scc_init(Object *obj)
>
> memory_region_init_io(&s->iomem, obj, &mps2_scc_ops, s, "mps2-scc", 0x1000);
> sysbus_init_mmio(sbd, &s->iomem);
> +
> + for (size_t i = 0; i < ARRAY_SIZE(s->led); i++) {
> + char *name = g_strdup_printf("SCC LED%zu", i);
> + s->led[i] = create_led(obj, LED_COLOR_GREEN,
> + name, LED_RESET_INTENSITY_ACTIVE_HIGH);
> + g_free(name);
> + }
This has to go ...
> }
>
> static void mps2_scc_realize(DeviceState *dev, Error **errp)
... here to avoid:
**
ERROR:/tmp/qemu-test/src/hw/core/qdev.c:1074:device_finalize: assertion
failed: (dev->canonical_path)
Broken pipe
/tmp/qemu-test/src/tests/qtest/libqtest.c:175: kill_qemu() detected QEMU
death from signal 6 (Aborted) (core dumped)
ERROR - too few tests run (expected 6, got 5)
> diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
> index 889757731b..f278f7f354 100644
> --- a/hw/misc/Kconfig
> +++ b/hw/misc/Kconfig
> @@ -97,6 +97,7 @@ config MPS2_FPGAIO
>
> config MPS2_SCC
> bool
> + select LED
>
> config TZ_MPC
> bool
> diff --git a/hw/misc/trace-events b/hw/misc/trace-events
> index 8bc7a675e8..490a0f341a 100644
> --- a/hw/misc/trace-events
> +++ b/hw/misc/trace-events
> @@ -81,7 +81,6 @@ aspeed_scu_write(uint64_t offset, unsigned size, uint32_t data) "To 0x%" PRIx64
> mps2_scc_read(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
> mps2_scc_write(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
> mps2_scc_reset(void) "MPS2 SCC: reset"
> -mps2_scc_leds(char led7, char led6, char led5, char led4, char led3, char led2, char led1, char led0) "MPS2 SCC LEDs: %c%c%c%c%c%c%c%c"
> mps2_scc_cfg_write(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config write: function %d device %d data 0x%" PRIx32
> mps2_scc_cfg_read(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config read: function %d device %d data 0x%" PRIx32
>
>
© 2016 - 2026 Red Hat, Inc.