summary refs log tree commit diff stats
path: root/hw/misc/mps2-fpgaio.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-02-15 11:51:20 +0000
committerPeter Maydell <peter.maydell@linaro.org>2021-03-06 13:30:38 +0000
commitb2234223fd511230e933bba2572928ca97028bb8 (patch)
tree7ed4b414b4f68cb71917d3af35f7291bbc888b3e /hw/misc/mps2-fpgaio.c
parente8556f435eee97d508b58c06c156990d537823ab (diff)
downloadfocaccia-qemu-b2234223fd511230e933bba2572928ca97028bb8.tar.gz
focaccia-qemu-b2234223fd511230e933bba2572928ca97028bb8.zip
hw/misc/mps2-fpgaio: Support SWITCH register
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
Diffstat (limited to 'hw/misc/mps2-fpgaio.c')
-rw-r--r--hw/misc/mps2-fpgaio.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c
index e74dec670f..b04fcda844 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(),
 };