All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jamin Lin <jamin_lin@aspeedtech.com>
To: "Cédric Le Goater" <clg@kaod.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Steven Lee" <steven_lee@aspeedtech.com>,
	"Troy Lee" <leetroy@gmail.com>,
	"Kane Chen" <kane_chen@aspeedtech.com>,
	"Andrew Jeffery" <andrew@codeconstruct.com.au>,
	"Joel Stanley" <joel@jms.id.au>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"open list:ASPEED BMCs" <qemu-arm@nongnu.org>,
	"open list:All patches CC here" <qemu-devel@nongnu.org>
Cc: "Jamin Lin" <jamin_lin@aspeedtech.com>,
	"Troy Lee" <troy_lee@aspeedtech.com>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
Subject: [PATCH v6 05/11] hw/arm/ast27x0: Add DRAM alias for TSP SDRAM remap
Date: Thu, 23 Jul 2026 02:23:07 +0000	[thread overview]
Message-ID: <20260723022300.4174471-6-jamin_lin@aspeedtech.com> (raw)
In-Reply-To: <20260723022300.4174471-1-jamin_lin@aspeedtech.com>

This commit adds a MemoryRegion alias to support PSP access to
TSP SDRAM through shared memory remapping.

The TSP coprocessor exposes one DRAM alias:
- remap maps PSP DRAM at 0x42E000000 to TSP SDRAM offset 0x0

These mappings follow the default SCU register configuration used by
the ASPEED SDK firmware, which defines the memory window mapping
between PSP and TSP.

The alias MemoryRegion belongs to the TSP coprocessor state itself
(Aspeed27x0CoprocessorState), mirroring the SSP remap; the SCU only
holds a pointer to it (tsp_remap) so its control registers can
reposition/resize the alias at runtime. This can't be a QOM link
property since the SCU is already realized by the time the TSP sets
it, so the pointer is written in directly.

The TSP cpu_index is only known once the TSP's armv7m core is
realized, so it is written directly into the shared SCU at that
point. Its "not wired up" default of -1 is now set explicitly in the
SCU's own realize(), since nothing else sets it via a QOM property
anymore.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Tested-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 include/hw/misc/aspeed_scu.h |  2 ++
 hw/arm/aspeed_ast27x0-fc.c   |  2 ++
 hw/arm/aspeed_ast27x0-tsp.c  | 30 ++++++++++++++++++++++++++++++
 hw/misc/aspeed_scu.c         |  1 +
 4 files changed, 35 insertions(+)

diff --git a/include/hw/misc/aspeed_scu.h b/include/hw/misc/aspeed_scu.h
index 01e8854104..aef13e8915 100644
--- a/include/hw/misc/aspeed_scu.h
+++ b/include/hw/misc/aspeed_scu.h
@@ -46,7 +46,9 @@ struct Aspeed2700SCUState {
     AspeedSCUState parent_obj;
 
     MemoryRegion *ssp_remap[2];
+    MemoryRegion *tsp_remap;
     int ssp_cpuid;
+    int tsp_cpuid;
 };
 
 #define AST2400_A1_SILICON_REV   0x02010303U
diff --git a/hw/arm/aspeed_ast27x0-fc.c b/hw/arm/aspeed_ast27x0-fc.c
index af700e748f..e51d8024eb 100644
--- a/hw/arm/aspeed_ast27x0-fc.c
+++ b/hw/arm/aspeed_ast27x0-fc.c
@@ -191,6 +191,8 @@ static bool ast2700fc_tsp_init(Ast2700FCState *s, AspeedSoCState *psp,
                             &error_abort);
     object_property_set_link(OBJECT(&s->tsp), "sram",
                              OBJECT(&psp->sram), &error_abort);
+    object_property_set_link(OBJECT(&s->tsp), "dram",
+                             OBJECT(psp->dram_mr), &error_abort);
     object_property_set_link(OBJECT(&s->tsp), "scu",
                              OBJECT(&s->ca35.scu), &error_abort);
     object_property_set_link(OBJECT(&s->tsp), "scuio",
diff --git a/hw/arm/aspeed_ast27x0-tsp.c b/hw/arm/aspeed_ast27x0-tsp.c
index 4212e7bd4c..9a860f6ea3 100644
--- a/hw/arm/aspeed_ast27x0-tsp.c
+++ b/hw/arm/aspeed_ast27x0-tsp.c
@@ -184,6 +184,12 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)
         return;
     }
 
+    if (!a->dram) {
+        error_setg(errp, TYPE_ASPEED27X0TSP_COPROCESSOR
+                   ": 'dram' link is not set");
+        return;
+    }
+
     /* AST27X0 TSP Core */
     armv7m = DEVICE(&a->armv7m);
     qdev_prop_set_uint32(armv7m, "num-irq", 256);
@@ -201,6 +207,12 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)
                              &error_abort);
     sysbus_realize(SYS_BUS_DEVICE(&a->armv7m), &error_abort);
 
+    /*
+     * cpu_index is only known once the armv7m core above is realized;
+     * write it directly into the shared SCU.
+     */
+    a->scu->tsp_cpuid = CPU(a->armv7m.cpu)->cpu_index;
+
     /* SDRAM */
     sdram_name = g_strdup_printf("aspeed.sdram.%d",
                                  CPU(a->armv7m.cpu)->cpu_index);
@@ -232,6 +244,22 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)
     memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_SCUIO],
                                 &a->scuio_alias);
 
+    /*
+     * DRAM remap alias used by PSP to access TSP SDRAM:
+     * - remap maps PSP DRAM at 0x42E000000 (size: 32MB) to TSP SDRAM
+     *   offset 0x0
+     */
+    memory_region_init_alias(&a->dram_remap[0], OBJECT(a), "tsp.dram.remap",
+                             a->dram, 0x2e000000, 32 * MiB);
+    memory_region_add_subregion(&s->sdram, 0, &a->dram_remap[0]);
+
+    /*
+     * The SCU is already realized at this point (it belongs to the PSP,
+     * which is realized before the TSP), so the remap is linked in
+     * directly instead of via a QOM property.
+     */
+    a->scu->tsp_remap = &a->dram_remap[0];
+
     /* INTC */
     if (!sysbus_realize(SYS_BUS_DEVICE(&a->intc[0]), errp)) {
         return;
@@ -317,6 +345,8 @@ static const Property aspeed_27x0_coprocessor_properties[] = {
                      TYPE_ASPEED_SCU, AspeedSCUState *),
     DEFINE_PROP_LINK("fmc", Aspeed27x0CoprocessorState, fmc, TYPE_ASPEED_SMC,
                      AspeedSMCState *),
+    DEFINE_PROP_LINK("dram", Aspeed27x0CoprocessorState, dram,
+                     TYPE_MEMORY_REGION, MemoryRegion *),
 };
 
 static void aspeed_soc_ast27x0tsp_class_init(ObjectClass *klass,
diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c
index 4025ea3205..5d34dbea5e 100644
--- a/hw/misc/aspeed_scu.c
+++ b/hw/misc/aspeed_scu.c
@@ -935,6 +935,7 @@ static void aspeed_2700_scu_realize(DeviceState *dev, Error **errp)
     Aspeed2700SCUState *a = ASPEED_2700_SCU(dev);
 
     a->ssp_cpuid = -1;
+    a->tsp_cpuid = -1;
     aspeed_scu_realize(dev, errp);
 }
 
-- 
2.43.0


  parent reply	other threads:[~2026-07-23  2:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  2:23 [PATCH v6 00/11] Add SSP/TSP power control and DRAM remap support for AST2700 Jamin Lin
2026-07-23  2:23 ` [PATCH v6 01/11] hw/arm/aspeed_ast1700: Correct AST2700 SCU to SCUIO Jamin Lin
2026-07-23  2:23 ` [PATCH v6 02/11] hw/arm/ast27x0: Start SSP in powered-off state to match hardware behavior Jamin Lin
2026-07-23  2:23 ` [PATCH v6 03/11] hw/arm/ast27x0: Start TSP " Jamin Lin
2026-07-23  2:23 ` [PATCH v6 04/11] hw/arm/ast27x0: Add DRAM alias for SSP SDRAM remap Jamin Lin
2026-07-23  2:23 ` Jamin Lin [this message]
2026-07-23  2:23 ` [PATCH v6 06/11] hw/misc/aspeed_scu: Implement SSP reset and power-on control via SCU registers Jamin Lin
2026-07-23  2:23 ` [PATCH v6 07/11] hw/misc/aspeed_scu: Implement TSP " Jamin Lin
2026-07-23  2:23 ` [PATCH v6 08/11] hw/misc/aspeed_scu: Add SCU support for SSP SDRAM remap Jamin Lin
2026-07-23  2:23 ` [PATCH v6 09/11] hw/misc/aspeed_scu: Add SCU support for TSP " Jamin Lin
2026-07-23  2:23 ` [PATCH v6 10/11] tests/functional/aarch64/test_aspeed_ast2700fc: Boot SSP/TSP via PSP and load binaries from DRAM Jamin Lin
2026-07-23  2:23 ` [PATCH v6 11/11] docs: Add support vbootrom and update Manual boot for ast2700fc Jamin Lin

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=20260723022300.4174471-6-jamin_lin@aspeedtech.com \
    --to=jamin_lin@aspeedtech.com \
    --cc=andrew@codeconstruct.com.au \
    --cc=clg@kaod.org \
    --cc=joel@jms.id.au \
    --cc=kane_chen@aspeedtech.com \
    --cc=leetroy@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=steven_lee@aspeedtech.com \
    --cc=troy_lee@aspeedtech.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.