xref: /qemu/hw/arm/fsl-imx25.c (revision 4771d756f46219762477aaeaaef9bd215e3d5c60)
1ee708c99SJean-Christophe Dubois /*
2ee708c99SJean-Christophe Dubois  * Copyright (c) 2013 Jean-Christophe Dubois <jcd@tribudubois.net>
3ee708c99SJean-Christophe Dubois  *
4ee708c99SJean-Christophe Dubois  * i.MX25 SOC emulation.
5ee708c99SJean-Christophe Dubois  *
6ee708c99SJean-Christophe Dubois  * Based on hw/arm/xlnx-zynqmp.c
7ee708c99SJean-Christophe Dubois  *
8ee708c99SJean-Christophe Dubois  * Copyright (C) 2015 Xilinx Inc
9ee708c99SJean-Christophe Dubois  * Written by Peter Crosthwaite <peter.crosthwaite@xilinx.com>
10ee708c99SJean-Christophe Dubois  *
11ee708c99SJean-Christophe Dubois  *  This program is free software; you can redistribute it and/or modify it
12ee708c99SJean-Christophe Dubois  *  under the terms of the GNU General Public License as published by the
13ee708c99SJean-Christophe Dubois  *  Free Software Foundation; either version 2 of the License, or
14ee708c99SJean-Christophe Dubois  *  (at your option) any later version.
15ee708c99SJean-Christophe Dubois  *
16ee708c99SJean-Christophe Dubois  *  This program is distributed in the hope that it will be useful, but WITHOUT
17ee708c99SJean-Christophe Dubois  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18ee708c99SJean-Christophe Dubois  *  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19ee708c99SJean-Christophe Dubois  *  for more details.
20ee708c99SJean-Christophe Dubois  *
21ee708c99SJean-Christophe Dubois  *  You should have received a copy of the GNU General Public License along
22ee708c99SJean-Christophe Dubois  *  with this program; if not, see <http://www.gnu.org/licenses/>.
23ee708c99SJean-Christophe Dubois  */
24ee708c99SJean-Christophe Dubois 
2512b16722SPeter Maydell #include "qemu/osdep.h"
26da34e65cSMarkus Armbruster #include "qapi/error.h"
27*4771d756SPaolo Bonzini #include "qemu-common.h"
28*4771d756SPaolo Bonzini #include "cpu.h"
29ee708c99SJean-Christophe Dubois #include "hw/arm/fsl-imx25.h"
30ee708c99SJean-Christophe Dubois #include "sysemu/sysemu.h"
31ee708c99SJean-Christophe Dubois #include "exec/address-spaces.h"
32ee708c99SJean-Christophe Dubois #include "hw/boards.h"
33ee708c99SJean-Christophe Dubois #include "sysemu/char.h"
34ee708c99SJean-Christophe Dubois 
35ee708c99SJean-Christophe Dubois static void fsl_imx25_init(Object *obj)
36ee708c99SJean-Christophe Dubois {
37ee708c99SJean-Christophe Dubois     FslIMX25State *s = FSL_IMX25(obj);
38ee708c99SJean-Christophe Dubois     int i;
39ee708c99SJean-Christophe Dubois 
40ee708c99SJean-Christophe Dubois     object_initialize(&s->cpu, sizeof(s->cpu), "arm926-" TYPE_ARM_CPU);
41ee708c99SJean-Christophe Dubois 
42ee708c99SJean-Christophe Dubois     object_initialize(&s->avic, sizeof(s->avic), TYPE_IMX_AVIC);
43ee708c99SJean-Christophe Dubois     qdev_set_parent_bus(DEVICE(&s->avic), sysbus_get_default());
44ee708c99SJean-Christophe Dubois 
4592eccc6eSJean-Christophe Dubois     object_initialize(&s->ccm, sizeof(s->ccm), TYPE_IMX25_CCM);
46ee708c99SJean-Christophe Dubois     qdev_set_parent_bus(DEVICE(&s->ccm), sysbus_get_default());
47ee708c99SJean-Christophe Dubois 
48ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_UARTS; i++) {
49ee708c99SJean-Christophe Dubois         object_initialize(&s->uart[i], sizeof(s->uart[i]), TYPE_IMX_SERIAL);
50ee708c99SJean-Christophe Dubois         qdev_set_parent_bus(DEVICE(&s->uart[i]), sysbus_get_default());
51ee708c99SJean-Christophe Dubois     }
52ee708c99SJean-Christophe Dubois 
53ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_GPTS; i++) {
54ee708c99SJean-Christophe Dubois         object_initialize(&s->gpt[i], sizeof(s->gpt[i]), TYPE_IMX_GPT);
55ee708c99SJean-Christophe Dubois         qdev_set_parent_bus(DEVICE(&s->gpt[i]), sysbus_get_default());
56ee708c99SJean-Christophe Dubois     }
57ee708c99SJean-Christophe Dubois 
58ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_EPITS; i++) {
59ee708c99SJean-Christophe Dubois         object_initialize(&s->epit[i], sizeof(s->epit[i]), TYPE_IMX_EPIT);
60ee708c99SJean-Christophe Dubois         qdev_set_parent_bus(DEVICE(&s->epit[i]), sysbus_get_default());
61ee708c99SJean-Christophe Dubois     }
62ee708c99SJean-Christophe Dubois 
63ee708c99SJean-Christophe Dubois     object_initialize(&s->fec, sizeof(s->fec), TYPE_IMX_FEC);
64ee708c99SJean-Christophe Dubois     qdev_set_parent_bus(DEVICE(&s->fec), sysbus_get_default());
65ee708c99SJean-Christophe Dubois 
66ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_I2CS; i++) {
67ee708c99SJean-Christophe Dubois         object_initialize(&s->i2c[i], sizeof(s->i2c[i]), TYPE_IMX_I2C);
68ee708c99SJean-Christophe Dubois         qdev_set_parent_bus(DEVICE(&s->i2c[i]), sysbus_get_default());
69ee708c99SJean-Christophe Dubois     }
706abc7158SJean-Christophe Dubois 
716abc7158SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_GPIOS; i++) {
726abc7158SJean-Christophe Dubois         object_initialize(&s->gpio[i], sizeof(s->gpio[i]), TYPE_IMX_GPIO);
736abc7158SJean-Christophe Dubois         qdev_set_parent_bus(DEVICE(&s->gpio[i]), sysbus_get_default());
746abc7158SJean-Christophe Dubois     }
75ee708c99SJean-Christophe Dubois }
76ee708c99SJean-Christophe Dubois 
77ee708c99SJean-Christophe Dubois static void fsl_imx25_realize(DeviceState *dev, Error **errp)
78ee708c99SJean-Christophe Dubois {
79ee708c99SJean-Christophe Dubois     FslIMX25State *s = FSL_IMX25(dev);
80ee708c99SJean-Christophe Dubois     uint8_t i;
81ee708c99SJean-Christophe Dubois     Error *err = NULL;
82ee708c99SJean-Christophe Dubois 
83ee708c99SJean-Christophe Dubois     object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
84ee708c99SJean-Christophe Dubois     if (err) {
85ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
86ee708c99SJean-Christophe Dubois         return;
87ee708c99SJean-Christophe Dubois     }
88ee708c99SJean-Christophe Dubois 
89ee708c99SJean-Christophe Dubois     object_property_set_bool(OBJECT(&s->avic), true, "realized", &err);
90ee708c99SJean-Christophe Dubois     if (err) {
91ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
92ee708c99SJean-Christophe Dubois         return;
93ee708c99SJean-Christophe Dubois     }
94ee708c99SJean-Christophe Dubois     sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX25_AVIC_ADDR);
95ee708c99SJean-Christophe Dubois     sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 0,
96ee708c99SJean-Christophe Dubois                        qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ));
97ee708c99SJean-Christophe Dubois     sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 1,
98ee708c99SJean-Christophe Dubois                        qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
99ee708c99SJean-Christophe Dubois 
100ee708c99SJean-Christophe Dubois     object_property_set_bool(OBJECT(&s->ccm), true, "realized", &err);
101ee708c99SJean-Christophe Dubois     if (err) {
102ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
103ee708c99SJean-Christophe Dubois         return;
104ee708c99SJean-Christophe Dubois     }
105ee708c99SJean-Christophe Dubois     sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX25_CCM_ADDR);
106ee708c99SJean-Christophe Dubois 
107ee708c99SJean-Christophe Dubois     /* Initialize all UARTs */
108ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_UARTS; i++) {
109ee708c99SJean-Christophe Dubois         static const struct {
110ee708c99SJean-Christophe Dubois             hwaddr addr;
111ee708c99SJean-Christophe Dubois             unsigned int irq;
112ee708c99SJean-Christophe Dubois         } serial_table[FSL_IMX25_NUM_UARTS] = {
113ee708c99SJean-Christophe Dubois             { FSL_IMX25_UART1_ADDR, FSL_IMX25_UART1_IRQ },
114ee708c99SJean-Christophe Dubois             { FSL_IMX25_UART2_ADDR, FSL_IMX25_UART2_IRQ },
115ee708c99SJean-Christophe Dubois             { FSL_IMX25_UART3_ADDR, FSL_IMX25_UART3_IRQ },
116ee708c99SJean-Christophe Dubois             { FSL_IMX25_UART4_ADDR, FSL_IMX25_UART4_IRQ },
117ee708c99SJean-Christophe Dubois             { FSL_IMX25_UART5_ADDR, FSL_IMX25_UART5_IRQ }
118ee708c99SJean-Christophe Dubois         };
119ee708c99SJean-Christophe Dubois 
120ee708c99SJean-Christophe Dubois         if (i < MAX_SERIAL_PORTS) {
121ee708c99SJean-Christophe Dubois             CharDriverState *chr;
122ee708c99SJean-Christophe Dubois 
123ee708c99SJean-Christophe Dubois             chr = serial_hds[i];
124ee708c99SJean-Christophe Dubois 
125ee708c99SJean-Christophe Dubois             if (!chr) {
126ee708c99SJean-Christophe Dubois                 char label[20];
127ee708c99SJean-Christophe Dubois                 snprintf(label, sizeof(label), "imx31.uart%d", i);
128ee708c99SJean-Christophe Dubois                 chr = qemu_chr_new(label, "null", NULL);
129ee708c99SJean-Christophe Dubois             }
130ee708c99SJean-Christophe Dubois 
131ee708c99SJean-Christophe Dubois             qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
132ee708c99SJean-Christophe Dubois         }
133ee708c99SJean-Christophe Dubois 
134ee708c99SJean-Christophe Dubois         object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
135ee708c99SJean-Christophe Dubois         if (err) {
136ee708c99SJean-Christophe Dubois             error_propagate(errp, err);
137ee708c99SJean-Christophe Dubois             return;
138ee708c99SJean-Christophe Dubois         }
139ee708c99SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr);
140ee708c99SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
141ee708c99SJean-Christophe Dubois                            qdev_get_gpio_in(DEVICE(&s->avic),
142ee708c99SJean-Christophe Dubois                                             serial_table[i].irq));
143ee708c99SJean-Christophe Dubois     }
144ee708c99SJean-Christophe Dubois 
145ee708c99SJean-Christophe Dubois     /* Initialize all GPT timers */
146ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_GPTS; i++) {
147ee708c99SJean-Christophe Dubois         static const struct {
148ee708c99SJean-Christophe Dubois             hwaddr addr;
149ee708c99SJean-Christophe Dubois             unsigned int irq;
150ee708c99SJean-Christophe Dubois         } gpt_table[FSL_IMX25_NUM_GPTS] = {
151ee708c99SJean-Christophe Dubois             { FSL_IMX25_GPT1_ADDR, FSL_IMX25_GPT1_IRQ },
152ee708c99SJean-Christophe Dubois             { FSL_IMX25_GPT2_ADDR, FSL_IMX25_GPT2_IRQ },
153ee708c99SJean-Christophe Dubois             { FSL_IMX25_GPT3_ADDR, FSL_IMX25_GPT3_IRQ },
154ee708c99SJean-Christophe Dubois             { FSL_IMX25_GPT4_ADDR, FSL_IMX25_GPT4_IRQ }
155ee708c99SJean-Christophe Dubois         };
156ee708c99SJean-Christophe Dubois 
157cb54d868SJean-Christophe Dubois         s->gpt[i].ccm = IMX_CCM(&s->ccm);
158ee708c99SJean-Christophe Dubois 
159ee708c99SJean-Christophe Dubois         object_property_set_bool(OBJECT(&s->gpt[i]), true, "realized", &err);
160ee708c99SJean-Christophe Dubois         if (err) {
161ee708c99SJean-Christophe Dubois             error_propagate(errp, err);
162ee708c99SJean-Christophe Dubois             return;
163ee708c99SJean-Christophe Dubois         }
164ee708c99SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, gpt_table[i].addr);
165ee708c99SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0,
166ee708c99SJean-Christophe Dubois                            qdev_get_gpio_in(DEVICE(&s->avic),
167ee708c99SJean-Christophe Dubois                                             gpt_table[i].irq));
168ee708c99SJean-Christophe Dubois     }
169ee708c99SJean-Christophe Dubois 
170ee708c99SJean-Christophe Dubois     /* Initialize all EPIT timers */
171ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_EPITS; i++) {
172ee708c99SJean-Christophe Dubois         static const struct {
173ee708c99SJean-Christophe Dubois             hwaddr addr;
174ee708c99SJean-Christophe Dubois             unsigned int irq;
175ee708c99SJean-Christophe Dubois         } epit_table[FSL_IMX25_NUM_EPITS] = {
176ee708c99SJean-Christophe Dubois             { FSL_IMX25_EPIT1_ADDR, FSL_IMX25_EPIT1_IRQ },
177ee708c99SJean-Christophe Dubois             { FSL_IMX25_EPIT2_ADDR, FSL_IMX25_EPIT2_IRQ }
178ee708c99SJean-Christophe Dubois         };
179ee708c99SJean-Christophe Dubois 
180cb54d868SJean-Christophe Dubois         s->epit[i].ccm = IMX_CCM(&s->ccm);
181ee708c99SJean-Christophe Dubois 
182ee708c99SJean-Christophe Dubois         object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", &err);
183ee708c99SJean-Christophe Dubois         if (err) {
184ee708c99SJean-Christophe Dubois             error_propagate(errp, err);
185ee708c99SJean-Christophe Dubois             return;
186ee708c99SJean-Christophe Dubois         }
187ee708c99SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr);
188ee708c99SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0,
189ee708c99SJean-Christophe Dubois                            qdev_get_gpio_in(DEVICE(&s->avic),
190ee708c99SJean-Christophe Dubois                                             epit_table[i].irq));
191ee708c99SJean-Christophe Dubois     }
192ee708c99SJean-Christophe Dubois 
193ee708c99SJean-Christophe Dubois     qdev_set_nic_properties(DEVICE(&s->fec), &nd_table[0]);
194ee708c99SJean-Christophe Dubois     object_property_set_bool(OBJECT(&s->fec), true, "realized", &err);
195ee708c99SJean-Christophe Dubois     if (err) {
196ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
197ee708c99SJean-Christophe Dubois         return;
198ee708c99SJean-Christophe Dubois     }
199ee708c99SJean-Christophe Dubois     sysbus_mmio_map(SYS_BUS_DEVICE(&s->fec), 0, FSL_IMX25_FEC_ADDR);
200ee708c99SJean-Christophe Dubois     sysbus_connect_irq(SYS_BUS_DEVICE(&s->fec), 0,
201ee708c99SJean-Christophe Dubois                        qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX25_FEC_IRQ));
202ee708c99SJean-Christophe Dubois 
203ee708c99SJean-Christophe Dubois 
204ee708c99SJean-Christophe Dubois     /* Initialize all I2C */
205ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_I2CS; i++) {
206ee708c99SJean-Christophe Dubois         static const struct {
207ee708c99SJean-Christophe Dubois             hwaddr addr;
208ee708c99SJean-Christophe Dubois             unsigned int irq;
209ee708c99SJean-Christophe Dubois         } i2c_table[FSL_IMX25_NUM_I2CS] = {
210ee708c99SJean-Christophe Dubois             { FSL_IMX25_I2C1_ADDR, FSL_IMX25_I2C1_IRQ },
211ee708c99SJean-Christophe Dubois             { FSL_IMX25_I2C2_ADDR, FSL_IMX25_I2C2_IRQ },
212ee708c99SJean-Christophe Dubois             { FSL_IMX25_I2C3_ADDR, FSL_IMX25_I2C3_IRQ }
213ee708c99SJean-Christophe Dubois         };
214ee708c99SJean-Christophe Dubois 
215ee708c99SJean-Christophe Dubois         object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", &err);
216ee708c99SJean-Christophe Dubois         if (err) {
217ee708c99SJean-Christophe Dubois             error_propagate(errp, err);
218ee708c99SJean-Christophe Dubois             return;
219ee708c99SJean-Christophe Dubois         }
220ee708c99SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr);
221ee708c99SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0,
222ee708c99SJean-Christophe Dubois                            qdev_get_gpio_in(DEVICE(&s->avic),
223ee708c99SJean-Christophe Dubois                                             i2c_table[i].irq));
224ee708c99SJean-Christophe Dubois     }
225ee708c99SJean-Christophe Dubois 
2266abc7158SJean-Christophe Dubois     /* Initialize all GPIOs */
2276abc7158SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_GPIOS; i++) {
2286abc7158SJean-Christophe Dubois         static const struct {
2296abc7158SJean-Christophe Dubois             hwaddr addr;
2306abc7158SJean-Christophe Dubois             unsigned int irq;
2316abc7158SJean-Christophe Dubois         } gpio_table[FSL_IMX25_NUM_GPIOS] = {
2326abc7158SJean-Christophe Dubois             { FSL_IMX25_GPIO1_ADDR, FSL_IMX25_GPIO1_IRQ },
2336abc7158SJean-Christophe Dubois             { FSL_IMX25_GPIO2_ADDR, FSL_IMX25_GPIO2_IRQ },
2346abc7158SJean-Christophe Dubois             { FSL_IMX25_GPIO3_ADDR, FSL_IMX25_GPIO3_IRQ },
2356abc7158SJean-Christophe Dubois             { FSL_IMX25_GPIO4_ADDR, FSL_IMX25_GPIO4_IRQ }
2366abc7158SJean-Christophe Dubois         };
2376abc7158SJean-Christophe Dubois 
2386abc7158SJean-Christophe Dubois         object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", &err);
2396abc7158SJean-Christophe Dubois         if (err) {
2406abc7158SJean-Christophe Dubois             error_propagate(errp, err);
2416abc7158SJean-Christophe Dubois             return;
2426abc7158SJean-Christophe Dubois         }
2436abc7158SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);
2446abc7158SJean-Christophe Dubois         /* Connect GPIO IRQ to PIC */
2456abc7158SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,
2466abc7158SJean-Christophe Dubois                            qdev_get_gpio_in(DEVICE(&s->avic),
2476abc7158SJean-Christophe Dubois                                             gpio_table[i].irq));
2486abc7158SJean-Christophe Dubois     }
2496abc7158SJean-Christophe Dubois 
250ee708c99SJean-Christophe Dubois     /* initialize 2 x 16 KB ROM */
251ee708c99SJean-Christophe Dubois     memory_region_init_rom_device(&s->rom[0], NULL, NULL, NULL,
252ee708c99SJean-Christophe Dubois                                   "imx25.rom0", FSL_IMX25_ROM0_SIZE, &err);
253ee708c99SJean-Christophe Dubois     if (err) {
254ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
255ee708c99SJean-Christophe Dubois         return;
256ee708c99SJean-Christophe Dubois     }
257ee708c99SJean-Christophe Dubois     memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM0_ADDR,
258ee708c99SJean-Christophe Dubois                                 &s->rom[0]);
259ee708c99SJean-Christophe Dubois     memory_region_init_rom_device(&s->rom[1], NULL, NULL, NULL,
260ee708c99SJean-Christophe Dubois                                   "imx25.rom1", FSL_IMX25_ROM1_SIZE, &err);
261ee708c99SJean-Christophe Dubois     if (err) {
262ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
263ee708c99SJean-Christophe Dubois         return;
264ee708c99SJean-Christophe Dubois     }
265ee708c99SJean-Christophe Dubois     memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM1_ADDR,
266ee708c99SJean-Christophe Dubois                                 &s->rom[1]);
267ee708c99SJean-Christophe Dubois 
268ee708c99SJean-Christophe Dubois     /* initialize internal RAM (128 KB) */
269ee708c99SJean-Christophe Dubois     memory_region_init_ram(&s->iram, NULL, "imx25.iram", FSL_IMX25_IRAM_SIZE,
270ee708c99SJean-Christophe Dubois                            &err);
271ee708c99SJean-Christophe Dubois     if (err) {
272ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
273ee708c99SJean-Christophe Dubois         return;
274ee708c99SJean-Christophe Dubois     }
275ee708c99SJean-Christophe Dubois     memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ADDR,
276ee708c99SJean-Christophe Dubois                                 &s->iram);
277ee708c99SJean-Christophe Dubois     vmstate_register_ram_global(&s->iram);
278ee708c99SJean-Christophe Dubois 
279ee708c99SJean-Christophe Dubois     /* internal RAM (128 KB) is aliased over 128 MB - 128 KB */
280ee708c99SJean-Christophe Dubois     memory_region_init_alias(&s->iram_alias, NULL, "imx25.iram_alias",
281ee708c99SJean-Christophe Dubois                              &s->iram, 0, FSL_IMX25_IRAM_ALIAS_SIZE);
282ee708c99SJean-Christophe Dubois     memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ALIAS_ADDR,
283ee708c99SJean-Christophe Dubois                                 &s->iram_alias);
284ee708c99SJean-Christophe Dubois }
285ee708c99SJean-Christophe Dubois 
286ee708c99SJean-Christophe Dubois static void fsl_imx25_class_init(ObjectClass *oc, void *data)
287ee708c99SJean-Christophe Dubois {
288ee708c99SJean-Christophe Dubois     DeviceClass *dc = DEVICE_CLASS(oc);
289ee708c99SJean-Christophe Dubois 
290ee708c99SJean-Christophe Dubois     dc->realize = fsl_imx25_realize;
2914c315c27SMarkus Armbruster 
2924c315c27SMarkus Armbruster     /*
2934c315c27SMarkus Armbruster      * Reason: creates an ARM CPU, thus use after free(), see
2944c315c27SMarkus Armbruster      * arm_cpu_class_init()
2954c315c27SMarkus Armbruster      */
2964c315c27SMarkus Armbruster     dc->cannot_destroy_with_object_finalize_yet = true;
297eccfa35eSJean-Christophe Dubois     dc->desc = "i.MX25 SOC";
298ee708c99SJean-Christophe Dubois }
299ee708c99SJean-Christophe Dubois 
300ee708c99SJean-Christophe Dubois static const TypeInfo fsl_imx25_type_info = {
301ee708c99SJean-Christophe Dubois     .name = TYPE_FSL_IMX25,
302ee708c99SJean-Christophe Dubois     .parent = TYPE_DEVICE,
303ee708c99SJean-Christophe Dubois     .instance_size = sizeof(FslIMX25State),
304ee708c99SJean-Christophe Dubois     .instance_init = fsl_imx25_init,
305ee708c99SJean-Christophe Dubois     .class_init = fsl_imx25_class_init,
306ee708c99SJean-Christophe Dubois };
307ee708c99SJean-Christophe Dubois 
308ee708c99SJean-Christophe Dubois static void fsl_imx25_register_types(void)
309ee708c99SJean-Christophe Dubois {
310ee708c99SJean-Christophe Dubois     type_register_static(&fsl_imx25_type_info);
311ee708c99SJean-Christophe Dubois }
312ee708c99SJean-Christophe Dubois 
313ee708c99SJean-Christophe Dubois type_init(fsl_imx25_register_types)
314