aspeed: cleanups and extenstions
cover aspeed: cleanups and extenstions
Hello,
Here is a series adding a couple of cleanups to the Aspeed SoCs to prepare ground for extensions and new SoCs.
Thanks,
C.
Cédric Le Goater (3):
aspeed: add a per SoC mapping for the interrupt space
aspeed: add a per SoC mapping for the memory space
aspeed: use sysbus_init_child_obj() to initialize children
include/hw/arm/aspeed_soc.h | 3 +- hw/arm/aspeed_soc.c | 266 ++++++++++++++++++++++++------------ 2 files changed, 184 insertions(+), 85 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/3 aspeed: add a per SoC mapping for the interrupt space
This will simplify the definition of new SoCs, like the AST2600 which should use a different CPU and a different IRQ number layout.
--- include/hw/arm/aspeed_soc.h | 1 + hw/arm/aspeed_soc.c | 93 +++++++++++++++++++++++++++++++++---- 2 files changed, 86 insertions(+), 8 deletions(-)
include/hw/arm/aspeed_soc.h +1 -0
@@ -57,6 +57,7 @@ typedef struct AspeedSoCInfo {const char *fmc_typename;const char **spi_typename;int wdts_num; +const int *irqmap; } AspeedSoCInfo; typedef struct AspeedSoCClass {
hw/arm/aspeed_soc.c +85 -8
165 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-arm] [Qemu-devel] [PATCH 1/3] aspeed: add a per SoC mapping for the interrupt space
Hi Cédric,
Quoted 45 lines · Cédric Le Goater
This will simplify the definition of new SoCs, like the AST2600 which should use a different CPU and a different IRQ number layout.
Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/arm/aspeed_soc.h | 1 + hw/arm/aspeed_soc.c | 93 +++++++++++++++++++++++++++++++++---- 2 files changed, 86 insertions(+), 8 deletions(-)include/hw/arm/aspeed_soc.h +1
-0@@ -57,6 +57,7 @@ typedef struct AspeedSoCInfo {const char *fmc_typename;const char **spi_typename;int wdts_num; +const int *irqmap; } AspeedSoCInfo; typedef struct AspeedSoCClass {hw/arm/aspeed_soc.c +16
-0@@ -22,6 +22,42 @@#include "hw/i2c/aspeed_i2c.h" #include "net/net.h" +enum { +ASPEED_IOMEM , +ASPEED_UART1 , +ASPEED_UART2 , +ASPEED_UART3 , +ASPEED_UART4 , +ASPEED_UART5 , +ASPEED_VUART , +ASPEED_FMC , +ASPEED_SPI1 , +ASPEED_SPI2 , +ASPEED_VIC , +ASPEED_SDMC , +ASPEED_SCU , +ASPEED_ADC , +ASPEED_SRAM ,
hw/arm/aspeed_soc.c line 50
Quoted 10 lines
hw/arm/aspeed_soc.c +10
-0+ASPEED_GPIO , +ASPEED_RTC , +ASPEED_TIMER1 , +ASPEED_TIMER2 , +ASPEED_TIMER3 , +ASPEED_TIMER4 , +ASPEED_TIMER5 , +ASPEED_TIMER6 , +ASPEED_TIMER7 , + ASPEED_TIMER8,
You use an enum to define const values. It is recommended to also define the value, to avoid problems if someone add/remove a value in the list (unlikely, but we never know... imagine someone wants to try this SoC with 9 timers and add ASPEED_TIMER9) ;)
Quoted 146 lines
hw/arm/aspeed_soc.c +59
-8+ASPEED_WDT , +ASPEED_PWM , +ASPEED_LPC , +ASPEED_IBT , +ASPEED_I2C , +ASPEED_ETH1 , +ASPEED_ETH2 , + ASPEED_SDRAM, +}; +#define ASPEED_SOC_UART_5_BASE 0x00184000#define ASPEED_SOC_IOMEM_SIZE 0x00200000#define ASPEED_SOC_IOMEM_BASE 0x1E600000@@ -38,12 +74,42 @@#define ASPEED_SOC_ETH1_BASE 0x1E660000#define ASPEED_SOC_ETH2_BASE 0x1E680000 -static const int uart_irqs[] = {9 ,32 ,33 ,34 ,10 }; -static const int timer_irqs[] = {16 ,17 ,18 ,35 ,36 ,37 ,38 ,39 , }; +static const int aspeed_soc_ast2400_irqmap[] = { + [ASPEED_UART1 ] =9 , + [ASPEED_UART2 ] =32 , + [ASPEED_UART3 ] =33 , + [ASPEED_UART4 ] =34 , + [ASPEED_UART5 ] =10 , + [ASPEED_VUART ] =8 , + [ASPEED_FMC ] =19 , + [ASPEED_SDMC ] =0 , + [ASPEED_SCU ] =21 , + [ASPEED_ADC ] =31 , + [ASPEED_GPIO ] =20 , + [ASPEED_RTC ] =22 , + [ASPEED_TIMER1 ] =16 , + [ASPEED_TIMER2 ] =17 , + [ASPEED_TIMER3 ] =18 , + [ASPEED_TIMER4 ] =35 , + [ASPEED_TIMER5 ] =36 , + [ASPEED_TIMER6 ] =37 , + [ASPEED_TIMER7 ] =38 , + [ASPEED_TIMER8 ] =39 , + [ASPEED_WDT ] =27 , + [ASPEED_PWM ] =28 , + [ASPEED_LPC ] =8 , + [ASPEED_IBT ] =8 ,/* LPC */ + [ASPEED_I2C ] =12 , + [ASPEED_ETH1 ] =2 , + [ASPEED_ETH2 ] =3 , +};#define AST2400_SDRAM_BASE 0x40000000#define AST2500_SDRAM_BASE 0x80000000 +/* AST2500 uses the same IRQs as the AST2400 */ +#define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap +static const hwaddr aspeed_soc_ast2400_spi_bases[] = {ASPEED_SOC_SPI_BASE };static const char *aspeed_soc_ast2400_typenames[] = {"aspeed.smc.spi" };@@ -64,6 +130,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .fmc_typename = "aspeed.smc.fmc", .spi_typename = aspeed_soc_ast2400_typenames, .wdts_num = 2, + .irqmap = aspeed_soc_ast2400_irqmap, }, { .name = "ast2400-a1", .cpu_type = ARM_CPU_TYPE_NAME("arm926"),@@ -75,6 +142,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .fmc_typename = "aspeed.smc.fmc", .spi_typename = aspeed_soc_ast2400_typenames, .wdts_num = 2, + .irqmap = aspeed_soc_ast2400_irqmap, }, { .name = "ast2400", .cpu_type = ARM_CPU_TYPE_NAME("arm926"),@@ -86,6 +154,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .fmc_typename = "aspeed.smc.fmc", .spi_typename = aspeed_soc_ast2400_typenames, .wdts_num = 2, + .irqmap = aspeed_soc_ast2400_irqmap, }, { .name = "ast2500-a1", .cpu_type = ARM_CPU_TYPE_NAME("arm1176"),@@ -97,9 +166,17 @@ static const AspeedSoCInfo aspeed_socs[] = { .fmc_typename = "aspeed.smc.ast2500-fmc", .spi_typename = aspeed_soc_ast2500_typenames, .wdts_num = 3, + .irqmap = aspeed_soc_ast2500_irqmap, }, }; +static qemu_irq aspeed_soc_get_irq (AspeedSoCState *s,int ctrl) +{ +AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); + +return qdev_get_gpio_in (DEVICE (&s->vic), sc->info->irqmap[ctrl]); +} +static void aspeed_soc_init (Object *obj) {AspeedSoCState *s =ASPEED_SOC (obj);@@ -226,14 +303,14 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)return ; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->timerctrl),0 ,ASPEED_SOC_TIMER_BASE ); -for (i =0 ; i <ARRAY_SIZE (timer_irqs); i++) { -qemu_irq irq =qdev_get_gpio_in (DEVICE (&s->vic), timer_irqs[i]); +for (i =0 ; i <ASPEED_TIMER_NR_TIMERS ; i++) { +qemu_irq irq =aspeed_soc_get_irq (s,ASPEED_TIMER1 + i);sysbus_connect_irq (SYS_BUS_DEVICE (&s->timerctrl), i, irq); }/* UART - attach an 8250 to the IO space as our UART5 */ if (serial_hd (0 )) { -qemu_irq uart5 =qdev_get_gpio_in (DEVICE (&s->vic), uart_irqs[4 ]); +qemu_irq uart5 =aspeed_soc_get_irq (s,ASPEED_UART5 );serial_mm_init (get_system_memory (),ASPEED_SOC_IOMEM_BASE +ASPEED_SOC_UART_5_BASE ,2 , uart5,38400 ,serial_hd (0 ),DEVICE_LITTLE_ENDIAN );@@ -247,7 +324,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) }sysbus_mmio_map (SYS_BUS_DEVICE (&s->i2c),0 ,ASPEED_SOC_I2C_BASE );sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c),0 , -qdev_get_gpio_in (DEVICE (&s->vic),12 )); +aspeed_soc_get_irq (s,ASPEED_I2C ));/* FMC, The number of CS is set at the board level */ object_property_set_bool (OBJECT (&s->fmc), true,"realized" , &err);@@ -259,7 +336,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (SYS_BUS_DEVICE (&s->fmc),1 , s->fmc.ctrl->flash_window_base);sysbus_connect_irq (SYS_BUS_DEVICE (&s->fmc),0 , -qdev_get_gpio_in (DEVICE (&s->vic),19 )); +aspeed_soc_get_irq (s,ASPEED_FMC ));/* SPI */ for (i =0 ; i < sc->info->spis_num; i++) {@@ -307,7 +384,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) }sysbus_mmio_map (SYS_BUS_DEVICE (&s->ftgmac100),0 ,ASPEED_SOC_ETH1_BASE );sysbus_connect_irq (SYS_BUS_DEVICE (&s->ftgmac100),0 , -qdev_get_gpio_in (DEVICE (&s->vic),2 )); +aspeed_soc_get_irq (s,ASPEED_ETH1 )); }static void aspeed_soc_class_init (ObjectClass *oc,void *data)
Re: [Qemu-arm] [Qemu-devel] [PATCH 1/3] aspeed: add a per SoC mapping for the interrupt space
Quoted 55 lines · Philippe Mathieu-Daudé
Hi Cédric,
Quoted 52 lines · Cédric Le Goater
This will simplify the definition of new SoCs, like the AST2600 which should use a different CPU and a different IRQ number layout.
Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/arm/aspeed_soc.h | 1 + hw/arm/aspeed_soc.c | 93 +++++++++++++++++++++++++++++++++---- 2 files changed, 86 insertions(+), 8 deletions(-)include/hw/arm/aspeed_soc.h +1
-0@@ -57,6 +57,7 @@ typedef struct AspeedSoCInfo {const char *fmc_typename;const char **spi_typename;int wdts_num; +const int *irqmap; } AspeedSoCInfo; typedef struct AspeedSoCClass {hw/arm/aspeed_soc.c +23
-0@@ -22,6 +22,42 @@#include "hw/i2c/aspeed_i2c.h" #include "net/net.h" +enum { +ASPEED_IOMEM , +ASPEED_UART1 , +ASPEED_UART2 , +ASPEED_UART3 , +ASPEED_UART4 , +ASPEED_UART5 , +ASPEED_VUART , +ASPEED_FMC , +ASPEED_SPI1 , +ASPEED_SPI2 , +ASPEED_VIC , +ASPEED_SDMC , +ASPEED_SCU , +ASPEED_ADC , +ASPEED_SRAM , +ASPEED_GPIO , +ASPEED_RTC , +ASPEED_TIMER1 , +ASPEED_TIMER2 , +ASPEED_TIMER3 , +ASPEED_TIMER4 , +ASPEED_TIMER5 ,
Quoted 8 lines
hw/arm/aspeed_soc.c line 50
Quoted 3 lines
hw/arm/aspeed_soc.c +3
-0+ASPEED_TIMER6 , +ASPEED_TIMER7 , + ASPEED_TIMER8,You use an enum to define const values. It is recommended to also define the value, to avoid problems if someone add/remove a value in the list (unlikely, but we never know... imagine someone wants to try this SoC with 9 timers and add
ASPEED_TIMER9) ;)
The enum's not used outside of aspeed_soc.c though, so it should all be self-consistent? Adding ASPEED_TIMER9 would just adjust the designated initialiser index values in aspeed_soc_ast2400_irqmap declaration below. Am I missing something?
Specifying enum values seems tedious in this case.
Andrew
Quoted 148 lines
Quoted 147 lines
hw/arm/aspeed_soc.c +59
-8+ASPEED_WDT , +ASPEED_PWM , +ASPEED_LPC , +ASPEED_IBT , +ASPEED_I2C , +ASPEED_ETH1 , +ASPEED_ETH2 , + ASPEED_SDRAM, +}; +#define ASPEED_SOC_UART_5_BASE 0x00184000#define ASPEED_SOC_IOMEM_SIZE 0x00200000#define ASPEED_SOC_IOMEM_BASE 0x1E600000@@ -38,12 +74,42 @@#define ASPEED_SOC_ETH1_BASE 0x1E660000#define ASPEED_SOC_ETH2_BASE 0x1E680000 -static const int uart_irqs[] = {9 ,32 ,33 ,34 ,10 }; -static const int timer_irqs[] = {16 ,17 ,18 ,35 ,36 ,37 ,38 ,39 , }; +static const int aspeed_soc_ast2400_irqmap[] = { + [ASPEED_UART1 ] =9 , + [ASPEED_UART2 ] =32 , + [ASPEED_UART3 ] =33 , + [ASPEED_UART4 ] =34 , + [ASPEED_UART5 ] =10 , + [ASPEED_VUART ] =8 , + [ASPEED_FMC ] =19 , + [ASPEED_SDMC ] =0 , + [ASPEED_SCU ] =21 , + [ASPEED_ADC ] =31 , + [ASPEED_GPIO ] =20 , + [ASPEED_RTC ] =22 , + [ASPEED_TIMER1 ] =16 , + [ASPEED_TIMER2 ] =17 , + [ASPEED_TIMER3 ] =18 , + [ASPEED_TIMER4 ] =35 , + [ASPEED_TIMER5 ] =36 , + [ASPEED_TIMER6 ] =37 , + [ASPEED_TIMER7 ] =38 , + [ASPEED_TIMER8 ] =39 , + [ASPEED_WDT ] =27 , + [ASPEED_PWM ] =28 , + [ASPEED_LPC ] =8 , + [ASPEED_IBT ] =8 ,/* LPC */ + [ASPEED_I2C ] =12 , + [ASPEED_ETH1 ] =2 , + [ASPEED_ETH2 ] =3 , +};#define AST2400_SDRAM_BASE 0x40000000#define AST2500_SDRAM_BASE 0x80000000 +/* AST2500 uses the same IRQs as the AST2400 */ +#define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap +static const hwaddr aspeed_soc_ast2400_spi_bases[] = {ASPEED_SOC_SPI_BASE };static const char *aspeed_soc_ast2400_typenames[] = {"aspeed.smc.spi" };@@ -64,6 +130,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .fmc_typename = "aspeed.smc.fmc", .spi_typename = aspeed_soc_ast2400_typenames, .wdts_num = 2, + .irqmap = aspeed_soc_ast2400_irqmap, }, { .name = "ast2400-a1", .cpu_type = ARM_CPU_TYPE_NAME("arm926"),@@ -75,6 +142,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .fmc_typename = "aspeed.smc.fmc", .spi_typename = aspeed_soc_ast2400_typenames, .wdts_num = 2, + .irqmap = aspeed_soc_ast2400_irqmap, }, { .name = "ast2400", .cpu_type = ARM_CPU_TYPE_NAME("arm926"),@@ -86,6 +154,7 @@ static const AspeedSoCInfo aspeed_socs[] = { .fmc_typename = "aspeed.smc.fmc", .spi_typename = aspeed_soc_ast2400_typenames, .wdts_num = 2, + .irqmap = aspeed_soc_ast2400_irqmap, }, { .name = "ast2500-a1", .cpu_type = ARM_CPU_TYPE_NAME("arm1176"),@@ -97,9 +166,17 @@ static const AspeedSoCInfo aspeed_socs[] = { .fmc_typename = "aspeed.smc.ast2500-fmc", .spi_typename = aspeed_soc_ast2500_typenames, .wdts_num = 3, + .irqmap = aspeed_soc_ast2500_irqmap, }, }; +static qemu_irq aspeed_soc_get_irq (AspeedSoCState *s,int ctrl) +{ +AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); + +return qdev_get_gpio_in (DEVICE (&s->vic), sc->info->irqmap[ctrl]); +} +static void aspeed_soc_init (Object *obj) {AspeedSoCState *s =ASPEED_SOC (obj);@@ -226,14 +303,14 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)return ; }sysbus_mmio_map (SYS_BUS_DEVICE (&s->timerctrl),0 ,ASPEED_SOC_TIMER_BASE ); -for (i =0 ; i <ARRAY_SIZE (timer_irqs); i++) { -qemu_irq irq =qdev_get_gpio_in (DEVICE (&s->vic), timer_irqs[i]); +for (i =0 ; i <ASPEED_TIMER_NR_TIMERS ; i++) { +qemu_irq irq =aspeed_soc_get_irq (s,ASPEED_TIMER1 + i);sysbus_connect_irq (SYS_BUS_DEVICE (&s->timerctrl), i, irq); }/* UART - attach an 8250 to the IO space as our UART5 */ if (serial_hd (0 )) { -qemu_irq uart5 =qdev_get_gpio_in (DEVICE (&s->vic), uart_irqs[4 ]); +qemu_irq uart5 =aspeed_soc_get_irq (s,ASPEED_UART5 );serial_mm_init (get_system_memory (),ASPEED_SOC_IOMEM_BASE +ASPEED_SOC_UART_5_BASE ,2 , uart5,38400 ,serial_hd (0 ),DEVICE_LITTLE_ENDIAN );@@ -247,7 +324,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) }sysbus_mmio_map (SYS_BUS_DEVICE (&s->i2c),0 ,ASPEED_SOC_I2C_BASE );sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c),0 , -qdev_get_gpio_in (DEVICE (&s->vic),12 )); +aspeed_soc_get_irq (s,ASPEED_I2C ));/* FMC, The number of CS is set at the board level */ object_property_set_bool (OBJECT (&s->fmc), true,"realized" , &err);@@ -259,7 +336,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (SYS_BUS_DEVICE (&s->fmc),1 , s->fmc.ctrl->flash_window_base);sysbus_connect_irq (SYS_BUS_DEVICE (&s->fmc),0 , -qdev_get_gpio_in (DEVICE (&s->vic),19 )); +aspeed_soc_get_irq (s,ASPEED_FMC ));/* SPI */ for (i =0 ; i < sc->info->spis_num; i++) {@@ -307,7 +384,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) }sysbus_mmio_map (SYS_BUS_DEVICE (&s->ftgmac100),0 ,ASPEED_SOC_ETH1_BASE );sysbus_connect_irq (SYS_BUS_DEVICE (&s->ftgmac100),0 , -qdev_get_gpio_in (DEVICE (&s->vic),2 )); +aspeed_soc_get_irq (s,ASPEED_ETH1 )); }static void aspeed_soc_class_init (ObjectClass *oc,void *data)
Re: [Qemu-arm] [PATCH 1/3] aspeed: add a per SoC mapping for the interrupt space
In reply to Cédric Le GoaterQuoted 5 lines · Cédric Le Goater
This will simplify the definition of new SoCs, like the AST2600 which should use a different CPU and a different IRQ number layout.
Signed-off-by Cédric Le Goater <[email protected]>
PATCH 2/3 aspeed: add a per SoC mapping for the memory space
In reply to Cédric Le GoaterThis will simplify the definition of new SoCs, like the AST2600 which should use a slightly different address space and have a different set of controllers.
--- include/hw/arm/aspeed_soc.h | 2 +- hw/arm/aspeed_soc.c | 121 ++++++++++++++++++++++-------------- 2 files changed, 77 insertions(+), 46 deletions(-)
include/hw/arm/aspeed_soc.h +1 -1
@@ -53,11 +53,11 @@ typedef struct AspeedSoCInfo {hwaddr sdram_base;uint64_t sram_size;int spis_num; -const hwaddr *spi_bases;const char *fmc_typename;const char **spi_typename;int wdts_num;const int *irqmap; +const hwaddr *memmap; } AspeedSoCInfo; typedef struct AspeedSoCClass {
hw/arm/aspeed_soc.c +76 -45
251 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [Qemu-arm] [PATCH 2/3] aspeed: add a per SoC mapping for the memory space
Quoted 11 lines · Cédric Le Goater
This will simplify the definition of new SoCs, like the AST2600 which should use a slightly different address space and have a different set of controllers.
Signed-off-by Cédric Le Goater <[email protected]>hw/arm/aspeed_soc.c +0
-0
hw/arm/aspeed_soc.c enum {
Quoted 4 lines
hw/arm/aspeed_soc.c +2
-0+static const hwaddr aspeed_soc_ast2400_memmap[] = { +static const hwaddr aspeed_soc_ast2500_memmap[] = {
Most of these arrays is common. And some of it will stay common in the 2600. Any ideas how we could avoid duplication?
This is fine for now.
Andrew Jeffery
Reviewed-byRe: [Qemu-arm] [PATCH 2/3] aspeed: add a per SoC mapping for the memory space
Quoted 13 lines · Joel Stanley
Quoted 11 lines · Cédric Le Goater
This will simplify the definition of new SoCs, like the AST2600 which should use a slightly different address space and have a different set of controllers.
Signed-off-by Cédric Le Goater <[email protected]>hw/arm/aspeed_soc.c +0
-0
Quoted 6 lines
hw/arm/aspeed_soc.c enum {
Quoted 3 lines
hw/arm/aspeed_soc.c +2
-0+static const hwaddr aspeed_soc_ast2400_memmap[] = { +static const hwaddr aspeed_soc_ast2500_memmap[] = {Most of these arrays is common. And some of it will stay common in the 2600. Any ideas how we could avoid duplication?
I dunno, I feel that any attempt to create some "common" layout concept is more distracting than having soc-specific, complete layouts described.
There's no reason why they're common beyond coincidence (i.e. it's at ASPEED's whim). I think this is fine.
Quoted 5 lines
This is fine for now.
Reviewed-by Joel Stanley <[email protected]>
Re: [Qemu-arm] [PATCH 2/3] aspeed: add a per SoC mapping for the memory space
Quoted 18 lines · Andrew Jeffery
Quoted 15 lines · Joel Stanley
Quoted 13 lines · Cédric Le Goater
This will simplify the definition of new SoCs, like the AST2600 which should use a slightly different address space and have a different set of controllers.
Signed-off-by Cédric Le Goater <[email protected]>hw/arm/aspeed_soc.c +1
-0+static const hwaddr aspeed_soc_ast2400_memmap[] = {
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
+static const hwaddr aspeed_soc_ast2500_memmap[] = {
Most of these arrays is common. And some of it will stay common in the 2600. Any ideas how we could avoid duplication?
I dunno, I feel that any attempt to create some "common" layout concept is more distracting than having soc-specific, complete layouts described.
yes. I rather duplicate some values and see in one glance the full address space.
Thanks,
C.
Quoted 11 lines
There's no reason why they're common beyond coincidence (i.e. it's at ASPEED's whim). I think this is fine.
Reviewed-by Andrew Jeffery <[email protected]>Quoted 5 lines
This is fine for now.
Reviewed-by Joel Stanley <[email protected]>
PATCH 3/3 aspeed: use sysbus_init_child_obj() to initialize children
In reply to Cédric Le Goater--- hw/arm/aspeed_soc.c | 50 ++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 30 deletions(-)
hw/arm/aspeed_soc.c +20 -30
@@ -212,12 +212,11 @@ static void aspeed_soc_init(Object *obj)AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s);int i; -object_initialize (&s->cpu,sizeof (s->cpu), sc->info->cpu_type); -object_property_add_child (obj,"cpu" ,OBJECT (&s->cpu),NULL ); +object_initialize_child (obj,"cpu" ,OBJECT (&s->cpu),sizeof (s->cpu), + sc->info->cpu_type, &error_abort,NULL ); -object_initialize (&s->scu,sizeof (s->scu),TYPE_ASPEED_SCU ); -object_property_add_child (obj,"scu" ,OBJECT (&s->scu),NULL ); -qdev_set_parent_bus (DEVICE (&s->scu),sysbus_get_default ()); +sysbus_init_child_obj (obj,"scu" ,OBJECT (&s->scu),sizeof (s->scu), +TYPE_ASPEED_SCU );qdev_prop_set_uint32 (DEVICE (&s->scu),"silicon-rev" , sc->info->silicon_rev); object_property_add_alias(obj, "hw-strap1", OBJECT(&s->scu),
@@ -227,36 +226,29 @@ static void aspeed_soc_init(Object *obj)object_property_add_alias (obj,"hw-prot-key" ,OBJECT (&s->scu),"hw-prot-key" , &error_abort); -object_initialize (&s->vic,sizeof (s->vic),TYPE_ASPEED_VIC ); -object_property_add_child (obj,"vic" ,OBJECT (&s->vic),NULL ); -qdev_set_parent_bus (DEVICE (&s->vic),sysbus_get_default ()); +sysbus_init_child_obj (obj,"vic" ,OBJECT (&s->vic),sizeof (s->vic), +TYPE_ASPEED_VIC ); -object_initialize (&s->timerctrl,sizeof (s->timerctrl),TYPE_ASPEED_TIMER ); -object_property_add_child (obj,"timerctrl" ,OBJECT (&s->timerctrl),NULL ); +sysbus_init_child_obj (obj,"timerctrl" ,OBJECT (&s->timerctrl), +sizeof (s->timerctrl),TYPE_ASPEED_TIMER );object_property_add_const_link (OBJECT (&s->timerctrl),"scu" ,OBJECT (&s->scu), &error_abort); -qdev_set_parent_bus (DEVICE (&s->timerctrl),sysbus_get_default ()); -object_initialize (&s->i2c,sizeof (s->i2c),TYPE_ASPEED_I2C ); -object_property_add_child (obj,"i2c" ,OBJECT (&s->i2c),NULL ); -qdev_set_parent_bus (DEVICE (&s->i2c),sysbus_get_default ()); +sysbus_init_child_obj (obj,"i2c" ,OBJECT (&s->i2c),sizeof (s->i2c), +TYPE_ASPEED_I2C ); -object_initialize (&s->fmc,sizeof (s->fmc), sc->info->fmc_typename); -object_property_add_child (obj,"fmc" ,OBJECT (&s->fmc),NULL ); -qdev_set_parent_bus (DEVICE (&s->fmc),sysbus_get_default ()); +sysbus_init_child_obj (obj,"fmc" ,OBJECT (&s->fmc),sizeof (s->fmc), + sc->info->fmc_typename);object_property_add_alias (obj,"num-cs" ,OBJECT (&s->fmc),"num-cs" , &error_abort);for (i =0 ; i < sc->info->spis_num; i++) { -object_initialize (&s->spi[i],sizeof (s->spi[i]), - sc->info->spi_typename[i]); -object_property_add_child (obj,"spi[*]" ,OBJECT (&s->spi[i]),NULL ); -qdev_set_parent_bus (DEVICE (&s->spi[i]),sysbus_get_default ()); +sysbus_init_child_obj (obj,"spi[*]" ,OBJECT (&s->spi[i]), +sizeof (s->spi[i]), sc->info->spi_typename[i]); } -object_initialize (&s->sdmc,sizeof (s->sdmc),TYPE_ASPEED_SDMC ); -object_property_add_child (obj,"sdmc" ,OBJECT (&s->sdmc),NULL ); -qdev_set_parent_bus (DEVICE (&s->sdmc),sysbus_get_default ()); +sysbus_init_child_obj (obj,"sdmc" ,OBJECT (&s->sdmc),sizeof (s->sdmc), +TYPE_ASPEED_SDMC );qdev_prop_set_uint32 (DEVICE (&s->sdmc),"silicon-rev" , sc->info->silicon_rev); object_property_add_alias(obj, "ram-size", OBJECT(&s->sdmc),
@@ -265,16 +257,14 @@ static void aspeed_soc_init(Object *obj) "max-ram-size", &error_abort);for (i =0 ; i < sc->info->wdts_num; i++) { -object_initialize (&s->wdt[i],sizeof (s->wdt[i]),TYPE_ASPEED_WDT ); -object_property_add_child (obj,"wdt[*]" ,OBJECT (&s->wdt[i]),NULL ); -qdev_set_parent_bus (DEVICE (&s->wdt[i]),sysbus_get_default ()); +sysbus_init_child_obj (obj,"wdt[*]" ,OBJECT (&s->wdt[i]), +sizeof (s->wdt[i]),TYPE_ASPEED_WDT );qdev_prop_set_uint32 (DEVICE (&s->wdt[i]),"silicon-rev" , sc->info->silicon_rev); } -object_initialize (&s->ftgmac100,sizeof (s->ftgmac100),TYPE_FTGMAC100 ); -object_property_add_child (obj,"ftgmac100" ,OBJECT (&s->ftgmac100),NULL ); -qdev_set_parent_bus (DEVICE (&s->ftgmac100),sysbus_get_default ()); +sysbus_init_child_obj (obj,"ftgmac100" ,OBJECT (&s->ftgmac100), +sizeof (s->ftgmac100),TYPE_FTGMAC100 ); }static void aspeed_soc_realize (DeviceState *dev,Error **errp)
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH 3/3] aspeed: use sysbus_init_child_obj() to initialize children
Quoted 2 lines · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>
Re: [Qemu-arm] [PATCH 3/3] aspeed: use sysbus_init_child_obj() to initialize children
In reply to Cédric Le GoaterQuoted 1 line · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>
Quoted 99 lines
--- hw/arm/aspeed_soc.c | 50 ++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 30 deletions(-)hw/arm/aspeed_soc.c +20
-30@@ -212,12 +212,11 @@ static void aspeed_soc_init(Object *obj)AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s);int i; -object_initialize (&s->cpu,sizeof (s->cpu), sc->info->cpu_type); -object_property_add_child (obj,"cpu" ,OBJECT (&s->cpu),NULL ); +object_initialize_child (obj,"cpu" ,OBJECT (&s->cpu),sizeof (s->cpu), + sc->info->cpu_type, &error_abort,NULL ); -object_initialize (&s->scu,sizeof (s->scu),TYPE_ASPEED_SCU ); -object_property_add_child (obj,"scu" ,OBJECT (&s->scu),NULL ); -qdev_set_parent_bus (DEVICE (&s->scu),sysbus_get_default ()); +sysbus_init_child_obj (obj,"scu" ,OBJECT (&s->scu),sizeof (s->scu), +TYPE_ASPEED_SCU );qdev_prop_set_uint32 (DEVICE (&s->scu),"silicon-rev" , sc->info->silicon_rev); object_property_add_alias(obj, "hw-strap1", OBJECT(&s->scu),@@ -227,36 +226,29 @@ static void aspeed_soc_init(Object *obj)object_property_add_alias (obj,"hw-prot-key" ,OBJECT (&s->scu),"hw-prot-key" , &error_abort); -object_initialize (&s->vic,sizeof (s->vic),TYPE_ASPEED_VIC ); -object_property_add_child (obj,"vic" ,OBJECT (&s->vic),NULL ); -qdev_set_parent_bus (DEVICE (&s->vic),sysbus_get_default ()); +sysbus_init_child_obj (obj,"vic" ,OBJECT (&s->vic),sizeof (s->vic), +TYPE_ASPEED_VIC ); -object_initialize (&s->timerctrl,sizeof (s->timerctrl),TYPE_ASPEED_TIMER ); -object_property_add_child (obj,"timerctrl" ,OBJECT (&s->timerctrl),NULL ); +sysbus_init_child_obj (obj,"timerctrl" ,OBJECT (&s->timerctrl), +sizeof (s->timerctrl),TYPE_ASPEED_TIMER );object_property_add_const_link (OBJECT (&s->timerctrl),"scu" ,OBJECT (&s->scu), &error_abort); -qdev_set_parent_bus (DEVICE (&s->timerctrl),sysbus_get_default ()); -object_initialize (&s->i2c,sizeof (s->i2c),TYPE_ASPEED_I2C ); -object_property_add_child (obj,"i2c" ,OBJECT (&s->i2c),NULL ); -qdev_set_parent_bus (DEVICE (&s->i2c),sysbus_get_default ()); +sysbus_init_child_obj (obj,"i2c" ,OBJECT (&s->i2c),sizeof (s->i2c), +TYPE_ASPEED_I2C ); -object_initialize (&s->fmc,sizeof (s->fmc), sc->info->fmc_typename); -object_property_add_child (obj,"fmc" ,OBJECT (&s->fmc),NULL ); -qdev_set_parent_bus (DEVICE (&s->fmc),sysbus_get_default ()); +sysbus_init_child_obj (obj,"fmc" ,OBJECT (&s->fmc),sizeof (s->fmc), + sc->info->fmc_typename);object_property_add_alias (obj,"num-cs" ,OBJECT (&s->fmc),"num-cs" , &error_abort);for (i =0 ; i < sc->info->spis_num; i++) { -object_initialize (&s->spi[i],sizeof (s->spi[i]), - sc->info->spi_typename[i]); -object_property_add_child (obj,"spi[*]" ,OBJECT (&s->spi[i]),NULL ); -qdev_set_parent_bus (DEVICE (&s->spi[i]),sysbus_get_default ()); +sysbus_init_child_obj (obj,"spi[*]" ,OBJECT (&s->spi[i]), +sizeof (s->spi[i]), sc->info->spi_typename[i]); } -object_initialize (&s->sdmc,sizeof (s->sdmc),TYPE_ASPEED_SDMC ); -object_property_add_child (obj,"sdmc" ,OBJECT (&s->sdmc),NULL ); -qdev_set_parent_bus (DEVICE (&s->sdmc),sysbus_get_default ()); +sysbus_init_child_obj (obj,"sdmc" ,OBJECT (&s->sdmc),sizeof (s->sdmc), +TYPE_ASPEED_SDMC );qdev_prop_set_uint32 (DEVICE (&s->sdmc),"silicon-rev" , sc->info->silicon_rev); object_property_add_alias(obj, "ram-size", OBJECT(&s->sdmc),@@ -265,16 +257,14 @@ static void aspeed_soc_init(Object *obj) "max-ram-size", &error_abort);for (i =0 ; i < sc->info->wdts_num; i++) { -object_initialize (&s->wdt[i],sizeof (s->wdt[i]),TYPE_ASPEED_WDT ); -object_property_add_child (obj,"wdt[*]" ,OBJECT (&s->wdt[i]),NULL ); -qdev_set_parent_bus (DEVICE (&s->wdt[i]),sysbus_get_default ()); +sysbus_init_child_obj (obj,"wdt[*]" ,OBJECT (&s->wdt[i]), +sizeof (s->wdt[i]),TYPE_ASPEED_WDT );qdev_prop_set_uint32 (DEVICE (&s->wdt[i]),"silicon-rev" , sc->info->silicon_rev); } -object_initialize (&s->ftgmac100,sizeof (s->ftgmac100),TYPE_FTGMAC100 ); -object_property_add_child (obj,"ftgmac100" ,OBJECT (&s->ftgmac100),NULL ); -qdev_set_parent_bus (DEVICE (&s->ftgmac100),sysbus_get_default ()); +sysbus_init_child_obj (obj,"ftgmac100" ,OBJECT (&s->ftgmac100), +sizeof (s->ftgmac100),TYPE_FTGMAC100 ); }static void aspeed_soc_realize (DeviceState *dev,Error **errp)Signature · 1 line
2.20.1
Peter Maydell
AppliedQuoted 6 lines · Cédric Le Goater
Hello,
Here is a series adding a couple of cleanups to the Aspeed SoCs to prepare ground for extensions and new SoCs.
Quoted 9 lines
Thanks,
C.
Cédric Le Goater (3):
aspeed: add a per SoC mapping for the interrupt space
aspeed: add a per SoC mapping for the memory space
aspeed: usesysbus_init_child_obj()to initialize children
Applied to target-arm.next, thanks.
-- PMM
Quoted 20 lines · Peter Maydell
Quoted 6 lines · Cédric Le Goater
Hello,
Here is a series adding a couple of cleanups to the Aspeed SoCs to prepare ground for extensions and new SoCs.
Quoted 9 lines
Thanks,
C.
Cédric Le Goater (3):
aspeed: add a per SoC mapping for the interrupt space
aspeed: add a per SoC mapping for the memory space
aspeed: usesysbus_init_child_obj()to initialize children
Quoted 1 line
Applied to target-arm.next, thanks.
...spoke too soon. Clang doesn't like this:
/home/petmay01/linaro/qemu-from-laptop/qemu/hw/arm/aspeed_soc.c:155:25:
error: initializer element is not a
compile-time constant
.sdram_base = aspeed_soc_ast2400_memmap[ASPEED_SDRAM],
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated. /home/petmay01/linaro/qemu-from-laptop/qemu/rules.mak:69: recipe for target 'hw/arm/aspeed_soc.o' failed
thanks
-- PMM