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"
187e6b5497SBernhard Beschow #include "hw/char/serial-mm.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[] = {
29db052d0eSJamin Lin [ASPEED_DEV_SPI_BOOT] = 0x00000000,
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,
345efe45c1SGuenter Roeck [ASPEED_DEV_UHCI] = 0x1E6B0000,
35dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VIC] = 0x1E6C0000,
36dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDMC] = 0x1E6E0000,
37dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SCU] = 0x1E6E2000,
38dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_HACE] = 0x1E6E3000,
39a726d631SJoel Stanley [ASPEED_DEV_GFX] = 0x1E6E6000,
40dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_XDMA] = 0x1E6E7000,
41dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VIDEO] = 0x1E700000,
42dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ADC] = 0x1E6E9000,
43dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SRAM] = 0x1E720000,
44dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDHCI] = 0x1E740000,
45dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_GPIO] = 0x1E780000,
46dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_RTC] = 0x1E781000,
47dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER1] = 0x1E782000,
48dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_WDT] = 0x1E785000,
49dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_PWM] = 0x1E786000,
50dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_LPC] = 0x1E789000,
51dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_IBT] = 0x1E789140,
52dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_I2C] = 0x1E78A000,
53dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_PECI] = 0x1E78B000,
54dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ETH1] = 0x1E660000,
55dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ETH2] = 0x1E680000,
56dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART1] = 0x1E783000,
57dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART2] = 0x1E78D000,
58dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART3] = 0x1E78E000,
59dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART4] = 0x1E78F000,
60dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART5] = 0x1E784000,
61dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VUART] = 0x1E787000,
62dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDRAM] = 0x40000000,
63dd41ce7aSPhilippe Mathieu-Daudé };
64dd41ce7aSPhilippe Mathieu-Daudé
65dd41ce7aSPhilippe Mathieu-Daudé static const hwaddr aspeed_soc_ast2500_memmap[] = {
66db052d0eSJamin Lin [ASPEED_DEV_SPI_BOOT] = 0x00000000,
67dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_IOMEM] = 0x1E600000,
68dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_FMC] = 0x1E620000,
69dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SPI1] = 0x1E630000,
70dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SPI2] = 0x1E631000,
71dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_EHCI1] = 0x1E6A1000,
72dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_EHCI2] = 0x1E6A3000,
735efe45c1SGuenter Roeck [ASPEED_DEV_UHCI] = 0x1E6B0000,
74dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VIC] = 0x1E6C0000,
75dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDMC] = 0x1E6E0000,
76dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SCU] = 0x1E6E2000,
77dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_HACE] = 0x1E6E3000,
78a726d631SJoel Stanley [ASPEED_DEV_GFX] = 0x1E6E6000,
79dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_XDMA] = 0x1E6E7000,
80dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ADC] = 0x1E6E9000,
81dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VIDEO] = 0x1E700000,
82dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SRAM] = 0x1E720000,
83dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDHCI] = 0x1E740000,
84dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_GPIO] = 0x1E780000,
85dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_RTC] = 0x1E781000,
86dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER1] = 0x1E782000,
87dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_WDT] = 0x1E785000,
88dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_PWM] = 0x1E786000,
89dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_LPC] = 0x1E789000,
90dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_IBT] = 0x1E789140,
91dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_I2C] = 0x1E78A000,
92dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_PECI] = 0x1E78B000,
93dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ETH1] = 0x1E660000,
94dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ETH2] = 0x1E680000,
95dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART1] = 0x1E783000,
96dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART2] = 0x1E78D000,
97dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART3] = 0x1E78E000,
98dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART4] = 0x1E78F000,
99dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART5] = 0x1E784000,
100dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VUART] = 0x1E787000,
101dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDRAM] = 0x80000000,
102dd41ce7aSPhilippe Mathieu-Daudé };
103dd41ce7aSPhilippe Mathieu-Daudé
104dd41ce7aSPhilippe Mathieu-Daudé static const int aspeed_soc_ast2400_irqmap[] = {
105dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART1] = 9,
106dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART2] = 32,
107dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART3] = 33,
108dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART4] = 34,
109dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_UART5] = 10,
110dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_VUART] = 8,
111dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_FMC] = 19,
112dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_EHCI1] = 5,
113dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_EHCI2] = 13,
1145efe45c1SGuenter Roeck [ASPEED_DEV_UHCI] = 14,
115dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDMC] = 0,
116dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SCU] = 21,
117dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ADC] = 31,
118a726d631SJoel Stanley [ASPEED_DEV_GFX] = 25,
119dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_GPIO] = 20,
120dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_RTC] = 22,
121dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER1] = 16,
122dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER2] = 17,
123dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER3] = 18,
124dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER4] = 35,
125dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER5] = 36,
126dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER6] = 37,
127dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER7] = 38,
128dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_TIMER8] = 39,
129dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_WDT] = 27,
130dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_PWM] = 28,
131dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_LPC] = 8,
132dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_I2C] = 12,
133dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_PECI] = 15,
134dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ETH1] = 2,
135dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_ETH2] = 3,
136dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_XDMA] = 6,
137dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_SDHCI] = 26,
138dd41ce7aSPhilippe Mathieu-Daudé [ASPEED_DEV_HACE] = 4,
139dd41ce7aSPhilippe Mathieu-Daudé };
140dd41ce7aSPhilippe Mathieu-Daudé
141dd41ce7aSPhilippe Mathieu-Daudé #define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap
142dd41ce7aSPhilippe Mathieu-Daudé
aspeed_soc_ast2400_get_irq(AspeedSoCState * s,int dev)143dd41ce7aSPhilippe Mathieu-Daudé static qemu_irq aspeed_soc_ast2400_get_irq(AspeedSoCState *s, int dev)
144dd41ce7aSPhilippe Mathieu-Daudé {
145dd41ce7aSPhilippe Mathieu-Daudé Aspeed2400SoCState *a = ASPEED2400_SOC(s);
146dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
147dd41ce7aSPhilippe Mathieu-Daudé
148dd41ce7aSPhilippe Mathieu-Daudé return qdev_get_gpio_in(DEVICE(&a->vic), sc->irqmap[dev]);
149dd41ce7aSPhilippe Mathieu-Daudé }
150dd41ce7aSPhilippe Mathieu-Daudé
aspeed_ast2400_soc_init(Object * obj)151dd41ce7aSPhilippe Mathieu-Daudé static void aspeed_ast2400_soc_init(Object *obj)
152dd41ce7aSPhilippe Mathieu-Daudé {
153dd41ce7aSPhilippe Mathieu-Daudé Aspeed2400SoCState *a = ASPEED2400_SOC(obj);
154dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCState *s = ASPEED_SOC(obj);
155dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
156dd41ce7aSPhilippe Mathieu-Daudé int i;
157dd41ce7aSPhilippe Mathieu-Daudé char socname[8];
158dd41ce7aSPhilippe Mathieu-Daudé char typename[64];
159dd41ce7aSPhilippe Mathieu-Daudé
160dd41ce7aSPhilippe Mathieu-Daudé if (sscanf(sc->name, "%7s", socname) != 1) {
161dd41ce7aSPhilippe Mathieu-Daudé g_assert_not_reached();
162dd41ce7aSPhilippe Mathieu-Daudé }
163dd41ce7aSPhilippe Mathieu-Daudé
164dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->num_cpus; i++) {
165d815649cSPhilippe Mathieu-Daudé object_initialize_child(obj, "cpu[*]", &a->cpu[i],
166d815649cSPhilippe Mathieu-Daudé aspeed_soc_cpu_type(sc));
167dd41ce7aSPhilippe Mathieu-Daudé }
168dd41ce7aSPhilippe Mathieu-Daudé
169dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.scu-%s", socname);
170dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "scu", &s->scu, typename);
171dd41ce7aSPhilippe Mathieu-Daudé qdev_prop_set_uint32(DEVICE(&s->scu), "silicon-rev",
172dd41ce7aSPhilippe Mathieu-Daudé sc->silicon_rev);
173dd41ce7aSPhilippe Mathieu-Daudé object_property_add_alias(obj, "hw-strap1", OBJECT(&s->scu),
174dd41ce7aSPhilippe Mathieu-Daudé "hw-strap1");
175dd41ce7aSPhilippe Mathieu-Daudé object_property_add_alias(obj, "hw-strap2", OBJECT(&s->scu),
176dd41ce7aSPhilippe Mathieu-Daudé "hw-strap2");
177dd41ce7aSPhilippe Mathieu-Daudé object_property_add_alias(obj, "hw-prot-key", OBJECT(&s->scu),
178dd41ce7aSPhilippe Mathieu-Daudé "hw-prot-key");
179dd41ce7aSPhilippe Mathieu-Daudé
180dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "vic", &a->vic, TYPE_ASPEED_VIC);
181dd41ce7aSPhilippe Mathieu-Daudé
182dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "rtc", &s->rtc, TYPE_ASPEED_RTC);
183dd41ce7aSPhilippe Mathieu-Daudé
184dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.timer-%s", socname);
185dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "timerctrl", &s->timerctrl, typename);
186dd41ce7aSPhilippe Mathieu-Daudé
1877879cf19SCédric Le Goater for (i = 0; i < sc->wdts_num; i++) {
1887879cf19SCédric Le Goater snprintf(typename, sizeof(typename), "aspeed.wdt-%s", socname);
1897879cf19SCédric Le Goater object_initialize_child(obj, "wdt[*]", &s->wdt[i], typename);
1907879cf19SCédric Le Goater }
1917879cf19SCédric Le Goater
192dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.adc-%s", socname);
193dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "adc", &s->adc, typename);
194dd41ce7aSPhilippe Mathieu-Daudé
195dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.i2c-%s", socname);
196dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "i2c", &s->i2c, typename);
197dd41ce7aSPhilippe Mathieu-Daudé
198dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "peci", &s->peci, TYPE_ASPEED_PECI);
199dd41ce7aSPhilippe Mathieu-Daudé
200dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.fmc-%s", socname);
201dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "fmc", &s->fmc, typename);
202dd41ce7aSPhilippe Mathieu-Daudé
203dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->spis_num; i++) {
204dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, socname);
205dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "spi[*]", &s->spi[i], typename);
206dd41ce7aSPhilippe Mathieu-Daudé }
207dd41ce7aSPhilippe Mathieu-Daudé
208dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->ehcis_num; i++) {
209dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "ehci[*]", &s->ehci[i],
210dd41ce7aSPhilippe Mathieu-Daudé TYPE_PLATFORM_EHCI);
211dd41ce7aSPhilippe Mathieu-Daudé }
212dd41ce7aSPhilippe Mathieu-Daudé
2135efe45c1SGuenter Roeck object_initialize_child(obj, "uhci", &s->uhci, TYPE_ASPEED_UHCI);
2145efe45c1SGuenter Roeck
215dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.sdmc-%s", socname);
216dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "sdmc", &s->sdmc, typename);
217dd41ce7aSPhilippe Mathieu-Daudé object_property_add_alias(obj, "ram-size", OBJECT(&s->sdmc),
218dd41ce7aSPhilippe Mathieu-Daudé "ram-size");
219dd41ce7aSPhilippe Mathieu-Daudé
220dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->macs_num; i++) {
221dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "ftgmac100[*]", &s->ftgmac100[i],
222dd41ce7aSPhilippe Mathieu-Daudé TYPE_FTGMAC100);
223dd41ce7aSPhilippe Mathieu-Daudé }
224dd41ce7aSPhilippe Mathieu-Daudé
225dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->uarts_num; i++) {
226dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "uart[*]", &s->uart[i], TYPE_SERIAL_MM);
227dd41ce7aSPhilippe Mathieu-Daudé }
228dd41ce7aSPhilippe Mathieu-Daudé
229dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), TYPE_ASPEED_XDMA "-%s", socname);
230dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "xdma", &s->xdma, typename);
231dd41ce7aSPhilippe Mathieu-Daudé
232dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.gpio-%s", socname);
233dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "gpio", &s->gpio, typename);
234dd41ce7aSPhilippe Mathieu-Daudé
235*de042938SJamin Lin snprintf(typename, sizeof(typename), "aspeed.sdhci-%s", socname);
236*de042938SJamin Lin object_initialize_child(obj, "sdc", &s->sdhci, typename);
237dd41ce7aSPhilippe Mathieu-Daudé
238dd41ce7aSPhilippe Mathieu-Daudé object_property_set_int(OBJECT(&s->sdhci), "num-slots", 2, &error_abort);
239dd41ce7aSPhilippe Mathieu-Daudé
240dd41ce7aSPhilippe Mathieu-Daudé /* Init sd card slot class here so that they're under the correct parent */
241dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
242dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "sdhci[*]", &s->sdhci.slots[i],
243dd41ce7aSPhilippe Mathieu-Daudé TYPE_SYSBUS_SDHCI);
244dd41ce7aSPhilippe Mathieu-Daudé }
245dd41ce7aSPhilippe Mathieu-Daudé
246dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "lpc", &s->lpc, TYPE_ASPEED_LPC);
247dd41ce7aSPhilippe Mathieu-Daudé
24868857fbeSCédric Le Goater object_initialize_child(obj, "ibt", &s->ibt, TYPE_ASPEED_IBT);
24968857fbeSCédric Le Goater
250dd41ce7aSPhilippe Mathieu-Daudé snprintf(typename, sizeof(typename), "aspeed.hace-%s", socname);
251dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "hace", &s->hace, typename);
252dd41ce7aSPhilippe Mathieu-Daudé
253a726d631SJoel Stanley object_initialize_child(obj, "gfx", &s->gfx, TYPE_ASPEED_GFX);
254a726d631SJoel Stanley
255dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "iomem", &s->iomem, TYPE_UNIMPLEMENTED_DEVICE);
256dd41ce7aSPhilippe Mathieu-Daudé object_initialize_child(obj, "video", &s->video, TYPE_UNIMPLEMENTED_DEVICE);
257a1bf0762SCédric Le Goater
258a1bf0762SCédric Le Goater object_initialize_child(obj, "pwm", &s->pwm, TYPE_ASPEED_PWM);
259dd41ce7aSPhilippe Mathieu-Daudé }
260dd41ce7aSPhilippe Mathieu-Daudé
aspeed_ast2400_soc_realize(DeviceState * dev,Error ** errp)261dd41ce7aSPhilippe Mathieu-Daudé static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp)
262dd41ce7aSPhilippe Mathieu-Daudé {
263dd41ce7aSPhilippe Mathieu-Daudé int i;
264dd41ce7aSPhilippe Mathieu-Daudé Aspeed2400SoCState *a = ASPEED2400_SOC(dev);
265dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCState *s = ASPEED_SOC(dev);
266dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
267dd41ce7aSPhilippe Mathieu-Daudé g_autofree char *sram_name = NULL;
268dd41ce7aSPhilippe Mathieu-Daudé
269dd41ce7aSPhilippe Mathieu-Daudé /* Default boot region (SPI memory or ROMs) */
270dd41ce7aSPhilippe Mathieu-Daudé memory_region_init(&s->spi_boot_container, OBJECT(s),
271dd41ce7aSPhilippe Mathieu-Daudé "aspeed.spi_boot_container", 0x10000000);
272dd41ce7aSPhilippe Mathieu-Daudé memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_SPI_BOOT],
273dd41ce7aSPhilippe Mathieu-Daudé &s->spi_boot_container);
274dd41ce7aSPhilippe Mathieu-Daudé
275dd41ce7aSPhilippe Mathieu-Daudé /* IO space */
276dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->iomem), "aspeed.io",
277dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_IOMEM],
278dd41ce7aSPhilippe Mathieu-Daudé ASPEED_SOC_IOMEM_SIZE);
279dd41ce7aSPhilippe Mathieu-Daudé
280dd41ce7aSPhilippe Mathieu-Daudé /* Video engine stub */
281dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->video), "aspeed.video",
282dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_VIDEO], 0x1000);
283dd41ce7aSPhilippe Mathieu-Daudé
284dd41ce7aSPhilippe Mathieu-Daudé /* CPU */
285dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->num_cpus; i++) {
286dd41ce7aSPhilippe Mathieu-Daudé object_property_set_link(OBJECT(&a->cpu[i]), "memory",
287dd41ce7aSPhilippe Mathieu-Daudé OBJECT(s->memory), &error_abort);
288dd41ce7aSPhilippe Mathieu-Daudé if (!qdev_realize(DEVICE(&a->cpu[i]), NULL, errp)) {
289dd41ce7aSPhilippe Mathieu-Daudé return;
290dd41ce7aSPhilippe Mathieu-Daudé }
291dd41ce7aSPhilippe Mathieu-Daudé }
292dd41ce7aSPhilippe Mathieu-Daudé
293dd41ce7aSPhilippe Mathieu-Daudé /* SRAM */
294dd41ce7aSPhilippe Mathieu-Daudé sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&a->cpu[0])->cpu_index);
2952198f5f0SPhilippe Mathieu-Daudé if (!memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size,
2962198f5f0SPhilippe Mathieu-Daudé errp)) {
297dd41ce7aSPhilippe Mathieu-Daudé return;
298dd41ce7aSPhilippe Mathieu-Daudé }
299dd41ce7aSPhilippe Mathieu-Daudé memory_region_add_subregion(s->memory,
300dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_SRAM], &s->sram);
301dd41ce7aSPhilippe Mathieu-Daudé
302dd41ce7aSPhilippe Mathieu-Daudé /* SCU */
303dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->scu), errp)) {
304dd41ce7aSPhilippe Mathieu-Daudé return;
305dd41ce7aSPhilippe Mathieu-Daudé }
306dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]);
307dd41ce7aSPhilippe Mathieu-Daudé
308dd41ce7aSPhilippe Mathieu-Daudé /* VIC */
309dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&a->vic), errp)) {
310dd41ce7aSPhilippe Mathieu-Daudé return;
311dd41ce7aSPhilippe Mathieu-Daudé }
312dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&a->vic), 0, sc->memmap[ASPEED_DEV_VIC]);
313dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&a->vic), 0,
314dd41ce7aSPhilippe Mathieu-Daudé qdev_get_gpio_in(DEVICE(&a->cpu), ARM_CPU_IRQ));
315dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&a->vic), 1,
316dd41ce7aSPhilippe Mathieu-Daudé qdev_get_gpio_in(DEVICE(&a->cpu), ARM_CPU_FIQ));
317dd41ce7aSPhilippe Mathieu-Daudé
318dd41ce7aSPhilippe Mathieu-Daudé /* RTC */
319dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) {
320dd41ce7aSPhilippe Mathieu-Daudé return;
321dd41ce7aSPhilippe Mathieu-Daudé }
322dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_DEV_RTC]);
323dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0,
324dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_RTC));
325dd41ce7aSPhilippe Mathieu-Daudé
326dd41ce7aSPhilippe Mathieu-Daudé /* Timer */
327dd41ce7aSPhilippe Mathieu-Daudé object_property_set_link(OBJECT(&s->timerctrl), "scu", OBJECT(&s->scu),
328dd41ce7aSPhilippe Mathieu-Daudé &error_abort);
329dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->timerctrl), errp)) {
330dd41ce7aSPhilippe Mathieu-Daudé return;
331dd41ce7aSPhilippe Mathieu-Daudé }
332dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->timerctrl), 0,
333dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_TIMER1]);
334dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
335dd41ce7aSPhilippe Mathieu-Daudé qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_DEV_TIMER1 + i);
336dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq);
337dd41ce7aSPhilippe Mathieu-Daudé }
338dd41ce7aSPhilippe Mathieu-Daudé
3397879cf19SCédric Le Goater /* Watch dog */
3407879cf19SCédric Le Goater for (i = 0; i < sc->wdts_num; i++) {
3417879cf19SCédric Le Goater AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(&s->wdt[i]);
3427879cf19SCédric Le Goater
3437879cf19SCédric Le Goater object_property_set_link(OBJECT(&s->wdt[i]), "scu", OBJECT(&s->scu),
3447879cf19SCédric Le Goater &error_abort);
3457879cf19SCédric Le Goater if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), errp)) {
3467879cf19SCédric Le Goater return;
3477879cf19SCédric Le Goater }
3487879cf19SCédric Le Goater aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->wdt[i]), 0,
3497879cf19SCédric Le Goater sc->memmap[ASPEED_DEV_WDT] + i * awc->iosize);
3507879cf19SCédric Le Goater }
3517879cf19SCédric Le Goater
352dd41ce7aSPhilippe Mathieu-Daudé /* ADC */
353dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->adc), errp)) {
354dd41ce7aSPhilippe Mathieu-Daudé return;
355dd41ce7aSPhilippe Mathieu-Daudé }
356dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]);
357dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->adc), 0,
358dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_ADC));
359dd41ce7aSPhilippe Mathieu-Daudé
360dd41ce7aSPhilippe Mathieu-Daudé /* UART */
361dd41ce7aSPhilippe Mathieu-Daudé if (!aspeed_soc_uart_realize(s, errp)) {
362dd41ce7aSPhilippe Mathieu-Daudé return;
363dd41ce7aSPhilippe Mathieu-Daudé }
364dd41ce7aSPhilippe Mathieu-Daudé
365dd41ce7aSPhilippe Mathieu-Daudé /* I2C */
366dd41ce7aSPhilippe Mathieu-Daudé object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
367dd41ce7aSPhilippe Mathieu-Daudé &error_abort);
368dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c), errp)) {
369dd41ce7aSPhilippe Mathieu-Daudé return;
370dd41ce7aSPhilippe Mathieu-Daudé }
371dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]);
372dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0,
373dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_I2C));
374dd41ce7aSPhilippe Mathieu-Daudé
375dd41ce7aSPhilippe Mathieu-Daudé /* PECI */
376dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->peci), errp)) {
377dd41ce7aSPhilippe Mathieu-Daudé return;
378dd41ce7aSPhilippe Mathieu-Daudé }
379dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->peci), 0,
380dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_PECI]);
381dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->peci), 0,
382dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_PECI));
383dd41ce7aSPhilippe Mathieu-Daudé
384dd41ce7aSPhilippe Mathieu-Daudé /* FMC, The number of CS is set at the board level */
385dd41ce7aSPhilippe Mathieu-Daudé object_property_set_link(OBJECT(&s->fmc), "dram", OBJECT(s->dram_mr),
386dd41ce7aSPhilippe Mathieu-Daudé &error_abort);
387dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->fmc), errp)) {
388dd41ce7aSPhilippe Mathieu-Daudé return;
389dd41ce7aSPhilippe Mathieu-Daudé }
390dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 0, sc->memmap[ASPEED_DEV_FMC]);
391dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->fmc), 1,
392dd41ce7aSPhilippe Mathieu-Daudé ASPEED_SMC_GET_CLASS(&s->fmc)->flash_window_base);
393dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0,
394dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_FMC));
395dd41ce7aSPhilippe Mathieu-Daudé
396dd41ce7aSPhilippe Mathieu-Daudé /* Set up an alias on the FMC CE0 region (boot default) */
397dd41ce7aSPhilippe Mathieu-Daudé MemoryRegion *fmc0_mmio = &s->fmc.flashes[0].mmio;
398dd41ce7aSPhilippe Mathieu-Daudé memory_region_init_alias(&s->spi_boot, OBJECT(s), "aspeed.spi_boot",
399dd41ce7aSPhilippe Mathieu-Daudé fmc0_mmio, 0, memory_region_size(fmc0_mmio));
400dd41ce7aSPhilippe Mathieu-Daudé memory_region_add_subregion(&s->spi_boot_container, 0x0, &s->spi_boot);
401dd41ce7aSPhilippe Mathieu-Daudé
402dd41ce7aSPhilippe Mathieu-Daudé /* SPI */
403dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->spis_num; i++) {
404dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
405dd41ce7aSPhilippe Mathieu-Daudé return;
406dd41ce7aSPhilippe Mathieu-Daudé }
407dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 0,
408dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_SPI1 + i]);
409dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->spi[i]), 1,
410dd41ce7aSPhilippe Mathieu-Daudé ASPEED_SMC_GET_CLASS(&s->spi[i])->flash_window_base);
411dd41ce7aSPhilippe Mathieu-Daudé }
412dd41ce7aSPhilippe Mathieu-Daudé
413dd41ce7aSPhilippe Mathieu-Daudé /* EHCI */
414dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->ehcis_num; i++) {
415dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->ehci[i]), errp)) {
416dd41ce7aSPhilippe Mathieu-Daudé return;
417dd41ce7aSPhilippe Mathieu-Daudé }
418dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->ehci[i]), 0,
419dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_EHCI1 + i]);
420dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->ehci[i]), 0,
421dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_EHCI1 + i));
422dd41ce7aSPhilippe Mathieu-Daudé }
423dd41ce7aSPhilippe Mathieu-Daudé
4245efe45c1SGuenter Roeck /* UHCI */
4255efe45c1SGuenter Roeck if (!sysbus_realize(SYS_BUS_DEVICE(&s->uhci), errp)) {
4265efe45c1SGuenter Roeck return;
4275efe45c1SGuenter Roeck }
4285efe45c1SGuenter Roeck aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->uhci), 0,
4295efe45c1SGuenter Roeck sc->memmap[ASPEED_DEV_UHCI]);
4305efe45c1SGuenter Roeck sysbus_connect_irq(SYS_BUS_DEVICE(&s->uhci), 0,
4315efe45c1SGuenter Roeck aspeed_soc_get_irq(s, ASPEED_DEV_UHCI));
4325efe45c1SGuenter Roeck
433dd41ce7aSPhilippe Mathieu-Daudé /* SDMC - SDRAM Memory Controller */
434dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdmc), errp)) {
435dd41ce7aSPhilippe Mathieu-Daudé return;
436dd41ce7aSPhilippe Mathieu-Daudé }
437dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdmc), 0,
438dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_SDMC]);
439dd41ce7aSPhilippe Mathieu-Daudé
440dd41ce7aSPhilippe Mathieu-Daudé /* RAM */
441dd41ce7aSPhilippe Mathieu-Daudé if (!aspeed_soc_dram_init(s, errp)) {
442dd41ce7aSPhilippe Mathieu-Daudé return;
443dd41ce7aSPhilippe Mathieu-Daudé }
444dd41ce7aSPhilippe Mathieu-Daudé
445dd41ce7aSPhilippe Mathieu-Daudé /* Net */
446dd41ce7aSPhilippe Mathieu-Daudé for (i = 0; i < sc->macs_num; i++) {
447dd41ce7aSPhilippe Mathieu-Daudé object_property_set_bool(OBJECT(&s->ftgmac100[i]), "aspeed", true,
448dd41ce7aSPhilippe Mathieu-Daudé &error_abort);
449dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->ftgmac100[i]), errp)) {
450dd41ce7aSPhilippe Mathieu-Daudé return;
451dd41ce7aSPhilippe Mathieu-Daudé }
452dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
453dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_ETH1 + i]);
454dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
455dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_ETH1 + i));
456dd41ce7aSPhilippe Mathieu-Daudé }
457dd41ce7aSPhilippe Mathieu-Daudé
458dd41ce7aSPhilippe Mathieu-Daudé /* XDMA */
459dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->xdma), errp)) {
460dd41ce7aSPhilippe Mathieu-Daudé return;
461dd41ce7aSPhilippe Mathieu-Daudé }
462dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->xdma), 0,
463dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_XDMA]);
464dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0,
465dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_XDMA));
466dd41ce7aSPhilippe Mathieu-Daudé
467dd41ce7aSPhilippe Mathieu-Daudé /* GPIO */
468dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) {
469dd41ce7aSPhilippe Mathieu-Daudé return;
470dd41ce7aSPhilippe Mathieu-Daudé }
471dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gpio), 0,
472dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_GPIO]);
473dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0,
474dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_GPIO));
475dd41ce7aSPhilippe Mathieu-Daudé
476dd41ce7aSPhilippe Mathieu-Daudé /* SDHCI */
477dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp)) {
478dd41ce7aSPhilippe Mathieu-Daudé return;
479dd41ce7aSPhilippe Mathieu-Daudé }
480dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdhci), 0,
481dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_SDHCI]);
482dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0,
483dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_SDHCI));
484dd41ce7aSPhilippe Mathieu-Daudé
485dd41ce7aSPhilippe Mathieu-Daudé /* LPC */
486dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->lpc), errp)) {
487dd41ce7aSPhilippe Mathieu-Daudé return;
488dd41ce7aSPhilippe Mathieu-Daudé }
489dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->lpc), 0, sc->memmap[ASPEED_DEV_LPC]);
490dd41ce7aSPhilippe Mathieu-Daudé
491dd41ce7aSPhilippe Mathieu-Daudé /* Connect the LPC IRQ to the VIC */
492dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 0,
493dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_LPC));
494dd41ce7aSPhilippe Mathieu-Daudé
495dd41ce7aSPhilippe Mathieu-Daudé /*
496dd41ce7aSPhilippe Mathieu-Daudé * On the AST2400 and AST2500 the one LPC IRQ is shared between all of the
497dd41ce7aSPhilippe Mathieu-Daudé * subdevices. Connect the LPC subdevice IRQs to the LPC controller IRQ (by
498dd41ce7aSPhilippe Mathieu-Daudé * contrast, on the AST2600, the subdevice IRQs are connected straight to
499dd41ce7aSPhilippe Mathieu-Daudé * the GIC).
500dd41ce7aSPhilippe Mathieu-Daudé *
501dd41ce7aSPhilippe Mathieu-Daudé * LPC subdevice IRQ sources are offset from 1 because the shared IRQ output
502dd41ce7aSPhilippe Mathieu-Daudé * to the VIC is at offset 0.
503dd41ce7aSPhilippe Mathieu-Daudé */
504dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_1,
505dd41ce7aSPhilippe Mathieu-Daudé qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_1));
506dd41ce7aSPhilippe Mathieu-Daudé
507dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_2,
508dd41ce7aSPhilippe Mathieu-Daudé qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_2));
509dd41ce7aSPhilippe Mathieu-Daudé
510dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_3,
511dd41ce7aSPhilippe Mathieu-Daudé qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_3));
512dd41ce7aSPhilippe Mathieu-Daudé
513dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_4,
514dd41ce7aSPhilippe Mathieu-Daudé qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_kcs_4));
515dd41ce7aSPhilippe Mathieu-Daudé
51668857fbeSCédric Le Goater /* iBT */
51768857fbeSCédric Le Goater if (!sysbus_realize(SYS_BUS_DEVICE(&s->ibt), errp)) {
51868857fbeSCédric Le Goater return;
51968857fbeSCédric Le Goater }
52068857fbeSCédric Le Goater memory_region_add_subregion(&s->lpc.iomem,
52168857fbeSCédric Le Goater sc->memmap[ASPEED_DEV_IBT] - sc->memmap[ASPEED_DEV_LPC],
52268857fbeSCédric Le Goater &s->ibt.iomem);
52368857fbeSCédric Le Goater sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_ibt,
52468857fbeSCédric Le Goater qdev_get_gpio_in(DEVICE(&s->lpc), aspeed_lpc_ibt));
52568857fbeSCédric Le Goater
526dd41ce7aSPhilippe Mathieu-Daudé /* HACE */
527dd41ce7aSPhilippe Mathieu-Daudé object_property_set_link(OBJECT(&s->hace), "dram", OBJECT(s->dram_mr),
528dd41ce7aSPhilippe Mathieu-Daudé &error_abort);
529dd41ce7aSPhilippe Mathieu-Daudé if (!sysbus_realize(SYS_BUS_DEVICE(&s->hace), errp)) {
530dd41ce7aSPhilippe Mathieu-Daudé return;
531dd41ce7aSPhilippe Mathieu-Daudé }
532dd41ce7aSPhilippe Mathieu-Daudé aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->hace), 0,
533dd41ce7aSPhilippe Mathieu-Daudé sc->memmap[ASPEED_DEV_HACE]);
534dd41ce7aSPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0,
535dd41ce7aSPhilippe Mathieu-Daudé aspeed_soc_get_irq(s, ASPEED_DEV_HACE));
536a726d631SJoel Stanley
537a726d631SJoel Stanley /* GFX */
538a726d631SJoel Stanley if (!sysbus_realize(SYS_BUS_DEVICE(&s->gfx), errp)) {
539a726d631SJoel Stanley return;
540a726d631SJoel Stanley }
541a726d631SJoel Stanley aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gfx), 0, sc->memmap[ASPEED_DEV_GFX]);
542a726d631SJoel Stanley sysbus_connect_irq(SYS_BUS_DEVICE(&s->gfx), 0,
543a726d631SJoel Stanley aspeed_soc_get_irq(s, ASPEED_DEV_GFX));
544a1bf0762SCédric Le Goater
545a1bf0762SCédric Le Goater /* PWM */
546a1bf0762SCédric Le Goater if (!sysbus_realize(SYS_BUS_DEVICE(&s->pwm), errp)) {
547a1bf0762SCédric Le Goater return;
548a1bf0762SCédric Le Goater }
549a1bf0762SCédric Le Goater aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->pwm), 0, sc->memmap[ASPEED_DEV_PWM]);
550a1bf0762SCédric Le Goater sysbus_connect_irq(SYS_BUS_DEVICE(&s->pwm), 0,
551a1bf0762SCédric Le Goater aspeed_soc_get_irq(s, ASPEED_DEV_PWM));
552dd41ce7aSPhilippe Mathieu-Daudé }
553dd41ce7aSPhilippe Mathieu-Daudé
aspeed_soc_ast2400_class_init(ObjectClass * oc,void * data)554dd41ce7aSPhilippe Mathieu-Daudé static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data)
555dd41ce7aSPhilippe Mathieu-Daudé {
556dc13909eSPhilippe Mathieu-Daudé static const char * const valid_cpu_types[] = {
557dc13909eSPhilippe Mathieu-Daudé ARM_CPU_TYPE_NAME("arm926"),
558dc13909eSPhilippe Mathieu-Daudé NULL
559dc13909eSPhilippe Mathieu-Daudé };
560dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc);
561dd41ce7aSPhilippe Mathieu-Daudé DeviceClass *dc = DEVICE_CLASS(oc);
562dd41ce7aSPhilippe Mathieu-Daudé
563dd41ce7aSPhilippe Mathieu-Daudé dc->realize = aspeed_ast2400_soc_realize;
564dd41ce7aSPhilippe Mathieu-Daudé /* Reason: Uses serial_hds and nd_table in realize() directly */
565dd41ce7aSPhilippe Mathieu-Daudé dc->user_creatable = false;
566dd41ce7aSPhilippe Mathieu-Daudé
567dd41ce7aSPhilippe Mathieu-Daudé sc->name = "ast2400-a1";
568dc13909eSPhilippe Mathieu-Daudé sc->valid_cpu_types = valid_cpu_types;
569dd41ce7aSPhilippe Mathieu-Daudé sc->silicon_rev = AST2400_A1_SILICON_REV;
570dd41ce7aSPhilippe Mathieu-Daudé sc->sram_size = 0x8000;
571dd41ce7aSPhilippe Mathieu-Daudé sc->spis_num = 1;
572dd41ce7aSPhilippe Mathieu-Daudé sc->ehcis_num = 1;
573dd41ce7aSPhilippe Mathieu-Daudé sc->wdts_num = 2;
574dd41ce7aSPhilippe Mathieu-Daudé sc->macs_num = 2;
575dd41ce7aSPhilippe Mathieu-Daudé sc->uarts_num = 5;
576944128eeSJamin Lin sc->uarts_base = ASPEED_DEV_UART1;
577dd41ce7aSPhilippe Mathieu-Daudé sc->irqmap = aspeed_soc_ast2400_irqmap;
578dd41ce7aSPhilippe Mathieu-Daudé sc->memmap = aspeed_soc_ast2400_memmap;
579dd41ce7aSPhilippe Mathieu-Daudé sc->num_cpus = 1;
580dd41ce7aSPhilippe Mathieu-Daudé sc->get_irq = aspeed_soc_ast2400_get_irq;
581dd41ce7aSPhilippe Mathieu-Daudé }
582dd41ce7aSPhilippe Mathieu-Daudé
aspeed_soc_ast2500_class_init(ObjectClass * oc,void * data)583dd41ce7aSPhilippe Mathieu-Daudé static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data)
584dd41ce7aSPhilippe Mathieu-Daudé {
585dc13909eSPhilippe Mathieu-Daudé static const char * const valid_cpu_types[] = {
586dc13909eSPhilippe Mathieu-Daudé ARM_CPU_TYPE_NAME("arm1176"),
587dc13909eSPhilippe Mathieu-Daudé NULL
588dc13909eSPhilippe Mathieu-Daudé };
589dd41ce7aSPhilippe Mathieu-Daudé AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc);
590dd41ce7aSPhilippe Mathieu-Daudé DeviceClass *dc = DEVICE_CLASS(oc);
591dd41ce7aSPhilippe Mathieu-Daudé
592dd41ce7aSPhilippe Mathieu-Daudé dc->realize = aspeed_ast2400_soc_realize;
593dd41ce7aSPhilippe Mathieu-Daudé /* Reason: Uses serial_hds and nd_table in realize() directly */
594dd41ce7aSPhilippe Mathieu-Daudé dc->user_creatable = false;
595dd41ce7aSPhilippe Mathieu-Daudé
596dd41ce7aSPhilippe Mathieu-Daudé sc->name = "ast2500-a1";
597dc13909eSPhilippe Mathieu-Daudé sc->valid_cpu_types = valid_cpu_types;
598dd41ce7aSPhilippe Mathieu-Daudé sc->silicon_rev = AST2500_A1_SILICON_REV;
599dd41ce7aSPhilippe Mathieu-Daudé sc->sram_size = 0x9000;
600dd41ce7aSPhilippe Mathieu-Daudé sc->spis_num = 2;
601dd41ce7aSPhilippe Mathieu-Daudé sc->ehcis_num = 2;
602dd41ce7aSPhilippe Mathieu-Daudé sc->wdts_num = 3;
603dd41ce7aSPhilippe Mathieu-Daudé sc->macs_num = 2;
604dd41ce7aSPhilippe Mathieu-Daudé sc->uarts_num = 5;
605944128eeSJamin Lin sc->uarts_base = ASPEED_DEV_UART1;
606dd41ce7aSPhilippe Mathieu-Daudé sc->irqmap = aspeed_soc_ast2500_irqmap;
607dd41ce7aSPhilippe Mathieu-Daudé sc->memmap = aspeed_soc_ast2500_memmap;
608dd41ce7aSPhilippe Mathieu-Daudé sc->num_cpus = 1;
609dd41ce7aSPhilippe Mathieu-Daudé sc->get_irq = aspeed_soc_ast2400_get_irq;
610dd41ce7aSPhilippe Mathieu-Daudé }
611dd41ce7aSPhilippe Mathieu-Daudé
612dd41ce7aSPhilippe Mathieu-Daudé static const TypeInfo aspeed_soc_ast2400_types[] = {
613dd41ce7aSPhilippe Mathieu-Daudé {
614dd41ce7aSPhilippe Mathieu-Daudé .name = TYPE_ASPEED2400_SOC,
615dd41ce7aSPhilippe Mathieu-Daudé .parent = TYPE_ASPEED_SOC,
616dd41ce7aSPhilippe Mathieu-Daudé .instance_init = aspeed_ast2400_soc_init,
617dd41ce7aSPhilippe Mathieu-Daudé .instance_size = sizeof(Aspeed2400SoCState),
618dd41ce7aSPhilippe Mathieu-Daudé .abstract = true,
619dd41ce7aSPhilippe Mathieu-Daudé }, {
620dd41ce7aSPhilippe Mathieu-Daudé .name = "ast2400-a1",
621dd41ce7aSPhilippe Mathieu-Daudé .parent = TYPE_ASPEED2400_SOC,
622dd41ce7aSPhilippe Mathieu-Daudé .class_init = aspeed_soc_ast2400_class_init,
623dd41ce7aSPhilippe Mathieu-Daudé }, {
624dd41ce7aSPhilippe Mathieu-Daudé .name = "ast2500-a1",
625dd41ce7aSPhilippe Mathieu-Daudé .parent = TYPE_ASPEED2400_SOC,
626dd41ce7aSPhilippe Mathieu-Daudé .class_init = aspeed_soc_ast2500_class_init,
627dd41ce7aSPhilippe Mathieu-Daudé },
628dd41ce7aSPhilippe Mathieu-Daudé };
629dd41ce7aSPhilippe Mathieu-Daudé
630dd41ce7aSPhilippe Mathieu-Daudé DEFINE_TYPES(aspeed_soc_ast2400_types)
631