qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 24/26] hw/misc/mps2-scc: Support using CFG0 bit 0 for remapping
Date: Mon, 10 May 2021 13:25:46 +0100	[thread overview]
Message-ID: <20210510122548.28638-25-peter.maydell@linaro.org> (raw)
In-Reply-To: <20210510122548.28638-1-peter.maydell@linaro.org>

On some boards, SCC config register CFG0 bit 0 controls whether
parts of the board memory map are remapped. Support this with:
 * a device property scc-cfg0 so the board can specify the
   initial value of the CFG0 register
 * an outbound GPIO line which tracks bit 0 and which the board
   can wire up to provide the remapping

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20210504120912.23094-3-peter.maydell@linaro.org
---
 include/hw/misc/mps2-scc.h |  9 +++++++++
 hw/misc/mps2-scc.c         | 13 ++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h
index ea261ea30d6..3b2d13ac9c3 100644
--- a/include/hw/misc/mps2-scc.h
+++ b/include/hw/misc/mps2-scc.h
@@ -18,8 +18,14 @@
  *  + QOM property "scc-cfg4": value of the read-only CFG4 register
  *  + QOM property "scc-aid": value of the read-only SCC_AID register
  *  + QOM property "scc-id": value of the read-only SCC_ID register
+ *  + QOM property "scc-cfg0": reset value of the CFG0 register
  *  + QOM property array "oscclk": reset values of the OSCCLK registers
  *    (which are accessed via the SYS_CFG channel provided by this device)
+ *  + named GPIO output "remap": this tracks the value of CFG0 register
+ *    bit 0. Boards where this bit controls memory remapping should
+ *    connect this GPIO line to a function performing that mapping.
+ *    Boards where bit 0 has no special function should leave the GPIO
+ *    output disconnected.
  */
 #ifndef MPS2_SCC_H
 #define MPS2_SCC_H
@@ -55,6 +61,9 @@ struct MPS2SCC {
     uint32_t num_oscclk;
     uint32_t *oscclk;
     uint32_t *oscclk_reset;
+    uint32_t cfg0_reset;
+
+    qemu_irq remap;
 };
 
 #endif
diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
index c56aca86ad5..b3b42a792cd 100644
--- a/hw/misc/mps2-scc.c
+++ b/hw/misc/mps2-scc.c
@@ -23,6 +23,7 @@
 #include "qemu/bitops.h"
 #include "trace.h"
 #include "hw/sysbus.h"
+#include "hw/irq.h"
 #include "migration/vmstate.h"
 #include "hw/registerfields.h"
 #include "hw/misc/mps2-scc.h"
@@ -186,10 +187,13 @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value,
     switch (offset) {
     case A_CFG0:
         /*
-         * TODO on some boards bit 0 controls RAM remapping;
-         * on others bit 1 is CPU_WAIT.
+         * On some boards bit 0 controls board-specific remapping;
+         * we always reflect bit 0 in the 'remap' GPIO output line,
+         * and let the board wire it up or not as it chooses.
+         * TODO on some boards bit 1 is CPU_WAIT.
          */
         s->cfg0 = value;
+        qemu_set_irq(s->remap, s->cfg0 & 1);
         break;
     case A_CFG1:
         s->cfg1 = value;
@@ -283,7 +287,7 @@ static void mps2_scc_reset(DeviceState *dev)
     int i;
 
     trace_mps2_scc_reset();
-    s->cfg0 = 0;
+    s->cfg0 = s->cfg0_reset;
     s->cfg1 = 0;
     s->cfg2 = 0;
     s->cfg5 = 0;
@@ -308,6 +312,7 @@ 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);
+    qdev_init_gpio_out_named(DEVICE(obj), &s->remap, "remap", 1);
 }
 
 static void mps2_scc_realize(DeviceState *dev, Error **errp)
@@ -353,6 +358,8 @@ static Property mps2_scc_properties[] = {
     DEFINE_PROP_UINT32("scc-cfg4", MPS2SCC, cfg4, 0),
     DEFINE_PROP_UINT32("scc-aid", MPS2SCC, aid, 0),
     DEFINE_PROP_UINT32("scc-id", MPS2SCC, id, 0),
+    /* Reset value for CFG0 register */
+    DEFINE_PROP_UINT32("scc-cfg0", MPS2SCC, cfg0_reset, 0),
     /*
      * These are the initial settings for the source clocks on the board.
      * In hardware they can be configured via a config file read by the
-- 
2.20.1



  parent reply	other threads:[~2021-05-10 12:43 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10 12:25 [PULL 00/26] target-arm queue Peter Maydell
2021-05-10 12:25 ` [PULL 01/26] docs: fix link in sbsa description Peter Maydell
2021-05-10 12:25 ` [PULL 02/26] linux-user/aarch64: Enable hwcap for RND, BTI, and MTE Peter Maydell
2021-05-10 12:25 ` [PULL 03/26] target/arm: Fix tlbbits calculation in tlbi_aa64_vae2is_write() Peter Maydell
2021-05-10 12:25 ` [PULL 04/26] target/arm: Move constant expanders to translate.h Peter Maydell
2021-05-10 12:25 ` [PULL 05/26] target/arm: Share unallocated_encoding() and gen_exception_insn() Peter Maydell
2021-05-10 12:25 ` [PULL 06/26] target/arm: Make functions used by m-nocp global Peter Maydell
2021-05-10 12:25 ` [PULL 07/26] target/arm: Split m-nocp trans functions into their own file Peter Maydell
2021-05-10 12:25 ` [PULL 08/26] target/arm: Move gen_aa32 functions to translate-a32.h Peter Maydell
2021-05-10 12:25 ` [PULL 09/26] target/arm: Move vfp_{load, store}_reg{32, 64} to translate-vfp.c.inc Peter Maydell
2021-05-10 12:25 ` [PULL 10/26] target/arm: Make functions used by translate-vfp global Peter Maydell
2021-05-10 12:25 ` [PULL 11/26] target/arm: Make translate-vfp.c.inc its own compilation unit Peter Maydell
2021-05-10 12:25 ` [PULL 12/26] target/arm: Move vfp_reg_ptr() to translate-neon.c.inc Peter Maydell
2021-05-10 12:25 ` [PULL 13/26] target/arm: Delete unused typedef Peter Maydell
2021-05-10 12:25 ` [PULL 14/26] target/arm: Move NeonGenThreeOpEnvFn typedef to translate.h Peter Maydell
2021-05-10 12:25 ` [PULL 15/26] target/arm: Make functions used by translate-neon global Peter Maydell
2021-05-10 12:25 ` [PULL 16/26] target/arm: Make translate-neon.c.inc its own compilation unit Peter Maydell
2021-05-10 12:25 ` [PULL 17/26] target/arm: Make WFI a NOP for userspace emulators Peter Maydell
2021-05-10 12:25 ` [PULL 18/26] hw/sd/omap_mmc: Use device_cold_reset() instead of device_legacy_reset() Peter Maydell
2021-05-10 12:25 ` [PULL 19/26] osdep: Make os-win32.h and os-posix.h handle 'extern "C"' themselves Peter Maydell
2021-05-10 12:25 ` [PULL 20/26] include/qemu/bswap.h: Handle being included outside extern "C" block Peter Maydell
2021-05-10 12:25 ` [PULL 21/26] include/disas/dis-asm.h: Handle being included outside 'extern "C"' Peter Maydell
2021-05-10 12:25 ` [PULL 22/26] hw/arm/imx25_pdk: Fix error message for invalid RAM size Peter Maydell
2021-05-10 12:25 ` [PULL 23/26] hw/misc/mps2-scc: Add "QEMU interface" comment Peter Maydell
2021-05-10 12:25 ` Peter Maydell [this message]
2021-05-10 12:25 ` [PULL 25/26] hw/arm/mps2-tz: Implement AN524 memory remapping via machine property Peter Maydell
2021-05-10 12:25 ` [PULL 26/26] hw/arm/xlnx: Fix PHY address for xilinx-zynq-a9 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210510122548.28638-25-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).