xref: /qemu/hw/arm/fsl-imx25.c (revision bfae1772c4377fdaa1b33ca361edf8d70a7ae820)
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"
274771d756SPaolo Bonzini #include "cpu.h"
28ee708c99SJean-Christophe Dubois #include "hw/arm/fsl-imx25.h"
29ee708c99SJean-Christophe Dubois #include "sysemu/sysemu.h"
30ee708c99SJean-Christophe Dubois #include "exec/address-spaces.h"
31a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h"
328228e353SMarc-André Lureau #include "chardev/char.h"
33ee708c99SJean-Christophe Dubois 
34*bfae1772SGuenter Roeck #define IMX25_ESDHC_CAPABILITIES     0x07e20000
35*bfae1772SGuenter Roeck 
36ee708c99SJean-Christophe Dubois static void fsl_imx25_init(Object *obj)
37ee708c99SJean-Christophe Dubois {
38ee708c99SJean-Christophe Dubois     FslIMX25State *s = FSL_IMX25(obj);
39ee708c99SJean-Christophe Dubois     int i;
40ee708c99SJean-Christophe Dubois 
41eaa9a878SPhilippe Mathieu-Daudé     object_initialize_child(obj, "cpu", &s->cpu, sizeof(s->cpu),
42eaa9a878SPhilippe Mathieu-Daudé                             ARM_CPU_TYPE_NAME("arm926"),
43eaa9a878SPhilippe Mathieu-Daudé                             &error_abort, NULL);
44ee708c99SJean-Christophe Dubois 
4551dd12acSThomas Huth     sysbus_init_child_obj(obj, "avic", &s->avic, sizeof(s->avic),
4651dd12acSThomas Huth                           TYPE_IMX_AVIC);
47ee708c99SJean-Christophe Dubois 
4851dd12acSThomas Huth     sysbus_init_child_obj(obj, "ccm", &s->ccm, sizeof(s->ccm), TYPE_IMX25_CCM);
49ee708c99SJean-Christophe Dubois 
50ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_UARTS; i++) {
5151dd12acSThomas Huth         sysbus_init_child_obj(obj, "uart[*]", &s->uart[i], sizeof(s->uart[i]),
5251dd12acSThomas Huth                               TYPE_IMX_SERIAL);
53ee708c99SJean-Christophe Dubois     }
54ee708c99SJean-Christophe Dubois 
55ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_GPTS; i++) {
5651dd12acSThomas Huth         sysbus_init_child_obj(obj, "gpt[*]", &s->gpt[i], sizeof(s->gpt[i]),
5751dd12acSThomas Huth                               TYPE_IMX25_GPT);
58ee708c99SJean-Christophe Dubois     }
59ee708c99SJean-Christophe Dubois 
60ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_EPITS; i++) {
6151dd12acSThomas Huth         sysbus_init_child_obj(obj, "epit[*]", &s->epit[i], sizeof(s->epit[i]),
6251dd12acSThomas Huth                               TYPE_IMX_EPIT);
63ee708c99SJean-Christophe Dubois     }
64ee708c99SJean-Christophe Dubois 
6551dd12acSThomas Huth     sysbus_init_child_obj(obj, "fec", &s->fec, sizeof(s->fec), TYPE_IMX_FEC);
66ee708c99SJean-Christophe Dubois 
67f0396549SMartin Kaiser     sysbus_init_child_obj(obj, "rngc", &s->rngc, sizeof(s->rngc),
68f0396549SMartin Kaiser                           TYPE_IMX_RNGC);
69f0396549SMartin Kaiser 
70ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_I2CS; i++) {
7151dd12acSThomas Huth         sysbus_init_child_obj(obj, "i2c[*]", &s->i2c[i], sizeof(s->i2c[i]),
7251dd12acSThomas Huth                               TYPE_IMX_I2C);
73ee708c99SJean-Christophe Dubois     }
746abc7158SJean-Christophe Dubois 
756abc7158SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_GPIOS; i++) {
7651dd12acSThomas Huth         sysbus_init_child_obj(obj, "gpio[*]", &s->gpio[i], sizeof(s->gpio[i]),
7751dd12acSThomas Huth                               TYPE_IMX_GPIO);
786abc7158SJean-Christophe Dubois     }
79*bfae1772SGuenter Roeck 
80*bfae1772SGuenter Roeck     for (i = 0; i < FSL_IMX25_NUM_ESDHCS; i++) {
81*bfae1772SGuenter Roeck         sysbus_init_child_obj(obj, "sdhc[*]", &s->esdhc[i], sizeof(s->esdhc[i]),
82*bfae1772SGuenter Roeck                               TYPE_IMX_USDHC);
83*bfae1772SGuenter Roeck     }
84ee708c99SJean-Christophe Dubois }
85ee708c99SJean-Christophe Dubois 
86ee708c99SJean-Christophe Dubois static void fsl_imx25_realize(DeviceState *dev, Error **errp)
87ee708c99SJean-Christophe Dubois {
88ee708c99SJean-Christophe Dubois     FslIMX25State *s = FSL_IMX25(dev);
89ee708c99SJean-Christophe Dubois     uint8_t i;
90ee708c99SJean-Christophe Dubois     Error *err = NULL;
91ee708c99SJean-Christophe Dubois 
92ee708c99SJean-Christophe Dubois     object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
93ee708c99SJean-Christophe Dubois     if (err) {
94ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
95ee708c99SJean-Christophe Dubois         return;
96ee708c99SJean-Christophe Dubois     }
97ee708c99SJean-Christophe Dubois 
98ee708c99SJean-Christophe Dubois     object_property_set_bool(OBJECT(&s->avic), true, "realized", &err);
99ee708c99SJean-Christophe Dubois     if (err) {
100ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
101ee708c99SJean-Christophe Dubois         return;
102ee708c99SJean-Christophe Dubois     }
103ee708c99SJean-Christophe Dubois     sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX25_AVIC_ADDR);
104ee708c99SJean-Christophe Dubois     sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 0,
105ee708c99SJean-Christophe Dubois                        qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ));
106ee708c99SJean-Christophe Dubois     sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 1,
107ee708c99SJean-Christophe Dubois                        qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
108ee708c99SJean-Christophe Dubois 
109ee708c99SJean-Christophe Dubois     object_property_set_bool(OBJECT(&s->ccm), true, "realized", &err);
110ee708c99SJean-Christophe Dubois     if (err) {
111ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
112ee708c99SJean-Christophe Dubois         return;
113ee708c99SJean-Christophe Dubois     }
114ee708c99SJean-Christophe Dubois     sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX25_CCM_ADDR);
115ee708c99SJean-Christophe Dubois 
116ee708c99SJean-Christophe Dubois     /* Initialize all UARTs */
117ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_UARTS; i++) {
118ee708c99SJean-Christophe Dubois         static const struct {
119ee708c99SJean-Christophe Dubois             hwaddr addr;
120ee708c99SJean-Christophe Dubois             unsigned int irq;
121ee708c99SJean-Christophe Dubois         } serial_table[FSL_IMX25_NUM_UARTS] = {
122ee708c99SJean-Christophe Dubois             { FSL_IMX25_UART1_ADDR, FSL_IMX25_UART1_IRQ },
123ee708c99SJean-Christophe Dubois             { FSL_IMX25_UART2_ADDR, FSL_IMX25_UART2_IRQ },
124ee708c99SJean-Christophe Dubois             { FSL_IMX25_UART3_ADDR, FSL_IMX25_UART3_IRQ },
125ee708c99SJean-Christophe Dubois             { FSL_IMX25_UART4_ADDR, FSL_IMX25_UART4_IRQ },
126ee708c99SJean-Christophe Dubois             { FSL_IMX25_UART5_ADDR, FSL_IMX25_UART5_IRQ }
127ee708c99SJean-Christophe Dubois         };
128ee708c99SJean-Christophe Dubois 
1299bca0edbSPeter Maydell         qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
130ee708c99SJean-Christophe Dubois 
131ee708c99SJean-Christophe Dubois         object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
132ee708c99SJean-Christophe Dubois         if (err) {
133ee708c99SJean-Christophe Dubois             error_propagate(errp, err);
134ee708c99SJean-Christophe Dubois             return;
135ee708c99SJean-Christophe Dubois         }
136ee708c99SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr);
137ee708c99SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
138ee708c99SJean-Christophe Dubois                            qdev_get_gpio_in(DEVICE(&s->avic),
139ee708c99SJean-Christophe Dubois                                             serial_table[i].irq));
140ee708c99SJean-Christophe Dubois     }
141ee708c99SJean-Christophe Dubois 
142ee708c99SJean-Christophe Dubois     /* Initialize all GPT timers */
143ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_GPTS; i++) {
144ee708c99SJean-Christophe Dubois         static const struct {
145ee708c99SJean-Christophe Dubois             hwaddr addr;
146ee708c99SJean-Christophe Dubois             unsigned int irq;
147ee708c99SJean-Christophe Dubois         } gpt_table[FSL_IMX25_NUM_GPTS] = {
148ee708c99SJean-Christophe Dubois             { FSL_IMX25_GPT1_ADDR, FSL_IMX25_GPT1_IRQ },
149ee708c99SJean-Christophe Dubois             { FSL_IMX25_GPT2_ADDR, FSL_IMX25_GPT2_IRQ },
150ee708c99SJean-Christophe Dubois             { FSL_IMX25_GPT3_ADDR, FSL_IMX25_GPT3_IRQ },
151ee708c99SJean-Christophe Dubois             { FSL_IMX25_GPT4_ADDR, FSL_IMX25_GPT4_IRQ }
152ee708c99SJean-Christophe Dubois         };
153ee708c99SJean-Christophe Dubois 
154cb54d868SJean-Christophe Dubois         s->gpt[i].ccm = IMX_CCM(&s->ccm);
155ee708c99SJean-Christophe Dubois 
156ee708c99SJean-Christophe Dubois         object_property_set_bool(OBJECT(&s->gpt[i]), true, "realized", &err);
157ee708c99SJean-Christophe Dubois         if (err) {
158ee708c99SJean-Christophe Dubois             error_propagate(errp, err);
159ee708c99SJean-Christophe Dubois             return;
160ee708c99SJean-Christophe Dubois         }
161ee708c99SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, gpt_table[i].addr);
162ee708c99SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0,
163ee708c99SJean-Christophe Dubois                            qdev_get_gpio_in(DEVICE(&s->avic),
164ee708c99SJean-Christophe Dubois                                             gpt_table[i].irq));
165ee708c99SJean-Christophe Dubois     }
166ee708c99SJean-Christophe Dubois 
167ee708c99SJean-Christophe Dubois     /* Initialize all EPIT timers */
168ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_EPITS; i++) {
169ee708c99SJean-Christophe Dubois         static const struct {
170ee708c99SJean-Christophe Dubois             hwaddr addr;
171ee708c99SJean-Christophe Dubois             unsigned int irq;
172ee708c99SJean-Christophe Dubois         } epit_table[FSL_IMX25_NUM_EPITS] = {
173ee708c99SJean-Christophe Dubois             { FSL_IMX25_EPIT1_ADDR, FSL_IMX25_EPIT1_IRQ },
174ee708c99SJean-Christophe Dubois             { FSL_IMX25_EPIT2_ADDR, FSL_IMX25_EPIT2_IRQ }
175ee708c99SJean-Christophe Dubois         };
176ee708c99SJean-Christophe Dubois 
177cb54d868SJean-Christophe Dubois         s->epit[i].ccm = IMX_CCM(&s->ccm);
178ee708c99SJean-Christophe Dubois 
179ee708c99SJean-Christophe Dubois         object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", &err);
180ee708c99SJean-Christophe Dubois         if (err) {
181ee708c99SJean-Christophe Dubois             error_propagate(errp, err);
182ee708c99SJean-Christophe Dubois             return;
183ee708c99SJean-Christophe Dubois         }
184ee708c99SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr);
185ee708c99SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0,
186ee708c99SJean-Christophe Dubois                            qdev_get_gpio_in(DEVICE(&s->avic),
187ee708c99SJean-Christophe Dubois                                             epit_table[i].irq));
188ee708c99SJean-Christophe Dubois     }
189ee708c99SJean-Christophe Dubois 
190ee708c99SJean-Christophe Dubois     qdev_set_nic_properties(DEVICE(&s->fec), &nd_table[0]);
191a699b410SJean-Christophe Dubois 
192ee708c99SJean-Christophe Dubois     object_property_set_bool(OBJECT(&s->fec), true, "realized", &err);
193ee708c99SJean-Christophe Dubois     if (err) {
194ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
195ee708c99SJean-Christophe Dubois         return;
196ee708c99SJean-Christophe Dubois     }
197ee708c99SJean-Christophe Dubois     sysbus_mmio_map(SYS_BUS_DEVICE(&s->fec), 0, FSL_IMX25_FEC_ADDR);
198ee708c99SJean-Christophe Dubois     sysbus_connect_irq(SYS_BUS_DEVICE(&s->fec), 0,
199ee708c99SJean-Christophe Dubois                        qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX25_FEC_IRQ));
200ee708c99SJean-Christophe Dubois 
201f0396549SMartin Kaiser     object_property_set_bool(OBJECT(&s->rngc), true, "realized", &err);
202f0396549SMartin Kaiser     if (err) {
203f0396549SMartin Kaiser         error_propagate(errp, err);
204f0396549SMartin Kaiser         return;
205f0396549SMartin Kaiser     }
206f0396549SMartin Kaiser     sysbus_mmio_map(SYS_BUS_DEVICE(&s->rngc), 0, FSL_IMX25_RNGC_ADDR);
207f0396549SMartin Kaiser     sysbus_connect_irq(SYS_BUS_DEVICE(&s->rngc), 0,
208f0396549SMartin Kaiser                        qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX25_RNGC_IRQ));
209ee708c99SJean-Christophe Dubois 
210ee708c99SJean-Christophe Dubois     /* Initialize all I2C */
211ee708c99SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_I2CS; i++) {
212ee708c99SJean-Christophe Dubois         static const struct {
213ee708c99SJean-Christophe Dubois             hwaddr addr;
214ee708c99SJean-Christophe Dubois             unsigned int irq;
215ee708c99SJean-Christophe Dubois         } i2c_table[FSL_IMX25_NUM_I2CS] = {
216ee708c99SJean-Christophe Dubois             { FSL_IMX25_I2C1_ADDR, FSL_IMX25_I2C1_IRQ },
217ee708c99SJean-Christophe Dubois             { FSL_IMX25_I2C2_ADDR, FSL_IMX25_I2C2_IRQ },
218ee708c99SJean-Christophe Dubois             { FSL_IMX25_I2C3_ADDR, FSL_IMX25_I2C3_IRQ }
219ee708c99SJean-Christophe Dubois         };
220ee708c99SJean-Christophe Dubois 
221ee708c99SJean-Christophe Dubois         object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", &err);
222ee708c99SJean-Christophe Dubois         if (err) {
223ee708c99SJean-Christophe Dubois             error_propagate(errp, err);
224ee708c99SJean-Christophe Dubois             return;
225ee708c99SJean-Christophe Dubois         }
226ee708c99SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr);
227ee708c99SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0,
228ee708c99SJean-Christophe Dubois                            qdev_get_gpio_in(DEVICE(&s->avic),
229ee708c99SJean-Christophe Dubois                                             i2c_table[i].irq));
230ee708c99SJean-Christophe Dubois     }
231ee708c99SJean-Christophe Dubois 
2326abc7158SJean-Christophe Dubois     /* Initialize all GPIOs */
2336abc7158SJean-Christophe Dubois     for (i = 0; i < FSL_IMX25_NUM_GPIOS; i++) {
2346abc7158SJean-Christophe Dubois         static const struct {
2356abc7158SJean-Christophe Dubois             hwaddr addr;
2366abc7158SJean-Christophe Dubois             unsigned int irq;
2376abc7158SJean-Christophe Dubois         } gpio_table[FSL_IMX25_NUM_GPIOS] = {
2386abc7158SJean-Christophe Dubois             { FSL_IMX25_GPIO1_ADDR, FSL_IMX25_GPIO1_IRQ },
2396abc7158SJean-Christophe Dubois             { FSL_IMX25_GPIO2_ADDR, FSL_IMX25_GPIO2_IRQ },
2406abc7158SJean-Christophe Dubois             { FSL_IMX25_GPIO3_ADDR, FSL_IMX25_GPIO3_IRQ },
2416abc7158SJean-Christophe Dubois             { FSL_IMX25_GPIO4_ADDR, FSL_IMX25_GPIO4_IRQ }
2426abc7158SJean-Christophe Dubois         };
2436abc7158SJean-Christophe Dubois 
2446abc7158SJean-Christophe Dubois         object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", &err);
2456abc7158SJean-Christophe Dubois         if (err) {
2466abc7158SJean-Christophe Dubois             error_propagate(errp, err);
2476abc7158SJean-Christophe Dubois             return;
2486abc7158SJean-Christophe Dubois         }
2496abc7158SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);
2506abc7158SJean-Christophe Dubois         /* Connect GPIO IRQ to PIC */
2516abc7158SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,
2526abc7158SJean-Christophe Dubois                            qdev_get_gpio_in(DEVICE(&s->avic),
2536abc7158SJean-Christophe Dubois                                             gpio_table[i].irq));
2546abc7158SJean-Christophe Dubois     }
2556abc7158SJean-Christophe Dubois 
256*bfae1772SGuenter Roeck     /* Initialize all SDHC */
257*bfae1772SGuenter Roeck     for (i = 0; i < FSL_IMX25_NUM_ESDHCS; i++) {
258*bfae1772SGuenter Roeck         static const struct {
259*bfae1772SGuenter Roeck             hwaddr addr;
260*bfae1772SGuenter Roeck             unsigned int irq;
261*bfae1772SGuenter Roeck         } esdhc_table[FSL_IMX25_NUM_ESDHCS] = {
262*bfae1772SGuenter Roeck             { FSL_IMX25_ESDHC1_ADDR, FSL_IMX25_ESDHC1_IRQ },
263*bfae1772SGuenter Roeck             { FSL_IMX25_ESDHC2_ADDR, FSL_IMX25_ESDHC2_IRQ },
264*bfae1772SGuenter Roeck         };
265*bfae1772SGuenter Roeck 
266*bfae1772SGuenter Roeck         object_property_set_uint(OBJECT(&s->esdhc[i]), 2, "sd-spec-version",
267*bfae1772SGuenter Roeck                                  &err);
268*bfae1772SGuenter Roeck         object_property_set_uint(OBJECT(&s->esdhc[i]), IMX25_ESDHC_CAPABILITIES,
269*bfae1772SGuenter Roeck                                  "capareg", &err);
270*bfae1772SGuenter Roeck         object_property_set_bool(OBJECT(&s->esdhc[i]), true, "realized", &err);
271*bfae1772SGuenter Roeck         if (err) {
272*bfae1772SGuenter Roeck             error_propagate(errp, err);
273*bfae1772SGuenter Roeck             return;
274*bfae1772SGuenter Roeck         }
275*bfae1772SGuenter Roeck         sysbus_mmio_map(SYS_BUS_DEVICE(&s->esdhc[i]), 0, esdhc_table[i].addr);
276*bfae1772SGuenter Roeck         sysbus_connect_irq(SYS_BUS_DEVICE(&s->esdhc[i]), 0,
277*bfae1772SGuenter Roeck                            qdev_get_gpio_in(DEVICE(&s->avic),
278*bfae1772SGuenter Roeck                                             esdhc_table[i].irq));
279*bfae1772SGuenter Roeck     }
280*bfae1772SGuenter Roeck 
281ee708c99SJean-Christophe Dubois     /* initialize 2 x 16 KB ROM */
282eda40cc1SPeter Maydell     memory_region_init_rom(&s->rom[0], NULL,
283ee708c99SJean-Christophe Dubois                            "imx25.rom0", FSL_IMX25_ROM0_SIZE, &err);
284ee708c99SJean-Christophe Dubois     if (err) {
285ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
286ee708c99SJean-Christophe Dubois         return;
287ee708c99SJean-Christophe Dubois     }
288ee708c99SJean-Christophe Dubois     memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM0_ADDR,
289ee708c99SJean-Christophe Dubois                                 &s->rom[0]);
290eda40cc1SPeter Maydell     memory_region_init_rom(&s->rom[1], NULL,
291ee708c99SJean-Christophe Dubois                            "imx25.rom1", FSL_IMX25_ROM1_SIZE, &err);
292ee708c99SJean-Christophe Dubois     if (err) {
293ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
294ee708c99SJean-Christophe Dubois         return;
295ee708c99SJean-Christophe Dubois     }
296ee708c99SJean-Christophe Dubois     memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM1_ADDR,
297ee708c99SJean-Christophe Dubois                                 &s->rom[1]);
298ee708c99SJean-Christophe Dubois 
299ee708c99SJean-Christophe Dubois     /* initialize internal RAM (128 KB) */
30098a99ce0SPeter Maydell     memory_region_init_ram(&s->iram, NULL, "imx25.iram", FSL_IMX25_IRAM_SIZE,
301ee708c99SJean-Christophe Dubois                            &err);
302ee708c99SJean-Christophe Dubois     if (err) {
303ee708c99SJean-Christophe Dubois         error_propagate(errp, err);
304ee708c99SJean-Christophe Dubois         return;
305ee708c99SJean-Christophe Dubois     }
306ee708c99SJean-Christophe Dubois     memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ADDR,
307ee708c99SJean-Christophe Dubois                                 &s->iram);
308ee708c99SJean-Christophe Dubois 
309ee708c99SJean-Christophe Dubois     /* internal RAM (128 KB) is aliased over 128 MB - 128 KB */
310ee708c99SJean-Christophe Dubois     memory_region_init_alias(&s->iram_alias, NULL, "imx25.iram_alias",
311ee708c99SJean-Christophe Dubois                              &s->iram, 0, FSL_IMX25_IRAM_ALIAS_SIZE);
312ee708c99SJean-Christophe Dubois     memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ALIAS_ADDR,
313ee708c99SJean-Christophe Dubois                                 &s->iram_alias);
314ee708c99SJean-Christophe Dubois }
315ee708c99SJean-Christophe Dubois 
316ee708c99SJean-Christophe Dubois static void fsl_imx25_class_init(ObjectClass *oc, void *data)
317ee708c99SJean-Christophe Dubois {
318ee708c99SJean-Christophe Dubois     DeviceClass *dc = DEVICE_CLASS(oc);
319ee708c99SJean-Christophe Dubois 
320ee708c99SJean-Christophe Dubois     dc->realize = fsl_imx25_realize;
321eccfa35eSJean-Christophe Dubois     dc->desc = "i.MX25 SOC";
3225e0c7044SThomas Huth     /*
3235e0c7044SThomas Huth      * Reason: uses serial_hds in realize and the imx25 board does not
3245e0c7044SThomas Huth      * support multiple CPUs
3255e0c7044SThomas Huth      */
3265e0c7044SThomas Huth     dc->user_creatable = false;
327ee708c99SJean-Christophe Dubois }
328ee708c99SJean-Christophe Dubois 
329ee708c99SJean-Christophe Dubois static const TypeInfo fsl_imx25_type_info = {
330ee708c99SJean-Christophe Dubois     .name = TYPE_FSL_IMX25,
331ee708c99SJean-Christophe Dubois     .parent = TYPE_DEVICE,
332ee708c99SJean-Christophe Dubois     .instance_size = sizeof(FslIMX25State),
333ee708c99SJean-Christophe Dubois     .instance_init = fsl_imx25_init,
334ee708c99SJean-Christophe Dubois     .class_init = fsl_imx25_class_init,
335ee708c99SJean-Christophe Dubois };
336ee708c99SJean-Christophe Dubois 
337ee708c99SJean-Christophe Dubois static void fsl_imx25_register_types(void)
338ee708c99SJean-Christophe Dubois {
339ee708c99SJean-Christophe Dubois     type_register_static(&fsl_imx25_type_info);
340ee708c99SJean-Christophe Dubois }
341ee708c99SJean-Christophe Dubois 
342ee708c99SJean-Christophe Dubois type_init(fsl_imx25_register_types)
343