[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 31/49] hw/misc/mps2-fpgaio: Support SWITCH register
From: |
Peter Maydell |
Subject: |
[PULL 31/49] hw/misc/mps2-fpgaio: Support SWITCH register |
Date: |
Fri, 5 Mar 2021 17:14:57 +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>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20210215115138.20465-7-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..0d3c8eef56c 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 has_switches;
uint32_t led0;
uint32_t prescale;
diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c
index e74dec670f0..b04fcda844c 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->has_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("has-switches", MPS2FPGAIO, has_switches, false),
DEFINE_PROP_END_OF_LIST(),
};
--
2.20.1
- [PULL 16/49] hw/arm/musicpal: Remove dead code for non-32-bit-RGB surfaces, (continued)
- [PULL 16/49] hw/arm/musicpal: Remove dead code for non-32-bit-RGB surfaces, Peter Maydell, 2021/03/05
- [PULL 20/49] hw/display/omap_lcdc: Expand out macros in template header, Peter Maydell, 2021/03/05
- [PULL 19/49] hw/display/tc6393xb: Inline tc6393xb_draw_graphic32() at its callsite, Peter Maydell, 2021/03/05
- [PULL 22/49] hw/display/omap_lcdc: Fix coding style issues in template header, Peter Maydell, 2021/03/05
- [PULL 29/49] hw/arm/mps2-tz: Make the OSCCLK settings be configurable per-board, Peter Maydell, 2021/03/05
- [PULL 23/49] hw/display/omap_lcdc: Inline template header into C file, Peter Maydell, 2021/03/05
- [PULL 21/49] hw/display/omap_lcdc: Drop broken bigendian ifdef, Peter Maydell, 2021/03/05
- [PULL 24/49] hw/display/omap_lcdc: Delete unnecessary macro, Peter Maydell, 2021/03/05
- [PULL 28/49] hw/arm/mps2-tz: Correct the OSCCLK settings for mps2-an505 and mps2-an511, Peter Maydell, 2021/03/05
- [PULL 32/49] hw/arm/mps2-tz: Make FPGAIO switch and LED config per-board, Peter Maydell, 2021/03/05
- [PULL 31/49] hw/misc/mps2-fpgaio: Support SWITCH register,
Peter Maydell <=
- [PULL 26/49] hw/arm/mps2-tz: Make SYSCLK frequency board-specific, Peter Maydell, 2021/03/05
- [PULL 37/49] hw/arm/mps2-tz: Allow PPCPortInfo structures to specify device interrupts, Peter Maydell, 2021/03/05
- [PULL 30/49] hw/misc/mps2-fpgaio: Make number of LEDs configurable by board, Peter Maydell, 2021/03/05
- [PULL 27/49] hw/misc/mps2-scc: Support configurable number of OSCCLK values, Peter Maydell, 2021/03/05
- [PULL 34/49] hw/arm/mps2-tz: Make number of IRQs board-specific, Peter Maydell, 2021/03/05
- [PULL 35/49] hw/misc/mps2-scc: Implement CFG_REG5 and CFG_REG6 for MPS3 AN524, Peter Maydell, 2021/03/05
- [PULL 46/49] hw/arm/mps2-tz: Stub out USB controller for mps3-an524, Peter Maydell, 2021/03/05
- [PULL 38/49] hw/arm/mps2-tz: Move device IRQ info to data structures, Peter Maydell, 2021/03/05
- [PULL 43/49] hw/arm/mps2-tz: Support ROMs as well as RAMs, Peter Maydell, 2021/03/05
- [PULL 44/49] hw/arm/mps2-tz: Get armv7m_load_kernel() size argument from RAMInfo, Peter Maydell, 2021/03/05