Message ID | 20220624003701.1363500-4-pdel@fb.com |
---|---|
State | New |
Headers | show |
Series | aspeed: Add multi-SoC machine | expand |
On 6/24/22 02:36, Peter Delevoryas wrote: > sysbus_mmio_map maps devices into "get_system_memory()". > > With the new SoC memory attribute, we want to make sure that each device is > mapped into the SoC memory. > > In single SoC machines, the SoC memory is the same as "get_system_memory()", > but in multi SoC machines it will be different. > > Signed-off-by: Peter Delevoryas <pdel@fb.com> Reviewed-by: Cédric Le Goater <clg@kaod.org> Thanks, C. > --- > hw/arm/aspeed_ast10x0.c | 25 +++++++++--------- > hw/arm/aspeed_ast2600.c | 51 ++++++++++++++++++++----------------- > hw/arm/aspeed_soc.c | 47 ++++++++++++++++++++-------------- > include/hw/arm/aspeed_soc.h | 1 + > 4 files changed, 69 insertions(+), 55 deletions(-) > > diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c > index e074f80cc7..f8f321374a 100644 > --- a/hw/arm/aspeed_ast10x0.c > +++ b/hw/arm/aspeed_ast10x0.c > @@ -188,7 +188,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]); > > /* I2C */ > > @@ -197,7 +197,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]); > + 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), > sc->irqmap[ASPEED_DEV_I2C] + i); > @@ -209,7 +209,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); > > /* Connect the LPC IRQ to the GIC. It is otherwise unused. */ > sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0, > @@ -243,7 +243,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->timerctrl), 0, > sc->memmap[ASPEED_DEV_TIMER1]); > for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { > qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i); > @@ -254,7 +254,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->adc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->adc), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_ADC)); > > @@ -264,8 +264,8 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->fmc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 1, > ASPEED_SMC_GET_CLASS(&s->fmc)->flash_window_base); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_FMC)); > @@ -277,9 +277,9 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 0, > sc->memmap[ASPEED_DEV_SPI1 + i]); > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 1, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 1, > ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base); > } > > @@ -287,7 +287,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->sbc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sbc), 0, sc->memmap[ASPEED_DEV_SBC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sbc), 0, sc->memmap[ASPEED_DEV_SBC]); > > /* Watch dog */ > for (i = 0; i < sc->wdts_num; i++) { > @@ -298,7 +298,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->wdt[i]), 0, > sc->memmap[ASPEED_DEV_WDT] + i * awc->offset); > } > > @@ -306,7 +306,8 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, sc->memmap[ASPEED_DEV_GPIO]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gpio), 0, > + sc->memmap[ASPEED_DEV_GPIO]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_GPIO)); > } > diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c > index d8e5b607e9..477dd36042 100644 > --- a/hw/arm/aspeed_ast2600.c > +++ b/hw/arm/aspeed_ast2600.c > @@ -310,7 +310,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > &error_abort); > > sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort); > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, ASPEED_A7MPCORE_ADDR); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->a7mpcore), 0, ASPEED_A7MPCORE_ADDR); > > for (i = 0; i < sc->num_cpus; i++) { > SysBusDevice *sbd = SYS_BUS_DEVICE(&s->a7mpcore); > @@ -344,13 +344,13 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]); > > /* RTC */ > if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_DEV_RTC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_DEV_RTC]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_RTC)); > > @@ -360,7 +360,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->timerctrl), 0, > sc->memmap[ASPEED_DEV_TIMER1]); > for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { > qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i); > @@ -371,7 +371,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->adc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->adc), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_ADC)); > > @@ -384,7 +384,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]); > + 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->a7mpcore), > sc->irqmap[ASPEED_DEV_I2C] + i); > @@ -398,8 +398,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->fmc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 1, > ASPEED_SMC_GET_CLASS(&s->fmc)->flash_window_base); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_FMC)); > @@ -411,9 +411,9 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 0, > sc->memmap[ASPEED_DEV_SPI1 + i]); > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 1, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 1, > ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base); > } > > @@ -422,7 +422,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->ehci[i]), 0, > sc->memmap[ASPEED_DEV_EHCI1 + i]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->ehci[i]), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_EHCI1 + i)); > @@ -432,7 +432,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, sc->memmap[ASPEED_DEV_SDMC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdmc), 0, > + sc->memmap[ASPEED_DEV_SDMC]); > > /* Watch dog */ > for (i = 0; i < sc->wdts_num; i++) { > @@ -443,7 +444,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->wdt[i]), 0, > sc->memmap[ASPEED_DEV_WDT] + i * awc->offset); > } > > @@ -454,7 +455,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, > sc->memmap[ASPEED_DEV_ETH1 + i]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_ETH1 + i)); > @@ -465,7 +466,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > return; > } > > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->mii[i]), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->mii[i]), 0, > sc->memmap[ASPEED_DEV_MII1 + i]); > } > > @@ -473,7 +474,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->xdma), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->xdma), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->xdma), 0, > sc->memmap[ASPEED_DEV_XDMA]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_XDMA)); > @@ -482,14 +483,14 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, sc->memmap[ASPEED_DEV_GPIO]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gpio), 0, sc->memmap[ASPEED_DEV_GPIO]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_GPIO)); > > if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio_1_8v), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio_1_8v), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gpio_1_8v), 0, > sc->memmap[ASPEED_DEV_GPIO_1_8V]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio_1_8v), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_GPIO_1_8V)); > @@ -498,7 +499,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdhci), 0, > sc->memmap[ASPEED_DEV_SDHCI]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_SDHCI)); > @@ -507,7 +508,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->emmc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->emmc), 0, sc->memmap[ASPEED_DEV_EMMC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->emmc), 0, > + sc->memmap[ASPEED_DEV_EMMC]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->emmc), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_EMMC)); > > @@ -515,7 +517,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); > > /* Connect the LPC IRQ to the GIC. It is otherwise unused. */ > sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0, > @@ -551,7 +553,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->hace), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->hace), 0, sc->memmap[ASPEED_DEV_HACE]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->hace), 0, > + sc->memmap[ASPEED_DEV_HACE]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_HACE)); > > @@ -559,7 +562,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->i3c), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]); > + 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->a7mpcore), > sc->irqmap[ASPEED_DEV_I3C] + i); > @@ -571,7 +574,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->sbc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sbc), 0, sc->memmap[ASPEED_DEV_SBC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sbc), 0, sc->memmap[ASPEED_DEV_SBC]); > } > > static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) > diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c > index 3b531519e9..46cbc63644 100644 > --- a/hw/arm/aspeed_soc.c > +++ b/hw/arm/aspeed_soc.c > @@ -268,13 +268,13 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]); > + 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)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->vic), 0, sc->memmap[ASPEED_DEV_VIC]); > + 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, > @@ -284,7 +284,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_DEV_RTC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_DEV_RTC]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_RTC)); > > @@ -294,7 +294,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->timerctrl), 0, > sc->memmap[ASPEED_DEV_TIMER1]); > for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { > qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i); > @@ -305,7 +305,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->adc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->adc), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_ADC)); > > @@ -318,7 +318,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_I2C)); > > @@ -328,8 +328,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->fmc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 1, > ASPEED_SMC_GET_CLASS(&s->fmc)->flash_window_base); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_FMC)); > @@ -339,9 +339,9 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 0, > sc->memmap[ASPEED_DEV_SPI1 + i]); > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 1, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 1, > ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base); > } > > @@ -350,7 +350,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->ehci[i]), 0, > sc->memmap[ASPEED_DEV_EHCI1 + i]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->ehci[i]), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_EHCI1 + i)); > @@ -360,7 +360,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, sc->memmap[ASPEED_DEV_SDMC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdmc), 0, > + sc->memmap[ASPEED_DEV_SDMC]); > > /* Watch dog */ > for (i = 0; i < sc->wdts_num; i++) { > @@ -371,7 +372,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->wdt[i]), 0, > sc->memmap[ASPEED_DEV_WDT] + i * awc->offset); > } > > @@ -382,7 +383,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, > sc->memmap[ASPEED_DEV_ETH1 + i]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_ETH1 + i)); > @@ -392,7 +393,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->xdma), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->xdma), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->xdma), 0, > sc->memmap[ASPEED_DEV_XDMA]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_XDMA)); > @@ -401,7 +402,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, sc->memmap[ASPEED_DEV_GPIO]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gpio), 0, > + sc->memmap[ASPEED_DEV_GPIO]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_GPIO)); > > @@ -409,7 +411,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci), 0, > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdhci), 0, > sc->memmap[ASPEED_DEV_SDHCI]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_SDHCI)); > @@ -418,7 +420,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); > > /* Connect the LPC IRQ to the VIC */ > sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0, > @@ -451,7 +453,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(&s->hace), errp)) { > return; > } > - sysbus_mmio_map(SYS_BUS_DEVICE(&s->hace), 0, sc->memmap[ASPEED_DEV_HACE]); > + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->hace), 0, > + sc->memmap[ASPEED_DEV_HACE]); > sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0, > aspeed_soc_get_irq(s, ASPEED_DEV_HACE)); > } > @@ -602,3 +605,9 @@ bool aspeed_soc_dram_init(AspeedSoCState *s, Error **errp) > &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)); > +} > diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h > index c8e903b821..1ab328d00c 100644 > --- a/include/hw/arm/aspeed_soc.h > +++ b/include/hw/arm/aspeed_soc.h > @@ -168,5 +168,6 @@ enum { > qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev); > void aspeed_soc_uart_init(AspeedSoCState *s); > bool aspeed_soc_dram_init(AspeedSoCState *s, Error **errp); > +void aspeed_mmio_map(AspeedSoCState *s, SysBusDevice *dev, int n, hwaddr addr); > > #endif /* ASPEED_SOC_H */
diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c index e074f80cc7..f8f321374a 100644 --- a/hw/arm/aspeed_ast10x0.c +++ b/hw/arm/aspeed_ast10x0.c @@ -188,7 +188,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]); /* I2C */ @@ -197,7 +197,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]); + 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), sc->irqmap[ASPEED_DEV_I2C] + i); @@ -209,7 +209,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); /* Connect the LPC IRQ to the GIC. It is otherwise unused. */ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0, @@ -243,7 +243,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->timerctrl), 0, sc->memmap[ASPEED_DEV_TIMER1]); for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i); @@ -254,7 +254,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->adc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->adc), 0, aspeed_soc_get_irq(s, ASPEED_DEV_ADC)); @@ -264,8 +264,8 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->fmc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 1, ASPEED_SMC_GET_CLASS(&s->fmc)->flash_window_base); sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0, aspeed_soc_get_irq(s, ASPEED_DEV_FMC)); @@ -277,9 +277,9 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 0, sc->memmap[ASPEED_DEV_SPI1 + i]); - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 1, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 1, ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base); } @@ -287,7 +287,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->sbc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sbc), 0, sc->memmap[ASPEED_DEV_SBC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sbc), 0, sc->memmap[ASPEED_DEV_SBC]); /* Watch dog */ for (i = 0; i < sc->wdts_num; i++) { @@ -298,7 +298,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->wdt[i]), 0, sc->memmap[ASPEED_DEV_WDT] + i * awc->offset); } @@ -306,7 +306,8 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, sc->memmap[ASPEED_DEV_GPIO]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gpio), 0, + sc->memmap[ASPEED_DEV_GPIO]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0, aspeed_soc_get_irq(s, ASPEED_DEV_GPIO)); } diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index d8e5b607e9..477dd36042 100644 --- a/hw/arm/aspeed_ast2600.c +++ b/hw/arm/aspeed_ast2600.c @@ -310,7 +310,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) &error_abort); sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort); - sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, ASPEED_A7MPCORE_ADDR); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->a7mpcore), 0, ASPEED_A7MPCORE_ADDR); for (i = 0; i < sc->num_cpus; i++) { SysBusDevice *sbd = SYS_BUS_DEVICE(&s->a7mpcore); @@ -344,13 +344,13 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]); /* RTC */ if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_DEV_RTC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_DEV_RTC]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, aspeed_soc_get_irq(s, ASPEED_DEV_RTC)); @@ -360,7 +360,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->timerctrl), 0, sc->memmap[ASPEED_DEV_TIMER1]); for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i); @@ -371,7 +371,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->adc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->adc), 0, aspeed_soc_get_irq(s, ASPEED_DEV_ADC)); @@ -384,7 +384,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]); + 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->a7mpcore), sc->irqmap[ASPEED_DEV_I2C] + i); @@ -398,8 +398,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->fmc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 1, ASPEED_SMC_GET_CLASS(&s->fmc)->flash_window_base); sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0, aspeed_soc_get_irq(s, ASPEED_DEV_FMC)); @@ -411,9 +411,9 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 0, sc->memmap[ASPEED_DEV_SPI1 + i]); - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 1, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 1, ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base); } @@ -422,7 +422,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->ehci[i]), 0, sc->memmap[ASPEED_DEV_EHCI1 + i]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->ehci[i]), 0, aspeed_soc_get_irq(s, ASPEED_DEV_EHCI1 + i)); @@ -432,7 +432,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, sc->memmap[ASPEED_DEV_SDMC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdmc), 0, + sc->memmap[ASPEED_DEV_SDMC]); /* Watch dog */ for (i = 0; i < sc->wdts_num; i++) { @@ -443,7 +444,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->wdt[i]), 0, sc->memmap[ASPEED_DEV_WDT] + i * awc->offset); } @@ -454,7 +455,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, sc->memmap[ASPEED_DEV_ETH1 + i]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, aspeed_soc_get_irq(s, ASPEED_DEV_ETH1 + i)); @@ -465,7 +466,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->mii[i]), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->mii[i]), 0, sc->memmap[ASPEED_DEV_MII1 + i]); } @@ -473,7 +474,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->xdma), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->xdma), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->xdma), 0, sc->memmap[ASPEED_DEV_XDMA]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0, aspeed_soc_get_irq(s, ASPEED_DEV_XDMA)); @@ -482,14 +483,14 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, sc->memmap[ASPEED_DEV_GPIO]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gpio), 0, sc->memmap[ASPEED_DEV_GPIO]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0, aspeed_soc_get_irq(s, ASPEED_DEV_GPIO)); if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio_1_8v), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio_1_8v), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gpio_1_8v), 0, sc->memmap[ASPEED_DEV_GPIO_1_8V]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio_1_8v), 0, aspeed_soc_get_irq(s, ASPEED_DEV_GPIO_1_8V)); @@ -498,7 +499,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdhci), 0, sc->memmap[ASPEED_DEV_SDHCI]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0, aspeed_soc_get_irq(s, ASPEED_DEV_SDHCI)); @@ -507,7 +508,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->emmc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->emmc), 0, sc->memmap[ASPEED_DEV_EMMC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->emmc), 0, + sc->memmap[ASPEED_DEV_EMMC]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->emmc), 0, aspeed_soc_get_irq(s, ASPEED_DEV_EMMC)); @@ -515,7 +517,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); /* Connect the LPC IRQ to the GIC. It is otherwise unused. */ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0, @@ -551,7 +553,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->hace), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->hace), 0, sc->memmap[ASPEED_DEV_HACE]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->hace), 0, + sc->memmap[ASPEED_DEV_HACE]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0, aspeed_soc_get_irq(s, ASPEED_DEV_HACE)); @@ -559,7 +562,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->i3c), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]); + 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->a7mpcore), sc->irqmap[ASPEED_DEV_I3C] + i); @@ -571,7 +574,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->sbc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sbc), 0, sc->memmap[ASPEED_DEV_SBC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sbc), 0, sc->memmap[ASPEED_DEV_SBC]); } static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c index 3b531519e9..46cbc63644 100644 --- a/hw/arm/aspeed_soc.c +++ b/hw/arm/aspeed_soc.c @@ -268,13 +268,13 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]); + 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)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->vic), 0, sc->memmap[ASPEED_DEV_VIC]); + 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, @@ -284,7 +284,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_DEV_RTC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_DEV_RTC]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, aspeed_soc_get_irq(s, ASPEED_DEV_RTC)); @@ -294,7 +294,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->timerctrl), 0, sc->memmap[ASPEED_DEV_TIMER1]); for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i); @@ -305,7 +305,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->adc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->adc), 0, aspeed_soc_get_irq(s, ASPEED_DEV_ADC)); @@ -318,7 +318,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0, aspeed_soc_get_irq(s, ASPEED_DEV_I2C)); @@ -328,8 +328,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->fmc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 1, ASPEED_SMC_GET_CLASS(&s->fmc)->flash_window_base); sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0, aspeed_soc_get_irq(s, ASPEED_DEV_FMC)); @@ -339,9 +339,9 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 0, sc->memmap[ASPEED_DEV_SPI1 + i]); - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 1, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 1, ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base); } @@ -350,7 +350,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ehci[i]), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->ehci[i]), 0, sc->memmap[ASPEED_DEV_EHCI1 + i]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->ehci[i]), 0, aspeed_soc_get_irq(s, ASPEED_DEV_EHCI1 + i)); @@ -360,7 +360,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, sc->memmap[ASPEED_DEV_SDMC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdmc), 0, + sc->memmap[ASPEED_DEV_SDMC]); /* Watch dog */ for (i = 0; i < sc->wdts_num; i++) { @@ -371,7 +372,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->wdt[i]), 0, sc->memmap[ASPEED_DEV_WDT] + i * awc->offset); } @@ -382,7 +383,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, sc->memmap[ASPEED_DEV_ETH1 + i]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, aspeed_soc_get_irq(s, ASPEED_DEV_ETH1 + i)); @@ -392,7 +393,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->xdma), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->xdma), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->xdma), 0, sc->memmap[ASPEED_DEV_XDMA]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0, aspeed_soc_get_irq(s, ASPEED_DEV_XDMA)); @@ -401,7 +402,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, sc->memmap[ASPEED_DEV_GPIO]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gpio), 0, + sc->memmap[ASPEED_DEV_GPIO]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0, aspeed_soc_get_irq(s, ASPEED_DEV_GPIO)); @@ -409,7 +411,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci), 0, + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdhci), 0, sc->memmap[ASPEED_DEV_SDHCI]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0, aspeed_soc_get_irq(s, ASPEED_DEV_SDHCI)); @@ -418,7 +420,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); /* Connect the LPC IRQ to the VIC */ sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0, @@ -451,7 +453,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(&s->hace), errp)) { return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->hace), 0, sc->memmap[ASPEED_DEV_HACE]); + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->hace), 0, + sc->memmap[ASPEED_DEV_HACE]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0, aspeed_soc_get_irq(s, ASPEED_DEV_HACE)); } @@ -602,3 +605,9 @@ bool aspeed_soc_dram_init(AspeedSoCState *s, Error **errp) &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)); +} diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h index c8e903b821..1ab328d00c 100644 --- a/include/hw/arm/aspeed_soc.h +++ b/include/hw/arm/aspeed_soc.h @@ -168,5 +168,6 @@ enum { qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev); void aspeed_soc_uart_init(AspeedSoCState *s); bool aspeed_soc_dram_init(AspeedSoCState *s, Error **errp); +void aspeed_mmio_map(AspeedSoCState *s, SysBusDevice *dev, int n, hwaddr addr); #endif /* ASPEED_SOC_H */
sysbus_mmio_map maps devices into "get_system_memory()". With the new SoC memory attribute, we want to make sure that each device is mapped into the SoC memory. In single SoC machines, the SoC memory is the same as "get_system_memory()", but in multi SoC machines it will be different. Signed-off-by: Peter Delevoryas <pdel@fb.com> --- hw/arm/aspeed_ast10x0.c | 25 +++++++++--------- hw/arm/aspeed_ast2600.c | 51 ++++++++++++++++++++----------------- hw/arm/aspeed_soc.c | 47 ++++++++++++++++++++-------------- include/hw/arm/aspeed_soc.h | 1 + 4 files changed, 69 insertions(+), 55 deletions(-)