[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/24] hw/misc/mps2-fpgaio: Support SWITCH register
From: |
Peter Maydell |
Subject: |
[PATCH 06/24] hw/misc/mps2-fpgaio: Support SWITCH register |
Date: |
Fri, 5 Feb 2021 17:00:01 +0000 |
MPS3 boards have an extra SWITCH register in the FPGAIO block which
reports the value of some switches. Implement this, governed by a
property the board code can use to specify whether whether it exists.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
include/hw/misc/mps2-fpgaio.h | 1 +
hw/misc/mps2-fpgaio.c | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/include/hw/misc/mps2-fpgaio.h b/include/hw/misc/mps2-fpgaio.h
index bfe73134e78..83c6e18a4ee 100644
--- a/include/hw/misc/mps2-fpgaio.h
+++ b/include/hw/misc/mps2-fpgaio.h
@@ -38,6 +38,7 @@ struct MPS2FPGAIO {
MemoryRegion iomem;
LEDState *led[MPS2FPGAIO_MAX_LEDS];
uint32_t num_leds;
+ bool have_switches;
uint32_t led0;
uint32_t prescale;
diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c
index b28a1be22cc..b54657a4f07 100644
--- a/hw/misc/mps2-fpgaio.c
+++ b/hw/misc/mps2-fpgaio.c
@@ -35,6 +35,7 @@ REG32(CLK100HZ, 0x14)
REG32(COUNTER, 0x18)
REG32(PRESCALE, 0x1c)
REG32(PSCNTR, 0x20)
+REG32(SWITCH, 0x28)
REG32(MISC, 0x4c)
static uint32_t counter_from_tickoff(int64_t now, int64_t tick_offset, int frq)
@@ -156,7 +157,15 @@ static uint64_t mps2_fpgaio_read(void *opaque, hwaddr
offset, unsigned size)
resync_counter(s);
r = s->pscntr;
break;
+ case A_SWITCH:
+ if (!s->have_switches) {
+ goto bad_offset;
+ }
+ /* User-togglable board switches. We don't model that, so report 0. */
+ r = 0;
+ break;
default:
+ bad_offset:
qemu_log_mask(LOG_GUEST_ERROR,
"MPS2 FPGAIO read: bad offset %x\n", (int) offset);
r = 0;
@@ -318,6 +327,7 @@ static Property mps2_fpgaio_properties[] = {
DEFINE_PROP_UINT32("prescale-clk", MPS2FPGAIO, prescale_clk, 20000000),
/* Number of LEDs controlled by LED0 register */
DEFINE_PROP_UINT32("num-leds", MPS2FPGAIO, num_leds, 2),
+ DEFINE_PROP_BOOL("have-switches", MPS2FPGAIO, have_switches, false),
DEFINE_PROP_END_OF_LIST(),
};
--
2.20.1
- Re: [PATCH 01/24] hw/arm/mps2-tz: Make SYSCLK frequency board-specific, (continued)
- [PATCH 02/24] hw/misc/mps2-scc: Support configurable number of OSCCLK values, Peter Maydell, 2021/02/05
- [PATCH 04/24] hw/arm/mps2-tz: Make the OSCCLK settings be configurable per-board, Peter Maydell, 2021/02/05
- [PATCH 08/24] hw/arm/mps2-tz: Condition IRQ splitting on number of CPUs, not board type, Peter Maydell, 2021/02/05
- [PATCH 13/24] hw/arm/mps2-tz: Move device IRQ info to data structures, Peter Maydell, 2021/02/05
- [PATCH 05/24] hw/misc/mps2-fpgaio: Make number of LEDs configurable by board, Peter Maydell, 2021/02/05
- [PATCH 06/24] hw/misc/mps2-fpgaio: Support SWITCH register,
Peter Maydell <=
- Re: [PATCH 06/24] hw/misc/mps2-fpgaio: Support SWITCH register, Philippe Mathieu-Daudé, 2021/02/12
- [PATCH 07/24] hw/arm/mps2-tz: Make FPGAIO switch and LED config per-board, Peter Maydell, 2021/02/05
- [PATCH 20/24] hw/arm/mps2-tz: Add new mps3-an524 board, Peter Maydell, 2021/02/05