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"
27ee708c99SJean-Christophe Dubois #include "hw/arm/fsl-imx25.h"
2832cad1ffSPhilippe Mathieu-Daudé #include "system/system.h"
29a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h"
308228e353SMarc-André Lureau #include "chardev/char.h"
31d780d056SPhilippe Mathieu-Daudé #include "target/arm/cpu-qom.h"
32ee708c99SJean-Christophe Dubois
33bfae1772SGuenter Roeck #define IMX25_ESDHC_CAPABILITIES 0x07e20000
34bfae1772SGuenter Roeck
fsl_imx25_init(Object * obj)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
409fc7fc4dSMarkus Armbruster object_initialize_child(obj, "cpu", &s->cpu, ARM_CPU_TYPE_NAME("arm926"));
41ee708c99SJean-Christophe Dubois
42db873cc5SMarkus Armbruster object_initialize_child(obj, "avic", &s->avic, TYPE_IMX_AVIC);
43ee708c99SJean-Christophe Dubois
44db873cc5SMarkus Armbruster object_initialize_child(obj, "ccm", &s->ccm, TYPE_IMX25_CCM);
45ee708c99SJean-Christophe Dubois
46ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_UARTS; i++) {
47db873cc5SMarkus Armbruster object_initialize_child(obj, "uart[*]", &s->uart[i], TYPE_IMX_SERIAL);
48ee708c99SJean-Christophe Dubois }
49ee708c99SJean-Christophe Dubois
50ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_GPTS; i++) {
51db873cc5SMarkus Armbruster object_initialize_child(obj, "gpt[*]", &s->gpt[i], TYPE_IMX25_GPT);
52ee708c99SJean-Christophe Dubois }
53ee708c99SJean-Christophe Dubois
54ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_EPITS; i++) {
55db873cc5SMarkus Armbruster object_initialize_child(obj, "epit[*]", &s->epit[i], TYPE_IMX_EPIT);
56ee708c99SJean-Christophe Dubois }
57ee708c99SJean-Christophe Dubois
58db873cc5SMarkus Armbruster object_initialize_child(obj, "fec", &s->fec, TYPE_IMX_FEC);
59ee708c99SJean-Christophe Dubois
60db873cc5SMarkus Armbruster object_initialize_child(obj, "rngc", &s->rngc, TYPE_IMX_RNGC);
61f0396549SMartin Kaiser
62ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_I2CS; i++) {
63db873cc5SMarkus Armbruster object_initialize_child(obj, "i2c[*]", &s->i2c[i], TYPE_IMX_I2C);
64ee708c99SJean-Christophe Dubois }
656abc7158SJean-Christophe Dubois
666abc7158SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_GPIOS; i++) {
67db873cc5SMarkus Armbruster object_initialize_child(obj, "gpio[*]", &s->gpio[i], TYPE_IMX_GPIO);
686abc7158SJean-Christophe Dubois }
69bfae1772SGuenter Roeck
70bfae1772SGuenter Roeck for (i = 0; i < FSL_IMX25_NUM_ESDHCS; i++) {
71db873cc5SMarkus Armbruster object_initialize_child(obj, "sdhc[*]", &s->esdhc[i], TYPE_IMX_USDHC);
72bfae1772SGuenter Roeck }
7367f52ebeSGuenter Roeck
7467f52ebeSGuenter Roeck for (i = 0; i < FSL_IMX25_NUM_USBS; i++) {
75db873cc5SMarkus Armbruster object_initialize_child(obj, "usb[*]", &s->usb[i], TYPE_CHIPIDEA);
7667f52ebeSGuenter Roeck }
7767f52ebeSGuenter Roeck
78db873cc5SMarkus Armbruster object_initialize_child(obj, "wdt", &s->wdt, TYPE_IMX2_WDT);
79ee708c99SJean-Christophe Dubois }
80ee708c99SJean-Christophe Dubois
fsl_imx25_realize(DeviceState * dev,Error ** errp)81ee708c99SJean-Christophe Dubois static void fsl_imx25_realize(DeviceState *dev, Error **errp)
82ee708c99SJean-Christophe Dubois {
83ee708c99SJean-Christophe Dubois FslIMX25State *s = FSL_IMX25(dev);
84ee708c99SJean-Christophe Dubois uint8_t i;
85ee708c99SJean-Christophe Dubois
86668f62ecSMarkus Armbruster if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) {
87ee708c99SJean-Christophe Dubois return;
88ee708c99SJean-Christophe Dubois }
89ee708c99SJean-Christophe Dubois
90668f62ecSMarkus Armbruster if (!sysbus_realize(SYS_BUS_DEVICE(&s->avic), errp)) {
91ee708c99SJean-Christophe Dubois return;
92ee708c99SJean-Christophe Dubois }
93ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX25_AVIC_ADDR);
94ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 0,
95ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ));
96ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 1,
97ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
98ee708c99SJean-Christophe Dubois
99668f62ecSMarkus Armbruster if (!sysbus_realize(SYS_BUS_DEVICE(&s->ccm), errp)) {
100ee708c99SJean-Christophe Dubois return;
101ee708c99SJean-Christophe Dubois }
102ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX25_CCM_ADDR);
103ee708c99SJean-Christophe Dubois
104ee708c99SJean-Christophe Dubois /* Initialize all UARTs */
105ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_UARTS; i++) {
106ee708c99SJean-Christophe Dubois static const struct {
107ee708c99SJean-Christophe Dubois hwaddr addr;
108ee708c99SJean-Christophe Dubois unsigned int irq;
109ee708c99SJean-Christophe Dubois } serial_table[FSL_IMX25_NUM_UARTS] = {
110ee708c99SJean-Christophe Dubois { FSL_IMX25_UART1_ADDR, FSL_IMX25_UART1_IRQ },
111ee708c99SJean-Christophe Dubois { FSL_IMX25_UART2_ADDR, FSL_IMX25_UART2_IRQ },
112ee708c99SJean-Christophe Dubois { FSL_IMX25_UART3_ADDR, FSL_IMX25_UART3_IRQ },
113ee708c99SJean-Christophe Dubois { FSL_IMX25_UART4_ADDR, FSL_IMX25_UART4_IRQ },
114ee708c99SJean-Christophe Dubois { FSL_IMX25_UART5_ADDR, FSL_IMX25_UART5_IRQ }
115ee708c99SJean-Christophe Dubois };
116ee708c99SJean-Christophe Dubois
1179bca0edbSPeter Maydell qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
118ee708c99SJean-Christophe Dubois
119668f62ecSMarkus Armbruster if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), errp)) {
120ee708c99SJean-Christophe Dubois return;
121ee708c99SJean-Christophe Dubois }
122ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr);
123ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
124ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->avic),
125ee708c99SJean-Christophe Dubois serial_table[i].irq));
126ee708c99SJean-Christophe Dubois }
127ee708c99SJean-Christophe Dubois
128ee708c99SJean-Christophe Dubois /* Initialize all GPT timers */
129ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_GPTS; i++) {
130ee708c99SJean-Christophe Dubois static const struct {
131ee708c99SJean-Christophe Dubois hwaddr addr;
132ee708c99SJean-Christophe Dubois unsigned int irq;
133ee708c99SJean-Christophe Dubois } gpt_table[FSL_IMX25_NUM_GPTS] = {
134ee708c99SJean-Christophe Dubois { FSL_IMX25_GPT1_ADDR, FSL_IMX25_GPT1_IRQ },
135ee708c99SJean-Christophe Dubois { FSL_IMX25_GPT2_ADDR, FSL_IMX25_GPT2_IRQ },
136ee708c99SJean-Christophe Dubois { FSL_IMX25_GPT3_ADDR, FSL_IMX25_GPT3_IRQ },
137ee708c99SJean-Christophe Dubois { FSL_IMX25_GPT4_ADDR, FSL_IMX25_GPT4_IRQ }
138ee708c99SJean-Christophe Dubois };
139ee708c99SJean-Christophe Dubois
140cb54d868SJean-Christophe Dubois s->gpt[i].ccm = IMX_CCM(&s->ccm);
141ee708c99SJean-Christophe Dubois
142668f62ecSMarkus Armbruster if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpt[i]), errp)) {
143ee708c99SJean-Christophe Dubois return;
144ee708c99SJean-Christophe Dubois }
145ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, gpt_table[i].addr);
146ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0,
147ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->avic),
148ee708c99SJean-Christophe Dubois gpt_table[i].irq));
149ee708c99SJean-Christophe Dubois }
150ee708c99SJean-Christophe Dubois
151ee708c99SJean-Christophe Dubois /* Initialize all EPIT timers */
152ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_EPITS; i++) {
153ee708c99SJean-Christophe Dubois static const struct {
154ee708c99SJean-Christophe Dubois hwaddr addr;
155ee708c99SJean-Christophe Dubois unsigned int irq;
156ee708c99SJean-Christophe Dubois } epit_table[FSL_IMX25_NUM_EPITS] = {
157ee708c99SJean-Christophe Dubois { FSL_IMX25_EPIT1_ADDR, FSL_IMX25_EPIT1_IRQ },
158ee708c99SJean-Christophe Dubois { FSL_IMX25_EPIT2_ADDR, FSL_IMX25_EPIT2_IRQ }
159ee708c99SJean-Christophe Dubois };
160ee708c99SJean-Christophe Dubois
161cb54d868SJean-Christophe Dubois s->epit[i].ccm = IMX_CCM(&s->ccm);
162ee708c99SJean-Christophe Dubois
163668f62ecSMarkus Armbruster if (!sysbus_realize(SYS_BUS_DEVICE(&s->epit[i]), errp)) {
164ee708c99SJean-Christophe Dubois return;
165ee708c99SJean-Christophe Dubois }
166ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr);
167ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0,
168ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->avic),
169ee708c99SJean-Christophe Dubois epit_table[i].irq));
170ee708c99SJean-Christophe Dubois }
171ee708c99SJean-Christophe Dubois
1720cbb56c2SPhilippe Mathieu-Daudé object_property_set_uint(OBJECT(&s->fec), "phy-num", s->phy_num,
1730cbb56c2SPhilippe Mathieu-Daudé &error_abort);
1748cef839cSDavid Woodhouse qemu_configure_nic_device(DEVICE(&s->fec), true, NULL);
175a699b410SJean-Christophe Dubois
176668f62ecSMarkus Armbruster if (!sysbus_realize(SYS_BUS_DEVICE(&s->fec), errp)) {
177ee708c99SJean-Christophe Dubois return;
178ee708c99SJean-Christophe Dubois }
179ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->fec), 0, FSL_IMX25_FEC_ADDR);
180ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->fec), 0,
181ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX25_FEC_IRQ));
182ee708c99SJean-Christophe Dubois
183668f62ecSMarkus Armbruster if (!sysbus_realize(SYS_BUS_DEVICE(&s->rngc), errp)) {
184f0396549SMartin Kaiser return;
185f0396549SMartin Kaiser }
186f0396549SMartin Kaiser sysbus_mmio_map(SYS_BUS_DEVICE(&s->rngc), 0, FSL_IMX25_RNGC_ADDR);
187f0396549SMartin Kaiser sysbus_connect_irq(SYS_BUS_DEVICE(&s->rngc), 0,
188f0396549SMartin Kaiser qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX25_RNGC_IRQ));
189ee708c99SJean-Christophe Dubois
190ee708c99SJean-Christophe Dubois /* Initialize all I2C */
191ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_I2CS; i++) {
192ee708c99SJean-Christophe Dubois static const struct {
193ee708c99SJean-Christophe Dubois hwaddr addr;
194ee708c99SJean-Christophe Dubois unsigned int irq;
195ee708c99SJean-Christophe Dubois } i2c_table[FSL_IMX25_NUM_I2CS] = {
196ee708c99SJean-Christophe Dubois { FSL_IMX25_I2C1_ADDR, FSL_IMX25_I2C1_IRQ },
197ee708c99SJean-Christophe Dubois { FSL_IMX25_I2C2_ADDR, FSL_IMX25_I2C2_IRQ },
198ee708c99SJean-Christophe Dubois { FSL_IMX25_I2C3_ADDR, FSL_IMX25_I2C3_IRQ }
199ee708c99SJean-Christophe Dubois };
200ee708c99SJean-Christophe Dubois
201668f62ecSMarkus Armbruster if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c[i]), errp)) {
202ee708c99SJean-Christophe Dubois return;
203ee708c99SJean-Christophe Dubois }
204ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr);
205ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0,
206ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->avic),
207ee708c99SJean-Christophe Dubois i2c_table[i].irq));
208ee708c99SJean-Christophe Dubois }
209ee708c99SJean-Christophe Dubois
2106abc7158SJean-Christophe Dubois /* Initialize all GPIOs */
2116abc7158SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_GPIOS; i++) {
2126abc7158SJean-Christophe Dubois static const struct {
2136abc7158SJean-Christophe Dubois hwaddr addr;
2146abc7158SJean-Christophe Dubois unsigned int irq;
2156abc7158SJean-Christophe Dubois } gpio_table[FSL_IMX25_NUM_GPIOS] = {
2166abc7158SJean-Christophe Dubois { FSL_IMX25_GPIO1_ADDR, FSL_IMX25_GPIO1_IRQ },
2176abc7158SJean-Christophe Dubois { FSL_IMX25_GPIO2_ADDR, FSL_IMX25_GPIO2_IRQ },
2186abc7158SJean-Christophe Dubois { FSL_IMX25_GPIO3_ADDR, FSL_IMX25_GPIO3_IRQ },
2196abc7158SJean-Christophe Dubois { FSL_IMX25_GPIO4_ADDR, FSL_IMX25_GPIO4_IRQ }
2206abc7158SJean-Christophe Dubois };
2216abc7158SJean-Christophe Dubois
222668f62ecSMarkus Armbruster if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), errp)) {
2236abc7158SJean-Christophe Dubois return;
2246abc7158SJean-Christophe Dubois }
2256abc7158SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);
2266abc7158SJean-Christophe Dubois /* Connect GPIO IRQ to PIC */
2276abc7158SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,
2286abc7158SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->avic),
2296abc7158SJean-Christophe Dubois gpio_table[i].irq));
2306abc7158SJean-Christophe Dubois }
2316abc7158SJean-Christophe Dubois
232bfae1772SGuenter Roeck /* Initialize all SDHC */
233bfae1772SGuenter Roeck for (i = 0; i < FSL_IMX25_NUM_ESDHCS; i++) {
234bfae1772SGuenter Roeck static const struct {
235bfae1772SGuenter Roeck hwaddr addr;
236bfae1772SGuenter Roeck unsigned int irq;
237bfae1772SGuenter Roeck } esdhc_table[FSL_IMX25_NUM_ESDHCS] = {
238bfae1772SGuenter Roeck { FSL_IMX25_ESDHC1_ADDR, FSL_IMX25_ESDHC1_IRQ },
239bfae1772SGuenter Roeck { FSL_IMX25_ESDHC2_ADDR, FSL_IMX25_ESDHC2_IRQ },
240bfae1772SGuenter Roeck };
241bfae1772SGuenter Roeck
2425325cc34SMarkus Armbruster object_property_set_uint(OBJECT(&s->esdhc[i]), "sd-spec-version", 2,
2437cd1c981SMarkus Armbruster &error_abort);
2445325cc34SMarkus Armbruster object_property_set_uint(OBJECT(&s->esdhc[i]), "capareg",
2455325cc34SMarkus Armbruster IMX25_ESDHC_CAPABILITIES, &error_abort);
246668f62ecSMarkus Armbruster if (!sysbus_realize(SYS_BUS_DEVICE(&s->esdhc[i]), errp)) {
247bfae1772SGuenter Roeck return;
248bfae1772SGuenter Roeck }
249bfae1772SGuenter Roeck sysbus_mmio_map(SYS_BUS_DEVICE(&s->esdhc[i]), 0, esdhc_table[i].addr);
250bfae1772SGuenter Roeck sysbus_connect_irq(SYS_BUS_DEVICE(&s->esdhc[i]), 0,
251bfae1772SGuenter Roeck qdev_get_gpio_in(DEVICE(&s->avic),
252bfae1772SGuenter Roeck esdhc_table[i].irq));
253bfae1772SGuenter Roeck }
254bfae1772SGuenter Roeck
25567f52ebeSGuenter Roeck /* USB */
25667f52ebeSGuenter Roeck for (i = 0; i < FSL_IMX25_NUM_USBS; i++) {
25767f52ebeSGuenter Roeck static const struct {
25867f52ebeSGuenter Roeck hwaddr addr;
25967f52ebeSGuenter Roeck unsigned int irq;
26067f52ebeSGuenter Roeck } usb_table[FSL_IMX25_NUM_USBS] = {
26167f52ebeSGuenter Roeck { FSL_IMX25_USB1_ADDR, FSL_IMX25_USB1_IRQ },
26267f52ebeSGuenter Roeck { FSL_IMX25_USB2_ADDR, FSL_IMX25_USB2_IRQ },
26367f52ebeSGuenter Roeck };
26467f52ebeSGuenter Roeck
265db873cc5SMarkus Armbruster sysbus_realize(SYS_BUS_DEVICE(&s->usb[i]), &error_abort);
26667f52ebeSGuenter Roeck sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, usb_table[i].addr);
26767f52ebeSGuenter Roeck sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0,
26867f52ebeSGuenter Roeck qdev_get_gpio_in(DEVICE(&s->avic),
26967f52ebeSGuenter Roeck usb_table[i].irq));
27067f52ebeSGuenter Roeck }
27167f52ebeSGuenter Roeck
2724f0aff00SGuenter Roeck /* Watchdog */
2735325cc34SMarkus Armbruster object_property_set_bool(OBJECT(&s->wdt), "pretimeout-support", true,
2744f0aff00SGuenter Roeck &error_abort);
275db873cc5SMarkus Armbruster sysbus_realize(SYS_BUS_DEVICE(&s->wdt), &error_abort);
2764f0aff00SGuenter Roeck sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt), 0, FSL_IMX25_WDT_ADDR);
2774f0aff00SGuenter Roeck sysbus_connect_irq(SYS_BUS_DEVICE(&s->wdt), 0,
2784f0aff00SGuenter Roeck qdev_get_gpio_in(DEVICE(&s->avic),
2794f0aff00SGuenter Roeck FSL_IMX25_WDT_IRQ));
2804f0aff00SGuenter Roeck
281ee708c99SJean-Christophe Dubois /* initialize 2 x 16 KB ROM */
282419d8524SPhilippe Mathieu-Daudé if (!memory_region_init_rom(&s->rom[0], OBJECT(dev), "imx25.rom0",
283419d8524SPhilippe Mathieu-Daudé FSL_IMX25_ROM0_SIZE, errp)) {
284ee708c99SJean-Christophe Dubois return;
285ee708c99SJean-Christophe Dubois }
286ee708c99SJean-Christophe Dubois memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM0_ADDR,
287ee708c99SJean-Christophe Dubois &s->rom[0]);
288419d8524SPhilippe Mathieu-Daudé if (!memory_region_init_rom(&s->rom[1], OBJECT(dev), "imx25.rom1",
289419d8524SPhilippe Mathieu-Daudé FSL_IMX25_ROM1_SIZE, errp)) {
290ee708c99SJean-Christophe Dubois return;
291ee708c99SJean-Christophe Dubois }
292ee708c99SJean-Christophe Dubois memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM1_ADDR,
293ee708c99SJean-Christophe Dubois &s->rom[1]);
294ee708c99SJean-Christophe Dubois
295ee708c99SJean-Christophe Dubois /* initialize internal RAM (128 KB) */
2962198f5f0SPhilippe Mathieu-Daudé if (!memory_region_init_ram(&s->iram, NULL, "imx25.iram",
2972198f5f0SPhilippe Mathieu-Daudé FSL_IMX25_IRAM_SIZE, errp)) {
298ee708c99SJean-Christophe Dubois return;
299ee708c99SJean-Christophe Dubois }
300ee708c99SJean-Christophe Dubois memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ADDR,
301ee708c99SJean-Christophe Dubois &s->iram);
302ee708c99SJean-Christophe Dubois
303ee708c99SJean-Christophe Dubois /* internal RAM (128 KB) is aliased over 128 MB - 128 KB */
30432b9523aSPhilippe Mathieu-Daudé memory_region_init_alias(&s->iram_alias, OBJECT(dev), "imx25.iram_alias",
305ee708c99SJean-Christophe Dubois &s->iram, 0, FSL_IMX25_IRAM_ALIAS_SIZE);
306ee708c99SJean-Christophe Dubois memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ALIAS_ADDR,
307ee708c99SJean-Christophe Dubois &s->iram_alias);
308ee708c99SJean-Christophe Dubois }
309ee708c99SJean-Christophe Dubois
310e15bd5ddSRichard Henderson static const Property fsl_imx25_properties[] = {
31174c13305SJean-Christophe Dubois DEFINE_PROP_UINT32("fec-phy-num", FslIMX25State, phy_num, 0),
31274c13305SJean-Christophe Dubois };
31374c13305SJean-Christophe Dubois
fsl_imx25_class_init(ObjectClass * oc,const void * data)314*12d1a768SPhilippe Mathieu-Daudé static void fsl_imx25_class_init(ObjectClass *oc, const void *data)
315ee708c99SJean-Christophe Dubois {
316ee708c99SJean-Christophe Dubois DeviceClass *dc = DEVICE_CLASS(oc);
317ee708c99SJean-Christophe Dubois
31874c13305SJean-Christophe Dubois device_class_set_props(dc, fsl_imx25_properties);
319ee708c99SJean-Christophe Dubois dc->realize = fsl_imx25_realize;
320eccfa35eSJean-Christophe Dubois dc->desc = "i.MX25 SOC";
3215e0c7044SThomas Huth /*
3225e0c7044SThomas Huth * Reason: uses serial_hds in realize and the imx25 board does not
3235e0c7044SThomas Huth * support multiple CPUs
3245e0c7044SThomas Huth */
3255e0c7044SThomas Huth dc->user_creatable = false;
326ee708c99SJean-Christophe Dubois }
327ee708c99SJean-Christophe Dubois
328ee708c99SJean-Christophe Dubois static const TypeInfo fsl_imx25_type_info = {
329ee708c99SJean-Christophe Dubois .name = TYPE_FSL_IMX25,
330ee708c99SJean-Christophe Dubois .parent = TYPE_DEVICE,
331ee708c99SJean-Christophe Dubois .instance_size = sizeof(FslIMX25State),
332ee708c99SJean-Christophe Dubois .instance_init = fsl_imx25_init,
333ee708c99SJean-Christophe Dubois .class_init = fsl_imx25_class_init,
334ee708c99SJean-Christophe Dubois };
335ee708c99SJean-Christophe Dubois
fsl_imx25_register_types(void)336ee708c99SJean-Christophe Dubois static void fsl_imx25_register_types(void)
337ee708c99SJean-Christophe Dubois {
338ee708c99SJean-Christophe Dubois type_register_static(&fsl_imx25_type_info);
339ee708c99SJean-Christophe Dubois }
340ee708c99SJean-Christophe Dubois
341ee708c99SJean-Christophe Dubois type_init(fsl_imx25_register_types)
342