Refactor AST2700 SCU preparation for coprocessors
PATCH v3 9/9 tests/qtest/ast2700-smc-test: Add Data FIFO mode test
In reply to Jamin LinAdd two qtest cases exercising the new AST2700 Data FIFO-based flash access path (R_DATA_FIFO at spi_base + 0x200).
Write_page_datafifo sends the page-program command and data through the FIFO port, then verifies the result via the regular read path. Read_page_datafifo writes a page the regular way, then reads it back through the FIFO port, so both directions are checked independently.
--- tests/qtest/aspeed-smc-utils.h | 4 ++ tests/qtest/aspeed-smc-utils.c | 103 +++++++++++++++++++++++++++++++++ tests/qtest/ast2700-smc-test.c | 4 ++ 3 files changed, 111 insertions(+)
tests/qtest/aspeed-smc-utils.h +4 -0
@@ -33,6 +33,8 @@#define CTRL_DUMMY_LOW_SHIFT 6#define CTRL_DUMMY_HIGH_SHIFT 14#define SR_WEL BIT(1) +/* Data fifo */ +#define R_DATA_FIFO 0x200/* * Flash commands
@@ -87,5 +89,7 @@ void aspeed_smc_test_read_page_mem_dor(const void *data);void aspeed_smc_test_write_page_dor (const void *data);void aspeed_smc_test_read_page_mem_qor (const void *data);void aspeed_smc_test_write_page_qor (const void *data); +void aspeed_smc_test_write_page_datafifo (const void *data); +void aspeed_smc_test_read_page_datafifo (const void *data);#endif /* TESTS_ASPEED_SMC_UTILS_H */
tests/qtest/aspeed-smc-utils.c +103 -0
112 lines not on this page · raw message
tests/qtest/ast2700-smc-test.c +4 -0
@@ -64,6 +64,10 @@ static void test_ast2700_evb(AspeedSMCTestData *data) data, aspeed_smc_test_read_page_mem_qor);qtest_add_data_func ("/ast2700/smc/write_page_qor" , data, aspeed_smc_test_write_page_qor); +qtest_add_data_func ("/ast2700/smc/write_page_datafifo" , + data, aspeed_smc_test_write_page_datafifo); +qtest_add_data_func ("/ast2700/smc/read_page_datafifo" , + data, aspeed_smc_test_read_page_datafifo); }int main (int argc,char **argv)
Signature · 1 line
2.43.0
v3 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.
This series depends on https://github.com/legoater/qemu.git at aspeed-next branch.
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
v3:
1. Add Data FIFO mode test
2. Clarify SCU/SCUIO/FMC fields are shared with PSP SoC to AST2700
3. Bump vmstate version after ASPEED_SMC_R_MAX increase
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 (9):
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
tests/qtest/ast2700-smc-test: Add Data FIFO mode test
include/hw/arm/aspeed_ast1700.h | 2 +- include/hw/arm/aspeed_coprocessor.h | 16 +++- include/hw/arm/aspeed_soc.h | 1 + include/hw/misc/aspeed_scu.h | 5 ++ include/hw/ssi/aspeed_smc.h | 3 +- tests/qtest/aspeed-smc-utils.h | 4 + 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 | 117 +++++++++++++++++++++++++--- tests/qtest/aspeed-smc-utils.c | 103 ++++++++++++++++++++++++ tests/qtest/ast2700-smc-test.c | 4 + 15 files changed, 385 insertions(+), 58 deletions(-)
Signature · 1 line
2.43.0
PATCH v3 7/9 hw/arm/ast27x0: Share FMC controller with SSP and TSP
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.
--- include/hw/arm/aspeed_coprocessor.h | 7 +++++++ hw/arm/aspeed_ast27x0-fc.c | 4 ++++ hw/arm/aspeed_ast27x0-ssp.c | 16 ++++++++++++++++ hw/arm/aspeed_ast27x0-tsp.c | 16 ++++++++++++++++ 4 files changed, 43 insertions(+)
include/hw/arm/aspeed_coprocessor.h +7 -0
@@ -49,10 +49,17 @@ struct Aspeed27x0CoprocessorState {ARMv7MState armv7m; +/* +* SCU, SCUIO and FMC are not owned by this coprocessor: they are +* shared with the main PSP SoC, and only aliased into this +* coprocessor's own address space here. +*/ 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 v3 5/9 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 v3 2/9 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 */
@@ -934,7 +934,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 ;
@@ -1037,7 +1037,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 v3 3/9 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 | 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 v3 1/9 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 v3 8/9 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.
This breaks migration compatibility with older QEMU builds for the affected models, even though Aspeed machines are not officially covered by migration compatibility guarantees.
Bump version_id to 4 and minimum_version_id to 2 to reflect the incompatible format.
--- include/hw/ssi/aspeed_smc.h | 3 +- hw/ssi/aspeed_smc.c | 117 +++++++++++++++++++++++++++++++++--- 2 files changed, 109 insertions(+), 11 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 {
@@ -114,6 +114,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 +107 -10
219 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v3 4/9 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 v3 6/9 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
Re: [PATCH v3 9/9] tests/qtest/ast2700-smc-test: Add Data FIFO mode test
In reply to Jamin LinQuoted 8 lines · Jamin Lin
Add two qtest cases exercising the new AST2700 Data FIFO-based flash access path (
R_DATA_FIFOatspi_base+0x200).
Write_page_datafifosends the page-program command and data through the FIFO port, then verifies the result via the regular read path.Read_page_datafifowrites a page the regular way, then reads it back through the FIFO port, so both directions are checked independently.
Quoted 7 lines
Signed-off-by Jamin Lin <[email protected]>--- tests/qtest/aspeed-smc-utils.h | 4 ++ tests/qtest/aspeed-smc-utils.c | 103 +++++++++++++++++++++++++++++++++ tests/qtest/ast2700-smc-test.c | 4 ++ 3 files changed, 111 insertions(+)
This patch doesn't apply on aspeed-next.
Thanks,
C.
RE: [PATCH v3 9/9] tests/qtest/ast2700-smc-test: Add Data FIFO mode test
Quoted 16 lines
Subject: Re: [PATCH v3 9/9] tests/qtest/ast2700-smc-test: Add Data FIFO mode test
Quoted 8 lines · Jamin Lin
Add two qtest cases exercising the new AST2700 Data FIFO-based flash access path (
R_DATA_FIFOatspi_base+0x200).
Write_page_datafifosends the page-program command and data through the FIFO port, then verifies the result via the regular read path.Read_page_datafifowrites a page the regular way, then reads it back through the FIFO port, so both directions are checked independently.Quoted 4 lines
Signed-off-by Jamin Lin <[email protected]>--- tests/qtest/aspeed-smc-utils.h | 4 ++ tests/qtest/aspeed-smc-utils.c | 103
Quoted 6 lines
+++++++++++++++++++++++++++++++++
Quoted 3 lines
tests/qtest/ast2700-smc-test.c | 4 ++ 3 files changed, 111 insertions(+)This patch doesn't apply on aspeed-next.
Sorry resend v4
Jamin
Quoted 3 lines
Thanks,
C.