Refactor AST2700 SCU preparation for coprocessors
PATCH v2 1/8 hw/misc/aspeed_scu: Introduce Aspeed2700SCUState
In reply to Jamin LinIntroduce Aspeed2700SCUState as an AST2700-specific subclass of AspeedSCUState.
Currently, AST1700 and AST2700 reuse the generic AspeedSCUState. However, AST2700 requires SCU functionality that is specific to the platform, particularly for interactions with its coprocessors.
Introduce a dedicated Aspeed2700SCUState to provide an extension point for AST2700-specific functionality while keeping the generic AspeedSCUState unchanged.
Subsequent patches will migrate AST2700 users to the new subclass and move AST2700-specific code into it.
No functional change.
--- include/hw/misc/aspeed_scu.h | 5 +++++ hw/misc/aspeed_scu.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-)
include/hw/misc/aspeed_scu.h +5 -0
@@ -20,6 +20,7 @@ OBJECT_DECLARE_TYPE(AspeedSCUState, AspeedSCUClass, ASPEED_SCU)#define TYPE_ASPEED_2500_SCU TYPE_ASPEED_SCU "-ast2500"#define TYPE_ASPEED_2600_SCU TYPE_ASPEED_SCU "-ast2600"#define TYPE_ASPEED_2700_SCU TYPE_ASPEED_SCU "-ast2700" +OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2700SCUState, ASPEED_2700_SCU)#define TYPE_ASPEED_2700_SCUIO TYPE_ASPEED_SCU "io" "-ast2700"#define TYPE_ASPEED_1030_SCU TYPE_ASPEED_SCU "-ast1030"
@@ -41,6 +42,10 @@ struct AspeedSCUState {uint32_t hw_prot_key; }; +struct Aspeed2700SCUState { +AspeedSCUState parent_obj; +}; +#define AST2400_A1_SILICON_REV 0x02010303U#define AST2500_A1_SILICON_REV 0x04010303U#define AST2600_A3_SILICON_REV 0x05030303U
hw/misc/aspeed_scu.c +7 -1
@@ -930,6 +930,11 @@ static void aspeed_ast2700_scu_reset_hold(Object *obj, ResetType type) s->regs[AST2700_HW_STRAP1 ] = s->hw_strap1; } +static void aspeed_2700_scu_realize (DeviceState *dev,Error **errp) +{ +aspeed_scu_realize (dev, errp); +} +static void aspeed_2700_scu_class_init (ObjectClass *klass,const void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -937,6 +942,7 @@ static void aspeed_2700_scu_class_init(ObjectClass *klass, const void *data)AspeedSCUClass *asc =ASPEED_SCU_CLASS (klass); dc->desc ="ASPEED 2700 System Control Unit" ; + dc->realize = aspeed_2700_scu_realize; rc->phases.hold = aspeed_ast2700_scu_reset_hold; asc->resets = ast2700_a0_resets; asc->calc_hpll = aspeed_2600_scu_calc_hpll;
@@ -1161,7 +1167,7 @@ static const TypeInfo aspeed_scu_types[] = { { .name = TYPE_ASPEED_2700_SCU, .parent = TYPE_ASPEED_SCU, - .instance_size = sizeof(AspeedSCUState), + .instance_size = sizeof(Aspeed2700SCUState), .class_init = aspeed_2700_scu_class_init, }, {
Signature · 1 line
2.43.0
PATCH v2 6/8 hw/arm/ast27x0: Share single SCUIO instance across PSP, SSP, and TSP
In reply to Jamin LinAST2700 has a single SCUIO hardware block, memory-mapped at 0x14C02000–0x14C03FFF from the perspective of the main CA35 processor (PSP). The SSP and TSP coprocessors access this same SCUIO block at different
addresses: 0x74C02000–0x74C03FFF.
Previously, each subsystem (PSP, SSP, and TSP) instantiated its own SCUIO device, resulting in three independent SCUIO instances in the QEMU model. In real hardware, however, only a single SCUIO exists and is shared among all processors.
This commit reworks the SCUIO model to correctly reflect the hardware behavior by allowing SSP and TSP to reference the PSP’s SCUIO instance. The following changes are introduced:
- Add a scuio property to Aspeed27x0CoprocessorState for linking the coprocessor to the PSP’s SCUIO instance.
- Replace per-coprocessor SCUIO instantiation with a shared SCUIO link.
- Add "MemoryRegion scuio_alias" to model address remapping for SSP and TSP.
- Create SCUIO alias regions in both SSP and TSP coprocessors and map them at 0x74C02000 to mirror the PSP’s SCUIO registers.
- Ensure the SCUIO device in PSP is realized before SSP/TSP alias setup.
With this change, PSP, SSP, and TSP now share a consistent SCUIO state, matching the single-SCUIO hardware design of AST2700.
--- include/hw/arm/aspeed_coprocessor.h | 4 ++-- hw/arm/aspeed_ast27x0-fc.c | 4 ++++ hw/arm/aspeed_ast27x0-ssp.c | 20 +++++++++++++++----- hw/arm/aspeed_ast27x0-tsp.c | 20 +++++++++++++++----- 4 files changed, 36 insertions(+), 12 deletions(-)
include/hw/arm/aspeed_coprocessor.h +2 -2
@@ -22,7 +22,6 @@ struct AspeedCoprocessorState {MemoryRegion uart_alias;Clock *sysclk; -AspeedSCUState scuio;AspeedTimerCtrlState timerctrl;SerialMM *uart;int uart_dev;
@@ -45,14 +44,15 @@ struct Aspeed27x0CoprocessorState {AspeedCoprocessorState parent;AspeedINTCState intc[2 ];UnimplementedDeviceState ipc[2 ]; -UnimplementedDeviceState scuio;UnimplementedDeviceState pric[2 ];UnimplementedDeviceState otp;ARMv7MState armv7m;MemoryRegion scu_alias; +MemoryRegion scuio_alias;Aspeed2700SCUState *scu; +AspeedSCUState *scuio; };#define TYPE_ASPEED27X0SSP_COPROCESSOR "aspeed27x0ssp-coprocessor"
hw/arm/aspeed_ast27x0-fc.c +4 -0
@@ -157,6 +157,8 @@ static bool ast2700fc_ssp_init(Ast2700FCState *s, AspeedSoCState *psp, OBJECT(&psp->sram), &error_abort);object_property_set_link (OBJECT (&s->ssp),"scu" ,OBJECT (&s->ca35.scu), &error_abort); +object_property_set_link (OBJECT (&s->ssp),"scuio" , +OBJECT (&psp->scuio), &error_abort);if (!qdev_realize (DEVICE (&s->ssp),NULL , errp)) {return false; }
@@ -187,6 +189,8 @@ static bool ast2700fc_tsp_init(Ast2700FCState *s, AspeedSoCState *psp, OBJECT(&psp->sram), &error_abort);object_property_set_link (OBJECT (&s->tsp),"scu" ,OBJECT (&s->ca35.scu), &error_abort); +object_property_set_link (OBJECT (&s->tsp),"scuio" , +OBJECT (&psp->scuio), &error_abort);if (!qdev_realize (DEVICE (&s->tsp),NULL , errp)) {return false; }
hw/arm/aspeed_ast27x0-ssp.c +15 -5
@@ -142,8 +142,6 @@ static void aspeed_soc_ast27x0ssp_init(Object *obj) TYPE_UNIMPLEMENTED_DEVICE);object_initialize_child (obj,"ipc1" , &a->ipc[1 ],TYPE_UNIMPLEMENTED_DEVICE ); -object_initialize_child (obj,"scuio" , &a->scuio, -TYPE_UNIMPLEMENTED_DEVICE );object_initialize_child (obj,"pric0" , &a->pric[0 ],TYPE_UNIMPLEMENTED_DEVICE ); object_initialize_child(obj, "pric1", &a->pric[1],
@@ -173,6 +171,12 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)return ; } +if (!a->scuio) { +error_setg (errp,TYPE_ASPEED27X0SSP_COPROCESSOR +": 'scuio' link is not set" ); +return ; + } +/* AST27X0 SSP Core */ armv7m =DEVICE (&a->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,256 );
@@ -207,6 +211,13 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_SCU ], &a->scu_alias); +/* SCUIO */ +memory_region_init_alias (&a->scuio_alias,OBJECT (a),"scuio.alias" , + &a->scuio->iomem,0 , +memory_region_size (&a->scuio->iomem)); +memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_SCUIO ], + &a->scuio_alias); +/* INTC */ if (!sysbus_realize (SYS_BUS_DEVICE (&a->intc[0 ]), errp)) {return ;
@@ -267,9 +278,6 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)aspeed_mmio_map_unimplemented (s->memory,SYS_BUS_DEVICE (&a->ipc[1 ]),"aspeed.ipc1" , sc->memmap[ASPEED_DEV_IPC1 ],0x1000 ); -aspeed_mmio_map_unimplemented (s->memory,SYS_BUS_DEVICE (&a->scuio), -"aspeed.scuio" , - sc->memmap[ASPEED_DEV_SCUIO ],0x1000 );aspeed_mmio_map_unimplemented (s->memory,SYS_BUS_DEVICE (&a->pric[0 ]),"aspeed.pric0" , sc->memmap[ASPEED_DEV_PRIC0 ],0x1000 );
@@ -284,6 +292,8 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)static const Property aspeed_27x0_coprocessor_properties[] = {DEFINE_PROP_LINK ("scu" , Aspeed27x0CoprocessorState, scu, TYPE_ASPEED_2700_SCU, Aspeed2700SCUState *), +DEFINE_PROP_LINK ("scuio" , Aspeed27x0CoprocessorState, scuio, + TYPE_ASPEED_SCU, AspeedSCUState *), }; static void aspeed_soc_ast27x0ssp_class_init(ObjectClass *klass,
hw/arm/aspeed_ast27x0-tsp.c +15 -5
@@ -142,8 +142,6 @@ static void aspeed_soc_ast27x0tsp_init(Object *obj) TYPE_UNIMPLEMENTED_DEVICE);object_initialize_child (obj,"ipc1" , &a->ipc[1 ],TYPE_UNIMPLEMENTED_DEVICE ); -object_initialize_child (obj,"scuio" , &a->scuio, -TYPE_UNIMPLEMENTED_DEVICE );object_initialize_child (obj,"pric0" , &a->pric[0 ],TYPE_UNIMPLEMENTED_DEVICE ); object_initialize_child(obj, "pric1", &a->pric[1],
@@ -173,6 +171,12 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)return ; } +if (!a->scuio) { +error_setg (errp,TYPE_ASPEED27X0TSP_COPROCESSOR +": 'scuio' link is not set" ); +return ; + } +/* AST27X0 TSP Core */ armv7m =DEVICE (&a->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,256 );
@@ -207,6 +211,13 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_SCU ], &a->scu_alias); +/* SCUIO */ +memory_region_init_alias (&a->scuio_alias,OBJECT (a),"scuio.alias" , + &a->scuio->iomem,0 , +memory_region_size (&a->scuio->iomem)); +memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_SCUIO ], + &a->scuio_alias); +/* INTC */ if (!sysbus_realize (SYS_BUS_DEVICE (&a->intc[0 ]), errp)) {return ;
@@ -267,9 +278,6 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)aspeed_mmio_map_unimplemented (s->memory,SYS_BUS_DEVICE (&a->ipc[1 ]),"aspeed.ipc1" , sc->memmap[ASPEED_DEV_IPC1 ],0x1000 ); -aspeed_mmio_map_unimplemented (s->memory,SYS_BUS_DEVICE (&a->scuio), -"aspeed.scuio" , - sc->memmap[ASPEED_DEV_SCUIO ],0x1000 );aspeed_mmio_map_unimplemented (s->memory,SYS_BUS_DEVICE (&a->pric[0 ]),"aspeed.pric0" , sc->memmap[ASPEED_DEV_PRIC0 ],0x1000 );
@@ -284,6 +292,8 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)static const Property aspeed_27x0_coprocessor_properties[] = {DEFINE_PROP_LINK ("scu" , Aspeed27x0CoprocessorState, scu, TYPE_ASPEED_2700_SCU, Aspeed2700SCUState *), +DEFINE_PROP_LINK ("scuio" , Aspeed27x0CoprocessorState, scuio, + TYPE_ASPEED_SCU, AspeedSCUState *), }; static void aspeed_soc_ast27x0tsp_class_init(ObjectClass *klass,
Signature · 1 line
2.43.0
v2 cover Refactor AST2700 SCU preparation for coprocessors
The original AST2700 FC support series [1] is fairly large, making it difficult to review all changes together.
To help speed up the review process, this series extracts the SCU/FMC-related refactoring into a standalone prerequisite series.
v1:
Compared with the original series, the SCU preparation patch has been split into three smaller patches:
Introduce Aspeed2700SCUState.
Convert AST1700/AST27x0 users to the new SCU subclass. Move the SCU link property into the AST27x0-specific coprocessor implementation.
In addition, the SCUIO reset handling has been separated into an independent patch.
This series contains no functional changes. It is purely a refactoring to isolate AST2700-specific SCU support from the generic implementation and prepare for the subsequent AST2700 FC support.
v2:
1. Pass realized PSP SoC to SSP/TSP initialization
2. Share single SCUIO instance across PSP, SSP, and TSP
3. Share FMC controller with SSP and TSP
4. Add Data FIFO-based flash access support for
This series depends on:
https://patchwork.ozlabs.org/project/qemu-devel/cover/[email protected]/
Supersedes the following patches from the original FC support series [1]:
Patch 1:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/
Patch 2:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/
Patch 4:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/
Patch 15:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/
Patch 18:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/
Patch
[1] Original AST2700 FC support series:
https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/
Jamin Lin (8):
hw/misc/aspeed_scu: Introduce Aspeed2700SCUState hw/arm/aspeed: Use Aspeed2700SCUState for AST2700 users hw/arm/aspeed_ast27x0: Move SCU link into AST27x0 coprocessors hw/misc/aspeed_scu: Add separate reset handler for AST2700 SCUIO hw/arm/aspeed_ast27x0: Pass realized PSP SoC to SSP/TSP initialization hw/arm/ast27x0: Share single SCUIO instance across PSP, SSP, and TSP hw/arm/ast27x0: Share FMC controller with SSP and TSP hw/ssi/aspeed_smc: Add Data FIFO-based flash access support for
AST2700
include/hw/arm/aspeed_ast1700.h | 2 +- include/hw/arm/aspeed_coprocessor.h | 11 ++- include/hw/arm/aspeed_soc.h | 1 + include/hw/misc/aspeed_scu.h | 5 ++ include/hw/ssi/aspeed_smc.h | 3 +- hw/arm/aspeed_ast27x0-fc.c | 38 +++++++--- hw/arm/aspeed_ast27x0-ssp.c | 56 +++++++++++--- hw/arm/aspeed_ast27x0-tsp.c | 56 +++++++++++--- hw/arm/aspeed_ast27x0.c | 16 ++-- hw/arm/aspeed_coprocessor_common.c | 2 - hw/misc/aspeed_scu.c | 20 ++++- hw/ssi/aspeed_smc.c | 113 ++++++++++++++++++++++++++-- 12 files changed, 267 insertions(+), 56 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 3/8 hw/arm/aspeed_ast27x0: Move SCU link into AST27x0 coprocessors
The SCU link is only needed by the AST27x0 SSP/TSP coprocessors for their AST2700-specific SCU alias window.
Move the link property from the common AspeedCoprocessorState into Aspeed27x0CoprocessorState, so the generic coprocessor model no longer contains an AST2700-specific dependency.
Also validate that the SCU link has been provided during device realize before accessing it.
No functional change.
--- include/hw/arm/aspeed_coprocessor.h | 5 +++-- hw/arm/aspeed_ast27x0-ssp.c | 20 ++++++++++++++++---- hw/arm/aspeed_ast27x0-tsp.c | 20 ++++++++++++++++---- hw/arm/aspeed_coprocessor_common.c | 2 -- 4 files changed, 35 insertions(+), 12 deletions(-)
include/hw/arm/aspeed_coprocessor.h +3 -2
@@ -20,10 +20,8 @@ struct AspeedCoprocessorState {MemoryRegion *sram;MemoryRegion sram_alias;MemoryRegion uart_alias; -MemoryRegion scu_alias;Clock *sysclk; -AspeedSCUState *scu;AspeedSCUState scuio;AspeedTimerCtrlState timerctrl;SerialMM *uart;
@@ -52,6 +50,9 @@ struct Aspeed27x0CoprocessorState {UnimplementedDeviceState otp;ARMv7MState armv7m; + +MemoryRegion scu_alias; +Aspeed2700SCUState *scu; };#define TYPE_ASPEED27X0SSP_COPROCESSOR "aspeed27x0ssp-coprocessor"
hw/arm/aspeed_ast27x0-ssp.c +16 -4
@@ -167,6 +167,12 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)return ; } +if (!a->scu) { +error_setg (errp,TYPE_ASPEED27X0SSP_COPROCESSOR +": 'scu' link is not set" ); +return ; + } +/* AST27X0 SSP Core */ armv7m =DEVICE (&a->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,256 );
@@ -195,11 +201,11 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp) &s->sram_alias);/* SCU */ -memory_region_init_alias (&s->scu_alias,OBJECT (s),"scu.alias" , - &s->scu->iomem,0 , -memory_region_size (&s->scu->iomem)); +memory_region_init_alias (&a->scu_alias,OBJECT (a),"scu.alias" , + &a->scu->parent_obj.iomem,0 , +memory_region_size (&a->scu->parent_obj.iomem));memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_SCU ], - &s->scu_alias); + &a->scu_alias);/* INTC */ if (!sysbus_realize (SYS_BUS_DEVICE (&a->intc[0 ]), errp)) {
@@ -275,6 +281,11 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp) sc->memmap[ASPEED_DEV_OTP], 0x800); } +static const Property aspeed_27x0_coprocessor_properties[] = { +DEFINE_PROP_LINK ("scu" , Aspeed27x0CoprocessorState, scu, + TYPE_ASPEED_2700_SCU, Aspeed2700SCUState *), +}; +static void aspeed_soc_ast27x0ssp_class_init (ObjectClass *klass,const void *data) {
@@ -288,6 +299,7 @@ static void aspeed_soc_ast27x0ssp_class_init(ObjectClass *klass,/* Reason: The Aspeed Coprocessor can only be instantiated from a board */ dc->user_creatable = false; dc->realize = aspeed_soc_ast27x0ssp_realize; +device_class_set_props (dc, aspeed_27x0_coprocessor_properties); sc->valid_cpu_types = valid_cpu_types; sc->irqmap = aspeed_soc_ast27x0ssp_irqmap;
hw/arm/aspeed_ast27x0-tsp.c +16 -4
@@ -167,6 +167,12 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)return ; } +if (!a->scu) { +error_setg (errp,TYPE_ASPEED27X0TSP_COPROCESSOR +": 'scu' link is not set" ); +return ; + } +/* AST27X0 TSP Core */ armv7m =DEVICE (&a->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,256 );
@@ -195,11 +201,11 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp) &s->sram_alias);/* SCU */ -memory_region_init_alias (&s->scu_alias,OBJECT (s),"scu.alias" , - &s->scu->iomem,0 , -memory_region_size (&s->scu->iomem)); +memory_region_init_alias (&a->scu_alias,OBJECT (a),"scu.alias" , + &a->scu->parent_obj.iomem,0 , +memory_region_size (&a->scu->parent_obj.iomem));memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_SCU ], - &s->scu_alias); + &a->scu_alias);/* INTC */ if (!sysbus_realize (SYS_BUS_DEVICE (&a->intc[0 ]), errp)) {
@@ -275,6 +281,11 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp) sc->memmap[ASPEED_DEV_OTP], 0x800); } +static const Property aspeed_27x0_coprocessor_properties[] = { +DEFINE_PROP_LINK ("scu" , Aspeed27x0CoprocessorState, scu, + TYPE_ASPEED_2700_SCU, Aspeed2700SCUState *), +}; +static void aspeed_soc_ast27x0tsp_class_init (ObjectClass *klass,const void *data) {
@@ -288,6 +299,7 @@ static void aspeed_soc_ast27x0tsp_class_init(ObjectClass *klass,/* Reason: The Aspeed Coprocessor can only be instantiated from a board */ dc->user_creatable = false; dc->realize = aspeed_soc_ast27x0tsp_realize; +device_class_set_props (dc, aspeed_27x0_coprocessor_properties); sc->valid_cpu_types = valid_cpu_types; sc->irqmap = aspeed_soc_ast27x0tsp_irqmap;
hw/arm/aspeed_coprocessor_common.c +0 -2
@@ -27,8 +27,6 @@ static const Property aspeed_coprocessor_properties[] = { TYPE_MEMORY_REGION, MemoryRegion *),DEFINE_PROP_LINK ("sram" , AspeedCoprocessorState, sram,TYPE_MEMORY_REGION , MemoryRegion *), -DEFINE_PROP_LINK ("scu" , AspeedCoprocessorState, scu,TYPE_ASPEED_SCU , - AspeedSCUState *),DEFINE_PROP_LINK ("uart" , AspeedCoprocessorState, uart,TYPE_SERIAL_MM , SerialMM *), DEFINE_PROP_INT32("uart-dev", AspeedCoprocessorState, uart_dev, 0),
Signature · 1 line
2.43.0
PATCH v2 7/8 hw/arm/ast27x0: Share FMC controller with SSP and TSP
In reply to Jamin LinAST2700 provides a single FMC controller shared by the main CA35 processor (PSP) and the SSP/TSP coprocessors.
From the PSP perspective, the FMC controller is memory-mapped at 0x14000000–0x140000FF. The SSP and TSP access the same controller through a different address window at 0x74000000–0x740000FF.
This change allows the SSP and TSP SoC models to reference the existing PSP FMC instance instead of creating independent controllers. An MMIO alias is added in the SSP and TSP address spaces to map their FMC access window to the shared FMC device.
This ensures consistent FMC state across PSP, SSP, and TSP and matches the AST2700 hardware design.
--- include/hw/arm/aspeed_coprocessor.h | 2 ++ hw/arm/aspeed_ast27x0-fc.c | 4 ++++ hw/arm/aspeed_ast27x0-ssp.c | 16 ++++++++++++++++ hw/arm/aspeed_ast27x0-tsp.c | 16 ++++++++++++++++ 4 files changed, 38 insertions(+)
include/hw/arm/aspeed_coprocessor.h +2 -0
@@ -51,8 +51,10 @@ struct Aspeed27x0CoprocessorState {MemoryRegion scu_alias;MemoryRegion scuio_alias; +MemoryRegion fmc_alias;Aspeed2700SCUState *scu;AspeedSCUState *scuio; +AspeedSMCState *fmc; };#define TYPE_ASPEED27X0SSP_COPROCESSOR "aspeed27x0ssp-coprocessor"
hw/arm/aspeed_ast27x0-fc.c +4 -0
@@ -159,6 +159,8 @@ static bool ast2700fc_ssp_init(Ast2700FCState *s, AspeedSoCState *psp, OBJECT(&s->ca35.scu), &error_abort);object_property_set_link (OBJECT (&s->ssp),"scuio" ,OBJECT (&psp->scuio), &error_abort); +object_property_set_link (OBJECT (&s->ssp),"fmc" , +OBJECT (&psp->fmc), &error_abort);if (!qdev_realize (DEVICE (&s->ssp),NULL , errp)) {return false; }
@@ -191,6 +193,8 @@ static bool ast2700fc_tsp_init(Ast2700FCState *s, AspeedSoCState *psp, OBJECT(&s->ca35.scu), &error_abort);object_property_set_link (OBJECT (&s->tsp),"scuio" ,OBJECT (&psp->scuio), &error_abort); +object_property_set_link (OBJECT (&s->tsp),"fmc" , +OBJECT (&psp->fmc), &error_abort);if (!qdev_realize (DEVICE (&s->tsp),NULL , errp)) {return false; }
hw/arm/aspeed_ast27x0-ssp.c +16 -0
@@ -27,6 +27,7 @@ static const hwaddr aspeed_soc_ast27x0ssp_memmap[] = { [ASPEED_DEV_TIMER1] = 0x72C10000, [ASPEED_DEV_UART4] = 0x72C1A000, [ASPEED_DEV_IPC0] = 0x72C1C000, + [ASPEED_DEV_FMC] = 0x74000000, [ASPEED_DEV_PRIC1] = 0x74100000, [ASPEED_DEV_SCUIO] = 0x74C02000, [ASPEED_DEV_OTP] = 0x74C07000,
@@ -177,6 +178,12 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)return ; } +if (!a->fmc) { +error_setg (errp,TYPE_ASPEED27X0SSP_COPROCESSOR +": 'fmc' link is not set" ); +return ; + } +/* AST27X0 SSP Core */ armv7m =DEVICE (&a->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,256 );
@@ -269,6 +276,13 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (s->uart),0 ,aspeed_soc_ast27x0ssp_get_irq (s, s->uart_dev)); +/* FMC */ +memory_region_init_alias (&a->fmc_alias,OBJECT (a),"fmc.alias" , + &a->fmc->mmio,0 , +memory_region_size (&a->fmc->mmio)); +memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_FMC ], + &a->fmc_alias); +aspeed_mmio_map_unimplemented (s->memory,SYS_BUS_DEVICE (&s->timerctrl),"aspeed.timerctrl" , sc->memmap[ASPEED_DEV_TIMER1 ],0x200 );
@@ -294,6 +308,8 @@ static const Property aspeed_27x0_coprocessor_properties[] = { TYPE_ASPEED_2700_SCU, Aspeed2700SCUState *),DEFINE_PROP_LINK ("scuio" , Aspeed27x0CoprocessorState, scuio, TYPE_ASPEED_SCU, AspeedSCUState *), +DEFINE_PROP_LINK ("fmc" , Aspeed27x0CoprocessorState, fmc,TYPE_ASPEED_SMC , + AspeedSMCState *), }; static void aspeed_soc_ast27x0ssp_class_init(ObjectClass *klass,
hw/arm/aspeed_ast27x0-tsp.c +16 -0
@@ -27,6 +27,7 @@ static const hwaddr aspeed_soc_ast27x0tsp_memmap[] = { [ASPEED_DEV_TIMER1] = 0x72C10000, [ASPEED_DEV_UART4] = 0x72C1A000, [ASPEED_DEV_IPC0] = 0x72C1C000, + [ASPEED_DEV_FMC] = 0x74000000, [ASPEED_DEV_PRIC1] = 0x74100000, [ASPEED_DEV_SCUIO] = 0x74C02000, [ASPEED_DEV_OTP] = 0x74C07000,
@@ -177,6 +178,12 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)return ; } +if (!a->fmc) { +error_setg (errp,TYPE_ASPEED27X0TSP_COPROCESSOR +": 'fmc' link is not set" ); +return ; + } +/* AST27X0 TSP Core */ armv7m =DEVICE (&a->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,256 );
@@ -269,6 +276,13 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (s->uart),0 ,aspeed_soc_ast27x0tsp_get_irq (s, s->uart_dev)); +/* FMC */ +memory_region_init_alias (&a->fmc_alias,OBJECT (a),"fmc.alias" , + &a->fmc->mmio,0 , +memory_region_size (&a->fmc->mmio)); +memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_FMC ], + &a->fmc_alias); +aspeed_mmio_map_unimplemented (s->memory,SYS_BUS_DEVICE (&s->timerctrl),"aspeed.timerctrl" , sc->memmap[ASPEED_DEV_TIMER1 ],0x200 );
@@ -294,6 +308,8 @@ static const Property aspeed_27x0_coprocessor_properties[] = { TYPE_ASPEED_2700_SCU, Aspeed2700SCUState *),DEFINE_PROP_LINK ("scuio" , Aspeed27x0CoprocessorState, scuio, TYPE_ASPEED_SCU, AspeedSCUState *), +DEFINE_PROP_LINK ("fmc" , Aspeed27x0CoprocessorState, fmc,TYPE_ASPEED_SMC , + AspeedSMCState *), }; static void aspeed_soc_ast27x0tsp_class_init(ObjectClass *klass,
Signature · 1 line
2.43.0
PATCH v2 8/8 hw/ssi/aspeed_smc: Add Data FIFO-based flash access support for AST2700
In reply to Jamin LinAST2700 supports a Data FIFO mode where flash accesses can be performed directly through Data FIFO MMIO offsets. The Data FIFO start offset increments by one for every 16MB of flash address space, allowing the chip select (CS) to be decoded from the Data FIFO offset.
This change adds Data FIFO support to the Aspeed SMC model and introduces a class callback to translate Data FIFO offsets into CS indices. For AST2700, the Data FIFO offset is matched against the segment start address of each CS to determine the target flash device.
The SMC register region size (nregs) is also extended dynamically based on the number of supported chip selects to cover all possible Data FIFO regions.
--- include/hw/ssi/aspeed_smc.h | 3 +- hw/ssi/aspeed_smc.c | 113 +++++++++++++++++++++++++++++++++--- 2 files changed, 107 insertions(+), 9 deletions(-)
include/hw/ssi/aspeed_smc.h +2 -1
@@ -47,7 +47,7 @@ struct AspeedSMCFlash {#define TYPE_ASPEED_SMC "aspeed.smc" OBJECT_DECLARE_TYPE(AspeedSMCState, AspeedSMCClass, ASPEED_SMC) -#define ASPEED_SMC_R_MAX (0x100 / 4) +#define ASPEED_SMC_R_MAX (0x300 / 4)#define ASPEED_SMC_CS_MAX 5struct AspeedSMCState {
@@ -116,6 +116,7 @@ struct AspeedSMCClass { AspeedSegments *seg);void (*dma_ctrl)(AspeedSMCState *s,uint32_t value);int (*addr_width)(const AspeedSMCState *s); +int (*data_fifo_offset_to_cs)(const AspeedSMCState *s,uint32_t offset);const MemoryRegionOps *reg_ops; };
hw/ssi/aspeed_smc.c +105 -8
209 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 5/8 hw/arm/aspeed_ast27x0: Pass realized PSP SoC to SSP/TSP initialization
In reply to Jamin LinPass the realized PSP SoC to the SSP/TSP initialization helpers instead of retrieving it from the MachineState.
This makes the dependency explicit, since the SSP and TSP coprocessors use resources owned by the PSP SoC, including the UARTs, SRAM, SCU and SCUIO. The PSP SoC must therefore be realized before the coprocessors are initialized.
No functional change.
--- hw/arm/aspeed_ast27x0-fc.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
hw/arm/aspeed_ast27x0-fc.c +16 -10
@@ -134,11 +134,9 @@ static bool ast2700fc_ca35_init(MachineState *machine, Error **errp)return true; } -static bool ast2700fc_ssp_init (MachineState *machine,Error **errp) +static bool ast2700fc_ssp_init (Ast2700FCState *s,AspeedSoCState *psp, +Error **errp) { -Ast2700FCState *s =AST2700FC (machine); -AspeedSoCState *psp =ASPEED_SOC (&s->ca35); - s->ssp_sysclk =clock_new (OBJECT (s),"SSP_SYSCLK" );clock_set_hz (s->ssp_sysclk,200000000ULL );
@@ -166,11 +164,9 @@ static bool ast2700fc_ssp_init(MachineState *machine, Error **errp)return true; } -static bool ast2700fc_tsp_init (MachineState *machine,Error **errp) +static bool ast2700fc_tsp_init (Ast2700FCState *s,AspeedSoCState *psp, +Error **errp) { -Ast2700FCState *s =AST2700FC (machine); -AspeedSoCState *psp =ASPEED_SOC (&s->ca35); - s->tsp_sysclk =clock_new (OBJECT (s),"TSP_SYSCLK" );clock_set_hz (s->tsp_sysclk,200000000ULL );
@@ -200,9 +196,19 @@ static bool ast2700fc_tsp_init(MachineState *machine, Error **errp)static void ast2700fc_init (MachineState *machine) { +Ast2700FCState *s =AST2700FC (machine); +AspeedSoCState *psp; +ast2700fc_ca35_init (machine, &error_abort); -ast2700fc_ssp_init (machine, &error_abort); -ast2700fc_tsp_init (machine, &error_abort); + +/* +* SSP and TSP use resources owned by the PSP SoC, such as UART, +* SRAM, SCU and SCUIO. Therefore the PSP SoC must be realized +* before the coprocessors are initialized. +*/ + psp =ASPEED_SOC (&s->ca35); +ast2700fc_ssp_init (s, psp, &error_abort); +ast2700fc_tsp_init (s, psp, &error_abort); }static void ast2700fc_class_init (ObjectClass *oc,const void *data)
Signature · 1 line
2.43.0
PATCH v2 4/8 hw/misc/aspeed_scu: Add separate reset handler for AST2700 SCUIO
In reply to Jamin LinIntroduce a dedicated reset handler for SCUIO.
Previously, SCU and SCUIO shared the same reset handler. This no longer fits the AST2700 design, where SCU uses the Aspeed2700SCUState subclass and will handle coprocessor-related control in future changes.
Since these controls are defined in SCU (not SCUIO), SCU and SCUIO should not share the same reset logic.
This change gives SCUIO its own reset handler and prepares for upcoming SCU-specific functionality.
No functional change.
--- hw/misc/aspeed_scu.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
hw/misc/aspeed_scu.c +11 -1
@@ -1069,6 +1069,16 @@ static const uint32_t ast2700_a0_resets_io[ASPEED_AST2700_SCU_NR_REGS] = { [AST2700_SCUIO_FREQ_CNT_CTL] = 0x00000080, }; +static void aspeed_ast2700_scuio_reset_hold (Object *obj,ResetType type) +{ +AspeedSCUState *s =ASPEED_SCU (obj); +AspeedSCUClass *asc =ASPEED_SCU_GET_CLASS (obj); + +memcpy (s->regs, asc->resets, asc->nr_regs *4 ); + s->regs[AST2700_SILICON_REV ] = s->silicon_rev; + s->regs[AST2700_HW_STRAP1 ] = s->hw_strap1; +} +static void aspeed_2700_scuio_class_init (ObjectClass *klass,const void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -1076,7 +1086,7 @@ static void aspeed_2700_scuio_class_init(ObjectClass *klass, const void *data)AspeedSCUClass *asc =ASPEED_SCU_CLASS (klass); dc->desc ="ASPEED 2700 System Control Unit I/O" ; - rc->phases.hold = aspeed_ast2700_scu_reset_hold; + rc->phases.hold = aspeed_ast2700_scuio_reset_hold; asc->resets = ast2700_a0_resets_io; asc->calc_hpll = aspeed_2600_scu_calc_hpll; asc->get_apb = aspeed_2700_scuio_get_apb_freq;
Signature · 1 line
2.43.0
PATCH v2 2/8 hw/arm/aspeed: Use Aspeed2700SCUState for AST2700 users
In reply to Jamin LinNow that Aspeed2700SCUState has been introduced, update the AST1700 and AST27x0 SoCs to instantiate the AST2700-specific SCU subclass instead of the generic AspeedSCUState.
Also update the AST27x0 FC board to link the SSP/TSP coprocessors to the AST2700 SCU instance.
This prepares the AST2700 platform for subsequent patches that move AST2700-specific SCU functionality into the subclass.
No functional change.
--- include/hw/arm/aspeed_ast1700.h | 2 +- include/hw/arm/aspeed_soc.h | 1 + hw/arm/aspeed_ast27x0-fc.c | 4 ++-- hw/arm/aspeed_ast27x0.c | 16 ++++++++-------- 4 files changed, 12 insertions(+), 11 deletions(-)
include/hw/arm/aspeed_ast1700.h +1 -1
@@ -41,7 +41,7 @@ struct AspeedAST1700SoCState {MemoryRegion sram;AspeedSMCState spi;AspeedADCState adc; -AspeedSCUState scu; +Aspeed2700SCUState scu;AspeedGPIOState gpio;AspeedSGPIOState sgpiom[AST1700_SGPIO_NUM ];AspeedI2CState i2c;
include/hw/arm/aspeed_soc.h +1 -0
@@ -151,6 +151,7 @@ struct Aspeed27x0SoCState {AspeedINTCState intcioexp[ASPEED_IOEXP_NUM ];GICv3State gic;MemoryRegion dram_empty; +Aspeed2700SCUState scu; };#define TYPE_ASPEED27X0_SOC "aspeed27x0-soc"
hw/arm/aspeed_ast27x0-fc.c +2 -2
@@ -158,7 +158,7 @@ static bool ast2700fc_ssp_init(MachineState *machine, Error **errp)object_property_set_link (OBJECT (&s->ssp),"sram" ,OBJECT (&psp->sram), &error_abort);object_property_set_link (OBJECT (&s->ssp),"scu" , -OBJECT (&psp->scu), &error_abort); +OBJECT (&s->ca35.scu), &error_abort);if (!qdev_realize (DEVICE (&s->ssp),NULL , errp)) {return false; }
@@ -190,7 +190,7 @@ static bool ast2700fc_tsp_init(MachineState *machine, Error **errp)object_property_set_link (OBJECT (&s->tsp),"sram" ,OBJECT (&psp->sram), &error_abort);object_property_set_link (OBJECT (&s->tsp),"scu" , -OBJECT (&psp->scu), &error_abort); +OBJECT (&s->ca35.scu), &error_abort);if (!qdev_realize (DEVICE (&s->tsp),NULL , errp)) {return false; }
hw/arm/aspeed_ast27x0.c +8 -8
@@ -435,12 +435,12 @@ static void aspeed_soc_ast2700_init(Object *obj)object_initialize_child (obj,"gic" , &a->gic,gicv3_class_name ()); -object_initialize_child (obj,"scu" , &s->scu,TYPE_ASPEED_2700_SCU ); -qdev_prop_set_uint32 (DEVICE (&s->scu),"silicon-rev" , +object_initialize_child (obj,"scu" , &a->scu,TYPE_ASPEED_2700_SCU ); +qdev_prop_set_uint32 (DEVICE (&a->scu),"silicon-rev" , sc->silicon_rev); -object_property_add_alias (obj,"hw-strap1" ,OBJECT (&s->scu), +object_property_add_alias (obj,"hw-strap1" ,OBJECT (&a->scu),"hw-strap1" ); -object_property_add_alias (obj,"hw-prot-key" ,OBJECT (&s->scu), +object_property_add_alias (obj,"hw-prot-key" ,OBJECT (&a->scu),"hw-prot-key" );object_initialize_child (obj,"scuio" , &s->scuio,TYPE_ASPEED_2700_SCUIO );
@@ -808,10 +808,10 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp) sc->memmap[ASPEED_DEV_VBOOTROM], &s->vbootrom);/* SCU */ -if (!sysbus_realize (SYS_BUS_DEVICE (&s->scu), errp)) { +if (!sysbus_realize (SYS_BUS_DEVICE (&a->scu), errp)) {return ; } -aspeed_mmio_map (s->memory,SYS_BUS_DEVICE (&s->scu),0 , +aspeed_mmio_map (s->memory,SYS_BUS_DEVICE (&a->scu),0 , sc->memmap[ASPEED_DEV_SCU ]);/* SCU1 */
@@ -929,7 +929,7 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)AspeedWDTClass *awc =ASPEED_WDT_GET_CLASS (&s->wdt[i]);hwaddr wdt_offset = sc->memmap[ASPEED_DEV_WDT ] + i * awc->iosize; -object_property_set_link (OBJECT (&s->wdt[i]),"scu" ,OBJECT (&s->scu), +object_property_set_link (OBJECT (&s->wdt[i]),"scu" ,OBJECT (&a->scu), &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->wdt[i]), errp)) {return ;
@@ -1032,7 +1032,7 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp) aspeed_soc_ast2700_get_irq(s, ASPEED_DEV_EMMC));/* Timer */ -object_property_set_link (OBJECT (&s->timerctrl),"scu" ,OBJECT (&s->scu), +object_property_set_link (OBJECT (&s->timerctrl),"scu" ,OBJECT (&a->scu), &error_abort);if (!sysbus_realize (SYS_BUS_DEVICE (&s->timerctrl), errp)) {return ;
Signature · 1 line
2.43.0
Re: [PATCH v2 4/8] hw/misc/aspeed_scu: Add separate reset handler for AST2700 SCUIO
In reply to Jamin LinQuoted 12 lines · Jamin Lin
Introduce a dedicated reset handler for SCUIO.
Previously, SCU and SCUIO shared the same reset handler. This no longer fits the AST2700 design, where SCU uses the Aspeed2700SCUState subclass and will handle coprocessor-related control in future changes.
Since these controls are defined in SCU (not SCUIO), SCU and SCUIO should not share the same reset logic.
This change gives SCUIO its own reset handler and prepares for upcoming SCU-specific functionality.
Quoted 6 lines
No functional change.
Signed-off-by Jamin Lin <[email protected]>--- hw/misc/aspeed_scu.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Re: [PATCH v2 6/8] hw/arm/ast27x0: Share single SCUIO instance across PSP, SSP, and TSP
In reply to Jamin LinQuoted 25 lines · Jamin Lin
AST2700 has a single SCUIO hardware block, memory-mapped at 0x14C02000–0x14C03FFF from the perspective of the main CA35 processor (PSP). The SSP and TSP coprocessors access this same SCUIO block at different
addresses: 0x74C02000–0x74C03FFF.Previously, each subsystem (PSP, SSP, and TSP) instantiated its own SCUIO device, resulting in three independent SCUIO instances in the QEMU model. In real hardware, however, only a single SCUIO exists and is shared among all processors.
This commit reworks the SCUIO model to correctly reflect the hardware behavior by allowing SSP and TSP to reference the PSP’s SCUIO instance. The following changes are introduced:
- Add a scuio property to Aspeed27x0CoprocessorState for linking the coprocessor to the PSP’s SCUIO instance.
- Replace per-coprocessor SCUIO instantiation with a shared SCUIO link.
- Add "MemoryRegionscuio_alias" to model address remapping for SSP and TSP.
- Create SCUIO alias regions in both SSP and TSP coprocessors and map them at0x74C02000to mirror the PSP’s SCUIO registers.
- Ensure the SCUIO device in PSP is realized before SSP/TSP alias setup.With this change, PSP, SSP, and TSP now share a consistent SCUIO state, matching the single-SCUIO hardware design of AST2700.
Quoted 7 lines
Signed-off-by Jamin Lin <[email protected]>--- include/hw/arm/aspeed_coprocessor.h | 4 ++-- hw/arm/aspeed_ast27x0-fc.c | 4 ++++ hw/arm/aspeed_ast27x0-ssp.c | 20 +++++++++++++++----- hw/arm/aspeed_ast27x0-tsp.c | 20 +++++++++++++++----- 4 files changed, 36 insertions(+), 12 deletions(-)
Nice.
Re: [PATCH v2 7/8] hw/arm/ast27x0: Share FMC controller with SSP and TSP
In reply to Jamin LinQuoted 15 lines · Jamin Lin
AST2700 provides a single FMC controller shared by the main CA35 processor (PSP) and the SSP/TSP coprocessors.
From the PSP perspective, the FMC controller is memory-mapped at
0x14000000–0x140000FF. The SSP and TSP access the same controller through a different address window at 0x74000000–0x740000FF.This change allows the SSP and TSP SoC models to reference the existing PSP FMC instance instead of creating independent controllers. An MMIO alias is added in the SSP and TSP address spaces to map their FMC access window to the shared FMC device.
This ensures consistent FMC state across PSP, SSP, and TSP and matches the AST2700 hardware design.
Quoted 7 lines
Signed-off-by Jamin Lin <[email protected]>--- include/hw/arm/aspeed_coprocessor.h | 2 ++ hw/arm/aspeed_ast27x0-fc.c | 4 ++++ hw/arm/aspeed_ast27x0-ssp.c | 16 ++++++++++++++++ hw/arm/aspeed_ast27x0-tsp.c | 16 ++++++++++++++++ 4 files changed, 38 insertions(+)
Re: [PATCH v2 5/8] hw/arm/aspeed_ast27x0: Pass realized PSP SoC to SSP/TSP initialization
In reply to Jamin LinQuoted 8 lines · Jamin Lin
Pass the realized PSP SoC to the SSP/TSP initialization helpers instead of retrieving it from the MachineState.
This makes the dependency explicit, since the SSP and TSP coprocessors use resources owned by the PSP SoC, including the UARTs, SRAM, SCU and SCUIO. The PSP SoC must therefore be realized before the coprocessors are initialized.
Quoted 6 lines
No functional change.
Signed-off-by Jamin Lin <[email protected]>--- hw/arm/aspeed_ast27x0-fc.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
Re: [PATCH v2 1/8] hw/misc/aspeed_scu: Introduce Aspeed2700SCUState
In reply to Jamin LinQuoted 14 lines · Jamin Lin
Introduce Aspeed2700SCUState as an AST2700-specific subclass of AspeedSCUState.
Currently, AST1700 and AST2700 reuse the generic AspeedSCUState. However, AST2700 requires SCU functionality that is specific to the platform, particularly for interactions with its coprocessors.
Introduce a dedicated Aspeed2700SCUState to provide an extension point for AST2700-specific functionality while keeping the generic AspeedSCUState unchanged.
Subsequent patches will migrate AST2700 users to the new subclass and move AST2700-specific code into it.
Quoted 7 lines
No functional change.
Signed-off-by Jamin Lin <[email protected]>--- include/hw/misc/aspeed_scu.h | 5 +++++ hw/misc/aspeed_scu.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-)
Re: [PATCH v2 2/8] hw/arm/aspeed: Use Aspeed2700SCUState for AST2700 users
In reply to Jamin LinQuoted 12 lines · Jamin Lin
Now that Aspeed2700SCUState has been introduced, update the AST1700 and AST27x0 SoCs to instantiate the AST2700-specific SCU subclass instead of the generic AspeedSCUState.
Also update the AST27x0 FC board to link the SSP/TSP coprocessors to the AST2700 SCU instance.
This prepares the AST2700 platform for subsequent patches that move AST2700-specific SCU functionality into the subclass.
No functional change.
Quoted 7 lines
Signed-off-by Jamin Lin <[email protected]>--- include/hw/arm/aspeed_ast1700.h | 2 +- include/hw/arm/aspeed_soc.h | 1 + hw/arm/aspeed_ast27x0-fc.c | 4 ++-- hw/arm/aspeed_ast27x0.c | 16 ++++++++-------- 4 files changed, 12 insertions(+), 11 deletions(-)
Quoted 13 lines · Jamin Lin
The original AST2700 FC support series [1] is fairly large, making it difficult to review all changes together.
Jamin Lin (8):
hw/misc/aspeed_scu: Introduce Aspeed2700SCUState hw/arm/aspeed: Use Aspeed2700SCUState for AST2700 users hw/arm/aspeed_ast27x0: Move SCU link into AST27x0 coprocessors hw/misc/aspeed_scu: Add separate reset handler for AST2700 SCUIO hw/arm/aspeed_ast27x0: Pass realized PSP SoC to SSP/TSP initialization hw/arm/ast27x0: Share single SCUIO instance across PSP, SSP, and TSP hw/arm/ast27x0: Share FMC controller with SSP and TSP hw/ssi/aspeed_smc: Add Data FIFO-based flash access support for
Quoted 1 line
AST2700
Series:
Hi Jamin,
Quoted 16 lines · Jamin Lin
The original AST2700 FC support series [1] is fairly large, making it difficult to review all changes together.
To help speed up the review process, this series extracts the SCU/FMC-related refactoring into a standalone prerequisite series.
Jamin Lin (8):
hw/misc/aspeed_scu: Introduce Aspeed2700SCUState hw/arm/aspeed: Use Aspeed2700SCUState for AST2700 users hw/arm/aspeed_ast27x0: Move SCU link into AST27x0 coprocessors hw/misc/aspeed_scu: Add separate reset handler for AST2700 SCUIO hw/arm/aspeed_ast27x0: Pass realized PSP SoC to SSP/TSP initialization hw/arm/ast27x0: Share single SCUIO instance across PSP, SSP, and TSP hw/arm/ast27x0: Share FMC controller with SSP and TSP hw/ssi/aspeed_smc: Add Data FIFO-based flash access support for
Quoted 1 line
AST2700
Looking at this machine in more detail, I think it would be better modelled as:
struct Ast2700FcMachineState {
MachineState parent_obj;
MemoryRegion dram;
Aspeed2700SCUState scu;
Aspeed27x0SoCState psp;
MemoryRegion psp_memory;
MemoryRegion psp_bootrom;
Aspeed27x0CoprocessorState ssp;
Clock *ssp_sysclk;
MemoryRegion ssp_memory;
Aspeed27x0CoprocessorState tsp;
Clock *tsp_sysclk;
MemoryRegion tsp_memory;
};- dram and scu are shared within psp/ssp/tsp
(ca35_dram renamed as generic dram)
(ca35_memory renamed as psp_memory)
(ca35_boot_rom renamed as psp_bootrom)
and:
struct Aspeed27x0SoCState {
AspeedSoCState parent;
ARMCPU cpu[ASPEED_CPUS_NUM];
AspeedINTCState intc[ASPEED_INTC_NUM];
AspeedINTCState intcioexp[ASPEED_IOEXP_NUM];
GICv3State gic;
MemoryRegion dram_empty;
Aspeed2700SCUState *scu;
};- scu becomes a link property
struct Ast2700FcMachineState {
MachineState parent_obj;
MemoryRegion dram;
Aspeed2700SCUState scu;
Aspeed27x0SoCState psp;
MemoryRegion psp_memory;
MemoryRegion psp_bootrom;
Aspeed27x0CoprocessorState ssp;
Clock *ssp_sysclk;
MemoryRegion ssp_memory;
Aspeed27x0CoprocessorState tsp;
Clock *tsp_sysclk;
MemoryRegion tsp_memory;
};My personal style preference being:
struct Ast2700FcMachineState {
MachineState parent_obj;
MemoryRegion dram;
Aspeed2700SCUState scu;
struct {
Aspeed27x0SoCState mpcore;
MemoryRegion memory;
MemoryRegion bootrom;
} psp;
struct {
Aspeed27x0CoprocessorState mcu;
Clock *sysclk;
MemoryRegion memory;
} ssp;
struct {
Aspeed27x0CoprocessorState mcu;
Clock *sysclk;
MemoryRegion memory;
} tsp;
};Quoted 10 lines · Jamin Lin
The original AST2700 FC support series [1] is fairly large, making it difficult to review all changes together.
To help speed up the review process, this series extracts the SCU/FMC-related refactoring into a standalone prerequisite series.
hw/arm/aspeed_ast27x0-ssp.c | 56 +++++++++++--- hw/arm/aspeed_ast27x0-tsp.c | 56 +++++++++++--- hw/arm/aspeed_coprocessor_common.c | 2 -
It is unfortunate these 2 complex models diverge so few...
$ diff -u -U0 hw/arm/aspeed_ast27x0-tsp.c hw/arm/aspeed_ast27x0-ssp.c
--- hw/arm/aspeed_ast27x0-tsp.c 2026-07-09 18:42:33
+++ hw/arm/aspeed_ast27x0-ssp.c 2026-07-09 18:42:33
@@ -2 +2 @@
- * ASPEED Ast27x0 TSP Coprocessor
+ * ASPEED Ast27x0 SSP Coprocessor
@@ -19 +19 @@
-#define AST2700_TSP_SDRAM_SIZE (512 * MiB)
+#define AST2700_SSP_SDRAM_SIZE (512 * MiB)
@@ -21 +21 @@
-static const hwaddr aspeed_soc_ast27x0tsp_memmap[] = {
+static const hwaddr aspeed_soc_ast27x0ssp_memmap[] = {
@@ -50 +50 @@
-static const int aspeed_soc_ast27x0tsp_irqmap[] = {
+static const int aspeed_soc_ast27x0ssp_irqmap[] = {
@@ -68,2 +68,2 @@
-/* TSPINT 164 */
-static const int ast2700_tsp164_intcmap[] = {
+/* SSPINT 164 */
+static const int ast2700_ssp164_intcmap[] = {
@@ -91 +91 @@
-static struct nvic_intc_irq_info ast2700_tsp_intcmap[] = {
+static struct nvic_intc_irq_info ast2700_ssp_intcmap[] = {
@@ -96 +96 @@
- {164, 1, 4, ast2700_tsp164_intcmap},
+ {164, 1, 4, ast2700_ssp164_intcmap},
@@ -104 +104 @@
-static qemu_irq aspeed_soc_ast27x0tsp_get_irq(AspeedCoprocessorState *s,
+static qemu_irq aspeed_soc_ast27x0ssp_get_irq(AspeedCoprocessorState *s,
@@ -107 +107 @@
- Aspeed27x0CoprocessorState *a = ASPEED27X0TSP_COPROCESSOR(s);
+ Aspeed27x0CoprocessorState *a = ASPEED27X0SSP_COPROCESSOR(s);
@@ -114,5 +114,5 @@
- for (i = 0; i < ARRAY_SIZE(ast2700_tsp_intcmap); i++) {
- if (sc->irqmap[dev] == ast2700_tsp_intcmap[i].irq) {
- assert(ast2700_tsp_intcmap[i].ptr);
- or_idx = ast2700_tsp_intcmap[i].orgate_idx;
- idx = ast2700_tsp_intcmap[i].intc_idx;
+ for (i = 0; i < ARRAY_SIZE(ast2700_ssp_intcmap); i++) {
+ if (sc->irqmap[dev] == ast2700_ssp_intcmap[i].irq) {
+ assert(ast2700_ssp_intcmap[i].ptr);
+ or_idx = ast2700_ssp_intcmap[i].orgate_idx;
+ idx = ast2700_ssp_intcmap[i].intc_idx;
@@ -120 +120 @@
- ast2700_tsp_intcmap[i].ptr[dev]);
+ ast2700_ssp_intcmap[i].ptr[dev]);
@@ -127 +127 @@
-static void aspeed_soc_ast27x0tsp_init(Object *obj)
+static void aspeed_soc_ast27x0ssp_init(Object *obj)
@@ -129 +129 @@
- Aspeed27x0CoprocessorState *a = ASPEED27X0TSP_COPROCESSOR(obj);
+ Aspeed27x0CoprocessorState *a = ASPEED27X0SSP_COPROCESSOR(obj);
@@ -136 +136 @@
- TYPE_ASPEED_2700TSP_INTC);
+ TYPE_ASPEED_2700SSP_INTC);
@@ -138 +138 @@
- TYPE_ASPEED_2700TSP_INTCIO);
+ TYPE_ASPEED_2700SSP_INTCIO);
@@ -154 +154 @@
-static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)
+static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)
@@ -156 +156 @@
- Aspeed27x0CoprocessorState *a = ASPEED27X0TSP_COPROCESSOR(dev_soc);
+ Aspeed27x0CoprocessorState *a = ASPEED27X0SSP_COPROCESSOR(dev_soc);
@@ -170 +170 @@
- error_setg(errp, TYPE_ASPEED27X0TSP_COPROCESSOR
+ error_setg(errp, TYPE_ASPEED27X0SSP_COPROCESSOR
@@ -176 +176 @@
- error_setg(errp, TYPE_ASPEED27X0TSP_COPROCESSOR
+ error_setg(errp, TYPE_ASPEED27X0SSP_COPROCESSOR
@@ -182 +182 @@
- error_setg(errp, TYPE_ASPEED27X0TSP_COPROCESSOR
+ error_setg(errp, TYPE_ASPEED27X0SSP_COPROCESSOR
@@ -187 +187 @@
- /* AST27X0 TSP Core */
+ /* AST27X0 SSP Core */
@@ -196,2 +196,2 @@
- * The TSP starts in a powered-down state and can be powered up
- * by setting the TSP Control Register through the SCU
+ * The SSP starts in a powered-down state and can be powered up
+ * by setting the SSP Control Register through the SCU
@@ -208 +208 @@
- AST2700_TSP_SDRAM_SIZE, errp)) {
+ AST2700_SSP_SDRAM_SIZE, errp)) {
@@ -235,2 +235,5 @@
- /* SDRAM remap alias used by PSP to access TSP SDRAM */
- memory_region_add_subregion(&s->sdram, 0, &a->scu->dram_remap_alias[2]);
+ /* SDRAM remap alias used by PSP to access SSP SDRAM */
+ memory_region_add_subregion(&s->sdram, 0, &a->scu->dram_remap_alias[1]);
+ memory_region_add_subregion(&s->sdram,
+ memory_region_size(&a->scu->dram_remap_alias[1]),
+ &a->scu->dram_remap_alias[0]);
@@ -254 +257 @@
- /* irq source orgates -> INTC */
+ /* irq source orgates -> INTC0 */
@@ -260 +263 @@
- assert(i < ARRAY_SIZE(ast2700_tsp_intcmap));
+ assert(i < ARRAY_SIZE(ast2700_ssp_intcmap));
@@ -263 +266 @@
- ast2700_tsp_intcmap[i].irq));
+ ast2700_ssp_intcmap[i].irq));
@@ -265 +268 @@
- /* irq source orgates -> INTC */
+ /* irq source orgates -> INTCIO */
@@ -287 +290 @@
- aspeed_soc_ast27x0tsp_get_irq(s, s->uart_dev));
+ aspeed_soc_ast27x0ssp_get_irq(s, s->uart_dev));
@@ -325 +328 @@
-static void aspeed_soc_ast27x0tsp_class_init(ObjectClass *klass,
+static void aspeed_soc_ast27x0ssp_class_init(ObjectClass *klass,
@@ -329 +332 @@
- ARM_CPU_TYPE_NAME("cortex-m4"), /* TODO cortex-m4f */
+ ARM_CPU_TYPE_NAME("cortex-m4"), /* TODO: cortex-m4f */
@@ -337 +340 @@
- dc->realize = aspeed_soc_ast27x0tsp_realize;
+ dc->realize = aspeed_soc_ast27x0ssp_realize;
@@ -341,2 +344,2 @@
- sc->irqmap = aspeed_soc_ast27x0tsp_irqmap;
- sc->memmap = aspeed_soc_ast27x0tsp_memmap;
+ sc->irqmap = aspeed_soc_ast27x0ssp_irqmap;
+ sc->memmap = aspeed_soc_ast27x0ssp_memmap;
@@ -345 +348 @@
-static const TypeInfo aspeed_soc_ast27x0tsp_types[] = {
+static const TypeInfo aspeed_soc_ast27x0ssp_types[] = {
@@ -347 +350 @@
- .name = TYPE_ASPEED27X0TSP_COPROCESSOR,
+ .name = TYPE_ASPEED27X0SSP_COPROCESSOR,
@@ -350,2 +353,2 @@
- .instance_init = aspeed_soc_ast27x0tsp_init,
- .class_init = aspeed_soc_ast27x0tsp_class_init,
+ .instance_init = aspeed_soc_ast27x0ssp_init,
+ .class_init = aspeed_soc_ast27x0ssp_class_init,
@@ -355 +358 @@
-DEFINE_TYPES(aspeed_soc_ast27x0tsp_types)
+DEFINE_TYPES(aspeed_soc_ast27x0ssp_types)And without the s/tsp/ssp/ name changes, the diff is as small as:
$ diff -u -U0 hw/arm/aspeed_ast27x0-tsp.c hw/arm/aspeed_ast27x0-ssp.c --- hw/arm/aspeed_ast27x0-tsp.c 2026-07-09 18:42:33 +++ hw/arm/aspeed_ast27x0-ssp.c 2026-07-10 01:10:06 @@ -236 +236,4 @@ - memory_region_add_subregion(&s->sdram, 0, &a->scu->dram_remap_alias[2]); + memory_region_add_subregion(&s->sdram, 0, &a->scu->dram_remap_alias[1]); + memory_region_add_subregion(&s->sdram, + memory_region_size(&a->scu->dram_remap_alias[1]), + &a->scu->dram_remap_alias[0]);
2 lines of differences! Could we unify?
Thanks,
Phil.
Re: [PATCH v2 8/8] hw/ssi/aspeed_smc: Add Data FIFO-based flash access support for AST2700
In reply to Jamin LinQuoted 14 lines · Jamin Lin
AST2700 supports a Data FIFO mode where flash accesses can be performed directly through Data FIFO MMIO offsets. The Data FIFO start offset increments by one for every 16MB of flash address space, allowing the chip select (CS) to be decoded from the Data FIFO offset.
This change adds Data FIFO support to the Aspeed SMC model and introduces a class callback to translate Data FIFO offsets into CS indices. For AST2700, the Data FIFO offset is matched against the segment start address of each CS to determine the target flash device.
The SMC register region size (nregs) is also extended dynamically based on the number of supported chip selects to cover all possible Data FIFO regions.
Quoted 5 lines
Signed-off-by Jamin Lin <[email protected]>--- include/hw/ssi/aspeed_smc.h | 3 +- hw/ssi/aspeed_smc.c | 113 +++++++++++++++++++++++++++++++++--- 2 files changed, 107 insertions(+), 9 deletions(-)
I am looking for a way to test "Data FIFO-based flash access". A qtest extension of the ast2700 smc test would be nice to have.
Is the latest SDK kernel using this feature ?
Thanks,
C.
RE: [PATCH v2 8/8] hw/ssi/aspeed_smc: Add Data FIFO-based flash access support for AST2700
Hi Cédric
Quoted 22 lines
Subject: Re: [PATCH v2 8/8] hw/ssi/aspeed_smc: Add Data FIFO-based flash access support for AST2700
Quoted 10 lines · Jamin Lin
AST2700 supports a Data FIFO mode where flash accesses can be performed directly through Data FIFO MMIO offsets. The Data FIFO start offset increments by one for every 16MB of flash address space, allowing the chip select (CS) to be decoded from the Data FIFO offset.
This change adds Data FIFO support to the Aspeed SMC model and introduces a class callback to translate Data FIFO offsets into CS indices. For AST2700, the Data FIFO offset is matched against the segment start address of each CS to determine the target flash device.
Quoted 8 lines
The SMC register region size (nregs) is also extended dynamically based on the number of supported chip selects to cover all possible Data FIFO regions.
Signed-off-by Jamin Lin <[email protected]>--- include/hw/ssi/aspeed_smc.h | 3 +- hw/ssi/aspeed_smc.c | 113
Quoted 6 lines
+++++++++++++++++++++++++++++++++---
Quoted 1 line
2 files changed, 107 insertions(+), 9 deletions(-)I am looking for a way to test "Data FIFO-based flash access". A qtest extension of the ast2700 smc test would be nice to have.
Will do.
Quoted 2 lines
Is the latest SDK kernel using this feature ?
Yes. Please try the following pre-built image:
https://github.com/AspeedTech-BMC/openbmc/releases/download/v11.02/ast2700-irot-obmc.tar.gz
The image-bmc file in the archive is smaller than 128 MB. Since the QEMU FMC flash model expects a 128 MB flash device, please resize it before using it:
jamin@JaminLin-PC:~/qemu-work/debug-qemu-ssp-review/ast2700-irot$ truncate --size 128M image-bmc
This pre-built image boots both the PSP and SSP.
After the system boots, log in to the Zephyr shell running on the SSP and use the following command to read the contents of the FMC CS0 flash:
ssp:~$ flash read fmc@0 0 100 00000000: 46 4c 53 48 01 00 11 00 aa 26 87 00 f9 64 80 79 |FLSH.... .&...d.y| 00000010: 01 00 00 00 dc 00 00 00 74 a6 01 00 02 00 00 00 |........ t.......| 00000020: 50 a7 01 00 84 3e 00 00 03 00 00 00 d4 e5 01 00 |P....>.. ........| 00000030: 60 ce 02 00 00 10 00 00 34 b4 04 00 d8 77 00 00 |`....... 4....w..| 00000040: 01 10 00 00 0c 2c 05 00 00 00 01 00 02 10 00 00 |.....,.. ........| 00000050: 0c 2c 06 00 b8 74 00 00 03 10 00 00 c4 a0 06 00 |.,...t.. ........| 00000060: 00 00 01 00 04 10 00 00 c4 a0 07 00 54 cf 00 00 |........ ....T...| 00000070: 05 10 00 00 18 70 08 00 00 00 01 00 06 10 00 00 |.....p.. ........| 00000080: 18 70 09 00 00 40 00 00 07 10 00 00 18 b0 09 00 |.p...@.. ........| 00000090: 00 a0 00 00 08 10 00 00 18 50 0a 00 6c 70 00 00 |........ .P..lp..| 000000A0: 09 10 00 00 84 c0 0a 00 90 ac 06 00 0a 10 00 00 |........ ........| 000000B0: 14 6d 11 00 58 82 0d 00 0b 10 00 00 6c ef 1e 00 |.m..X... ....l...| 000000C0: 6c 3e 03 00 0c 10 00 00 d8 2d 22 00 00 00 00 00 |l>...... .-".....| 000000D0: 0d 10 00 00 d8 2d 22 00 34 99 75 03 43 4d 41 4e |.....-". 4.u.CMAN| 000000E0: fc 16 00 00 5f 19 49 fc a6 6a 8d 66 e6 26 80 87 |...._.I. .j.f.&..| 000000F0: e3 f0 48 2a 3b 01 b0 63 fe cf 0a a3 20 56 f1 62 |..H*;..c .... V.b|
You can then compare it with the beginning of the image-bmc file on the host:
jamin@JaminLin-PC:~/qemu-work/debug-qemu-ssp-review/ast2700-irot$ xxd image-bmc | head 00000000: 464c 5348 0100 1100 aa26 8700 f964 8079 FLSH.....&...d.y 00000010: 0100 0000 dc00 0000 74a6 0100 0200 0000 ........t....... 00000020: 50a7 0100 843e 0000 0300 0000 d4e5 0100 P....>.......... 00000030: 60ce 0200 0010 0000 34b4 0400 d877 0000 `.......4....w.. 00000040: 0110 0000 0c2c 0500 0000 0100 0210 0000 .....,.......... 00000050: 0c2c 0600 b874 0000 0310 0000 c4a0 0600 .,...t.......... 00000060: 0000 0100 0410 0000 c4a0 0700 54cf 0000 ............T... 00000070: 0510 0000 1870 0800 0000 0100 0610 0000 .....p.......... 00000080: 1870 0900 0040 0000 0710 0000 18b0 0900 .p...@.......... 00000090: 00a0 0000 0810 0000 1850 0a00 6c70 0000 .........P..lp..
The contents read from the emulated flash should match the corresponding data in image-bmc
Thanks,
Jamin
Quoted 3 lines
Thanks,
C.
Hi Philippe, Cédric
Quoted 176 lines
Subject: Re: [PATCH v2 0/8] Refactor AST2700 SCU preparation for coprocessors
Quoted 10 lines · Jamin Lin
The original AST2700 FC support series [1] is fairly large, making it difficult to review all changes together.
To help speed up the review process, this series extracts the SCU/FMC-related refactoring into a standalone prerequisite series.
hw/arm/aspeed_ast27x0-ssp.c | 56 +++++++++++--- hw/arm/aspeed_ast27x0-tsp.c | 56 +++++++++++--- hw/arm/aspeed_coprocessor_common.c | 2 -It is unfortunate these 2 complex models diverge so few...
$ diff -u -U0 hw/arm/aspeed_ast27x0-tsp.c hw/arm/aspeed_ast27x0-ssp.carm/aspeed_ast27x0-ssp.c renamed from arm/aspeed_ast27x0-tsp.c +17
-16@@ -2 +2 @@ -* ASPEED Ast27x0 TSP Coprocessor +* ASPEED Ast27x0 SSP Coprocessor @@ -19 +19 @@ -#define AST2700_TSP_SDRAM_SIZE (512 * MiB) +#define AST2700_SSP_SDRAM_SIZE (512 * MiB)@@ -21 +21 @@ -static const hwaddr aspeed_soc_ast27x0tsp_memmap[] = { +static const hwaddr aspeed_soc_ast27x0ssp_memmap[] = {@@ -50 +50 @@ -static const int aspeed_soc_ast27x0tsp_irqmap[] = { +static const int aspeed_soc_ast27x0ssp_irqmap[] = {@@ -68,2 +68,2 @@ -/* TSPINT 164 */ -static const int ast2700_tsp164_intcmap[] = { +/* SSPINT 164 */ +static const int ast2700_ssp164_intcmap[] = {@@ -91 +91 @@ -static struct nvic_intc_irq_info ast2700_tsp_intcmap[] = { +static struct nvic_intc_irq_info ast2700_ssp_intcmap[] = {@@ -96 +96 @@ - {164, 1, 4, ast2700_tsp164_intcmap}, + {164, 1, 4, ast2700_ssp164_intcmap},@@ -104 +104 @@ -static qemu_irq aspeed_soc_ast27x0tsp_get_irq(AspeedCoprocessorState *s, +static qemu_irq aspeed_soc_ast27x0ssp_get_irq(AspeedCoprocessorState +*s,@@ -107 +107 @@ -Aspeed27x0CoprocessorState *a =ASPEED27X0TSP_COPROCESSOR (s); +Aspeed27x0CoprocessorState *a =ASPEED27X0SSP_COPROCESSOR (s);@@ -114,5 +114,5 @@ -for (i =0 ; i <ARRAY_SIZE (ast2700_tsp_intcmap); i++) { -if (sc->irqmap[dev] == ast2700_tsp_intcmap[i].irq) { -assert (ast2700_tsp_intcmap[i].ptr); - or_idx = ast2700_tsp_intcmap[i].orgate_idx; - idx = ast2700_tsp_intcmap[i].intc_idx; +for (i =0 ; i <ARRAY_SIZE (ast2700_ssp_intcmap); i++) { +if (sc->irqmap[dev] == ast2700_ssp_intcmap[i].irq) { +assert (ast2700_ssp_intcmap[i].ptr); + or_idx = ast2700_ssp_intcmap[i].orgate_idx; + idx = ast2700_ssp_intcmap[i].intc_idx;@@ -120 +120 @@ - ast2700_tsp_intcmap[i].ptr[dev]); +ast2700_ssp_intcmap[i].ptr[dev]);
arm/aspeed_ast27x0-ssp.c renamed from arm/aspeed_ast27x0-tsp.c +4
-5@@ -127 +127 @@ -static void aspeed_soc_ast27x0tsp_init (Object *obj) +static void aspeed_soc_ast27x0ssp_init (Object *obj)@@ -129 +129 @@ -Aspeed27x0CoprocessorState *a =ASPEED27X0TSP_COPROCESSOR (obj); +Aspeed27x0CoprocessorState *a =ASPEED27X0SSP_COPROCESSOR (obj);@@ -136 +136 @@ - TYPE_ASPEED_2700TSP_INTC); + TYPE_ASPEED_2700SSP_INTC);@@ -138 +138 @@ - TYPE_ASPEED_2700TSP_INTCIO); + TYPE_ASPEED_2700SSP_INTCIO);@@ -154 +154 @@ -static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error**errp)
+static voidaspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)arm/aspeed_ast27x0-ssp.c renamed from arm/aspeed_ast27x0-tsp.c +0
-1@@ -156 +156 @@ - Aspeed27x0CoprocessorState *a =
ASPEED27X0TSP_COPROCESSOR(dev_soc);
+ Aspeed27x0CoprocessorState *a =ASPEED27X0SSP_COPROCESSOR(dev_soc);arm/aspeed_ast27x0-ssp.c renamed from arm/aspeed_ast27x0-tsp.c +7
-9@@ -170 +170 @@ - error_setg(errp, TYPE_ASPEED27X0TSP_COPROCESSOR + error_setg(errp, TYPE_ASPEED27X0SSP_COPROCESSOR@@ -176 +176 @@ - error_setg(errp, TYPE_ASPEED27X0TSP_COPROCESSOR + error_setg(errp, TYPE_ASPEED27X0SSP_COPROCESSOR@@ -182 +182 @@ - error_setg(errp, TYPE_ASPEED27X0TSP_COPROCESSOR + error_setg(errp, TYPE_ASPEED27X0SSP_COPROCESSOR@@ -187 +187 @@ -/* AST27X0 TSP Core */ +/* AST27X0 SSP Core */ @@ -196,2 +196,2 @@ -* The TSP starts in a powered-down state and can be powered up -* by setting the TSP Control Register through the SCU +* The SSP starts in a powered-down state and can be powered up +* by setting the SSP Control Register through the SCU @@ -208 +208 @@ - AST2700_TSP_SDRAM_SIZE, errp)) { + AST2700_SSP_SDRAM_SIZE, errp)) {@@ -235,2 +235,5 @@ -/* SDRAM remap alias used by PSP to access TSP SDRAM */ - memory_region_add_subregion(&s->sdram, 0,&a->scu->dram_remap_alias[2]);
arm/aspeed_ast27x0-ssp.c renamed from arm/aspeed_ast27x0-tsp.c +2
-0+/* SDRAM remap alias used by PSP to access SSP SDRAM */ + memory_region_add_subregion(&s->sdram, 0,&a->scu->dram_remap_alias[1]);
arm/aspeed_ast27x0-ssp.c renamed from arm/aspeed_ast27x0-tsp.c +5
-3+memory_region_add_subregion (&s->sdram, +memory_region_size (&a->scu->dram_remap_alias[1 ]), + &a->scu->dram_remap_alias[0 ]);@@ -254 +257 @@ -/* irq source orgates -> INTC */ +/* irq source orgates -> INTC0 */ @@ -260 +263 @@ -assert (i <ARRAY_SIZE (ast2700_tsp_intcmap)); +assert (i <ARRAY_SIZE (ast2700_ssp_intcmap));@@ -263 +266 @@ -ast2700_tsp_intcmap[i].irq));
arm/aspeed_ast27x0-ssp.c renamed from arm/aspeed_ast27x0-tsp.c +14
-12+ + ast2700_ssp_intcmap[i].irq));@@ -265 +268 @@ -/* irq source orgates -> INTC */ +/* irq source orgates -> INTCIO */ @@ -287 +290 @@ - aspeed_soc_ast27x0tsp_get_irq(s, s->uart_dev)); + aspeed_soc_ast27x0ssp_get_irq(s, s->uart_dev));@@ -325 +328 @@ -static void aspeed_soc_ast27x0tsp_class_init(ObjectClass *klass, +static void aspeed_soc_ast27x0ssp_class_init(ObjectClass *klass,@@ -329 +332 @@ - ARM_CPU_TYPE_NAME("cortex-m4"), /* TODO cortex-m4f */ + ARM_CPU_TYPE_NAME("cortex-m4"), /* TODO: cortex-m4f */@@ -337 +340 @@ - dc->realize = aspeed_soc_ast27x0tsp_realize; + dc->realize = aspeed_soc_ast27x0ssp_realize;@@ -341,2 +344,2 @@ - sc->irqmap = aspeed_soc_ast27x0tsp_irqmap; - sc->memmap = aspeed_soc_ast27x0tsp_memmap; + sc->irqmap = aspeed_soc_ast27x0ssp_irqmap; + sc->memmap = aspeed_soc_ast27x0ssp_memmap;@@ -345 +348 @@ -static const TypeInfo aspeed_soc_ast27x0tsp_types[] = { +static const TypeInfo aspeed_soc_ast27x0ssp_types[] = {@@ -347 +350 @@ - .name = TYPE_ASPEED27X0TSP_COPROCESSOR, + .name = TYPE_ASPEED27X0SSP_COPROCESSOR,@@ -350,2 +353,2 @@ - .instance_init = aspeed_soc_ast27x0tsp_init, - .class_init = aspeed_soc_ast27x0tsp_class_init, + .instance_init = aspeed_soc_ast27x0ssp_init, + .class_init = aspeed_soc_ast27x0ssp_class_init,@@ -355 +358 @@ -DEFINE_TYPES (aspeed_soc_ast27x0tsp_types) +DEFINE_TYPES (aspeed_soc_ast27x0ssp_types)And without the s/tsp/ssp/ name changes, the diff is as small as:
$ diff -u -U0 hw/arm/aspeed_ast27x0-tsp.c hw/arm/aspeed_ast27x0-ssp.carm/aspeed_ast27x0-ssp.c renamed from arm/aspeed_ast27x0-tsp.c +0
-1@@ -236 +236,4 @@ - memory_region_add_subregion(&s->sdram, 0,&a->scu->dram_remap_alias[2]);
+ memory_region_add_subregion(&s->sdram, 0,
&a->scu->dram_remap_alias[1]);arm/aspeed_ast27x0-ssp.c renamed from arm/aspeed_ast27x0-tsp.c +3
-0+memory_region_add_subregion (&s->sdram, +memory_region_size (&a->scu->dram_remap_alias[1 ]), + &a->scu->dram_remap_alias[0 ]);
Quoted 5 lines
2 lines of differences! Could we unify?
Thanks,
Phil.
Below is my initial revision — please evaluate whether it needs to be merged into a single .c file.
The SSP and TSP coprocessor files are now identical except for two things, both stemming from the fact that SSP and TSP share the same PSP SCU instance:
- INTC/INTCIO subtype (TYPE_ASPEED_2700SSP_INTC vs TYPE_ASPEED_2700TSP_INTC)
- DRAM remap alias wiring — the SCU owns a single dram_remap_alias[] array shared by both cores (SSP uses two entries, TSP uses one), so each coprocessor needs to know which slice belongs to it.
Thanks,
Jamin
/*
* ASPEED Ast27x0 SSP/TSP Coprocessor
*
* Copyright (C) 2025 ASPEED Technology Inc.
*
* This code is licensed under the GPL version 2 or later. See
* the COPYING file in the top-level directory.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "hw/core/qdev-clock.h"
#include "hw/misc/unimp.h"
#include "hw/arm/aspeed_soc.h"
#include "hw/arm/aspeed_coprocessor.h"
#define AST2700_COPROCESSOR_SDRAM_SIZE (512 * MiB)
static const hwaddr aspeed_soc_ast27x0_coprocessor_memmap[] = {
[ASPEED_DEV_SDRAM] = 0x00000000,
[ASPEED_DEV_SRAM0] = 0x70000000,
[ASPEED_DEV_INTC] = 0x72100000,
[ASPEED_DEV_PRIC0] = 0x72140000,
[ASPEED_DEV_SCU] = 0x72C02000,
[ASPEED_DEV_TIMER1] = 0x72C10000,
[ASPEED_DEV_UART4] = 0x72C1A000,
[ASPEED_DEV_IPC0] = 0x72C1C000,
[ASPEED_DEV_FMC] = 0x74000000,
[ASPEED_DEV_PRIC1] = 0x74100000,
[ASPEED_DEV_SCUIO] = 0x74C02000,
[ASPEED_DEV_OTP] = 0x74C07000,
[ASPEED_DEV_INTCIO] = 0x74C18000,
[ASPEED_DEV_UART0] = 0x74C33000,
[ASPEED_DEV_UART1] = 0x74C33100,
[ASPEED_DEV_UART2] = 0x74C33200,
[ASPEED_DEV_UART3] = 0x74C33300,
[ASPEED_DEV_UART5] = 0x74C33400,
[ASPEED_DEV_UART6] = 0x74C33500,
[ASPEED_DEV_UART7] = 0x74C33600,
[ASPEED_DEV_UART8] = 0x74C33700,
[ASPEED_DEV_UART9] = 0x74C33800,
[ASPEED_DEV_UART10] = 0x74C33900,
[ASPEED_DEV_UART11] = 0x74C33A00,
[ASPEED_DEV_UART12] = 0x74C33B00,
[ASPEED_DEV_IPC1] = 0x74C39000,
};static const int aspeed_soc_ast27x0_coprocessor_irqmap[] = {
[ASPEED_DEV_UART4] = 8,
[ASPEED_DEV_SCU] = 12,
[ASPEED_DEV_TIMER1] = 16,
[ASPEED_DEV_UART0] = 164,
[ASPEED_DEV_UART1] = 164,
[ASPEED_DEV_UART2] = 164,
[ASPEED_DEV_UART3] = 164,
[ASPEED_DEV_UART5] = 164,
[ASPEED_DEV_UART6] = 164,
[ASPEED_DEV_UART7] = 164,
[ASPEED_DEV_UART8] = 164,
[ASPEED_DEV_UART9] = 164,
[ASPEED_DEV_UART10] = 164,
[ASPEED_DEV_UART11] = 164,
[ASPEED_DEV_UART12] = 164,
};/* IRQ 164 fans out to per-UART interrupts inside the shared orgate */
static const int ast2700_coprocessor_164_intcmap[] = {
[ASPEED_DEV_UART0] = 7,
[ASPEED_DEV_UART1] = 8,
[ASPEED_DEV_UART2] = 9,
[ASPEED_DEV_UART3] = 10,
[ASPEED_DEV_UART5] = 11,
[ASPEED_DEV_UART6] = 12,
[ASPEED_DEV_UART7] = 13,
[ASPEED_DEV_UART8] = 14,
[ASPEED_DEV_UART9] = 15,
[ASPEED_DEV_UART10] = 16,
[ASPEED_DEV_UART11] = 17,
[ASPEED_DEV_UART12] = 18,
};struct nvic_intc_irq_info {
int irq;
int intc_idx;
int orgate_idx;
const int *ptr;
};static struct nvic_intc_irq_info ast2700_coprocessor_intcmap[] = {
{160, 1, 0, NULL},
{161, 1, 1, NULL},
{162, 1, 2, NULL},
{163, 1, 3, NULL},
{164, 1, 4, ast2700_coprocessor_164_intcmap},
{165, 1, 5, NULL},
{166, 1, 6, NULL},
{167, 1, 7, NULL},
{168, 1, 8, NULL},
{169, 1, 9, NULL},
};static MemoryRegion *ast27x0ssp_dram_remap_alias(Aspeed2700SCUState *scu,
int *n)
{
*n = ARRAY_SIZE(scu->ssp_dram_remap_alias);
return scu->ssp_dram_remap_alias;
}static MemoryRegion *ast27x0tsp_dram_remap_alias(Aspeed2700SCUState *scu,
int *n)
{
*n = ARRAY_SIZE(scu->tsp_dram_remap_alias);
return scu->tsp_dram_remap_alias;
}static qemu_irq aspeed_soc_ast27x0_coprocessor_get_irq(AspeedCoprocessorState *s,
int dev)
{
Aspeed27x0CoprocessorState *a = ASPEED27X0_COPROCESSOR(s);
AspeedCoprocessorClass *sc = ASPEED_COPROCESSOR_GET_CLASS(s);
int or_idx;
int idx;
int i;
for (i = 0; i < ARRAY_SIZE(ast2700_coprocessor_intcmap); i++) {
if (sc->irqmap[dev] == ast2700_coprocessor_intcmap[i].irq) {
assert(ast2700_coprocessor_intcmap[i].ptr);
or_idx = ast2700_coprocessor_intcmap[i].orgate_idx;
idx = ast2700_coprocessor_intcmap[i].intc_idx;
return qdev_get_gpio_in(DEVICE(&a->intc[idx].orgates[or_idx]),
ast2700_coprocessor_intcmap[i].ptr[dev]);
}
}
return qdev_get_gpio_in(DEVICE(&a->armv7m), sc->irqmap[dev]);
}static void aspeed_soc_ast27x0_coprocessor_init(Object *obj)
{
Aspeed27x0CoprocessorState *a = ASPEED27X0_COPROCESSOR(obj);
Aspeed27x0CoprocessorClass *c = ASPEED27X0_COPROCESSOR_GET_CLASS(obj);
AspeedCoprocessorState *s = ASPEED_COPROCESSOR(obj);
object_initialize_child(obj, "armv7m", &a->armv7m, TYPE_ARMV7M);
s->sysclk = qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0);
object_initialize_child(obj, "intc0", &a->intc[0], c->intc_type);
object_initialize_child(obj, "intc1", &a->intc[1], c->intcio_type);
object_initialize_child(obj, "timerctrl", &s->timerctrl,
TYPE_UNIMPLEMENTED_DEVICE);
object_initialize_child(obj, "ipc0", &a->ipc[0],
TYPE_UNIMPLEMENTED_DEVICE);
object_initialize_child(obj, "ipc1", &a->ipc[1],
TYPE_UNIMPLEMENTED_DEVICE);
object_initialize_child(obj, "pric0", &a->pric[0],
TYPE_UNIMPLEMENTED_DEVICE);
object_initialize_child(obj, "pric1", &a->pric[1],
TYPE_UNIMPLEMENTED_DEVICE);
object_initialize_child(obj, "otp", &a->otp,
TYPE_UNIMPLEMENTED_DEVICE);
}static void aspeed_soc_ast27x0_coprocessor_realize(DeviceState *dev_soc,
Error **errp)
{
Aspeed27x0CoprocessorState *a = ASPEED27X0_COPROCESSOR(dev_soc);
Aspeed27x0CoprocessorClass *c = ASPEED27X0_COPROCESSOR_GET_CLASS(dev_soc);
AspeedCoprocessorState *s = ASPEED_COPROCESSOR(dev_soc);
AspeedCoprocessorClass *sc = ASPEED_COPROCESSOR_GET_CLASS(s);
DeviceState *armv7m;
MemoryRegion *mr;
MemoryRegion *remaps;
g_autofree char *sdram_name = NULL;
hwaddr remap_off;
int n;
int i;
if (!clock_has_source(s->sysclk)) {
error_setg(errp, "sysclk clock must be wired up by the board code");
return;
}
if (!a->scu) {
error_setg(errp, "%s: 'scu' link is not set",
object_get_typename(OBJECT(dev_soc)));
return;
}
if (!a->scuio) {
error_setg(errp, "%s: 'scuio' link is not set",
object_get_typename(OBJECT(dev_soc)));
return;
}
if (!a->fmc) {
error_setg(errp, "%s: 'fmc' link is not set",
object_get_typename(OBJECT(dev_soc)));
return;
}
/* AST27X0 SSP/TSP Core */
armv7m = DEVICE(&a->armv7m);
qdev_prop_set_uint32(armv7m, "num-irq", 256);
qdev_prop_set_string(armv7m, "cpu-type",
aspeed_soc_cpu_type(sc->valid_cpu_types));
qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk);
object_property_set_link(OBJECT(&a->armv7m), "memory",
OBJECT(s->memory), &error_abort);
/*
* The coprocessor starts in a powered-down state and can be powered up
* by setting its Control Register through the SCU (System Control Unit)
*/
object_property_set_bool(OBJECT(&a->armv7m), "start-powered-off", true,
&error_abort);
sysbus_realize(SYS_BUS_DEVICE(&a->armv7m), &error_abort);
/* SDRAM */
sdram_name = g_strdup_printf("aspeed.sdram.%d",
CPU(a->armv7m.cpu)->cpu_index);
if (!memory_region_init_ram(&s->sdram, OBJECT(s), sdram_name,
AST2700_COPROCESSOR_SDRAM_SIZE, errp)) {
return;
}
memory_region_add_subregion(s->memory,
sc->memmap[ASPEED_DEV_SDRAM],
&s->sdram);
/* SRAM */
memory_region_init_alias(&s->sram_alias, OBJECT(s), "sram.alias",
s->sram, 0, memory_region_size(s->sram));
memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_SRAM0],
&s->sram_alias);
/* SCU */
memory_region_init_alias(&a->scu_alias, OBJECT(a), "scu.alias",
&a->scu->parent_obj.iomem, 0,
memory_region_size(&a->scu->parent_obj.iomem));
memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_SCU],
&a->scu_alias);
/* SCUIO */
memory_region_init_alias(&a->scuio_alias, OBJECT(a), "scuio.alias",
&a->scuio->iomem, 0,
memory_region_size(&a->scuio->iomem));
memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_SCUIO],
&a->scuio_alias);
/*
* SDRAM remap alias used by PSP to access this coprocessor's SDRAM.
* Which/how many dram_remap_alias entries to concatenate is a per-model
* detail (see Aspeed27x0CoprocessorClass): SSP maps two, TSP maps one.
*/
remaps = c->dram_remap_alias(a->scu, &n);
remap_off = 0;
for (i = 0; i < n; i++) {
memory_region_add_subregion(&s->sdram, remap_off, &remaps[i]);
remap_off += memory_region_size(&remaps[i]);
}
/* INTC */
if (!sysbus_realize(SYS_BUS_DEVICE(&a->intc[0]), errp)) {
return;
}
aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&a->intc[0]), 0,
sc->memmap[ASPEED_DEV_INTC]);
/* INTCIO */
if (!sysbus_realize(SYS_BUS_DEVICE(&a->intc[1]), errp)) {
return;
}
aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&a->intc[1]), 0,
sc->memmap[ASPEED_DEV_INTCIO]);
/* irq source orgates -> INTC0 */
for (i = 0; i < ASPEED_INTC_GET_CLASS(&a->intc[0])->num_inpins; i++) {
qdev_connect_gpio_out(DEVICE(&a->intc[0].orgates[i]), 0,
qdev_get_gpio_in(DEVICE(&a->intc[0]), i));
}
for (i = 0; i < ASPEED_INTC_GET_CLASS(&a->intc[0])->num_outpins; i++) {
assert(i < ARRAY_SIZE(ast2700_coprocessor_intcmap));
sysbus_connect_irq(SYS_BUS_DEVICE(&a->intc[0]), i,
qdev_get_gpio_in(DEVICE(&a->armv7m),
ast2700_coprocessor_intcmap[i].irq));
}
/* irq source orgates -> INTCIO */
for (i = 0; i < ASPEED_INTC_GET_CLASS(&a->intc[1])->num_inpins; i++) {
qdev_connect_gpio_out(DEVICE(&a->intc[1].orgates[i]), 0,
qdev_get_gpio_in(DEVICE(&a->intc[1]), i));
}
/* INTCIO -> INTC */
for (i = 0; i < ASPEED_INTC_GET_CLASS(&a->intc[1])->num_outpins; i++) {
sysbus_connect_irq(SYS_BUS_DEVICE(&a->intc[1]), i,
qdev_get_gpio_in(DEVICE(&a->intc[0].orgates[0]), i));
}
/* UART */
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(s->uart), 0);
memory_region_init_alias(&s->uart_alias, OBJECT(s), "uart.alias", mr, 0,
memory_region_size(mr));
memory_region_add_subregion(s->memory, sc->memmap[s->uart_dev],
&s->uart_alias);
/*
* Redirect the UART interrupt to the NVIC, replacing the default routing
* to the PSP's GIC.
*/
sysbus_connect_irq(SYS_BUS_DEVICE(s->uart), 0,
aspeed_soc_ast27x0_coprocessor_get_irq(s, s->uart_dev));
/* FMC */
memory_region_init_alias(&a->fmc_alias, OBJECT(a), "fmc.alias",
&a->fmc->mmio, 0,
memory_region_size(&a->fmc->mmio));
memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_FMC],
&a->fmc_alias);
aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->timerctrl),
"aspeed.timerctrl",
sc->memmap[ASPEED_DEV_TIMER1], 0x200);
aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->ipc[0]),
"aspeed.ipc0",
sc->memmap[ASPEED_DEV_IPC0], 0x1000);
aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->ipc[1]),
"aspeed.ipc1",
sc->memmap[ASPEED_DEV_IPC1], 0x1000);
aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->pric[0]),
"aspeed.pric0",
sc->memmap[ASPEED_DEV_PRIC0], 0x1000);
aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->pric[1]),
"aspeed.pric1",
sc->memmap[ASPEED_DEV_PRIC1], 0x1000);
aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->otp),
"aspeed.otp",
sc->memmap[ASPEED_DEV_OTP], 0x800);
}static const Property aspeed_27x0_coprocessor_properties[] = {
DEFINE_PROP_LINK("scu", Aspeed27x0CoprocessorState, scu,
TYPE_ASPEED_2700_SCU, Aspeed2700SCUState *),
DEFINE_PROP_LINK("scuio", Aspeed27x0CoprocessorState, scuio,
TYPE_ASPEED_SCU, AspeedSCUState *),
DEFINE_PROP_LINK("fmc", Aspeed27x0CoprocessorState, fmc, TYPE_ASPEED_SMC,
AspeedSMCState *),
};
static void aspeed_soc_ast27x0_coprocessor_class_init(ObjectClass *klass,
const void *data)
{
static const char * const valid_cpu_types[] = {
ARM_CPU_TYPE_NAME("cortex-m4"), /* TODO: cortex-m4f */
NULL
};
DeviceClass *dc = DEVICE_CLASS(klass);
AspeedCoprocessorClass *sc = ASPEED_COPROCESSOR_CLASS(klass);
/* Reason: The Aspeed Coprocessor can only be instantiated from a board */
dc->user_creatable = false;
dc->realize = aspeed_soc_ast27x0_coprocessor_realize;
device_class_set_props(dc, aspeed_27x0_coprocessor_properties);
sc->valid_cpu_types = valid_cpu_types;
sc->irqmap = aspeed_soc_ast27x0_coprocessor_irqmap;
sc->memmap = aspeed_soc_ast27x0_coprocessor_memmap;
}static void aspeed_soc_ast27x0ssp_class_init(ObjectClass *klass,
const void *data)
{
Aspeed27x0CoprocessorClass *c = ASPEED27X0_COPROCESSOR_CLASS(klass);
c->intc_type = TYPE_ASPEED_2700SSP_INTC;
c->intcio_type = TYPE_ASPEED_2700SSP_INTCIO;
c->dram_remap_alias = ast27x0ssp_dram_remap_alias;
}static void aspeed_soc_ast27x0tsp_class_init(ObjectClass *klass,
const void *data)
{
Aspeed27x0CoprocessorClass *c = ASPEED27X0_COPROCESSOR_CLASS(klass);
c->intc_type = TYPE_ASPEED_2700TSP_INTC;
c->intcio_type = TYPE_ASPEED_2700TSP_INTCIO;
c->dram_remap_alias = ast27x0tsp_dram_remap_alias;
}static const TypeInfo aspeed_soc_ast27x0_coprocessor_types[] = {
{
.name = TYPE_ASPEED27X0_COPROCESSOR,
.parent = TYPE_ASPEED_COPROCESSOR,
.instance_size = sizeof(Aspeed27x0CoprocessorState),
.class_size = sizeof(Aspeed27x0CoprocessorClass),
.instance_init = aspeed_soc_ast27x0_coprocessor_init,
.class_init = aspeed_soc_ast27x0_coprocessor_class_init,
.abstract = true,
},
{
.name = TYPE_ASPEED27X0SSP_COPROCESSOR,
.parent = TYPE_ASPEED27X0_COPROCESSOR,
.instance_size = sizeof(Aspeed27x0CoprocessorState),
.class_init = aspeed_soc_ast27x0ssp_class_init,
},
{
.name = TYPE_ASPEED27X0TSP_COPROCESSOR,
.parent = TYPE_ASPEED27X0_COPROCESSOR,
.instance_size = sizeof(Aspeed27x0CoprocessorState),
.class_init = aspeed_soc_ast27x0tsp_class_init,
},
};
DEFINE_TYPES(aspeed_soc_ast27x0_coprocessor_types)
aspeed_coprocessor.h
/*
* ASPEED Coprocessor
*
* Copyright (C) 2025 ASPEED Technology Inc.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef ASPEED_COPROCESSOR_H
#define ASPEED_COPROCESSOR_H
#include "qom/object.h"
#include "hw/arm/aspeed_soc.h"
struct AspeedCoprocessorState {
DeviceState parent;
MemoryRegion *memory;
MemoryRegion sdram;
MemoryRegion *sram;
MemoryRegion sram_alias;
MemoryRegion uart_alias;
Clock *sysclk;
AspeedTimerCtrlState timerctrl;
SerialMM *uart;
int uart_dev;
};#define TYPE_ASPEED_COPROCESSOR "aspeed-coprocessor" OBJECT_DECLARE_TYPE(AspeedCoprocessorState, AspeedCoprocessorClass,
ASPEED_COPROCESSOR)
struct AspeedCoprocessorClass {
DeviceClass parent_class;
/** valid_cpu_types: NULL terminated array of a single CPU type. */
const char * const *valid_cpu_types;
const hwaddr *memmap;
const int *irqmap;
};struct Aspeed27x0CoprocessorState {
AspeedCoprocessorState parent;
AspeedINTCState intc[2];
UnimplementedDeviceState ipc[2];
UnimplementedDeviceState pric[2];
UnimplementedDeviceState otp;
ARMv7MState armv7m;
MemoryRegion scu_alias;
MemoryRegion scuio_alias;
MemoryRegion fmc_alias;
Aspeed2700SCUState *scu;
AspeedSCUState *scuio;
AspeedSMCState *fmc;
};/*
* TYPE_ASPEED27X0_COPROCESSOR is an abstract type shared by the SSP and TSP
* coprocessors: they use the exact same instance_init/realize logic and
* only differ in a handful of per-model constants (INTC subtype, and which
* SCU dram_remap_alias entries they map). Those constants live in
* Aspeed27x0CoprocessorClass and are set once by each concrete model's
* class_init (see aspeed_ast27x0-coprocessor.c). This is a reference/
* experimental merge of the former aspeed_ast27x0-ssp.c/-tsp.c, kept for
* comparison purposes.
*/
#define TYPE_ASPEED27X0_COPROCESSOR "aspeed27x0-coprocessor" OBJECT_DECLARE_TYPE(Aspeed27x0CoprocessorState, Aspeed27x0CoprocessorClass,
ASPEED27X0_COPROCESSOR)
struct Aspeed27x0CoprocessorClass {
AspeedCoprocessorClass parent_class;
const char *intc_type;
const char *intcio_type;
/*
* Returns this coprocessor's own SCU dram-remap-alias array (already in
* the order it should be concatenated at this coprocessor's own SDRAM
* offset 0), and stores its length in *n.
*/
MemoryRegion *(*dram_remap_alias)(Aspeed2700SCUState *scu, int *n);
};#define TYPE_ASPEED27X0SSP_COPROCESSOR "aspeed27x0ssp-coprocessor" #define TYPE_ASPEED27X0TSP_COPROCESSOR "aspeed27x0tsp-coprocessor"
#endif /* ASPEED_COPROCESSOR_H */
hw/misc/aspeed_scu.c --- a/hw/misc/aspeed_scu.c renamed from hw/misc/aspeed_scu.c +0 -0
+++ b/hw/misc/aspeed_scu.c
@@ -980,7 +980,7 @@ static void aspeed_ast2700_scu_write(void *opaque, hwaddr offset,
case AST2700_SCU_SSP_CTRL_1:
case AST2700_SCU_SSP_CTRL_2:
mr = (reg == AST2700_SCU_SSP_CTRL_1) ?
- &a->dram_remap_alias[0] : &a->dram_remap_alias[1];
+ &a->ssp_dram_remap_alias[1] : &a->ssp_dram_remap_alias[0];
if (a->ssp_cpuid < 0 || mr == NULL) {
return;
}
@@ -993,7 +993,7 @@ static void aspeed_ast2700_scu_write(void *opaque, hwaddr offset,
case AST2700_SCU_SSP_REMAP_ADDR_1:
case AST2700_SCU_SSP_REMAP_ADDR_2:
mr = (reg == AST2700_SCU_SSP_REMAP_ADDR_1) ?
- &a->dram_remap_alias[0] : &a->dram_remap_alias[1];
+ &a->ssp_dram_remap_alias[1] : &a->ssp_dram_remap_alias[0];
if (a->ssp_cpuid < 0 || mr == NULL) {
return;
}
@@ -1005,7 +1005,7 @@ static void aspeed_ast2700_scu_write(void *opaque, hwaddr offset,
case AST2700_SCU_SSP_REMAP_SIZE_1:
case AST2700_SCU_SSP_REMAP_SIZE_2:
mr = (reg == AST2700_SCU_SSP_REMAP_SIZE_1) ?
- &a->dram_remap_alias[0] : &a->dram_remap_alias[1];
+ &a->ssp_dram_remap_alias[1] : &a->ssp_dram_remap_alias[0];
if (a->ssp_cpuid < 0 || mr == NULL) {
return;
}
@@ -1015,7 +1015,7 @@ static void aspeed_ast2700_scu_write(void *opaque, hwaddr offset,
memory_region_transaction_commit();
break;
case AST2700_SCU_TSP_CTRL_1:
- mr = &a->dram_remap_alias[2];
+ mr = &a->tsp_dram_remap_alias[0];
if (a->tsp_cpuid < 0 || mr == NULL) {
return;
}
@@ -1026,7 +1026,7 @@ static void aspeed_ast2700_scu_write(void *opaque, hwaddr offset,
memory_region_transaction_commit();
break;
case AST2700_SCU_TSP_REMAP_SIZE_2:
- mr = &a->dram_remap_alias[2];
+ mr = &a->tsp_dram_remap_alias[0];
if (a->tsp_cpuid < 0 || mr == NULL) {
return;
}Hi Philippe
Quoted 78 lines
Looking at this machine in more detail, I think it would be better modelled as:
struct Ast2700FcMachineState { MachineState parent_obj; MemoryRegion dram; Aspeed2700SCUState scu; Aspeed27x0SoCState psp; MemoryRegion psp_memory; MemoryRegion psp_bootrom; Aspeed27x0CoprocessorState ssp; Clock *ssp_sysclk; MemoryRegion ssp_memory; Aspeed27x0CoprocessorState tsp; Clock *tsp_sysclk; MemoryRegion tsp_memory; };- dram and scu are shared within psp/ssp/tsp
(ca35_dramrenamed as generic dram)
(ca35_memoryrenamed aspsp_memory)
(ca35_boot_romrenamed aspsp_bootrom)and:
struct Aspeed27x0SoCState { AspeedSoCState parent; ARMCPU cpu[ASPEED_CPUS_NUM]; AspeedINTCState intc[ASPEED_INTC_NUM]; AspeedINTCState intcioexp[ASPEED_IOEXP_NUM]; GICv3State gic; MemoryRegion dram_empty; Aspeed2700SCUState *scu; };- scu becomes a link property
struct Ast2700FcMachineState { MachineState parent_obj; MemoryRegion dram; Aspeed2700SCUState scu; Aspeed27x0SoCState psp; MemoryRegion psp_memory; MemoryRegion psp_bootrom; Aspeed27x0CoprocessorState ssp; Clock *ssp_sysclk; MemoryRegion ssp_memory; Aspeed27x0CoprocessorState tsp; Clock *tsp_sysclk; MemoryRegion tsp_memory; };My personal style preference being:
struct Ast2700FcMachineState { MachineState parent_obj; MemoryRegion dram; Aspeed2700SCUState scu; struct { Aspeed27x0SoCState mpcore; MemoryRegion memory; MemoryRegion bootrom; } psp; struct { Aspeed27x0CoprocessorState mcu; Clock *sysclk; MemoryRegion memory;
Quoted 8 lines
} ssp;
struct {
Aspeed27x0CoprocessorState mcu;
Clock *sysclk;
MemoryRegion memory;
} tsp;
};Thanks for the suggestion. I've reworked Ast2700FCState to match your preferred nested-struct style — psp/ssp/tsp are now grouped structs (mpcore/memory/bootrom for psp, mcu/sysclk/memory for ssp and tsp), and ca35_dram is renamed to the generic dram as you suggested. Diff attached/inline below. Built and boot-tested both ast2700fc and ast2700a2-evb to confirm nothing regressed.
One part I couldn't do yet: making Aspeed27x0SoCState.scu a link property.
The blocker is hw-strap1/hw-strap2: they're property aliases created in instance_init(), pointing at the embedded scu. Both ast2700fc.c and hw/arm/aspeed.c set them right after object creation, before realize — but a link wouldn't be populated that early, so the alias would point at NULL.
hw/arm/aspeed.c isn't AST2700-specific — it's shared by every Aspeed BMC board. Fixing the timing there would touch all 24 of them (2400/2500/2600/1030/1040/2700 combined). "I do not prefer to change it to a link property."
Thanks,
Jamin
hw/arm/aspeed_ast27x0-fc.c +74 -67
@@ -34,18 +34,25 @@ static struct arm_boot_info ast2700fc_board_info = {struct Ast2700FCState {MachineState parent_obj; -MemoryRegion ca35_memory; -MemoryRegion ca35_dram; -MemoryRegion ca35_boot_rom; -MemoryRegion ssp_memory; -MemoryRegion tsp_memory; - -Clock *ssp_sysclk; -Clock *tsp_sysclk; - -Aspeed27x0SoCState ca35; -Aspeed27x0CoprocessorState ssp; -Aspeed27x0CoprocessorState tsp; +MemoryRegion dram; + +struct { +Aspeed27x0SoCState mpcore; +MemoryRegion memory; +MemoryRegion bootrom; + } psp; + +struct { +Aspeed27x0CoprocessorState mcu; +Clock *sysclk; +MemoryRegion memory; + } ssp; + +struct { +Aspeed27x0CoprocessorState mcu; +Clock *sysclk; +MemoryRegion memory; + } tsp; };#define AST2700FC_BMC_RAM_SIZE (2 * GiB)
@@ -67,23 +74,23 @@ static bool ast2700fc_ca35_init(MachineState *machine, Error **errp)DeviceState *dev =NULL ;uint64_t rom_size; -object_initialize_child (OBJECT (s),"ca35" , &s->ca35,"ast2700-a2" ); - soc =ASPEED_SOC (&s->ca35); +object_initialize_child (OBJECT (s),"ca35" , &s->psp.mpcore,"ast2700-a2" ); + soc =ASPEED_SOC (&s->psp.mpcore); sc =ASPEED_SOC_GET_CLASS (soc); -memory_region_init (&s->ca35_memory,OBJECT (&s->ca35),"ca35-memory" , +memory_region_init (&s->psp.memory,OBJECT (&s->psp.mpcore),"psp-memory" ,UINT64_MAX ); -memory_region_add_subregion (get_system_memory (),0 , &s->ca35_memory); +memory_region_add_subregion (get_system_memory (),0 , &s->psp.memory); -if (!memory_region_init_ram (&s->ca35_dram,OBJECT (&s->ca35),"ca35-dram" , +if (!memory_region_init_ram (&s->dram,OBJECT (&s->psp.mpcore),"dram" ,AST2700FC_BMC_RAM_SIZE , errp)) {return false; } -object_property_set_link (OBJECT (&s->ca35),"memory" , -OBJECT (&s->ca35_memory), &error_abort); -object_property_set_link (OBJECT (&s->ca35),"dram" ,OBJECT (&s->ca35_dram), - &error_abort); -object_property_set_int (OBJECT (&s->ca35),"ram-size" , +object_property_set_link (OBJECT (&s->psp.mpcore),"memory" , +OBJECT (&s->psp.memory), &error_abort); +object_property_set_link (OBJECT (&s->psp.mpcore),"dram" , +OBJECT (&s->dram), &error_abort); +object_property_set_int (OBJECT (&s->psp.mpcore),"ram-size" ,AST2700FC_BMC_RAM_SIZE , &error_abort);for (int i =0 ; i < sc->macs_num; i++) {
@@ -92,9 +99,9 @@ static bool ast2700fc_ca35_init(MachineState *machine, Error **errp)break ; } } -object_property_set_int (OBJECT (&s->ca35),"hw-strap1" , +object_property_set_int (OBJECT (&s->psp.mpcore),"hw-strap1" ,AST2700FC_HW_STRAP1 , &error_abort); -object_property_set_int (OBJECT (&s->ca35),"hw-strap2" , +object_property_set_int (OBJECT (&s->psp.mpcore),"hw-strap2" ,AST2700FC_HW_STRAP2 , &error_abort);aspeed_soc_uart_set_chr (soc->uart,ASPEED_DEV_UART12 , sc->uarts_base, sc->uarts_num,serial_hd (0 ));
@@ -102,7 +109,7 @@ static bool ast2700fc_ca35_init(MachineState *machine, Error **errp) sc->uarts_num, serial_hd(1));aspeed_soc_uart_set_chr (soc->uart,ASPEED_DEV_UART7 , sc->uarts_base, sc->uarts_num,serial_hd (2 )); -if (!qdev_realize (DEVICE (&s->ca35),NULL , errp)) { +if (!qdev_realize (DEVICE (&s->psp.mpcore),NULL , errp)) {return false; }
@@ -122,7 +129,7 @@ static bool ast2700fc_ca35_init(MachineState *machine, Error **errp)if (fmc0) { rom_size =memory_region_size (&soc->spi_boot); -aspeed_install_boot_rom (soc, fmc0, &s->ca35_boot_rom, rom_size); +aspeed_install_boot_rom (soc, fmc0, &s->psp.bootrom, rom_size); }/* VBOOTROM */
@@ -134,68 +141,68 @@ static bool ast2700fc_ca35_init(MachineState *machine, Error **errp)return true; } -static bool ast2700fc_ssp_init (Ast2700FCState *s,AspeedSoCState *psp, +static bool ast2700fc_ssp_init (Ast2700FCState *s,AspeedSoCState *soc,Error **errp) { - s->ssp_sysclk =clock_new (OBJECT (s),"SSP_SYSCLK" ); -clock_set_hz (s->ssp_sysclk,200000000ULL ); + s->ssp.sysclk =clock_new (OBJECT (s),"SSP_SYSCLK" ); +clock_set_hz (s->ssp.sysclk,200000000ULL ); -object_initialize_child (OBJECT (s),"ssp" , &s->ssp, +object_initialize_child (OBJECT (s),"ssp" , &s->ssp.mcu,TYPE_ASPEED27X0SSP_COPROCESSOR ); -memory_region_init (&s->ssp_memory,OBJECT (&s->ssp),"ssp-memory" , +memory_region_init (&s->ssp.memory,OBJECT (&s->ssp.mcu),"ssp-memory" ,UINT64_MAX ); -qdev_connect_clock_in (DEVICE (&s->ssp),"sysclk" , s->ssp_sysclk); -object_property_set_link (OBJECT (&s->ssp),"memory" , -OBJECT (&s->ssp_memory), &error_abort); +qdev_connect_clock_in (DEVICE (&s->ssp.mcu),"sysclk" , s->ssp.sysclk); +object_property_set_link (OBJECT (&s->ssp.mcu),"memory" , +OBJECT (&s->ssp.memory), &error_abort); -object_property_set_link (OBJECT (&s->ssp),"uart" , -OBJECT (&psp->uart[4 ]), &error_abort); -object_property_set_int (OBJECT (&s->ssp),"uart-dev" ,ASPEED_DEV_UART4 , +object_property_set_link (OBJECT (&s->ssp.mcu),"uart" , +OBJECT (&soc->uart[4 ]), &error_abort); +object_property_set_int (OBJECT (&s->ssp.mcu),"uart-dev" ,ASPEED_DEV_UART4 , &error_abort); -object_property_set_link (OBJECT (&s->ssp),"sram" , -OBJECT (&psp->sram), &error_abort); -object_property_set_link (OBJECT (&s->ssp),"scu" , -OBJECT (&s->ca35.scu), &error_abort); -object_property_set_link (OBJECT (&s->ssp),"scuio" , -OBJECT (&psp->scuio), &error_abort); -object_property_set_link (OBJECT (&s->ssp),"fmc" , -OBJECT (&psp->fmc), &error_abort); -if (!qdev_realize (DEVICE (&s->ssp),NULL , errp)) { +object_property_set_link (OBJECT (&s->ssp.mcu),"sram" , +OBJECT (&soc->sram), &error_abort); +object_property_set_link (OBJECT (&s->ssp.mcu),"scu" , +OBJECT (&s->psp.mpcore.scu), &error_abort); +object_property_set_link (OBJECT (&s->ssp.mcu),"scuio" , +OBJECT (&soc->scuio), &error_abort); +object_property_set_link (OBJECT (&s->ssp.mcu),"fmc" , +OBJECT (&soc->fmc), &error_abort); +if (!qdev_realize (DEVICE (&s->ssp.mcu),NULL , errp)) {return false; }return true; } -static bool ast2700fc_tsp_init (Ast2700FCState *s,AspeedSoCState *psp, +static bool ast2700fc_tsp_init (Ast2700FCState *s,AspeedSoCState *soc,Error **errp) { - s->tsp_sysclk =clock_new (OBJECT (s),"TSP_SYSCLK" ); -clock_set_hz (s->tsp_sysclk,200000000ULL ); + s->tsp.sysclk =clock_new (OBJECT (s),"TSP_SYSCLK" ); +clock_set_hz (s->tsp.sysclk,200000000ULL ); -object_initialize_child (OBJECT (s),"tsp" , &s->tsp, +object_initialize_child (OBJECT (s),"tsp" , &s->tsp.mcu,TYPE_ASPEED27X0TSP_COPROCESSOR ); -memory_region_init (&s->tsp_memory,OBJECT (&s->tsp),"tsp-memory" , +memory_region_init (&s->tsp.memory,OBJECT (&s->tsp.mcu),"tsp-memory" ,UINT64_MAX ); -qdev_connect_clock_in (DEVICE (&s->tsp),"sysclk" , s->tsp_sysclk); -object_property_set_link (OBJECT (&s->tsp),"memory" , -OBJECT (&s->tsp_memory), &error_abort); +qdev_connect_clock_in (DEVICE (&s->tsp.mcu),"sysclk" , s->tsp.sysclk); +object_property_set_link (OBJECT (&s->tsp.mcu),"memory" , +OBJECT (&s->tsp.memory), &error_abort); -object_property_set_link (OBJECT (&s->tsp),"uart" , -OBJECT (&psp->uart[7 ]), &error_abort); -object_property_set_int (OBJECT (&s->tsp),"uart-dev" ,ASPEED_DEV_UART7 , +object_property_set_link (OBJECT (&s->tsp.mcu),"uart" , +OBJECT (&soc->uart[7 ]), &error_abort); +object_property_set_int (OBJECT (&s->tsp.mcu),"uart-dev" ,ASPEED_DEV_UART7 , &error_abort); -object_property_set_link (OBJECT (&s->tsp),"sram" , -OBJECT (&psp->sram), &error_abort); -object_property_set_link (OBJECT (&s->tsp),"scu" , -OBJECT (&s->ca35.scu), &error_abort); -object_property_set_link (OBJECT (&s->tsp),"scuio" , -OBJECT (&psp->scuio), &error_abort); -object_property_set_link (OBJECT (&s->tsp),"fmc" , -OBJECT (&psp->fmc), &error_abort); -if (!qdev_realize (DEVICE (&s->tsp),NULL , errp)) { +object_property_set_link (OBJECT (&s->tsp.mcu),"sram" , +OBJECT (&soc->sram), &error_abort); +object_property_set_link (OBJECT (&s->tsp.mcu),"scu" , +OBJECT (&s->psp.mpcore.scu), &error_abort); +object_property_set_link (OBJECT (&s->tsp.mcu),"scuio" , +OBJECT (&soc->scuio), &error_abort); +object_property_set_link (OBJECT (&s->tsp.mcu),"fmc" , +OBJECT (&soc->fmc), &error_abort); +if (!qdev_realize (DEVICE (&s->tsp.mcu),NULL , errp)) {return false; }
@@ -214,7 +221,7 @@ static void ast2700fc_init(MachineState *machine)* SRAM, SCU and SCUIO. Therefore the PSP SoC must be realized * before the coprocessors are initialized. */ - psp =ASPEED_SOC (&s->ca35); + psp =ASPEED_SOC (&s->psp.mpcore);ast2700fc_ssp_init (s, psp, &error_abort);ast2700fc_tsp_init (s, psp, &error_abort); }
Quoted 130 lines · Jamin Lin
Hi Philippe
Quoted 78 lines
Looking at this machine in more detail, I think it would be better modelled as:
struct Ast2700FcMachineState { MachineState parent_obj; MemoryRegion dram; Aspeed2700SCUState scu; Aspeed27x0SoCState psp; MemoryRegion psp_memory; MemoryRegion psp_bootrom; Aspeed27x0CoprocessorState ssp; Clock *ssp_sysclk; MemoryRegion ssp_memory; Aspeed27x0CoprocessorState tsp; Clock *tsp_sysclk; MemoryRegion tsp_memory; };- dram and scu are shared within psp/ssp/tsp
(ca35_dramrenamed as generic dram)
(ca35_memoryrenamed aspsp_memory)
(ca35_boot_romrenamed aspsp_bootrom)and:
struct Aspeed27x0SoCState { AspeedSoCState parent; ARMCPU cpu[ASPEED_CPUS_NUM]; AspeedINTCState intc[ASPEED_INTC_NUM]; AspeedINTCState intcioexp[ASPEED_IOEXP_NUM]; GICv3State gic; MemoryRegion dram_empty; Aspeed2700SCUState *scu; };- scu becomes a link property
struct Ast2700FcMachineState { MachineState parent_obj; MemoryRegion dram; Aspeed2700SCUState scu; Aspeed27x0SoCState psp; MemoryRegion psp_memory; MemoryRegion psp_bootrom; Aspeed27x0CoprocessorState ssp; Clock *ssp_sysclk; MemoryRegion ssp_memory; Aspeed27x0CoprocessorState tsp; Clock *tsp_sysclk; MemoryRegion tsp_memory; };My personal style preference being:
struct Ast2700FcMachineState { MachineState parent_obj; MemoryRegion dram; Aspeed2700SCUState scu; struct { Aspeed27x0SoCState mpcore; MemoryRegion memory; MemoryRegion bootrom; } psp; struct { Aspeed27x0CoprocessorState mcu; Clock *sysclk; MemoryRegion memory;Quoted 8 lines
} ssp; struct { Aspeed27x0CoprocessorState mcu; Clock *sysclk; MemoryRegion memory; } tsp; };Thanks for the suggestion. I've reworked Ast2700FCState to match your preferred nested-struct style — psp/ssp/tsp are now grouped structs (mpcore/memory/bootrom for psp, mcu/sysclk/memory for ssp and tsp), and
ca35_dramis renamed to the generic dram as you suggested. Diff attached/inline below. Built and boot-tested both ast2700fc and ast2700a2-evb to confirm nothing regressed.One part I couldn't do yet: making Aspeed27x0SoCState.scu a link property.
The blocker is hw-strap1/hw-strap2: they're property aliases created in
instance_init(), pointing at the embedded scu. Bothast2700fc.candhw/arm/aspeed.cset them right after object creation, before realize — but a link wouldn't be populated that early, so the alias would point at NULL.
hw/arm/aspeed.cisn't AST2700-specific — it's shared by every Aspeed BMC board. Fixing the timing there would touch all 24 of them (2400/2500/2600/1030/1040/2700 combined). "I do not prefer to change it to a link property."Thanks,
Jaminhw/arm/aspeed_ast27x0-fc.c +9
-12@@ -34,18 +34,25 @@ static struct arm_boot_info ast2700fc_board_info = {struct Ast2700FCState {MachineState parent_obj; -MemoryRegion ca35_memory; -MemoryRegion ca35_dram; -MemoryRegion ca35_boot_rom; -MemoryRegion ssp_memory; -MemoryRegion tsp_memory; - -Clock *ssp_sysclk; -Clock *tsp_sysclk; - -Aspeed27x0SoCState ca35; -Aspeed27x0CoprocessorState ssp; -Aspeed27x0CoprocessorState tsp; +MemoryRegion dram; + +struct { +Aspeed27x0SoCState mpcore; +MemoryRegion memory; +MemoryRegion bootrom; + } psp; + +struct {
hw/arm/aspeed_ast27x0-fc.c static struct arm_boot_info ast2700fc_board_info = { · line 55
Quoted 10 lines
hw/arm/aspeed_ast27x0-fc.c +10
-0+Aspeed27x0CoprocessorState mcu; +Clock *sysclk; +MemoryRegion memory; + } ssp; + +struct { +Aspeed27x0CoprocessorState mcu; +Clock *sysclk; +MemoryRegion memory; + } tsp;
I prefer the current version which reflects "a bit" better the topology with the QOM tree. This is just personal test, plus the intuition that Aspeed27x0CoprocessorState could grow.
Thanks,
C.
Re: [PATCH v2 8/8] hw/ssi/aspeed_smc: Add Data FIFO-based flash access support for AST2700
In reply to Jamin LinQuoted 77 lines · Jamin Lin
Hi Cédric
Quoted 22 lines
Subject: Re: [PATCH v2 8/8] hw/ssi/aspeed_smc: Add Data FIFO-based flash access support for AST2700
Quoted 10 lines · Jamin Lin
AST2700 supports a Data FIFO mode where flash accesses can be performed directly through Data FIFO MMIO offsets. The Data FIFO start offset increments by one for every 16MB of flash address space, allowing the chip select (CS) to be decoded from the Data FIFO offset.
This change adds Data FIFO support to the Aspeed SMC model and introduces a class callback to translate Data FIFO offsets into CS indices. For AST2700, the Data FIFO offset is matched against the segment start address of each CS to determine the target flash device.
Quoted 8 lines
The SMC register region size (nregs) is also extended dynamically based on the number of supported chip selects to cover all possible Data FIFO regions.
Signed-off-by Jamin Lin <[email protected]>--- include/hw/ssi/aspeed_smc.h | 3 +- hw/ssi/aspeed_smc.c | 113Quoted 6 lines
+++++++++++++++++++++++++++++++++---
Quoted 1 line
2 files changed, 107 insertions(+), 9 deletions(-)I am looking for a way to test "Data FIFO-based flash access". A qtest extension of the ast2700 smc test would be nice to have.
Will do.
Quoted 2 lines
Is the latest SDK kernel using this feature ?
Yes. Please try the following pre-built image:
https://github.com/AspeedTech-BMC/openbmc/releases/download/v11.02/ast2700-irot-obmc.tar.gzThe image-bmc file in the archive is smaller than 128 MB. Since the QEMU FMC flash model expects a 128 MB flash device, please resize it before using it:
jamin@JaminLin-PC:~/qemu-work/debug-qemu-ssp-review/ast2700-irot$ truncate --size 128M image-bmcThis pre-built image boots both the PSP and SSP.
After the system boots, log in to the Zephyr shell running on the SSP and use the following command to read the contents of the FMC CS0 flash:
ssp:~$ flash read fmc@0 0 100 00000000: 46 4c 53 48 01 00 11 00 aa 26 87 00 f9 64 80 79 |FLSH.... .&...d.y| 00000010: 01 00 00 00 dc 00 00 00 74 a6 01 00 02 00 00 00 |........ t.......| 00000020: 50 a7 01 00 84 3e 00 00 03 00 00 00 d4 e5 01 00 |P....>.. ........| 00000030: 60 ce 02 00 00 10 00 00 34 b4 04 00 d8 77 00 00 |`....... 4....w..| 00000040: 01 10 00 00 0c 2c 05 00 00 00 01 00 02 10 00 00 |.....,.. ........| 00000050: 0c 2c 06 00 b8 74 00 00 03 10 00 00 c4 a0 06 00 |.,...t.. ........| 00000060: 00 00 01 00 04 10 00 00 c4 a0 07 00 54 cf 00 00 |........ ....T...| 00000070: 05 10 00 00 18 70 08 00 00 00 01 00 06 10 00 00 |.....p.. ........| 00000080: 18 70 09 00 00 40 00 00 07 10 00 00 18 b0 09 00 |.p...@.. ........| 00000090: 00 a0 00 00 08 10 00 00 18 50 0a 00 6c 70 00 00 |........ .P..lp..| 000000A0: 09 10 00 00 84 c0 0a 00 90 ac 06 00 0a 10 00 00 |........ ........| 000000B0: 14 6d 11 00 58 82 0d 00 0b 10 00 00 6c ef 1e 00 |.m..X... ....l...| 000000C0: 6c 3e 03 00 0c 10 00 00 d8 2d 22 00 00 00 00 00 |l>...... .-".....| 000000D0: 0d 10 00 00 d8 2d 22 00 34 99 75 03 43 4d 41 4e |.....-". 4.u.CMAN| 000000E0: fc 16 00 00 5f 19 49 fc a6 6a 8d 66 e6 26 80 87 |...._.I. .j.f.&..| 000000F0: e3 f0 48 2a 3b 01 b0 63 fe cf 0a a3 20 56 f1 62 |..H*;..c .... V.b|You can then compare it with the beginning of the image-bmc file on the host:
jamin@JaminLin-PC:~/qemu-work/debug-qemu-ssp-review/ast2700-irot$ xxd image-bmc | head 00000000: 464c 5348 0100 1100 aa26 8700 f964 8079 FLSH.....&...d.y 00000010: 0100 0000 dc00 0000 74a6 0100 0200 0000 ........t....... 00000020: 50a7 0100 843e 0000 0300 0000 d4e5 0100 P....>.......... 00000030: 60ce 0200 0010 0000 34b4 0400 d877 0000 `.......4....w.. 00000040: 0110 0000 0c2c 0500 0000 0100 0210 0000 .....,.......... 00000050: 0c2c 0600 b874 0000 0310 0000 c4a0 0600 .,...t.......... 00000060: 0000 0100 0410 0000 c4a0 0700 54cf 0000 ............T... 00000070: 0510 0000 1870 0800 0000 0100 0610 0000 .....p.......... 00000080: 1870 0900 0040 0000 0710 0000 18b0 0900 .p...@.......... 00000090: 00a0 0000 0810 0000 1850 0a00 6c70 0000 .........P..lp..
Quoted 1 line
The contents read from the emulated flash should match the corresponding data in image-bmc
I trust you will add a test case for Data FIFO-based flash access support in a follow up patch.
Thanks,
C.
Re: [PATCH v2 3/8] hw/arm/aspeed_ast27x0: Move SCU link into AST27x0 coprocessors
In reply to Jamin LinQuoted 37 lines · Jamin Lin
The SCU link is only needed by the AST27x0 SSP/TSP coprocessors for their AST2700-specific SCU alias window.
Move the link property from the common AspeedCoprocessorState into Aspeed27x0CoprocessorState, so the generic coprocessor model no longer contains an AST2700-specific dependency.
Also validate that the SCU link has been provided during device realize before accessing it.
No functional change.
Signed-off-by Jamin Lin <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/arm/aspeed_coprocessor.h | 5 +++-- hw/arm/aspeed_ast27x0-ssp.c | 20 ++++++++++++++++---- hw/arm/aspeed_ast27x0-tsp.c | 20 ++++++++++++++++---- hw/arm/aspeed_coprocessor_common.c | 2 -- 4 files changed, 35 insertions(+), 12 deletions(-)include/hw/arm/aspeed_coprocessor.h +0
-2@@ -20,10 +20,8 @@ struct AspeedCoprocessorState {MemoryRegion *sram;MemoryRegion sram_alias;MemoryRegion uart_alias; -MemoryRegion scu_alias;Clock *sysclk; -AspeedSCUState *scu;AspeedSCUState scuio;AspeedTimerCtrlState timerctrl;SerialMM *uart;
include/hw/arm/aspeed_coprocessor.h struct Aspeed27x0CoprocessorState { · line 53
Quoted 4 lines
include/hw/arm/aspeed_coprocessor.h +0
-0@@ -52,6 +50,9 @@ struct Aspeed27x0CoprocessorState {UnimplementedDeviceState otp;ARMv7MState armv7m;
If you resend, or in a following series, please add a comment saying that the fields below are shared with the main SoC.
Quoted 124 lines
include/hw/arm/aspeed_coprocessor.h +2
-0+MemoryRegion scu_alias; +Aspeed2700SCUState *scu; };#define TYPE_ASPEED27X0SSP_COPROCESSOR "aspeed27x0ssp-coprocessor"hw/arm/aspeed_ast27x0-ssp.c +16
-4@@ -167,6 +167,12 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)return ; } +if (!a->scu) { +error_setg (errp,TYPE_ASPEED27X0SSP_COPROCESSOR +": 'scu' link is not set" ); +return ; + } +/* AST27X0 SSP Core */ armv7m =DEVICE (&a->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,256 );@@ -195,11 +201,11 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp) &s->sram_alias);/* SCU */ -memory_region_init_alias (&s->scu_alias,OBJECT (s),"scu.alias" , - &s->scu->iomem,0 , -memory_region_size (&s->scu->iomem)); +memory_region_init_alias (&a->scu_alias,OBJECT (a),"scu.alias" , + &a->scu->parent_obj.iomem,0 , +memory_region_size (&a->scu->parent_obj.iomem));memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_SCU ], - &s->scu_alias); + &a->scu_alias);/* INTC */ if (!sysbus_realize (SYS_BUS_DEVICE (&a->intc[0 ]), errp)) {@@ -275,6 +281,11 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp) sc->memmap[ASPEED_DEV_OTP], 0x800); } +static const Property aspeed_27x0_coprocessor_properties[] = { +DEFINE_PROP_LINK ("scu" , Aspeed27x0CoprocessorState, scu, + TYPE_ASPEED_2700_SCU, Aspeed2700SCUState *), +}; +static void aspeed_soc_ast27x0ssp_class_init (ObjectClass *klass,const void *data) {@@ -288,6 +299,7 @@ static void aspeed_soc_ast27x0ssp_class_init(ObjectClass *klass,/* Reason: The Aspeed Coprocessor can only be instantiated from a board */ dc->user_creatable = false; dc->realize = aspeed_soc_ast27x0ssp_realize; +device_class_set_props (dc, aspeed_27x0_coprocessor_properties); sc->valid_cpu_types = valid_cpu_types; sc->irqmap = aspeed_soc_ast27x0ssp_irqmap;hw/arm/aspeed_ast27x0-tsp.c +16
-4@@ -167,6 +167,12 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)return ; } +if (!a->scu) { +error_setg (errp,TYPE_ASPEED27X0TSP_COPROCESSOR +": 'scu' link is not set" ); +return ; + } +/* AST27X0 TSP Core */ armv7m =DEVICE (&a->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,256 );@@ -195,11 +201,11 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp) &s->sram_alias);/* SCU */ -memory_region_init_alias (&s->scu_alias,OBJECT (s),"scu.alias" , - &s->scu->iomem,0 , -memory_region_size (&s->scu->iomem)); +memory_region_init_alias (&a->scu_alias,OBJECT (a),"scu.alias" , + &a->scu->parent_obj.iomem,0 , +memory_region_size (&a->scu->parent_obj.iomem));memory_region_add_subregion (s->memory, sc->memmap[ASPEED_DEV_SCU ], - &s->scu_alias); + &a->scu_alias);/* INTC */ if (!sysbus_realize (SYS_BUS_DEVICE (&a->intc[0 ]), errp)) {@@ -275,6 +281,11 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp) sc->memmap[ASPEED_DEV_OTP], 0x800); } +static const Property aspeed_27x0_coprocessor_properties[] = { +DEFINE_PROP_LINK ("scu" , Aspeed27x0CoprocessorState, scu, + TYPE_ASPEED_2700_SCU, Aspeed2700SCUState *), +}; +static void aspeed_soc_ast27x0tsp_class_init (ObjectClass *klass,const void *data) {@@ -288,6 +299,7 @@ static void aspeed_soc_ast27x0tsp_class_init(ObjectClass *klass,/* Reason: The Aspeed Coprocessor can only be instantiated from a board */ dc->user_creatable = false; dc->realize = aspeed_soc_ast27x0tsp_realize; +device_class_set_props (dc, aspeed_27x0_coprocessor_properties); sc->valid_cpu_types = valid_cpu_types; sc->irqmap = aspeed_soc_ast27x0tsp_irqmap;hw/arm/aspeed_coprocessor_common.c +0
-2@@ -27,8 +27,6 @@ static const Property aspeed_coprocessor_properties[] = { TYPE_MEMORY_REGION, MemoryRegion *),DEFINE_PROP_LINK ("sram" , AspeedCoprocessorState, sram,TYPE_MEMORY_REGION , MemoryRegion *), -DEFINE_PROP_LINK ("scu" , AspeedCoprocessorState, scu,TYPE_ASPEED_SCU , - AspeedSCUState *),DEFINE_PROP_LINK ("uart" , AspeedCoprocessorState, uart,TYPE_SERIAL_MM , SerialMM *), DEFINE_PROP_INT32("uart-dev", AspeedCoprocessorState, uart_dev, 0),
Re: [PATCH v2 8/8] hw/ssi/aspeed_smc: Add Data FIFO-based flash access support for AST2700
In reply to Jamin LinQuoted 25 lines · Jamin Lin
AST2700 supports a Data FIFO mode where flash accesses can be performed directly through Data FIFO MMIO offsets. The Data FIFO start offset increments by one for every 16MB of flash address space, allowing the chip select (CS) to be decoded from the Data FIFO offset.
This change adds Data FIFO support to the Aspeed SMC model and introduces a class callback to translate Data FIFO offsets into CS indices. For AST2700, the Data FIFO offset is matched against the segment start address of each CS to determine the target flash device.
The SMC register region size (nregs) is also extended dynamically based on the number of supported chip selects to cover all possible Data FIFO regions.
Signed-off-by Jamin Lin <[email protected]>--- include/hw/ssi/aspeed_smc.h | 3 +- hw/ssi/aspeed_smc.c | 113 +++++++++++++++++++++++++++++++++--- 2 files changed, 107 insertions(+), 9 deletions(-)include/hw/ssi/aspeed_smc.h +0
-0
include/hw/ssi/aspeed_smc.h struct AspeedSMCFlash { · line 50
Quoted 5 lines
include/hw/ssi/aspeed_smc.h +1
-1@@ -47,7 +47,7 @@ struct AspeedSMCFlash {#define TYPE_ASPEED_SMC "aspeed.smc" OBJECT_DECLARE_TYPE(AspeedSMCState, AspeedSMCClass, ASPEED_SMC) -#define ASPEED_SMC_R_MAX (0x100 / 4) +#define ASPEED_SMC_R_MAX (0x300 / 4)
This array increase always requires a commit log comment saying that migration compatibility is broken, may be a version bump too, even if we know that migration is *not* officially supported. Minor.
Thanks,
C.
Quoted 236 lines
include/hw/ssi/aspeed_smc.h +1
-0#define ASPEED_SMC_CS_MAX 5struct AspeedSMCState {@@ -116,6 +116,7 @@ struct AspeedSMCClass { AspeedSegments *seg);void (*dma_ctrl)(AspeedSMCState *s,uint32_t value);int (*addr_width)(const AspeedSMCState *s); +int (*data_fifo_offset_to_cs)(const AspeedSMCState *s,uint32_t offset);const MemoryRegionOps *reg_ops; };hw/ssi/aspeed_smc.c +105
-8@@ -163,6 +163,9 @@/* Read Timing Compensation Register */ #define R_TIMINGS (0x94 / 4) +/* Data fifo */ +#define R_DATA_FIFO (0x200 / 4) +/* SPI controller registers and bits (AST2400) */ #define R_SPI_CONF (0x00 / 4)#define SPI_CONF_ENABLE_W0 0@@ -212,6 +215,7 @@ static const AspeedSegments aspeed_2500_spi2_segments[];#define ASPEED_SMC_FEATURE_DMA_GRANT 0x2#define ASPEED_SMC_FEATURE_WDT_CONTROL 0x4#define ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH 0x08 +#define ASPEED_SMC_FEATURE_DATA_FIFO 0x10static inline bool aspeed_smc_has_dma (const AspeedSMCClass *asc) {@@ -228,6 +232,11 @@ static inline bool aspeed_smc_has_dma64(const AspeedSMCClass *asc)return !!(asc->features &ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH ); } +static inline bool aspeed_smc_has_data_fifo (const AspeedSMCClass *asc) +{ +return !!(asc->features &ASPEED_SMC_FEATURE_DATA_FIFO ); +} +#define aspeed_smc_error (fmt, ...) \ qemu_log_mask(LOG_GUEST_ERROR, "%s: " fmt "\n", __func__, ## __VA_ARGS__)@@ -764,6 +773,7 @@ static MemTxResult aspeed_smc_read(void *opaque, hwaddr addr, uint64_t *data, {AspeedSMCState *s =ASPEED_SMC (opaque);AspeedSMCClass *asc =ASPEED_SMC_GET_CLASS (opaque); +int cs; addr >>=2 ;@@ -789,6 +799,18 @@ static MemTxResult aspeed_smc_read(void *opaque, hwaddr addr, uint64_t *data,trace_aspeed_smc_read (addr <<2 , size, s->regs[addr]); *data = s->regs[addr]; + }else if (aspeed_smc_has_data_fifo (asc) && addr >=R_DATA_FIFO ) { + cs = asc->data_fifo_offset_to_cs (s, addr <<2 ); +if (cs >=0 ) { +/* +* Data fifo mode only supports SPI user mode. +* The flash address is provided by the SPI command/address cycles, +* the MMIO addr parameter is ignored. +*/ +return aspeed_smc_flash_read (&s->flashes[cs],0 , data, size, attrs); + } +aspeed_smc_error ("Invalid data fifo offset %" HWADDR_PRIx, addr <<2 ); +return MEMTX_ERROR ; }else {qemu_log_mask (LOG_UNIMP ,"%s: not implemented: 0x%" HWADDR_PRIx"\n" , __func__, addr);@@ -1163,6 +1185,19 @@ static MemTxResult aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data, }else if (aspeed_smc_has_dma (asc) &&aspeed_smc_has_dma64 (asc) && addr ==R_DMA_DRAM_ADDR_HIGH ) { s->regs[addr] =DMA_DRAM_ADDR_HIGH (value); + }else if (aspeed_smc_has_data_fifo (asc) && addr >=R_DATA_FIFO ) { +int cs = asc->data_fifo_offset_to_cs (s, addr <<2 ); +if (cs >=0 ) { +/* +* Data fifo mode only supports SPI user mode. +* The flash address is provided by the SPI command/address cycles, +* the MMIO addr parameter is ignored. +*/ +return aspeed_smc_flash_write (&s->flashes[cs],0 , data, size, + attrs); + } +aspeed_smc_error ("Invalid data fifo offset %" HWADDR_PRIx, addr <<2 ); +return MEMTX_ERROR ; }else {qemu_log_mask (LOG_UNIMP ,"%s: not implemented: 0x%" HWADDR_PRIx"\n" , __func__, addr);@@ -1909,6 +1944,39 @@ static void aspeed_2700_smc_reg_to_segment(const AspeedSMCState *s, } } +/* +* Convert a data fifo offset to a chip select (CS). +* +* Data fifo access starts at 0x200. The data fifo offset index is +* calculated by subtracting the data fifo base offset from the MMIO address. +* +* The data fifo offset index increments by 1 for every 16MB of flash address +* space. Each offset step therefore represents a 16MB address decode range. +* +* The CS is determined by matching the data fifo offset index against the +* segment start address of each CS. +* +* Returns the CS index on success, or -1 if the offset is invalid. +*/ +static int aspeed_2700_smc_data_fifo_offset_to_cs (const AspeedSMCState *s, +uint32_t offset) +{ +AspeedSMCClass *asc =ASPEED_SMC_GET_CLASS (s); +uint32_t start_offset; +uint32_t fifo_offset; +int i; + +for (i =0 ; i < asc->cs_num_max; i++) { + start_offset = (s->regs[R_SEG_ADDR0 + i] &0x0000ffff ) <<16 ; + fifo_offset = start_offset /0x1000000 ; +if (fifo_offset == offset - (R_DATA_FIFO <<2 )) { +return i; + } + } + +return -1 ; +} +static const uint32_t aspeed_2700_fmc_resets[ASPEED_SMC_R_MAX ] = { [R_CONF ] = (CONF_FLASH_TYPE_SPI <<CONF_FLASH_TYPE0 |CONF_FLASH_TYPE_SPI <<CONF_FLASH_TYPE1 ),@@ -1943,6 +2011,27 @@ static const AspeedSegments aspeed_2700_fmc_segments[] = { { 0x0, 0 }, /* disabled */ }; +/* +* AST2700 supports data fifo mode with a base data fifo start offset of 0x200. +* +* The data fifo start offset increments by 1 for every 16MB of flash address +* space. Each offset step therefore represents a 16MB address decode range. +* +* Assuming each chip select (CS) can use the maximum flash size of 256MB: +* 256MB / 16MB = 0x10 offset steps per CS. +* +* Data fifo start offset for CSn: +* 0x200 + (n * 0x10) +* +* Examples: +* CS0: 0x200 +* CS1: 0x210 +* CS2: 0x220 +* CS3: 0x230 +* +* asc->nregs should be set to: 0x200 + (asc->cs_num_max * 0x10) +* to cover all possible data fifo regions. +*/ static void aspeed_2700_fmc_class_init (ObjectClass *klass,const void *data) {DeviceClass *dc =DEVICE_CLASS (klass);@@ -1962,14 +2051,16 @@ static void aspeed_2700_fmc_class_init(ObjectClass *klass, const void *data) asc->flash_window_base =0x100000000 ; asc->flash_window_size =1 * GiB; asc->features =ASPEED_SMC_FEATURE_DMA | -ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH ; +ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH | +ASPEED_SMC_FEATURE_DATA_FIFO ; asc->dma_flash_mask =0x2FFFFFFC ; asc->dma_dram_mask =0xFFFFFFFC ; asc->dma_start_length =1 ; - asc->nregs =ASPEED_SMC_R_MAX ; + asc->nregs = (0x200 + (asc->cs_num_max *0x10 )) >>2 ; asc->segment_to_reg = aspeed_2700_smc_segment_to_reg; asc->reg_to_segment = aspeed_2700_smc_reg_to_segment; asc->dma_ctrl = aspeed_2600_smc_dma_ctrl; + asc->data_fifo_offset_to_cs = aspeed_2700_smc_data_fifo_offset_to_cs; asc->reg_ops = &aspeed_2700_smc_flash_ops; }@@ -1997,14 +2088,16 @@ static void aspeed_2700_spi0_class_init(ObjectClass *klass, const void *data) asc->flash_window_base =0x180000000 ; asc->flash_window_size =1 * GiB; asc->features =ASPEED_SMC_FEATURE_DMA | -ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH ; +ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH | +ASPEED_SMC_FEATURE_DATA_FIFO ; asc->dma_flash_mask =0x2FFFFFFC ; asc->dma_dram_mask =0xFFFFFFFC ; asc->dma_start_length =1 ; - asc->nregs =ASPEED_SMC_R_MAX ; + asc->nregs = (0x200 + (asc->cs_num_max *0x10 )) >>2 ; asc->segment_to_reg = aspeed_2700_smc_segment_to_reg; asc->reg_to_segment = aspeed_2700_smc_reg_to_segment; asc->dma_ctrl = aspeed_2600_smc_dma_ctrl; + asc->data_fifo_offset_to_cs = aspeed_2700_smc_data_fifo_offset_to_cs; asc->reg_ops = &aspeed_2700_smc_flash_ops; }@@ -2031,14 +2124,16 @@ static void aspeed_2700_spi1_class_init(ObjectClass *klass, const void *data) asc->flash_window_base =0x200000000 ; asc->flash_window_size =1 * GiB; asc->features =ASPEED_SMC_FEATURE_DMA | -ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH ; +ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH | +ASPEED_SMC_FEATURE_DATA_FIFO ; asc->dma_flash_mask =0x2FFFFFFC ; asc->dma_dram_mask =0xFFFFFFFC ; asc->dma_start_length =1 ; - asc->nregs =ASPEED_SMC_R_MAX ; + asc->nregs = (0x200 + (asc->cs_num_max *0x10 )) >>2 ; asc->segment_to_reg = aspeed_2700_smc_segment_to_reg; asc->reg_to_segment = aspeed_2700_smc_reg_to_segment; asc->dma_ctrl = aspeed_2600_smc_dma_ctrl; + asc->data_fifo_offset_to_cs = aspeed_2700_smc_data_fifo_offset_to_cs; asc->reg_ops = &aspeed_2700_smc_flash_ops; }@@ -2065,14 +2160,16 @@ static void aspeed_2700_spi2_class_init(ObjectClass *klass, const void *data) asc->flash_window_base =0x280000000 ; asc->flash_window_size =1 * GiB; asc->features =ASPEED_SMC_FEATURE_DMA | -ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH ; +ASPEED_SMC_FEATURE_DMA_DRAM_ADDR_HIGH | +ASPEED_SMC_FEATURE_DATA_FIFO ; asc->dma_flash_mask =0x0FFFFFFC ; asc->dma_dram_mask =0xFFFFFFFC ; asc->dma_start_length =1 ; - asc->nregs =ASPEED_SMC_R_MAX ; + asc->nregs = (0x200 + (asc->cs_num_max *0x10 )) >>2 ; asc->segment_to_reg = aspeed_2700_smc_segment_to_reg; asc->reg_to_segment = aspeed_2700_smc_reg_to_segment; asc->dma_ctrl = aspeed_2600_smc_dma_ctrl; + asc->data_fifo_offset_to_cs = aspeed_2700_smc_data_fifo_offset_to_cs; asc->reg_ops = &aspeed_2700_smc_flash_ops; }
Quoted 64 lines · Jamin Lin
The original AST2700 FC support series [1] is fairly large, making it difficult to review all changes together.
To help speed up the review process, this series extracts the SCU/FMC-related refactoring into a standalone prerequisite series.
v1:
Compared with the original series, the SCU preparation patch has been split into three smaller patches:Introduce Aspeed2700SCUState.
Convert AST1700/AST27x0 users to the new SCU subclass. Move the SCU link property into the AST27x0-specific coprocessor implementation.In addition, the SCUIO reset handling has been separated into an independent patch.
This series contains no functional changes. It is purely a refactoring to isolate AST2700-specific SCU support from the generic implementation and prepare for the subsequent AST2700 FC support.
v2:
1. Pass realized PSP SoC to SSP/TSP initialization
2. Share single SCUIO instance across PSP, SSP, and TSP
3. Share FMC controller with SSP and TSP
4. Add Data FIFO-based flash access support forThis series depends on:
https://patchwork.ozlabs.org/project/qemu-devel/cover/[email protected]/
Supersedes the following patches from the original FC support series [1]:
Patch 1:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/Patch 2:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/Patch 4:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/Patch 15:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/Patch 18:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/Patch
[1] Original AST2700 FC support series:
https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/Jamin Lin (8):
hw/misc/aspeed_scu: Introduce Aspeed2700SCUState hw/arm/aspeed: Use Aspeed2700SCUState for AST2700 users hw/arm/aspeed_ast27x0: Move SCU link into AST27x0 coprocessors hw/misc/aspeed_scu: Add separate reset handler for AST2700 SCUIO hw/arm/aspeed_ast27x0: Pass realized PSP SoC to SSP/TSP initialization hw/arm/ast27x0: Share single SCUIO instance across PSP, SSP, and TSP hw/arm/ast27x0: Share FMC controller with SSP and TSP hw/ssi/aspeed_smc: Add Data FIFO-based flash access support forAST2700
Quoted 14 lines
include/hw/arm/aspeed_ast1700.h | 2 +- include/hw/arm/aspeed_coprocessor.h | 11 ++- include/hw/arm/aspeed_soc.h | 1 + include/hw/misc/aspeed_scu.h | 5 ++ include/hw/ssi/aspeed_smc.h | 3 +- hw/arm/aspeed_ast27x0-fc.c | 38 +++++++--- hw/arm/aspeed_ast27x0-ssp.c | 56 +++++++++++--- hw/arm/aspeed_ast27x0-tsp.c | 56 +++++++++++--- hw/arm/aspeed_ast27x0.c | 16 ++-- hw/arm/aspeed_coprocessor_common.c | 2 - hw/misc/aspeed_scu.c | 20 ++++- hw/ssi/aspeed_smc.c | 113 ++++++++++++++++++++++++++-- 12 files changed, 267 insertions(+), 56 deletions(-)
Thanks,
C.
Quoted 64 lines · Jamin Lin
The original AST2700 FC support series [1] is fairly large, making it difficult to review all changes together.
To help speed up the review process, this series extracts the SCU/FMC-related refactoring into a standalone prerequisite series.
v1:
Compared with the original series, the SCU preparation patch has been split into three smaller patches:Introduce Aspeed2700SCUState.
Convert AST1700/AST27x0 users to the new SCU subclass. Move the SCU link property into the AST27x0-specific coprocessor implementation.In addition, the SCUIO reset handling has been separated into an independent patch.
This series contains no functional changes. It is purely a refactoring to isolate AST2700-specific SCU support from the generic implementation and prepare for the subsequent AST2700 FC support.
v2:
1. Pass realized PSP SoC to SSP/TSP initialization
2. Share single SCUIO instance across PSP, SSP, and TSP
3. Share FMC controller with SSP and TSP
4. Add Data FIFO-based flash access support forThis series depends on:
https://patchwork.ozlabs.org/project/qemu-devel/cover/[email protected]/
Supersedes the following patches from the original FC support series [1]:
Patch 1:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/Patch 2:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/Patch 4:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/Patch 15:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/Patch 18:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/Patch
[1] Original AST2700 FC support series:
https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/Jamin Lin (8):
hw/misc/aspeed_scu: Introduce Aspeed2700SCUState hw/arm/aspeed: Use Aspeed2700SCUState for AST2700 users hw/arm/aspeed_ast27x0: Move SCU link into AST27x0 coprocessors hw/misc/aspeed_scu: Add separate reset handler for AST2700 SCUIO hw/arm/aspeed_ast27x0: Pass realized PSP SoC to SSP/TSP initialization hw/arm/ast27x0: Share single SCUIO instance across PSP, SSP, and TSP hw/arm/ast27x0: Share FMC controller with SSP and TSP hw/ssi/aspeed_smc: Add Data FIFO-based flash access support forAST2700
Quoted 14 lines
include/hw/arm/aspeed_ast1700.h | 2 +- include/hw/arm/aspeed_coprocessor.h | 11 ++- include/hw/arm/aspeed_soc.h | 1 + include/hw/misc/aspeed_scu.h | 5 ++ include/hw/ssi/aspeed_smc.h | 3 +- hw/arm/aspeed_ast27x0-fc.c | 38 +++++++--- hw/arm/aspeed_ast27x0-ssp.c | 56 +++++++++++--- hw/arm/aspeed_ast27x0-tsp.c | 56 +++++++++++--- hw/arm/aspeed_ast27x0.c | 16 ++-- hw/arm/aspeed_coprocessor_common.c | 2 - hw/misc/aspeed_scu.c | 20 ++++- hw/ssi/aspeed_smc.c | 113 ++++++++++++++++++++++++++-- 12 files changed, 267 insertions(+), 56 deletions(-)
Applied to
https://github.com/legoater/qemu aspeed-next
Thanks,
C.