1dd41ce7aSPhilippe Mathieu-Daudé /* 2dd41ce7aSPhilippe Mathieu-Daudé * ASPEED SoC family 3dd41ce7aSPhilippe Mathieu-Daudé * 4dd41ce7aSPhilippe Mathieu-Daudé * Andrew Jeffery <andrew@aj.id.au> 5dd41ce7aSPhilippe Mathieu-Daudé * Jeremy Kerr <jk@ozlabs.org> 6dd41ce7aSPhilippe Mathieu-Daudé * 7dd41ce7aSPhilippe Mathieu-Daudé * Copyright 2016 IBM Corp. 8dd41ce7aSPhilippe Mathieu-Daudé * 9dd41ce7aSPhilippe Mathieu-Daudé * This code is licensed under the GPL version 2 or later. See 10dd41ce7aSPhilippe Mathieu-Daudé * the COPYING file in the top-level directory. 11dd41ce7aSPhilippe Mathieu-Daudé */ 12dd41ce7aSPhilippe Mathieu-Daudé 13dd41ce7aSPhilippe Mathieu-Daudé #include "qemu/osdep.h" 14dd41ce7aSPhilippe Mathieu-Daudé #include "qemu/units.h" 15dd41ce7aSPhilippe Mathieu-Daudé #include "qapi/error.h" 16dd41ce7aSPhilippe Mathieu-Daudé #include "hw/misc/unimp.h" 17dd41ce7aSPhilippe Mathieu-Daudé #include "hw/arm/aspeed_soc.h" 18dd41ce7aSPhilippe Mathieu-Daudé #include "hw/char/serial.h" 19dd41ce7aSPhilippe Mathieu-Daudé #include "qemu/module.h" 20dd41ce7aSPhilippe Mathieu-Daudé #include "qemu/error-report.h" 21dd41ce7aSPhilippe Mathieu-Daudé #include "hw/i2c/aspeed_i2c.h" 22dd41ce7aSPhilippe Mathieu-Daudé #include "net/net.h" 23dd41ce7aSPhilippe Mathieu-Daudé #include "sysemu/sysemu.h" 24d780d056SPhilippe Mathieu-Daudé #include "target/arm/cpu-qom.h" 25dd41ce7aSPhilippe Mathieu-Daudé 26dd41ce7aSPhilippe Mathieu-Daudé #define ASPEED_SOC_IOMEM_SIZE 0x00200000 27dd41ce7aSPhilippe Mathieu-Daudé 28dd41ce7aSPhilippe Mathieu-Daudé static const hwaddr aspeed_soc_ast2400_memmap[] = { 29dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SPI_BOOT] = ASPEED_SOC_SPI_BOOT_ADDR, 30dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_IOMEM] = 0x1E600000, 31dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_FMC] = 0x1E620000, 32dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SPI1] = 0x1E630000, 33dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_EHCI1] = 0x1E6A1000, 34dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VIC] = 0x1E6C0000, 35dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDMC] = 0x1E6E0000, 36dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SCU] = 0x1E6E2000, 37dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_HACE] = 0x1E6E3000, 38dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_XDMA] = 0x1E6E7000, 39dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VIDEO] = 0x1E700000, 40dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ADC] = 0x1E6E9000, 41dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SRAM] = 0x1E720000, 42dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDHCI] = 0x1E740000, 43dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_GPIO] = 0x1E780000, 44dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_RTC] = 0x1E781000, 45dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER1] = 0x1E782000, 46dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_WDT] = 0x1E785000, 47dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_PWM] = 0x1E786000, 48dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_LPC] = 0x1E789000, 49dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_IBT] = 0x1E789140, 50dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_I2C] = 0x1E78A000, 51dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_PECI] = 0x1E78B000, 52dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ETH1] = 0x1E660000, 53dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ETH2] = 0x1E680000, 54dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART1] = 0x1E783000, 55dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART2] = 0x1E78D000, 56dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART3] = 0x1E78E000, 57dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART4] = 0x1E78F000, 58dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART5] = 0x1E784000, 59dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VUART] = 0x1E787000, 60dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDRAM] = 0x40000000, 61dd41ce7aSPhilippe Mathieu-Daudé }; 62dd41ce7aSPhilippe Mathieu-Daudé 63dd41ce7aSPhilippe Mathieu-Daudé static const hwaddr aspeed_soc_ast2500_memmap[] = { 64dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SPI_BOOT] = ASPEED_SOC_SPI_BOOT_ADDR, 65dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_IOMEM] = 0x1E600000, 66dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_FMC] = 0x1E620000, 67dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SPI1] = 0x1E630000, 68dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SPI2] = 0x1E631000, 69dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_EHCI1] = 0x1E6A1000, 70dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_EHCI2] = 0x1E6A3000, 71dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VIC] = 0x1E6C0000, 72dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDMC] = 0x1E6E0000, 73dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SCU] = 0x1E6E2000, 74dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_HACE] = 0x1E6E3000, 75dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_XDMA] = 0x1E6E7000, 76dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ADC] = 0x1E6E9000, 77dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VIDEO] = 0x1E700000, 78dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SRAM] = 0x1E720000, 79dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDHCI] = 0x1E740000, 80dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_GPIO] = 0x1E780000, 81dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_RTC] = 0x1E781000, 82dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER1] = 0x1E782000, 83dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_WDT] = 0x1E785000, 84dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_PWM] = 0x1E786000, 85dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_LPC] = 0x1E789000, 86dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_IBT] = 0x1E789140, 87dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_I2C] = 0x1E78A000, 88dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_PECI] = 0x1E78B000, 89dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ETH1] = 0x1E660000, 90dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ETH2] = 0x1E680000, 91dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART1] = 0x1E783000, 92dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART2] = 0x1E78D000, 93dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART3] = 0x1E78E000, 94dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART4] = 0x1E78F000, 95dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART5] = 0x1E784000, 96dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VUART] = 0x1E787000, 97dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDRAM] = 0x80000000, 98dd41ce7aSPhilippe Mathieu-Daudé }; 99dd41ce7aSPhilippe Mathieu-Daudé 100dd41ce7aSPhilippe Mathieu-Daudé static const int aspeed_soc_ast2400_irqmap[] = { 101dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART1] = 9, 102dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART2] = 32, 103dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART3] = 33, 104dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART4] = 34, 105dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART5] = 10, 106dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VUART] = 8, 107dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_FMC] = 19, 108dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_EHCI1] = 5, 109dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_EHCI2] = 13, 110dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDMC] = 0, 111dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SCU] = 21, 112dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ADC] = 31, 113dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_GPIO] = 20, 114dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_RTC] = 22, 115dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER1] = 16, 116dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER2] = 17, 117dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER3] = 18, 118dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER4] = 35, 119dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER5] = 36, 120dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER6] = 37, 121dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER7] = 38, 122dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER8] = 39, 123dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_WDT] = 27, 124dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_PWM] = 28, 125dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_LPC] = 8, 126dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_I2C] = 12, 127dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_PECI] = 15, 128dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ETH1] = 2, 129dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ETH2] = 3, 130dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_XDMA] = 6, 131dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDHCI] = 26, 132dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_HACE] = 4, 133dd41ce7aSPhilippe Mathieu-Daudé }; 134dd41ce7aSPhilippe Mathieu-Daudé 135dd41ce7aSPhilippe Mathieu-Daudé #define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap 136dd41ce7aSPhilippe Mathieu-Daudé 137dd41ce7aSPhilippe Mathieu-Daudé static qemu_irq aspeed_soc_ast2400_get_irq(AspeedSoCState *s, int dev) 138dd41ce7aSPhilippe Mathieu-Daudé { 139dd41ce7aSPhilippe Mathieu-Daudé Aspeed2400SoCState *a = ASPEED2400_SOC(s); 140dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); 141dd41ce7aSPhilippe Mathieu-Daudé 142dd41ce7aSPhilippe Mathieu-Daudé return qdev_get_gpio_in(DEVICE(&a->vic), sc->irqmap[dev]); 143dd41ce7aSPhilippe Mathieu-Daudé } 144dd41ce7aSPhilippe Mathieu-Daudé 145dd41ce7aSPhilippe Mathieu-Daudé static void aspeed_ast2400_soc_init(Object *obj) 146dd41ce7aSPhilippe Mathieu-Daudé { 147dd41ce7aSPhilippe Mathieu-Daudé Aspeed2400SoCState *a = ASPEED2400_SOC(obj); 148dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCState *s = ASPEED_SOC(obj); 149dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); 150dd41ce7aSPhilippe Mathieu-Daudé int i; 151dd41ce7aSPhilippe Mathieu-Daudé char socname[8]; 152dd41ce7aSPhilippe Mathieu-Daudé char typename[64]; 153dd41ce7aSPhilippe Mathieu-Daudé 154dd41ce7aSPhilippe Mathieu-Daudé if (sscanf(sc->name, "%7s", socname) != 1) { 155dd41ce7aSPhilippe Mathieu-Daudé g_assert_not_reached(); 156dd41ce7aSPhilippe Mathieu-Daudé } 157dd41ce7aSPhilippe Mathieu-Daudé 158dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->num_cpus; i++) { 159d815649cSPhilippe Mathieu-Daudé object_initialize_child(obj, "cpu[*]", &a->cpu[i], 160d815649cSPhilippe Mathieu-Daudé aspeed_soc_cpu_type(sc)); 161dd41ce7aSPhilippe Mathieu-Daudé } 162dd41ce7aSPhilippe Mathieu-Daudé 163dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.scu-%s", socname); 164dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "scu", &s->scu, typename); 165dd41ce7aSPhilippe Mathieu-Daudé qdev_prop_set_uint32(DEVICE(&s->scu), "silicon-rev", 166dd41ce7aSPhilippe Mathieu-Daudé sc->silicon_rev); 167dd41ce7aSPhilippe Mathieu-Daudé object_property_add_alias(obj, "hw-strap1", OBJECT(&s->scu), 168dd41ce7aSPhilippe Mathieu-Daudé "hw-strap1"); 169dd41ce7aSPhilippe Mathieu-Daudé object_property_add_alias(obj, "hw-strap2", OBJECT(&s->scu), 170dd41ce7aSPhilippe Mathieu-Daudé "hw-strap2"); 171dd41ce7aSPhilippe Mathieu-Daudé object_property_add_alias(obj, "hw-prot-key", OBJECT(&s->scu), 172dd41ce7aSPhilippe Mathieu-Daudé "hw-prot-key"); 173dd41ce7aSPhilippe Mathieu-Daudé 174dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "vic", &a->vic, TYPE_ASPEED_VIC); 175dd41ce7aSPhilippe Mathieu-Daudé 176dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "rtc", &s->rtc, TYPE_ASPEED_RTC); 177dd41ce7aSPhilippe Mathieu-Daudé 178dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.timer-%s", socname); 179dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "timerctrl", &s->timerctrl, typename); 180dd41ce7aSPhilippe Mathieu-Daudé 181dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.adc-%s", socname); 182dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "adc", &s->adc, typename); 183dd41ce7aSPhilippe Mathieu-Daudé 184dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.i2c-%s", socname); 185dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "i2c", &s->i2c, typename); 186dd41ce7aSPhilippe Mathieu-Daudé 187dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "peci", &s->peci, TYPE_ASPEED_PECI); 188dd41ce7aSPhilippe Mathieu-Daudé 189dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.fmc-%s", socname); 190dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "fmc", &s->fmc, typename); 191dd41ce7aSPhilippe Mathieu-Daudé 192dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->spis_num; i++) { 193dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, socname); 194dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "spi[*]", &s->spi[i], typename); 195dd41ce7aSPhilippe Mathieu-Daudé } 196dd41ce7aSPhilippe Mathieu-Daudé 197dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->ehcis_num; i++) { 198dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "ehci[*]", &s->ehci[i], 199dd41ce7aSPhilippe Mathieu-Daudé TYPE_PLATFORM_EHCI); 200dd41ce7aSPhilippe Mathieu-Daudé } 201dd41ce7aSPhilippe Mathieu-Daudé 202dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.sdmc-%s", socname); 203dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "sdmc", &s->sdmc, typename); 204dd41ce7aSPhilippe Mathieu-Daudé object_property_add_alias(obj, "ram-size", OBJECT(&s->sdmc), 205dd41ce7aSPhilippe Mathieu-Daudé "ram-size"); 206dd41ce7aSPhilippe Mathieu-Daudé 207dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->wdts_num; i++) { 208dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.wdt-%s", socname); 209dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "wdt[*]", &s->wdt[i], typename); 210dd41ce7aSPhilippe Mathieu-Daudé } 211dd41ce7aSPhilippe Mathieu-Daudé 212dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->macs_num; i++) { 213dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "ftgmac100[*]", &s->ftgmac100[i], 214dd41ce7aSPhilippe Mathieu-Daudé TYPE_FTGMAC100); 215dd41ce7aSPhilippe Mathieu-Daudé } 216dd41ce7aSPhilippe Mathieu-Daudé 217dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->uarts_num; i++) { 218dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "uart[*]", &s->uart[i], TYPE_SERIAL_MM); 219dd41ce7aSPhilippe Mathieu-Daudé } 220dd41ce7aSPhilippe Mathieu-Daudé 221dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), TYPE_ASPEED_XDMA "-%s", socname); 222dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "xdma", &s->xdma, typename); 223dd41ce7aSPhilippe Mathieu-Daudé 224dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.gpio-%s", socname); 225dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "gpio", &s->gpio, typename); 226dd41ce7aSPhilippe Mathieu-Daudé 227dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "sdc", &s->sdhci, TYPE_ASPEED_SDHCI); 228dd41ce7aSPhilippe Mathieu-Daudé 229dd41ce7aSPhilippe Mathieu-Daudé object_property_set_int(OBJECT(&s->sdhci), "num-slots", 2, &error_abort); 230dd41ce7aSPhilippe Mathieu-Daudé 231dd41ce7aSPhilippe Mathieu-Daudé /* Init sd card slot class here so that they're under the correct parent */ 232dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) { 233dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "sdhci[*]", &s->sdhci.slots[i], 234dd41ce7aSPhilippe Mathieu-Daudé TYPE_SYSBUS_SDHCI); 235dd41ce7aSPhilippe Mathieu-Daudé } 236dd41ce7aSPhilippe Mathieu-Daudé 237dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "lpc", &s->lpc, TYPE_ASPEED_LPC); 238dd41ce7aSPhilippe Mathieu-Daudé 239dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.hace-%s", socname); 240dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "hace", &s->hace, typename); 241dd41ce7aSPhilippe Mathieu-Daudé 242dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "iomem", &s->iomem, TYPE_UNIMPLEMENTED_DEVICE); 243dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "video", &s->video, TYPE_UNIMPLEMENTED_DEVICE); 244dd41ce7aSPhilippe Mathieu-Daudé } 245dd41ce7aSPhilippe Mathieu-Daudé 246dd41ce7aSPhilippe Mathieu-Daudé static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp) 247dd41ce7aSPhilippe Mathieu-Daudé { 248dd41ce7aSPhilippe Mathieu-Daudé int i; 249dd41ce7aSPhilippe Mathieu-Daudé Aspeed2400SoCState *a = ASPEED2400_SOC(dev); 250dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCState *s = ASPEED_SOC(dev); 251dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); 252dd41ce7aSPhilippe Mathieu-Daudé g_autofree char *sram_name = NULL; 253dd41ce7aSPhilippe Mathieu-Daudé 254dd41ce7aSPhilippe Mathieu-Daudé /* Default boot region (SPI memory or ROMs) */ 255dd41ce7aSPhilippe Mathieu-Daudé memory_region_init(&s->spi_boot_container, OBJECT(s), 256dd41ce7aSPhilippe Mathieu-Daudé "aspeed.spi_boot_container", 0x10000000); 257dd41ce7aSPhilippe Mathieu-Daudé memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_SPI_BOOT], 258dd41ce7aSPhilippe Mathieu-Daudé &s->spi_boot_container); 259dd41ce7aSPhilippe Mathieu-Daudé 260dd41ce7aSPhilippe Mathieu-Daudé /* IO space */ 261dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->iomem), "aspeed.io", 262dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_IOMEM], 263dd41ce7aSPhilippe Mathieu-Daudé ASPEED_SOC_IOMEM_SIZE); 264dd41ce7aSPhilippe Mathieu-Daudé 265dd41ce7aSPhilippe Mathieu-Daudé /* Video engine stub */ 266dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->video), "aspeed.video", 267dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_VIDEO], 0x1000); 268dd41ce7aSPhilippe Mathieu-Daudé 269dd41ce7aSPhilippe Mathieu-Daudé /* CPU */ 270dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->num_cpus; i++) { 271dd41ce7aSPhilippe Mathieu-Daudé object_property_set_link(OBJECT(&a->cpu[i]), "memory", 272dd41ce7aSPhilippe Mathieu-Daudé OBJECT(s->memory), &error_abort); 273dd41ce7aSPhilippe Mathieu-Daudé if (!qdev_realize(DEVICE(&a->cpu[i]), NULL, errp)) { 274dd41ce7aSPhilippe Mathieu-Daudé return; 275dd41ce7aSPhilippe Mathieu-Daudé } 276dd41ce7aSPhilippe Mathieu-Daudé } 277dd41ce7aSPhilippe Mathieu-Daudé 278dd41ce7aSPhilippe Mathieu-Daudé /* SRAM */ 279dd41ce7aSPhilippe Mathieu-Daudé sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&a->cpu[0])->cpu_index); 2802198f5f0SPhilippe Mathieu-Daudé if (!memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size, 2812198f5f0SPhilippe Mathieu-Daudé errp)) { 282dd41ce7aSPhilippe Mathieu-Daudé return; 283dd41ce7aSPhilippe Mathieu-Daudé } 284dd41ce7aSPhilippe Mathieu-Daudé memory_region_add_subregion(s->memory, 285dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_SRAM], &s->sram); 286dd41ce7aSPhilippe Mathieu-Daudé 287dd41ce7aSPhilippe Mathieu-Daudé /* SCU */ 288dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) { 289dd41ce7aSPhilippe Mathieu-Daudé return; 290dd41ce7aSPhilippe Mathieu-Daudé } 291dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]); 292dd41ce7aSPhilippe Mathieu-Daudé 293dd41ce7aSPhilippe Mathieu-Daudé /* VIC */ 294dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&a->vic), errp)) { 295dd41ce7aSPhilippe Mathieu-Daudé return; 296dd41ce7aSPhilippe Mathieu-Daudé } 297dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&a->vic), 0, sc->memmap[ASPEED_DEV_VIC]); 298dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&a->vic), 0, 299dd41ce7aSPhilippe Mathieu-Daudé qdev_get_gpio_in(DEVICE(&a->cpu), ARM_CPU_IRQ)); 300dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&a->vic), 1, 301dd41ce7aSPhilippe Mathieu-Daudé qdev_get_gpio_in(DEVICE(&a->cpu), ARM_CPU_FIQ)); 302dd41ce7aSPhilippe Mathieu-Daudé 303dd41ce7aSPhilippe Mathieu-Daudé /* RTC */ 304dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) { 305dd41ce7aSPhilippe Mathieu-Daudé return; 306dd41ce7aSPhilippe Mathieu-Daudé } 307dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_DEV_RTC]); 308dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, 309dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_RTC)); 310dd41ce7aSPhilippe Mathieu-Daudé 311dd41ce7aSPhilippe Mathieu-Daudé /* Timer */ 312dd41ce7aSPhilippe Mathieu-Daudé object_property_set_link(OBJECT(&s->timerctrl), "scu", OBJECT(&s->scu), 313dd41ce7aSPhilippe Mathieu-Daudé &error_abort); 314dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), errp)) { 315dd41ce7aSPhilippe Mathieu-Daudé return; 316dd41ce7aSPhilippe Mathieu-Daudé } 317dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->timerctrl), 0, 318dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_TIMER1]); 319dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { 320dd41ce7aSPhilippe Mathieu-Daudé qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i); 321dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq); 322dd41ce7aSPhilippe Mathieu-Daudé } 323dd41ce7aSPhilippe Mathieu-Daudé 324dd41ce7aSPhilippe Mathieu-Daudé /* ADC */ 325dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->adc), errp)) { 326dd41ce7aSPhilippe Mathieu-Daudé return; 327dd41ce7aSPhilippe Mathieu-Daudé } 328dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]); 329dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->adc), 0, 330dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_ADC)); 331dd41ce7aSPhilippe Mathieu-Daudé 332dd41ce7aSPhilippe Mathieu-Daudé /* UART */ 333dd41ce7aSPhilippe Mathieu-Daudé if (!aspeed_soc_uart_realize(s, errp)) { 334dd41ce7aSPhilippe Mathieu-Daudé return; 335dd41ce7aSPhilippe Mathieu-Daudé } 336dd41ce7aSPhilippe Mathieu-Daudé 337dd41ce7aSPhilippe Mathieu-Daudé /* I2C */ 338dd41ce7aSPhilippe Mathieu-Daudé object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr), 339dd41ce7aSPhilippe Mathieu-Daudé &error_abort); 340dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), errp)) { 341dd41ce7aSPhilippe Mathieu-Daudé return; 342dd41ce7aSPhilippe Mathieu-Daudé } 343dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]); 344dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0, 345dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_I2C)); 346dd41ce7aSPhilippe Mathieu-Daudé 347dd41ce7aSPhilippe Mathieu-Daudé /* PECI */ 348dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->peci), errp)) { 349dd41ce7aSPhilippe Mathieu-Daudé return; 350dd41ce7aSPhilippe Mathieu-Daudé } 351dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->peci), 0, 352dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_PECI]); 353dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->peci), 0, 354dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_PECI)); 355dd41ce7aSPhilippe Mathieu-Daudé 356dd41ce7aSPhilippe Mathieu-Daudé /* FMC, The number of CS is set at the board level */ 357dd41ce7aSPhilippe Mathieu-Daudé object_property_set_link(OBJECT(&s->fmc), "dram", OBJECT(s->dram_mr), 358dd41ce7aSPhilippe Mathieu-Daudé &error_abort); 359dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->fmc), errp)) { 360dd41ce7aSPhilippe Mathieu-Daudé return; 361dd41ce7aSPhilippe Mathieu-Daudé } 362dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]); 363dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 1, 364dd41ce7aSPhilippe Mathieu-Daudé ASPEED_SMC_GET_CLASS(&s->fmc)->flash_window_base); 365dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0, 366dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_FMC)); 367dd41ce7aSPhilippe Mathieu-Daudé 368dd41ce7aSPhilippe Mathieu-Daudé /* Set up an alias on the FMC CE0 region (boot default) */ 369dd41ce7aSPhilippe Mathieu-Daudé MemoryRegion *fmc0_mmio = &s->fmc.flashes[0].mmio; 370dd41ce7aSPhilippe Mathieu-Daudé memory_region_init_alias(&s->spi_boot, OBJECT(s), "aspeed.spi_boot", 371dd41ce7aSPhilippe Mathieu-Daudé fmc0_mmio, 0, memory_region_size(fmc0_mmio)); 372dd41ce7aSPhilippe Mathieu-Daudé memory_region_add_subregion(&s->spi_boot_container, 0x0, &s->spi_boot); 373dd41ce7aSPhilippe Mathieu-Daudé 374dd41ce7aSPhilippe Mathieu-Daudé /* SPI */ 375dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->spis_num; i++) { 376dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) { 377dd41ce7aSPhilippe Mathieu-Daudé return; 378dd41ce7aSPhilippe Mathieu-Daudé } 379dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 0, 380dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_SPI1 + i]); 381dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 1, 382dd41ce7aSPhilippe Mathieu-Daudé ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base); 383dd41ce7aSPhilippe Mathieu-Daudé } 384dd41ce7aSPhilippe Mathieu-Daudé 385dd41ce7aSPhilippe Mathieu-Daudé /* EHCI */ 386dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->ehcis_num; i++) { 387dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), errp)) { 388dd41ce7aSPhilippe Mathieu-Daudé return; 389dd41ce7aSPhilippe Mathieu-Daudé } 390dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->ehci[i]), 0, 391dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_EHCI1 + i]); 392dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->ehci[i]), 0, 393dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_EHCI1 + i)); 394dd41ce7aSPhilippe Mathieu-Daudé } 395dd41ce7aSPhilippe Mathieu-Daudé 396dd41ce7aSPhilippe Mathieu-Daudé /* SDMC - SDRAM Memory Controller */ 397dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), errp)) { 398dd41ce7aSPhilippe Mathieu-Daudé return; 399dd41ce7aSPhilippe Mathieu-Daudé } 400dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdmc), 0, 401dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_SDMC]); 402dd41ce7aSPhilippe Mathieu-Daudé 403dd41ce7aSPhilippe Mathieu-Daudé /* Watch dog */ 404dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->wdts_num; i++) { 405dd41ce7aSPhilippe Mathieu-Daudé AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(&s->wdt[i]); 406dd41ce7aSPhilippe Mathieu-Daudé hwaddr wdt_offset = sc->memmap[ASPEED_DEV_WDT] + i * awc->iosize; 407dd41ce7aSPhilippe Mathieu-Daudé 408dd41ce7aSPhilippe Mathieu-Daudé object_property_set_link(OBJECT(&s->wdt[i]), "scu", OBJECT(&s->scu), 409dd41ce7aSPhilippe Mathieu-Daudé &error_abort); 410dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), errp)) { 411dd41ce7aSPhilippe Mathieu-Daudé return; 412dd41ce7aSPhilippe Mathieu-Daudé } 413dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->wdt[i]), 0, wdt_offset); 414dd41ce7aSPhilippe Mathieu-Daudé } 415dd41ce7aSPhilippe Mathieu-Daudé 416dd41ce7aSPhilippe Mathieu-Daudé /* RAM */ 417dd41ce7aSPhilippe Mathieu-Daudé if (!aspeed_soc_dram_init(s, errp)) { 418dd41ce7aSPhilippe Mathieu-Daudé return; 419dd41ce7aSPhilippe Mathieu-Daudé } 420dd41ce7aSPhilippe Mathieu-Daudé 421dd41ce7aSPhilippe Mathieu-Daudé /* Net */ 422dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->macs_num; i++) { 423dd41ce7aSPhilippe Mathieu-Daudé object_property_set_bool(OBJECT(&s->ftgmac100[i]), "aspeed", true, 424dd41ce7aSPhilippe Mathieu-Daudé &error_abort); 425dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), errp)) { 426dd41ce7aSPhilippe Mathieu-Daudé return; 427dd41ce7aSPhilippe Mathieu-Daudé } 428dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, 429dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_ETH1 + i]); 430dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, 431dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_ETH1 + i)); 432dd41ce7aSPhilippe Mathieu-Daudé } 433dd41ce7aSPhilippe Mathieu-Daudé 434dd41ce7aSPhilippe Mathieu-Daudé /* XDMA */ 435dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->xdma), errp)) { 436dd41ce7aSPhilippe Mathieu-Daudé return; 437dd41ce7aSPhilippe Mathieu-Daudé } 438dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->xdma), 0, 439dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_XDMA]); 440dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0, 441dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_XDMA)); 442dd41ce7aSPhilippe Mathieu-Daudé 443dd41ce7aSPhilippe Mathieu-Daudé /* GPIO */ 444dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { 445dd41ce7aSPhilippe Mathieu-Daudé return; 446dd41ce7aSPhilippe Mathieu-Daudé } 447dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gpio), 0, 448dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_GPIO]); 449dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0, 450dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_GPIO)); 451dd41ce7aSPhilippe Mathieu-Daudé 452dd41ce7aSPhilippe Mathieu-Daudé /* SDHCI */ 453dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp)) { 454dd41ce7aSPhilippe Mathieu-Daudé return; 455dd41ce7aSPhilippe Mathieu-Daudé } 456dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdhci), 0, 457dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_SDHCI]); 458dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0, 459dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_SDHCI)); 460dd41ce7aSPhilippe Mathieu-Daudé 461dd41ce7aSPhilippe Mathieu-Daudé /* LPC */ 462dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) { 463dd41ce7aSPhilippe Mathieu-Daudé return; 464dd41ce7aSPhilippe Mathieu-Daudé } 465dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]); 466dd41ce7aSPhilippe Mathieu-Daudé 467dd41ce7aSPhilippe Mathieu-Daudé /* Connect the LPC IRQ to the VIC */ 468dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0, 469dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_LPC)); 470dd41ce7aSPhilippe Mathieu-Daudé 471dd41ce7aSPhilippe Mathieu-Daudé /* 472dd41ce7aSPhilippe Mathieu-Daudé * On the AST2400 and AST2500 the one LPC IRQ is shared between all of the 473dd41ce7aSPhilippe Mathieu-Daudé * subdevices. Connect the LPC subdevice IRQs to the LPC controller IRQ (by 474dd41ce7aSPhilippe Mathieu-Daudé * contrast, on the AST2600, the subdevice IRQs are connected straight to 475dd41ce7aSPhilippe Mathieu-Daudé * the GIC). 476dd41ce7aSPhilippe Mathieu-Daudé * 477dd41ce7aSPhilippe Mathieu-Daudé * LPC subdevice IRQ sources are offset from 1 because the shared IRQ output 478dd41ce7aSPhilippe Mathieu-Daudé * to the VIC is at offset 0. 479dd41ce7aSPhilippe Mathieu-Daudé */ 480dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_1, 481dd41ce7aSPhilippe Mathieu-Daudé qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_1)); 482dd41ce7aSPhilippe Mathieu-Daudé 483dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_2, 484dd41ce7aSPhilippe Mathieu-Daudé qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_2)); 485dd41ce7aSPhilippe Mathieu-Daudé 486dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_3, 487dd41ce7aSPhilippe Mathieu-Daudé qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_3)); 488dd41ce7aSPhilippe Mathieu-Daudé 489dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_4, 490dd41ce7aSPhilippe Mathieu-Daudé qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_4)); 491dd41ce7aSPhilippe Mathieu-Daudé 492dd41ce7aSPhilippe Mathieu-Daudé /* HACE */ 493dd41ce7aSPhilippe Mathieu-Daudé object_property_set_link(OBJECT(&s->hace), "dram", OBJECT(s->dram_mr), 494dd41ce7aSPhilippe Mathieu-Daudé &error_abort); 495dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->hace), errp)) { 496dd41ce7aSPhilippe Mathieu-Daudé return; 497dd41ce7aSPhilippe Mathieu-Daudé } 498dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->hace), 0, 499dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_HACE]); 500dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0, 501dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_HACE)); 502dd41ce7aSPhilippe Mathieu-Daudé } 503dd41ce7aSPhilippe Mathieu-Daudé 504dd41ce7aSPhilippe Mathieu-Daudé static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data) 505dd41ce7aSPhilippe Mathieu-Daudé { 506*dc13909eSPhilippe Mathieu-Daudé static const char * const valid_cpu_types[] = { 507*dc13909eSPhilippe Mathieu-Daudé ARM_CPU_TYPE_NAME("arm926"), 508*dc13909eSPhilippe Mathieu-Daudé NULL 509*dc13909eSPhilippe Mathieu-Daudé }; 510dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc); 511dd41ce7aSPhilippe Mathieu-Daudé DeviceClass *dc = DEVICE_CLASS(oc); 512dd41ce7aSPhilippe Mathieu-Daudé 513dd41ce7aSPhilippe Mathieu-Daudé dc->realize = aspeed_ast2400_soc_realize; 514dd41ce7aSPhilippe Mathieu-Daudé /* Reason: Uses serial_hds and nd_table in realize() directly */ 515dd41ce7aSPhilippe Mathieu-Daudé dc->user_creatable = false; 516dd41ce7aSPhilippe Mathieu-Daudé 517dd41ce7aSPhilippe Mathieu-Daudé sc->name = "ast2400-a1"; 518*dc13909eSPhilippe Mathieu-Daudé sc->valid_cpu_types = valid_cpu_types; 519dd41ce7aSPhilippe Mathieu-Daudé sc->silicon_rev = AST2400_A1_SILICON_REV; 520dd41ce7aSPhilippe Mathieu-Daudé sc->sram_size = 0x8000; 521dd41ce7aSPhilippe Mathieu-Daudé sc->spis_num = 1; 522dd41ce7aSPhilippe Mathieu-Daudé sc->ehcis_num = 1; 523dd41ce7aSPhilippe Mathieu-Daudé sc->wdts_num = 2; 524dd41ce7aSPhilippe Mathieu-Daudé sc->macs_num = 2; 525dd41ce7aSPhilippe Mathieu-Daudé sc->uarts_num = 5; 526dd41ce7aSPhilippe Mathieu-Daudé sc->irqmap = aspeed_soc_ast2400_irqmap; 527dd41ce7aSPhilippe Mathieu-Daudé sc->memmap = aspeed_soc_ast2400_memmap; 528dd41ce7aSPhilippe Mathieu-Daudé sc->num_cpus = 1; 529dd41ce7aSPhilippe Mathieu-Daudé sc->get_irq = aspeed_soc_ast2400_get_irq; 530dd41ce7aSPhilippe Mathieu-Daudé } 531dd41ce7aSPhilippe Mathieu-Daudé 532dd41ce7aSPhilippe Mathieu-Daudé static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data) 533dd41ce7aSPhilippe Mathieu-Daudé { 534*dc13909eSPhilippe Mathieu-Daudé static const char * const valid_cpu_types[] = { 535*dc13909eSPhilippe Mathieu-Daudé ARM_CPU_TYPE_NAME("arm1176"), 536*dc13909eSPhilippe Mathieu-Daudé NULL 537*dc13909eSPhilippe Mathieu-Daudé }; 538dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc); 539dd41ce7aSPhilippe Mathieu-Daudé DeviceClass *dc = DEVICE_CLASS(oc); 540dd41ce7aSPhilippe Mathieu-Daudé 541dd41ce7aSPhilippe Mathieu-Daudé dc->realize = aspeed_ast2400_soc_realize; 542dd41ce7aSPhilippe Mathieu-Daudé /* Reason: Uses serial_hds and nd_table in realize() directly */ 543dd41ce7aSPhilippe Mathieu-Daudé dc->user_creatable = false; 544dd41ce7aSPhilippe Mathieu-Daudé 545dd41ce7aSPhilippe Mathieu-Daudé sc->name = "ast2500-a1"; 546*dc13909eSPhilippe Mathieu-Daudé sc->valid_cpu_types = valid_cpu_types; 547dd41ce7aSPhilippe Mathieu-Daudé sc->silicon_rev = AST2500_A1_SILICON_REV; 548dd41ce7aSPhilippe Mathieu-Daudé sc->sram_size = 0x9000; 549dd41ce7aSPhilippe Mathieu-Daudé sc->spis_num = 2; 550dd41ce7aSPhilippe Mathieu-Daudé sc->ehcis_num = 2; 551dd41ce7aSPhilippe Mathieu-Daudé sc->wdts_num = 3; 552dd41ce7aSPhilippe Mathieu-Daudé sc->macs_num = 2; 553dd41ce7aSPhilippe Mathieu-Daudé sc->uarts_num = 5; 554dd41ce7aSPhilippe Mathieu-Daudé sc->irqmap = aspeed_soc_ast2500_irqmap; 555dd41ce7aSPhilippe Mathieu-Daudé sc->memmap = aspeed_soc_ast2500_memmap; 556dd41ce7aSPhilippe Mathieu-Daudé sc->num_cpus = 1; 557dd41ce7aSPhilippe Mathieu-Daudé sc->get_irq = aspeed_soc_ast2400_get_irq; 558dd41ce7aSPhilippe Mathieu-Daudé } 559dd41ce7aSPhilippe Mathieu-Daudé 560dd41ce7aSPhilippe Mathieu-Daudé static const TypeInfo aspeed_soc_ast2400_types[] = { 561dd41ce7aSPhilippe Mathieu-Daudé { 562dd41ce7aSPhilippe Mathieu-Daudé .name = TYPE_ASPEED2400_SOC, 563dd41ce7aSPhilippe Mathieu-Daudé .parent = TYPE_ASPEED_SOC, 564dd41ce7aSPhilippe Mathieu-Daudé .instance_init = aspeed_ast2400_soc_init, 565dd41ce7aSPhilippe Mathieu-Daudé .instance_size = sizeof(Aspeed2400SoCState), 566dd41ce7aSPhilippe Mathieu-Daudé .abstract = true, 567dd41ce7aSPhilippe Mathieu-Daudé }, { 568dd41ce7aSPhilippe Mathieu-Daudé .name = "ast2400-a1", 569dd41ce7aSPhilippe Mathieu-Daudé .parent = TYPE_ASPEED2400_SOC, 570dd41ce7aSPhilippe Mathieu-Daudé .class_init = aspeed_soc_ast2400_class_init, 571dd41ce7aSPhilippe Mathieu-Daudé }, { 572dd41ce7aSPhilippe Mathieu-Daudé .name = "ast2500-a1", 573dd41ce7aSPhilippe Mathieu-Daudé .parent = TYPE_ASPEED2400_SOC, 574dd41ce7aSPhilippe Mathieu-Daudé .class_init = aspeed_soc_ast2500_class_init, 575dd41ce7aSPhilippe Mathieu-Daudé }, 576dd41ce7aSPhilippe Mathieu-Daudé }; 577dd41ce7aSPhilippe Mathieu-Daudé 578dd41ce7aSPhilippe Mathieu-Daudé DEFINE_TYPES(aspeed_soc_ast2400_types) 579