aspeed queue
Subsystems (2)
The following changes since commit a95260486aa7e78d7c7194eba65cf03311ad94ad:
Merge tag 'pull-tcg-20231023' of https://gitlab.com/rth7680/qemu into staging (2023-10-23 14:45:46 -0700)
are available in the Git repository at:
https://github.com/legoater/qemu/ tags/pull-aspeed-20231025
for you to fetch changes up to dd41ce7a6f13ad4f45ebaf52b9fa91fe5fc961df:
hw/arm/aspeed: Move AspeedSoCState::cpu/vic to Aspeed2400SoCState (2023-10-25 09:52:44 +0200)
----------------------------------------------------------------
aspeed queue:
* Update of Andrew's email
* Split of AspeedSoCState per 2400/2600/10x0
----------------------------------------------------------------
Andrew Jeffery (1):
MAINTAINERS: aspeed: Update Andrew's email address
Philippe Mathieu-Daudé (11):
hw/arm/aspeed: Extract code common to all boards to a common file hw/arm/aspeed: Rename aspeed_soc_init() as AST2400/2500 specific hw/arm/aspeed: Rename aspeed_soc_realize() as AST2400/2500 specific hw/arm/aspeed: Dynamically allocate AspeedMachineState::soc field hw/arm/aspeed: Introduce TYPE_ASPEED10X0_SOC hw/arm/aspeed: Introduce TYPE_ASPEED2600_SOC hw/arm/aspeed: Introduce TYPE_ASPEED2400_SOC hw/arm/aspeed: Check 'memory' link is set in common aspeed_soc_realize hw/arm/aspeed: Move AspeedSoCState::armv7m to Aspeed10x0SoCState hw/arm/aspeed: Move AspeedSoCState::a7mpcore to Aspeed2600SoCState hw/arm/aspeed: Move AspeedSoCState::cpu/vic to Aspeed2400SoCState
MAINTAINERS | 2 +-
include/hw/arm/aspeed_soc.h | 35 +++++-
hw/arm/aspeed.c | 101 +++++++--------
hw/arm/aspeed_ast10x0.c | 53 ++++----
hw/arm/{aspeed_soc.c => aspeed_ast2400.c} | 197 +++++++-----------------------
hw/arm/aspeed_ast2600.c | 75 ++++++------
hw/arm/aspeed_soc_common.c | 154 +++++++++++++++++++++++
hw/arm/fby35.c | 27 ++--
hw/arm/meson.build | 3 +-
9 files changed, 363 insertions(+), 284 deletions(-)
rename hw/arm/{aspeed_soc.c => aspeed_ast2400.c} (76%)
create mode 100644 hw/arm/aspeed_soc_common.c[PULL 01/12] MAINTAINERS: aspeed: Update Andrew's email address
From: Andrew Jeffery <[email protected]>
I've changed employers, have company email that deals with patch-based workflows without too much of a headache, and am trying to steer some content out of my personal mail.
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -1131,7 +1131,7 @@ F: docs/system/arm/emcraft-sf2.rst ASPEED BMCs M: Cédric Le Goater <[email protected]> M: Peter Maydell <[email protected]> -R: Andrew Jeffery <[email protected]> +R: Andrew Jeffery <[email protected]> R: Joel Stanley <[email protected]> L: [email protected] S: Maintained
Signature · 1 line
2.41.0
[PULL 07/12] hw/arm/aspeed: Introduce TYPE_ASPEED2600_SOC
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
TYPE_ASPEED2600_SOC inherits from TYPE_ASPEED_SOC. In few commits we'll add more fields, but to keep review process simple, don't add any yet.
--- include/hw/arm/aspeed_soc.h | 7 +++++++ hw/arm/aspeed_ast2600.c | 26 +++++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-)
include/hw/arm/aspeed_soc.h +7 -0
@@ -101,6 +101,13 @@ struct AspeedSoCState {#define TYPE_ASPEED_SOC "aspeed-soc" OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC) +struct Aspeed2600SoCState { +AspeedSoCState parent; +}; + +#define TYPE_ASPEED2600_SOC "aspeed2600-soc" +OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2600SoCState, ASPEED2600_SOC) +struct Aspeed10x0SoCState {AspeedSoCState parent; };
hw/arm/aspeed_ast2600.c +13 -13
@@ -646,18 +646,18 @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) sc->get_irq = aspeed_soc_ast2600_get_irq; } -static const TypeInfo aspeed_soc_ast2600_type_info = { - .name ="ast2600-a3" , - .parent =TYPE_ASPEED_SOC , - .instance_size =sizeof (AspeedSoCState), - .instance_init = aspeed_soc_ast2600_init, - .class_init = aspeed_soc_ast2600_class_init, - .class_size =sizeof (AspeedSoCClass), +static const TypeInfo aspeed_soc_ast2600_types[] = { + { + .name =TYPE_ASPEED2600_SOC , + .parent =TYPE_ASPEED_SOC , + .instance_size =sizeof (Aspeed2600SoCState), + .abstract = true, + }, { + .name ="ast2600-a3" , + .parent =TYPE_ASPEED2600_SOC , + .instance_init = aspeed_soc_ast2600_init, + .class_init = aspeed_soc_ast2600_class_init, + }, }; -static void aspeed_soc_register_types (void ) -{ -type_register_static (&aspeed_soc_ast2600_type_info); -}; - -type_init (aspeed_soc_register_types) +DEFINE_TYPES (aspeed_soc_ast2600_types)
Signature · 1 line
2.41.0
[PULL 08/12] hw/arm/aspeed: Introduce TYPE_ASPEED2400_SOC
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
TYPE_ASPEED2400_SOC inherits from TYPE_ASPEED_SOC. In few commits we'll add more fields, but to keep review process simple, don't add any yet.
TYPE_ASPEED_SOC is common to various Aspeed SoCs, define it in aspeed_soc_common.c.
--- include/hw/arm/aspeed_soc.h | 7 +++++ hw/arm/aspeed_soc.c | 61 +++++++++++-------------------------- hw/arm/aspeed_soc_common.c | 29 ++++++++++++++++++ 3 files changed, 53 insertions(+), 44 deletions(-)
include/hw/arm/aspeed_soc.h +7 -0
@@ -101,6 +101,13 @@ struct AspeedSoCState {#define TYPE_ASPEED_SOC "aspeed-soc" OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC) +struct Aspeed2400SoCState { +AspeedSoCState parent; +}; + +#define TYPE_ASPEED2400_SOC "aspeed2400-soc" +OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2400SoCState, ASPEED2400_SOC) +struct Aspeed2600SoCState {AspeedSoCState parent; };
hw/arm/aspeed_soc.c +17 -44
78 lines not on this page · raw message
hw/arm/aspeed_soc_common.c +29 -0
@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "hw/qdev-properties.h" #include "hw/misc/unimp.h" #include "hw/arm/aspeed_soc.h" #include "hw/char/serial.h"
@@ -112,3 +113,31 @@ void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev,memory_region_add_subregion_overlap (s->memory, addr,sysbus_mmio_get_region (dev,0 ),-1000 ); } + +static Property aspeed_soc_properties[] = { +DEFINE_PROP_LINK ("dram" , AspeedSoCState, dram_mr,TYPE_MEMORY_REGION , + MemoryRegion *), +DEFINE_PROP_LINK ("memory" , AspeedSoCState, memory,TYPE_MEMORY_REGION , + MemoryRegion *), +DEFINE_PROP_END_OF_LIST (), +}; + +static void aspeed_soc_class_init (ObjectClass *oc,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (oc); + +device_class_set_props (dc, aspeed_soc_properties); +} + +static const TypeInfo aspeed_soc_types[] = { + { + .name =TYPE_ASPEED_SOC , + .parent =TYPE_DEVICE , + .instance_size =sizeof (AspeedSoCState), + .class_size =sizeof (AspeedSoCClass), + .class_init = aspeed_soc_class_init, + .abstract = true, + }, +}; + +DEFINE_TYPES (aspeed_soc_types)
Signature · 1 line
2.41.0
[PULL 10/12] hw/arm/aspeed: Move AspeedSoCState::armv7m to Aspeed10x0SoCState
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
The v7-M core is specific to the Aspeed 10x0 series, remove it from the common AspeedSoCState.
--- include/hw/arm/aspeed_soc.h | 5 ++--- hw/arm/aspeed_ast10x0.c | 27 +++++++++++++++------------ hw/arm/fby35.c | 13 ++++++++----- 3 files changed, 25 insertions(+), 20 deletions(-)
include/hw/arm/aspeed_soc.h +2 -3
@@ -47,13 +47,10 @@#define ASPEED_JTAG_NUM 2struct AspeedSoCState { -/*< private >*/ DeviceState parent; -/*< public >*/ ARMCPU cpu[ASPEED_CPUS_NUM ];A15MPPrivState a7mpcore; -ARMv7MState armv7m;MemoryRegion *memory;MemoryRegion *dram_mr;MemoryRegion dram_container;
@@ -117,6 +114,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2600SoCState, ASPEED2600_SOC)struct Aspeed10x0SoCState {AspeedSoCState parent; + +ARMv7MState armv7m; };#define TYPE_ASPEED10X0_SOC "aspeed10x0-soc"
hw/arm/aspeed_ast10x0.c +15 -12
@@ -101,13 +101,15 @@ static const int aspeed_soc_ast1030_irqmap[] = {static qemu_irq aspeed_soc_ast1030_get_irq (AspeedSoCState *s,int dev) { +Aspeed10x0SoCState *a =ASPEED10X0_SOC (s);AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); -return qdev_get_gpio_in (DEVICE (&s->armv7m), sc->irqmap[dev]); +return qdev_get_gpio_in (DEVICE (&a->armv7m), sc->irqmap[dev]); }static void aspeed_soc_ast1030_init (Object *obj) { +Aspeed10x0SoCState *a =ASPEED10X0_SOC (obj);AspeedSoCState *s =ASPEED_SOC (obj);AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s);char socname[8 ];
@@ -118,7 +120,7 @@ static void aspeed_soc_ast1030_init(Object *obj)g_assert_not_reached (); } -object_initialize_child (obj,"armv7m" , &s->armv7m,TYPE_ARMV7M ); +object_initialize_child (obj,"armv7m" , &a->armv7m,TYPE_ARMV7M ); s->sysclk =qdev_init_clock_in (DEVICE (s),"sysclk" ,NULL ,NULL ,0 );
@@ -185,6 +187,7 @@ static void aspeed_soc_ast1030_init(Object *obj)static void aspeed_soc_ast1030_realize (DeviceState *dev_soc,Error **errp) { +Aspeed10x0SoCState *a =ASPEED10X0_SOC (dev_soc);AspeedSoCState *s =ASPEED_SOC (dev_soc);AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s);DeviceState *armv7m;
@@ -206,17 +209,17 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) 0x40000);/* AST1030 CPU Core */ - armv7m =DEVICE (&s->armv7m); + armv7m =DEVICE (&a->armv7m);qdev_prop_set_uint32 (armv7m,"num-irq" ,256 );qdev_prop_set_string (armv7m,"cpu-type" , sc->cpu_type);qdev_connect_clock_in (armv7m,"cpuclk" , s->sysclk); -object_property_set_link (OBJECT (&s->armv7m),"memory" , +object_property_set_link (OBJECT (&a->armv7m),"memory" ,OBJECT (s->memory), &error_abort); -sysbus_realize (SYS_BUS_DEVICE (&s->armv7m), &error_abort); +sysbus_realize (SYS_BUS_DEVICE (&a->armv7m), &error_abort);/* Internal SRAM */ sram_name =g_strdup_printf ("aspeed.sram.%d" , -CPU (s->armv7m.cpu)->cpu_index); +CPU (a->armv7m.cpu)->cpu_index);memory_region_init_ram (&s->sram,OBJECT (s), sram_name, sc->sram_size, &err);if (err !=NULL ) {error_propagate (errp, err);
@@ -249,7 +252,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) }aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->i2c),0 , sc->memmap[ASPEED_DEV_I2C ]);for (i =0 ; i <ASPEED_I2C_GET_CLASS (&s->i2c)->num_busses; i++) { -qemu_irq irq =qdev_get_gpio_in (DEVICE (&s->armv7m), +qemu_irq irq =qdev_get_gpio_in (DEVICE (&a->armv7m), sc->irqmap[ASPEED_DEV_I2C ] + i);/* The AST1030 I2C controller has one IRQ per bus. */ sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c.busses[i]),0 , irq);
@@ -261,7 +264,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) }aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->i3c),0 , sc->memmap[ASPEED_DEV_I3C ]);for (i =0 ; i <ASPEED_I3C_NR_DEVICES ; i++) { -qemu_irq irq =qdev_get_gpio_in (DEVICE (&s->armv7m), +qemu_irq irq =qdev_get_gpio_in (DEVICE (&a->armv7m), sc->irqmap[ASPEED_DEV_I3C ] + i);/* The AST1030 I3C controller has one IRQ per bus. */ sysbus_connect_irq (SYS_BUS_DEVICE (&s->i3c.devices[i]),0 , irq);
@@ -290,19 +293,19 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)* On the AST1030 LPC subdevice IRQs are connected straight to the GIC. */ sysbus_connect_irq (SYS_BUS_DEVICE (&s->lpc),1 + aspeed_lpc_kcs_1, -qdev_get_gpio_in (DEVICE (&s->armv7m), +qdev_get_gpio_in (DEVICE (&a->armv7m), sc->irqmap[ASPEED_DEV_KCS ] + aspeed_lpc_kcs_1));sysbus_connect_irq (SYS_BUS_DEVICE (&s->lpc),1 + aspeed_lpc_kcs_2, -qdev_get_gpio_in (DEVICE (&s->armv7m), +qdev_get_gpio_in (DEVICE (&a->armv7m), sc->irqmap[ASPEED_DEV_KCS ] + aspeed_lpc_kcs_2));sysbus_connect_irq (SYS_BUS_DEVICE (&s->lpc),1 + aspeed_lpc_kcs_3, -qdev_get_gpio_in (DEVICE (&s->armv7m), +qdev_get_gpio_in (DEVICE (&a->armv7m), sc->irqmap[ASPEED_DEV_KCS ] + aspeed_lpc_kcs_3));sysbus_connect_irq (SYS_BUS_DEVICE (&s->lpc),1 + aspeed_lpc_kcs_4, -qdev_get_gpio_in (DEVICE (&s->armv7m), +qdev_get_gpio_in (DEVICE (&a->armv7m), sc->irqmap[ASPEED_DEV_KCS ] + aspeed_lpc_kcs_4));/* UART */
hw/arm/fby35.c +8 -5
@@ -28,7 +28,7 @@ struct Fby35State {Clock *bic_sysclk;AspeedSoCState bmc; -AspeedSoCState bic; +Aspeed10x0SoCState bic;bool mmio_exec; };
@@ -114,10 +114,13 @@ static void fby35_bmc_init(Fby35State *s)static void fby35_bic_init (Fby35State *s) { +AspeedSoCState *soc; + s->bic_sysclk =clock_new (OBJECT (s),"SYSCLK" );clock_set_hz (s->bic_sysclk,200000000ULL );object_initialize_child (OBJECT (s),"bic" , &s->bic,"ast1030-a1" ); + soc =ASPEED_SOC (&s->bic);memory_region_init (&s->bic_memory,OBJECT (&s->bic),"bic-memory" ,UINT64_MAX );
@@ -125,12 +128,12 @@ static void fby35_bic_init(Fby35State *s)qdev_connect_clock_in (DEVICE (&s->bic),"sysclk" , s->bic_sysclk);object_property_set_link (OBJECT (&s->bic),"memory" ,OBJECT (&s->bic_memory), &error_abort); -aspeed_soc_uart_set_chr (&s->bic,ASPEED_DEV_UART5 ,serial_hd (1 )); +aspeed_soc_uart_set_chr (soc,ASPEED_DEV_UART5 ,serial_hd (1 ));qdev_realize (DEVICE (&s->bic),NULL , &error_abort); -aspeed_board_init_flashes (&s->bic.fmc,"sst25vf032b" ,2 ,2 ); -aspeed_board_init_flashes (&s->bic.spi[0 ],"sst25vf032b" ,2 ,4 ); -aspeed_board_init_flashes (&s->bic.spi[1 ],"sst25vf032b" ,2 ,6 ); +aspeed_board_init_flashes (&soc->fmc,"sst25vf032b" ,2 ,2 ); +aspeed_board_init_flashes (&soc->spi[0 ],"sst25vf032b" ,2 ,4 ); +aspeed_board_init_flashes (&soc->spi[1 ],"sst25vf032b" ,2 ,6 ); }static void fby35_init (MachineState *machine)
Signature · 1 line
2.41.0
[PULL 04/12] hw/arm/aspeed: Rename aspeed_soc_realize() as AST2400/2500 specific
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
Keep aspeed_soc_class_init() generic, set the realize handler to aspeed_ast2400_soc_realize() in each 2400/2500 class_init.
--- hw/arm/aspeed_soc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
hw/arm/aspeed_soc.c +11 -4
@@ -239,7 +239,7 @@ static void aspeed_ast2400_soc_init(Object *obj)object_initialize_child (obj,"video" , &s->video,TYPE_UNIMPLEMENTED_DEVICE ); } -static void aspeed_soc_realize (DeviceState *dev,Error **errp) +static void aspeed_ast2400_soc_realize (DeviceState *dev,Error **errp) {int i;AspeedSoCState *s =ASPEED_SOC (dev);
@@ -509,9 +509,6 @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data) {DeviceClass *dc =DEVICE_CLASS (oc); - dc->realize = aspeed_soc_realize; -/* Reason: Uses serial_hds and nd_table in realize() directly */ - dc->user_creatable = false;device_class_set_props (dc, aspeed_soc_properties); }
@@ -527,6 +524,11 @@ static const TypeInfo aspeed_soc_type_info = {static void aspeed_soc_ast2400_class_init (ObjectClass *oc,void *data) {AspeedSoCClass *sc =ASPEED_SOC_CLASS (oc); +DeviceClass *dc =DEVICE_CLASS (oc); + + dc->realize = aspeed_ast2400_soc_realize; +/* Reason: Uses serial_hds and nd_table in realize() directly */ + dc->user_creatable = false; sc->name ="ast2400-a1" ; sc->cpu_type =ARM_CPU_TYPE_NAME ("arm926" );
@@ -554,6 +556,11 @@ static const TypeInfo aspeed_soc_ast2400_type_info = {static void aspeed_soc_ast2500_class_init (ObjectClass *oc,void *data) {AspeedSoCClass *sc =ASPEED_SOC_CLASS (oc); +DeviceClass *dc =DEVICE_CLASS (oc); + + dc->realize = aspeed_ast2400_soc_realize; +/* Reason: Uses serial_hds and nd_table in realize() directly */ + dc->user_creatable = false; sc->name ="ast2500-a1" ; sc->cpu_type =ARM_CPU_TYPE_NAME ("arm1176" );
Signature · 1 line
2.41.0
[PULL 03/12] hw/arm/aspeed: Rename aspeed_soc_init() as AST2400/2500 specific
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
--- hw/arm/aspeed_soc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/arm/aspeed_soc.c +3 -3
@@ -140,7 +140,7 @@ static qemu_irq aspeed_soc_ast2400_get_irq(AspeedSoCState *s, int dev)return qdev_get_gpio_in (DEVICE (&s->vic), sc->irqmap[dev]); } -static void aspeed_soc_init (Object *obj) +static void aspeed_ast2400_soc_init (Object *obj) {AspeedSoCState *s =ASPEED_SOC (obj);AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s);
@@ -546,7 +546,7 @@ static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data)static const TypeInfo aspeed_soc_ast2400_type_info = { .name ="ast2400-a1" , .parent =TYPE_ASPEED_SOC , - .instance_init = aspeed_soc_init, + .instance_init = aspeed_ast2400_soc_init, .instance_size =sizeof (AspeedSoCState), .class_init = aspeed_soc_ast2400_class_init, };
@@ -573,7 +573,7 @@ static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data)static const TypeInfo aspeed_soc_ast2500_type_info = { .name ="ast2500-a1" , .parent =TYPE_ASPEED_SOC , - .instance_init = aspeed_soc_init, + .instance_init = aspeed_ast2400_soc_init, .instance_size =sizeof (AspeedSoCState), .class_init = aspeed_soc_ast2500_class_init, };
Signature · 1 line
2.41.0
[PULL 11/12] hw/arm/aspeed: Move AspeedSoCState::a7mpcore to Aspeed2600SoCState
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
The v7-A cluster is specific to the Aspeed 2600 series, remove it from the common AspeedSoCState.
The ARM cores belong to the MP cluster, but the array is currently used by TYPE_ASPEED2600_SOC. We'll clean that soon, but for now keep it in Aspeed2600SoCState.
--- include/hw/arm/aspeed_soc.h | 4 ++- hw/arm/aspeed_ast2600.c | 49 ++++++++++++++++++++----------------- hw/arm/fby35.c | 14 ++++++----- 3 files changed, 37 insertions(+), 30 deletions(-)
include/hw/arm/aspeed_soc.h +3 -1
@@ -50,7 +50,6 @@ struct AspeedSoCState {DeviceState parent;ARMCPU cpu[ASPEED_CPUS_NUM ]; -A15MPPrivState a7mpcore;MemoryRegion *memory;MemoryRegion *dram_mr;MemoryRegion dram_container;
@@ -107,6 +106,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2400SoCState, ASPEED2400_SOC)struct Aspeed2600SoCState {AspeedSoCState parent; + +A15MPPrivState a7mpcore; +ARMCPU cpu[ASPEED_CPUS_NUM ];/* XXX belong to a7mpcore */ };#define TYPE_ASPEED2600_SOC "aspeed2600-soc"
hw/arm/aspeed_ast2600.c +26 -23
138 lines not on this page · raw message
hw/arm/fby35.c +8 -6
@@ -27,7 +27,7 @@ struct Fby35State {MemoryRegion bic_memory;Clock *bic_sysclk; -AspeedSoCState bmc; +Aspeed2600SoCState bmc;Aspeed10x0SoCState bic;bool mmio_exec;
@@ -70,7 +70,10 @@ static void fby35_bmc_write_boot_rom(DriveInfo *dinfo, MemoryRegion *mr,static void fby35_bmc_init (Fby35State *s) { +AspeedSoCState *soc; +object_initialize_child (OBJECT (s),"bmc" , &s->bmc,"ast2600-a3" ); + soc =ASPEED_SOC (&s->bmc);memory_region_init (&s->bmc_memory,OBJECT (&s->bmc),"bmc-memory" ,UINT64_MAX );
@@ -87,22 +90,21 @@ static void fby35_bmc_init(Fby35State *s) &error_abort);object_property_set_int (OBJECT (&s->bmc),"hw-strap2" ,0x00000003 , &error_abort); -aspeed_soc_uart_set_chr (&s->bmc,ASPEED_DEV_UART5 ,serial_hd (0 )); +aspeed_soc_uart_set_chr (soc,ASPEED_DEV_UART5 ,serial_hd (0 ));qdev_realize (DEVICE (&s->bmc),NULL , &error_abort); -aspeed_board_init_flashes (&s->bmc.fmc,"n25q00" ,2 ,0 ); +aspeed_board_init_flashes (&soc->fmc,"n25q00" ,2 ,0 );/* Install first FMC flash content as a boot rom. */ if (!s->mmio_exec) {DriveInfo *mtd0 =drive_get (IF_MTD ,0 ,0 );if (mtd0) { -AspeedSoCState *bmc = &s->bmc; -uint64_t rom_size =memory_region_size (&bmc->spi_boot); +uint64_t rom_size =memory_region_size (&soc->spi_boot);memory_region_init_rom (&s->bmc_boot_rom,NULL ,"aspeed.boot_rom" , rom_size, &error_abort); -memory_region_add_subregion_overlap (&bmc->spi_boot_container,0 , +memory_region_add_subregion_overlap (&soc->spi_boot_container,0 , &s->bmc_boot_rom,1 ); fby35_bmc_write_boot_rom(mtd0, &s->bmc_boot_rom,
Signature · 1 line
2.41.0
[PULL 02/12] hw/arm/aspeed: Extract code common to all boards to a common file
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
aspeed_soc.c contains definitions specific to the AST2400 and AST2500 SoCs, but also some definitions for other AST
SoCs: move them to a common file.
--- hw/arm/aspeed_soc.c | 96 ------------------------------- hw/arm/aspeed_soc_common.c | 114 +++++++++++++++++++++++++++++++++++++ hw/arm/meson.build | 1 + 3 files changed, 115 insertions(+), 96 deletions(-) create mode 100644 hw/arm/aspeed_soc_common.c
hw/arm/aspeed_soc.c +0 -96
@@ -585,99 +585,3 @@ static void aspeed_soc_register_types(void) };type_init (aspeed_soc_register_types); - -qemu_irq aspeed_soc_get_irq (AspeedSoCState *s,int dev) -{ -return ASPEED_SOC_GET_CLASS (s)->get_irq (s, dev); -} - -bool aspeed_soc_uart_realize (AspeedSoCState *s,Error **errp) -{ -AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); -SerialMM *smm; - -for (int i =0 , uart =ASPEED_DEV_UART1 ; i < sc->uarts_num; i++, uart++) { - smm = &s->uart[i]; - -/* Chardev property is set by the machine. */ -qdev_prop_set_uint8 (DEVICE (smm),"regshift" ,2 ); -qdev_prop_set_uint32 (DEVICE (smm),"baudbase" ,38400 ); -qdev_set_legacy_instance_id (DEVICE (smm), sc->memmap[uart],2 ); -qdev_prop_set_uint8 (DEVICE (smm),"endianness" ,DEVICE_LITTLE_ENDIAN ); -if (!sysbus_realize (SYS_BUS_DEVICE (smm), errp)) { -return false; - } - -sysbus_connect_irq (SYS_BUS_DEVICE (smm),0 ,aspeed_soc_get_irq (s, uart)); -aspeed_mmio_map (s,SYS_BUS_DEVICE (smm),0 , sc->memmap[uart]); - } - -return true; -} - -void aspeed_soc_uart_set_chr (AspeedSoCState *s,int dev,Chardev *chr) -{ -AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); -int i = dev -ASPEED_DEV_UART1 ; - -g_assert (0 <= i && i <ARRAY_SIZE (s->uart) && i < sc->uarts_num); -qdev_prop_set_chr (DEVICE (&s->uart[i]),"chardev" , chr); -} - -/* -* SDMC should be realized first to get correct RAM size and max size -* values -*/ -bool aspeed_soc_dram_init (AspeedSoCState *s,Error **errp) -{ -AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); -ram_addr_t ram_size, max_ram_size; - - ram_size =object_property_get_uint (OBJECT (&s->sdmc),"ram-size" , - &error_abort); - max_ram_size =object_property_get_uint (OBJECT (&s->sdmc),"max-ram-size" , - &error_abort); - -memory_region_init (&s->dram_container,OBJECT (s),"ram-container" , - max_ram_size); -memory_region_add_subregion (&s->dram_container,0 , s->dram_mr); - -/* -* Add a memory region beyond the RAM region to let firmwares scan -* the address space with load/store and guess how much RAM the -* SoC has. -*/ -if (ram_size < max_ram_size) { -DeviceState *dev =qdev_new (TYPE_UNIMPLEMENTED_DEVICE ); - -qdev_prop_set_string (dev,"name" ,"ram-empty" ); -qdev_prop_set_uint64 (dev,"size" , max_ram_size - ram_size); -if (!sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), errp)) { -return false; - } - -memory_region_add_subregion_overlap (&s->dram_container, ram_size, -sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 ),-1000 ); - } - -memory_region_add_subregion (s->memory, - sc->memmap[ASPEED_DEV_SDRAM ], &s->dram_container); -return true; -} - -void aspeed_mmio_map (AspeedSoCState *s,SysBusDevice *dev,int n,hwaddr addr) -{ -memory_region_add_subregion (s->memory, addr, -sysbus_mmio_get_region (dev, n)); -} - -void aspeed_mmio_map_unimplemented (AspeedSoCState *s,SysBusDevice *dev, -const char *name,hwaddr addr,uint64_t size) -{ -qdev_prop_set_string (DEVICE (dev),"name" , name); -qdev_prop_set_uint64 (DEVICE (dev),"size" , size); -sysbus_realize (dev, &error_abort); - -memory_region_add_subregion_overlap (s->memory, addr, -sysbus_mmio_get_region (dev,0 ),-1000 ); -}
hw/arm/aspeed_soc_common.c new file +114 -0
114 lines not on this page · raw message
hw/arm/meson.build +1 -0
@@ -50,6 +50,7 @@ arm_ss.add(when: 'CONFIG_FSL_IMX6', if_true: files('fsl-imx6.c')) arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( 'aspeed_soc.c', 'aspeed.c', + 'aspeed_soc_common.c', 'aspeed_ast2600.c', 'aspeed_ast10x0.c', 'aspeed_eeprom.c',
Signature · 1 line
2.41.0
[PULL 06/12] hw/arm/aspeed: Introduce TYPE_ASPEED10X0_SOC
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
TYPE_ASPEED10X0_SOC inherits from TYPE_ASPEED_SOC. In few commits we'll add more fields, but to keep review process simple, don't add any yet.
--- include/hw/arm/aspeed_soc.h | 7 +++++++ hw/arm/aspeed_ast10x0.c | 26 +++++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-)
include/hw/arm/aspeed_soc.h +7 -0
@@ -101,6 +101,13 @@ struct AspeedSoCState {#define TYPE_ASPEED_SOC "aspeed-soc" OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC) +struct Aspeed10x0SoCState { +AspeedSoCState parent; +}; + +#define TYPE_ASPEED10X0_SOC "aspeed10x0-soc" +OBJECT_DECLARE_SIMPLE_TYPE(Aspeed10x0SoCState, ASPEED10X0_SOC) +struct AspeedSoCClass {DeviceClass parent_class;
hw/arm/aspeed_ast10x0.c +13 -13
@@ -435,18 +435,18 @@ static void aspeed_soc_ast1030_class_init(ObjectClass *klass, void *data) sc->get_irq = aspeed_soc_ast1030_get_irq; } -static const TypeInfo aspeed_soc_ast1030_type_info = { - .name ="ast1030-a1" , - .parent =TYPE_ASPEED_SOC , - .instance_size =sizeof (AspeedSoCState), - .instance_init = aspeed_soc_ast1030_init, - .class_init = aspeed_soc_ast1030_class_init, - .class_size =sizeof (AspeedSoCClass), +static const TypeInfo aspeed_soc_ast10x0_types[] = { + { + .name =TYPE_ASPEED10X0_SOC , + .parent =TYPE_ASPEED_SOC , + .instance_size =sizeof (Aspeed10x0SoCState), + .abstract = true, + }, { + .name ="ast1030-a1" , + .parent =TYPE_ASPEED10X0_SOC , + .instance_init = aspeed_soc_ast1030_init, + .class_init = aspeed_soc_ast1030_class_init, + }, }; -static void aspeed_soc_register_types (void ) -{ -type_register_static (&aspeed_soc_ast1030_type_info); -} - -type_init (aspeed_soc_register_types) +DEFINE_TYPES (aspeed_soc_ast10x0_types)
Signature · 1 line
2.41.0
[PULL 05/12] hw/arm/aspeed: Dynamically allocate AspeedMachineState::soc field
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
We want to derivate the big AspeedSoCState object in some more SoC-specific ones. Since the object size will vary, allocate it dynamically.
--- hw/arm/aspeed.c | 101 +++++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 49 deletions(-)
hw/arm/aspeed.c +52 -49
@@ -40,7 +40,7 @@ struct AspeedMachineState {MachineState parent_obj;/* Public */ -AspeedSoCState soc; +AspeedSoCState *soc;MemoryRegion boot_rom;bool mmio_exec;uint32_t uart_chosen;
@@ -288,7 +288,7 @@ static void write_boot_rom(BlockBackend *blk, hwaddr addr, size_t rom_size,static void aspeed_install_boot_rom (AspeedMachineState *bmc,BlockBackend *blk,uint64_t rom_size) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;memory_region_init_rom (&bmc->boot_rom,NULL ,"aspeed.boot_rom" , rom_size, &error_abort);
@@ -337,7 +337,7 @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo)static void connect_serial_hds_to_uarts (AspeedMachineState *bmc) {AspeedMachineClass *amc =ASPEED_MACHINE_GET_CLASS (bmc); -AspeedSoCState *s = &bmc->soc; +AspeedSoCState *s = bmc->soc;AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s);int uart_chosen = bmc->uart_chosen ? bmc->uart_chosen : amc->uart_default;
@@ -358,32 +358,33 @@ static void aspeed_machine_init(MachineState *machine)int i;NICInfo *nd = &nd_table[0 ]; -object_initialize_child (OBJECT (machine),"soc" , &bmc->soc, amc->soc_name); - - sc =ASPEED_SOC_GET_CLASS (&bmc->soc); + bmc->soc =ASPEED_SOC (object_new (amc->soc_name)); +object_property_add_child (OBJECT (machine),"soc" ,OBJECT (bmc->soc)); +object_unref (OBJECT (bmc->soc)); + sc =ASPEED_SOC_GET_CLASS (bmc->soc);/* * This will error out if the RAM size is not supported by the * memory controller of the SoC. */ -object_property_set_uint (OBJECT (&bmc->soc),"ram-size" , machine->ram_size, +object_property_set_uint (OBJECT (bmc->soc),"ram-size" , machine->ram_size, &error_fatal);for (i =0 ; i < sc->macs_num; i++) {if ((amc->macs_mask & (1 << i)) && nd->used) {qemu_check_nic_model (nd,TYPE_FTGMAC100 ); -qdev_set_nic_properties (DEVICE (&bmc->soc.ftgmac100[i]), nd); +qdev_set_nic_properties (DEVICE (&bmc->soc->ftgmac100[i]), nd); nd++; } } -object_property_set_int (OBJECT (&bmc->soc),"hw-strap1" , amc->hw_strap1, +object_property_set_int (OBJECT (bmc->soc),"hw-strap1" , amc->hw_strap1, &error_abort); -object_property_set_int (OBJECT (&bmc->soc),"hw-strap2" , amc->hw_strap2, +object_property_set_int (OBJECT (bmc->soc),"hw-strap2" , amc->hw_strap2, &error_abort); -object_property_set_link (OBJECT (&bmc->soc),"memory" , +object_property_set_link (OBJECT (bmc->soc),"memory" ,OBJECT (get_system_memory ()), &error_abort); -object_property_set_link (OBJECT (&bmc->soc),"dram" , +object_property_set_link (OBJECT (bmc->soc),"dram" ,OBJECT (machine->ram), &error_abort);if (machine->kernel_filename) {/*
@@ -391,17 +392,17 @@ static void aspeed_machine_init(MachineState *machine)* that runs to unlock the SCU. In this case set the default to * be unlocked as the kernel expects */ -object_property_set_int (OBJECT (&bmc->soc),"hw-prot-key" , +object_property_set_int (OBJECT (bmc->soc),"hw-prot-key" ,ASPEED_SCU_PROT_KEY , &error_abort); }connect_serial_hds_to_uarts (bmc); -qdev_realize (DEVICE (&bmc->soc),NULL , &error_abort); +qdev_realize (DEVICE (bmc->soc),NULL , &error_abort);if (defaults_enabled ()) { -aspeed_board_init_flashes (&bmc->soc.fmc, +aspeed_board_init_flashes (&bmc->soc->fmc, bmc->fmc_model ? bmc->fmc_model : amc->fmc_model, amc->num_cs,0 ); -aspeed_board_init_flashes (&bmc->soc.spi[0 ], +aspeed_board_init_flashes (&bmc->soc->spi[0 ], bmc->spi_model ? bmc->spi_model : amc->spi_model,1 , amc->num_cs); }
@@ -426,22 +427,22 @@ static void aspeed_machine_init(MachineState *machine) amc->i2c_init (bmc); } -for (i =0 ; i < bmc->soc.sdhci.num_slots; i++) { -sdhci_attach_drive (&bmc->soc.sdhci.slots[i], +for (i =0 ; i < bmc->soc->sdhci.num_slots; i++) { +sdhci_attach_drive (&bmc->soc->sdhci.slots[i],drive_get (IF_SD ,0 , i)); } -if (bmc->soc.emmc.num_slots) { -sdhci_attach_drive (&bmc->soc.emmc.slots[0 ], -drive_get (IF_SD ,0 , bmc->soc.sdhci.num_slots)); +if (bmc->soc->emmc.num_slots) { +sdhci_attach_drive (&bmc->soc->emmc.slots[0 ], +drive_get (IF_SD ,0 , bmc->soc->sdhci.num_slots)); }if (!bmc->mmio_exec) { -DeviceState *dev =ssi_get_cs (bmc->soc.fmc.spi,0 ); +DeviceState *dev =ssi_get_cs (bmc->soc->fmc.spi,0 );BlockBackend *fmc0 = dev ?m25p80_get_blk (dev) :NULL ;if (fmc0) { -uint64_t rom_size =memory_region_size (&bmc->soc.spi_boot); +uint64_t rom_size =memory_region_size (&bmc->soc->spi_boot);aspeed_install_boot_rom (bmc, fmc0, rom_size); } }
@@ -451,7 +452,7 @@ static void aspeed_machine_init(MachineState *machine)static void palmetto_bmc_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;DeviceState *dev;uint8_t *eeprom_buf =g_malloc0 (32 *1024 );
@@ -473,7 +474,7 @@ static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)static void quanta_q71l_bmc_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;/* * The quanta-q71l platform expects tmp75s which are compatible with
@@ -505,7 +506,7 @@ static void quanta_q71l_bmc_i2c_init(AspeedMachineState *bmc)static void ast2500_evb_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;uint8_t *eeprom_buf =g_malloc0 (8 *1024 ); smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 3), 0x50,
@@ -518,7 +519,7 @@ static void ast2500_evb_i2c_init(AspeedMachineState *bmc)static void ast2600_evb_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;uint8_t *eeprom_buf =g_malloc0 (8 *1024 ); smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 7), 0x50,
@@ -531,7 +532,7 @@ static void ast2600_evb_i2c_init(AspeedMachineState *bmc)static void yosemitev2_bmc_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,4 ),0x51 ,128 * KiB); at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 128 * KiB,
@@ -545,7 +546,7 @@ static void yosemitev2_bmc_i2c_init(AspeedMachineState *bmc)static void romulus_bmc_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;/* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is * good enough */
@@ -554,7 +555,7 @@ static void romulus_bmc_i2c_init(AspeedMachineState *bmc)static void tiogapass_bmc_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,4 ),0x54 ,128 * KiB); at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 6), 0x54, 128 * KiB,
@@ -573,7 +574,7 @@ static void create_pca9552(AspeedSoCState *soc, int bus_id, int addr)static void sonorapass_bmc_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;/* bus 2 : */ i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,2 ),"tmp105" ,0x48 );
@@ -627,7 +628,7 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc) {14, LED_COLOR_GREEN, "front-power-3", GPIO_POLARITY_ACTIVE_LOW}, {15, LED_COLOR_GREEN, "front-id-5", GPIO_POLARITY_ACTIVE_LOW}, }; -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;uint8_t *eeprom_buf =g_malloc0 (8 *1024 );DeviceState *dev;LEDState *led;
@@ -672,7 +673,7 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc)static void g220a_bmc_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;DeviceState *dev; dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 3),
@@ -708,7 +709,7 @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc)static void fp5280g2_bmc_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;I2CSlave *i2c_mux;/* The at24c256 */
@@ -735,7 +736,7 @@ static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc)static void rainier_bmc_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;I2CSlave *i2c_mux;at24c_eeprom_init (aspeed_i2c_get_bus (&soc->i2c,0 ),0x51 ,32 * KiB);
@@ -852,7 +853,7 @@ static void get_pca9548_channels(I2CBus *bus, uint8_t mux_addr,static void fuji_bmc_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;I2CBus *i2c[144 ] = {};for (int i =0 ; i <16 ; i++) {
@@ -930,7 +931,7 @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)static void bletchley_bmc_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;I2CBus *i2c[13 ] = {};for (int i =0 ; i <13 ; i++) {if ((i ==8 ) || (i ==11 )) {
@@ -976,7 +977,7 @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)static void fby35_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;I2CBus *i2c[16 ];for (int i =0 ; i <16 ; i++) {
@@ -1008,14 +1009,14 @@ static void fby35_i2c_init(AspeedMachineState *bmc)static void qcom_dc_scm_bmc_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,15 ),"tmp105" ,0x4d ); }static void qcom_dc_scm_firework_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;I2CSlave *therm_mux, *cpuvr_mux;/* Create the generic DC-SCM hardware */
@@ -1477,7 +1478,7 @@ static void aspeed_machine_bletchley_class_init(ObjectClass *oc, void *data)static void fby35_reset (MachineState *state,ShutdownCause reason) {AspeedMachineState *bmc =ASPEED_MACHINE (state); -AspeedGPIOState *gpio = &bmc->soc.gpio; +AspeedGPIOState *gpio = &bmc->soc->gpio;qemu_devices_reset (reason);
@@ -1528,24 +1529,26 @@ static void aspeed_minibmc_machine_init(MachineState *machine) sysclk =clock_new (OBJECT (machine),"SYSCLK" );clock_set_hz (sysclk,SYSCLK_FRQ ); -object_initialize_child (OBJECT (machine),"soc" , &bmc->soc, amc->soc_name); -qdev_connect_clock_in (DEVICE (&bmc->soc),"sysclk" , sysclk); + bmc->soc =ASPEED_SOC (object_new (amc->soc_name)); +object_property_add_child (OBJECT (machine),"soc" ,OBJECT (bmc->soc)); +object_unref (OBJECT (bmc->soc)); +qdev_connect_clock_in (DEVICE (bmc->soc),"sysclk" , sysclk); -object_property_set_link (OBJECT (&bmc->soc),"memory" , +object_property_set_link (OBJECT (bmc->soc),"memory" ,OBJECT (get_system_memory ()), &error_abort);connect_serial_hds_to_uarts (bmc); -qdev_realize (DEVICE (&bmc->soc),NULL , &error_abort); +qdev_realize (DEVICE (bmc->soc),NULL , &error_abort); -aspeed_board_init_flashes (&bmc->soc.fmc, +aspeed_board_init_flashes (&bmc->soc->fmc, bmc->fmc_model ? bmc->fmc_model : amc->fmc_model, amc->num_cs,0 ); -aspeed_board_init_flashes (&bmc->soc.spi[0 ], +aspeed_board_init_flashes (&bmc->soc->spi[0 ], bmc->spi_model ? bmc->spi_model : amc->spi_model, amc->num_cs, amc->num_cs); -aspeed_board_init_flashes (&bmc->soc.spi[1 ], +aspeed_board_init_flashes (&bmc->soc->spi[1 ], bmc->spi_model ? bmc->spi_model : amc->spi_model, amc->num_cs, (amc->num_cs *2 ));
@@ -1561,7 +1564,7 @@ static void aspeed_minibmc_machine_init(MachineState *machine)static void ast1030_evb_i2c_init (AspeedMachineState *bmc) { -AspeedSoCState *soc = &bmc->soc; +AspeedSoCState *soc = bmc->soc;/* U10 24C08 connects to SDA/SCL Group 1 by default */ uint8_t *eeprom_buf =g_malloc0 (32 *1024 );
Signature · 1 line
2.41.0
[PULL 12/12] hw/arm/aspeed: Move AspeedSoCState::cpu/vic to Aspeed2400SoCState
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
The ARM array and VIC peripheral are only used by the 2400 series, remove them from the common AspeedSoCState.
---
include/hw/arm/aspeed_soc.h | 5 +++--
hw/arm/{aspeed_soc.c => aspeed_ast2400.c} | 27 +++++++++++++----------
hw/arm/meson.build | 2 +-
3 files changed, 19 insertions(+), 15 deletions(-)
rename hw/arm/{aspeed_soc.c => aspeed_ast2400.c} (95%)include/hw/arm/aspeed_soc.h +3 -2
@@ -49,14 +49,12 @@struct AspeedSoCState {DeviceState parent; -ARMCPU cpu[ASPEED_CPUS_NUM ];MemoryRegion *memory;MemoryRegion *dram_mr;MemoryRegion dram_container;MemoryRegion sram;MemoryRegion spi_boot_container;MemoryRegion spi_boot; -AspeedVICState vic;AspeedRtcState rtc;AspeedTimerCtrlState timerctrl;AspeedI2CState i2c;
@@ -99,6 +97,9 @@ OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC)struct Aspeed2400SoCState {AspeedSoCState parent; + +ARMCPU cpu[ASPEED_CPUS_NUM ]; +AspeedVICState vic; };#define TYPE_ASPEED2400_SOC "aspeed2400-soc"
hw/arm/aspeed_ast2400.c renamed from hw/arm/aspeed_soc.c +15 -12
@@ -135,13 +135,15 @@ static const int aspeed_soc_ast2400_irqmap[] = {static qemu_irq aspeed_soc_ast2400_get_irq (AspeedSoCState *s,int dev) { +Aspeed2400SoCState *a =ASPEED2400_SOC (s);AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); -return qdev_get_gpio_in (DEVICE (&s->vic), sc->irqmap[dev]); +return qdev_get_gpio_in (DEVICE (&a->vic), sc->irqmap[dev]); }static void aspeed_ast2400_soc_init (Object *obj) { +Aspeed2400SoCState *a =ASPEED2400_SOC (obj);AspeedSoCState *s =ASPEED_SOC (obj);AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s);int i;
@@ -153,7 +155,7 @@ static void aspeed_ast2400_soc_init(Object *obj) }for (i =0 ; i < sc->num_cpus; i++) { -object_initialize_child (obj,"cpu[*]" , &s->cpu[i], sc->cpu_type); +object_initialize_child (obj,"cpu[*]" , &a->cpu[i], sc->cpu_type); }snprintf (typename,sizeof (typename),"aspeed.scu-%s" , socname);
@@ -167,7 +169,7 @@ static void aspeed_ast2400_soc_init(Object *obj)object_property_add_alias (obj,"hw-prot-key" ,OBJECT (&s->scu),"hw-prot-key" ); -object_initialize_child (obj,"vic" , &s->vic,TYPE_ASPEED_VIC ); +object_initialize_child (obj,"vic" , &a->vic,TYPE_ASPEED_VIC );object_initialize_child (obj,"rtc" , &s->rtc,TYPE_ASPEED_RTC );
@@ -242,6 +244,7 @@ static void aspeed_ast2400_soc_init(Object *obj)static void aspeed_ast2400_soc_realize (DeviceState *dev,Error **errp) {int i; +Aspeed2400SoCState *a =ASPEED2400_SOC (dev);AspeedSoCState *s =ASPEED_SOC (dev);AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s);Error *err =NULL ;
@@ -264,15 +267,15 @@ static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp)/* CPU */ for (i =0 ; i < sc->num_cpus; i++) { -object_property_set_link (OBJECT (&s->cpu[i]),"memory" , +object_property_set_link (OBJECT (&a->cpu[i]),"memory" ,OBJECT (s->memory), &error_abort); -if (!qdev_realize (DEVICE (&s->cpu[i]),NULL , errp)) { +if (!qdev_realize (DEVICE (&a->cpu[i]),NULL , errp)) {return ; } }/* SRAM */ - sram_name =g_strdup_printf ("aspeed.sram.%d" ,CPU (&s->cpu[0 ])->cpu_index); + sram_name =g_strdup_printf ("aspeed.sram.%d" ,CPU (&a->cpu[0 ])->cpu_index);memory_region_init_ram (&s->sram,OBJECT (s), sram_name, sc->sram_size, &err);if (err) {error_propagate (errp, err);
@@ -288,14 +291,14 @@ static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp)aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->scu),0 , sc->memmap[ASPEED_DEV_SCU ]);/* VIC */ -if (!sysbus_realize (SYS_BUS_DEVICE (&s->vic), errp)) { +if (!sysbus_realize (SYS_BUS_DEVICE (&a->vic), errp)) {return ; } -aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->vic),0 , sc->memmap[ASPEED_DEV_VIC ]); -sysbus_connect_irq (SYS_BUS_DEVICE (&s->vic),0 , -qdev_get_gpio_in (DEVICE (&s->cpu),ARM_CPU_IRQ )); -sysbus_connect_irq (SYS_BUS_DEVICE (&s->vic),1 , -qdev_get_gpio_in (DEVICE (&s->cpu),ARM_CPU_FIQ )); +aspeed_mmio_map (s,SYS_BUS_DEVICE (&a->vic),0 , sc->memmap[ASPEED_DEV_VIC ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&a->vic),0 , +qdev_get_gpio_in (DEVICE (&a->cpu),ARM_CPU_IRQ )); +sysbus_connect_irq (SYS_BUS_DEVICE (&a->vic),1 , +qdev_get_gpio_in (DEVICE (&a->cpu),ARM_CPU_FIQ ));/* RTC */ if (!sysbus_realize (SYS_BUS_DEVICE (&s->rtc), errp)) {
hw/arm/meson.build +1 -1
@@ -48,9 +48,9 @@ arm_ss.add(when: 'CONFIG_FSL_IMX25', if_true: files('fsl-imx25.c', 'imx25_pdk.c' arm_ss.add(when: 'CONFIG_FSL_IMX31', if_true: files('fsl-imx31.c', 'kzm.c')) arm_ss.add(when: 'CONFIG_FSL_IMX6', if_true: files('fsl-imx6.c')) arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( - 'aspeed_soc.c', 'aspeed.c', 'aspeed_soc_common.c', + 'aspeed_ast2400.c', 'aspeed_ast2600.c', 'aspeed_ast10x0.c', 'aspeed_eeprom.c',
Signature · 1 line
2.41.0
[PULL 09/12] hw/arm/aspeed: Check 'memory' link is set in common aspeed_soc_realize
In reply to Cédric Le GoaterFrom: Philippe Mathieu-Daudé <[email protected]>
--- hw/arm/aspeed_soc_common.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
hw/arm/aspeed_soc_common.c +11 -0
@@ -114,6 +114,16 @@ void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev, sysbus_mmio_get_region(dev, 0), -1000); } +static void aspeed_soc_realize (DeviceState *dev,Error **errp) +{ +AspeedSoCState *s =ASPEED_SOC (dev); + +if (!s->memory) { +error_setg (errp,"'memory' link is not set" ); +return ; + } +} +static Property aspeed_soc_properties[] = {DEFINE_PROP_LINK ("dram" , AspeedSoCState, dram_mr,TYPE_MEMORY_REGION , MemoryRegion *),
@@ -126,6 +136,7 @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data) {DeviceClass *dc =DEVICE_CLASS (oc); + dc->realize = aspeed_soc_realize;device_class_set_props (dc, aspeed_soc_properties); }
Signature · 1 line
2.41.0
Stefan Hajnoczi
AppliedApplied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes.