Refactor AST2700 SCU preparation for coprocessors
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-related refactoring into a standalone prerequisite series.
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.
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.ozlabs.org/project/qemu-devel/patch/[email protected]/
Patch 2:
https://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/
[1] Original AST2700 FC support series:
https://patchwork.ozlabs.org/project/qemu-devel/cover/[email protected]/
Jamin Lin (4):
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
include/hw/arm/aspeed_ast1700.h | 2 +- include/hw/arm/aspeed_coprocessor.h | 5 +++-- include/hw/arm/aspeed_soc.h | 1 + include/hw/misc/aspeed_scu.h | 5 +++++ hw/arm/aspeed_ast27x0-fc.c | 4 ++-- hw/arm/aspeed_ast27x0-ssp.c | 19 +++++++++++++++---- hw/arm/aspeed_ast27x0-tsp.c | 19 +++++++++++++++---- hw/arm/aspeed_ast27x0.c | 16 ++++++++-------- hw/arm/aspeed_coprocessor_common.c | 2 -- hw/misc/aspeed_scu.c | 20 ++++++++++++++++++-- 10 files changed, 68 insertions(+), 25 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/4 hw/misc/aspeed_scu: Introduce Aspeed2700SCUState
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.
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 3/4 hw/arm/aspeed_ast27x0: Move SCU link into AST27x0 coprocessors
In reply to Jamin LinThe 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 | 19 +++++++++++++++---- hw/arm/aspeed_ast27x0-tsp.c | 19 +++++++++++++++---- hw/arm/aspeed_coprocessor_common.c | 2 -- 4 files changed, 33 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 +15 -4
@@ -167,6 +167,11 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)return ; } +if (!a->scu) { +error_setg (errp,"'scu' link is not set" ); +return ; + } +/* AST27X0 SSP Core */ armv7m =DEVICE (&a->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,256 );
@@ -195,11 +200,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 +280,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 +298,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 +15 -4
@@ -167,6 +167,11 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)return ; } +if (!a->scu) { +error_setg (errp,"'scu' link is not set" ); +return ; + } +/* AST27X0 TSP Core */ armv7m =DEVICE (&a->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,256 );
@@ -195,11 +200,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 +280,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 +298,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 2/4 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
PATCH 4/4 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
Re: [PATCH v1 3/4] hw/arm/aspeed_ast27x0: Move SCU link into AST27x0 coprocessors
In reply to Jamin LinQuoted 12 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.
Quoted 7 lines
Signed-off-by Jamin Lin <[email protected]>--- include/hw/arm/aspeed_coprocessor.h | 5 +++-- hw/arm/aspeed_ast27x0-ssp.c | 19 +++++++++++++++---- hw/arm/aspeed_ast27x0-tsp.c | 19 +++++++++++++++---- hw/arm/aspeed_coprocessor_common.c | 2 -- 4 files changed, 33 insertions(+), 12 deletions(-)
Sorry
I will resend v2 due to split [1] Original AST2700 FC support series
Quoted 62 lines
Subject: [PATCH v1 0/4] 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-related refactoring into a standalone prerequisite series.
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.
This series depends on:
https://patchwork.ozlabs.org/project/qemu-devel/cover/20260706052701.114
[email protected]/Supersedes the following patches from the original FC support series [1]:
Patch 1:
https://patchwork.ozlabs.org/project/qemu-devel/patch/20260417032837.266
[email protected]/Patch 2:
https://patchwork.ozlabs.org/project/qemu-devel/patch/20260417032837.266
[email protected]/[1] Original AST2700 FC support series:
https://patchwork.ozlabs.org/project/qemu-devel/cover/20260417032837.266
[email protected]/Jamin Lin (4):
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 SCUIOinclude/hw/arm/aspeed_ast1700.h | 2 +- include/hw/arm/aspeed_coprocessor.h | 5 +++-- include/hw/arm/aspeed_soc.h | 1 + include/hw/misc/aspeed_scu.h | 5 +++++ hw/arm/aspeed_ast27x0-fc.c | 4 ++-- hw/arm/aspeed_ast27x0-ssp.c | 19 +++++++++++++++---- hw/arm/aspeed_ast27x0-tsp.c | 19 +++++++++++++++---- hw/arm/aspeed_ast27x0.c | 16 ++++++++-------- hw/arm/aspeed_coprocessor_common.c | 2 -- hw/misc/aspeed_scu.c | 20 ++++++++++++++++++-- 10 files changed, 68 insertions(+), 25 deletions(-)--
2.43.0