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>,
	"Kane Chen" <kane_chen@aspeedtech.com>,
	"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 v7 05/11] hw/arm/ast27x0: Add DRAM alias for TSP SDRAM remap
Date: Tue, 24 Nov 2026 05:51:56 +0000	[thread overview]
Message-ID: <20261124055150.1328856-6-jamin_lin@aspeedtech.com> (raw)
In-Reply-To: <20261124055150.1328856-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. The pointer is exposed as the
SCU's "tsp-remap" link property and is wired up by the board once the
TSP is realized, so the TSP does not need to reach into the shared SCU.

The TSP cpu_index is only known once the TSP's armv7m core is
realized, so the board also sets it in the SCU at that point. Its
"not wired up" default of -1 is set in the SCU's instance_init().

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   |  7 +++++++
 hw/arm/aspeed_ast27x0-tsp.c  | 17 +++++++++++++++++
 hw/misc/aspeed_scu.c         |  4 ++++
 4 files changed, 30 insertions(+)

diff --git a/include/hw/misc/aspeed_scu.h b/include/hw/misc/aspeed_scu.h
index d4a5fa43d0..4ad3bb2308 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 2ad1ad39f3..0da9608933 100644
--- a/hw/arm/aspeed_ast27x0-fc.c
+++ b/hw/arm/aspeed_ast27x0-fc.c
@@ -196,6 +196,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",
@@ -206,6 +208,11 @@ static bool ast2700fc_tsp_init(Ast2700FCState *s, AspeedSoCState *psp,
         return false;
     }
 
+    /* The remap alias and cpu_index only exist once the TSP is realized. */
+    object_property_set_link(OBJECT(&s->ca35.scu), "tsp-remap",
+                             OBJECT(&s->tsp.dram_remap[0]), &error_abort);
+    s->ca35.scu.tsp_cpuid = CPU(s->tsp.armv7m.cpu)->cpu_index;
+
     return true;
 }
 
diff --git a/hw/arm/aspeed_ast27x0-tsp.c b/hw/arm/aspeed_ast27x0-tsp.c
index 7348834458..a67823fc47 100644
--- a/hw/arm/aspeed_ast27x0-tsp.c
+++ b/hw/arm/aspeed_ast27x0-tsp.c
@@ -181,6 +181,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);
@@ -229,6 +235,15 @@ 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]);
+
     /* INTC */
     if (!sysbus_realize(SYS_BUS_DEVICE(&a->intc[0]), errp)) {
         return;
@@ -298,6 +313,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 1568b74964..f31545a126 100644
--- a/hw/misc/aspeed_scu.c
+++ b/hw/misc/aspeed_scu.c
@@ -952,6 +952,7 @@ static void aspeed_2700_scu_instance_init(Object *obj)
     Aspeed2700SCUState *a = ASPEED_2700_SCU(obj);
 
     a->ssp_cpuid = -1;
+    a->tsp_cpuid = -1;
 
     object_property_add_link(obj, "ssp-remap0", TYPE_MEMORY_REGION,
                              (Object **)&a->ssp_remap[0],
@@ -959,6 +960,9 @@ static void aspeed_2700_scu_instance_init(Object *obj)
     object_property_add_link(obj, "ssp-remap1", TYPE_MEMORY_REGION,
                              (Object **)&a->ssp_remap[1],
                              object_property_allow_set_link, 0);
+    object_property_add_link(obj, "tsp-remap", TYPE_MEMORY_REGION,
+                             (Object **)&a->tsp_remap,
+                             object_property_allow_set_link, 0);
 }
 
 static void aspeed_2700_scu_class_init(ObjectClass *klass, const void *data)
-- 
2.53.0


  parent reply	other threads:[~2026-11-24  5:57 UTC|newest]

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

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=20261124055150.1328856-6-jamin_lin@aspeedtech.com \
    --to=jamin_lin@aspeedtech.com \
    --cc=clg@kaod.org \
    --cc=kane_chen@aspeedtech.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=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.