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 34bfae1772SGuenter Roeck #define IMX25_ESDHC_CAPABILITIES 0x07e20000 35bfae1772SGuenter 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 41*9fc7fc4dSMarkus Armbruster object_initialize_child(obj, "cpu", &s->cpu, ARM_CPU_TYPE_NAME("arm926")); 42ee708c99SJean-Christophe Dubois 4351dd12acSThomas Huth sysbus_init_child_obj(obj, "avic", &s->avic, sizeof(s->avic), 4451dd12acSThomas Huth TYPE_IMX_AVIC); 45ee708c99SJean-Christophe Dubois 4651dd12acSThomas Huth sysbus_init_child_obj(obj, "ccm", &s->ccm, sizeof(s->ccm), TYPE_IMX25_CCM); 47ee708c99SJean-Christophe Dubois 48ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_UARTS; i++) { 4951dd12acSThomas Huth sysbus_init_child_obj(obj, "uart[*]", &s->uart[i], sizeof(s->uart[i]), 5051dd12acSThomas Huth TYPE_IMX_SERIAL); 51ee708c99SJean-Christophe Dubois } 52ee708c99SJean-Christophe Dubois 53ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_GPTS; i++) { 5451dd12acSThomas Huth sysbus_init_child_obj(obj, "gpt[*]", &s->gpt[i], sizeof(s->gpt[i]), 5551dd12acSThomas Huth TYPE_IMX25_GPT); 56ee708c99SJean-Christophe Dubois } 57ee708c99SJean-Christophe Dubois 58ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_EPITS; i++) { 5951dd12acSThomas Huth sysbus_init_child_obj(obj, "epit[*]", &s->epit[i], sizeof(s->epit[i]), 6051dd12acSThomas Huth TYPE_IMX_EPIT); 61ee708c99SJean-Christophe Dubois } 62ee708c99SJean-Christophe Dubois 6351dd12acSThomas Huth sysbus_init_child_obj(obj, "fec", &s->fec, sizeof(s->fec), TYPE_IMX_FEC); 64ee708c99SJean-Christophe Dubois 65f0396549SMartin Kaiser sysbus_init_child_obj(obj, "rngc", &s->rngc, sizeof(s->rngc), 66f0396549SMartin Kaiser TYPE_IMX_RNGC); 67f0396549SMartin Kaiser 68ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_I2CS; i++) { 6951dd12acSThomas Huth sysbus_init_child_obj(obj, "i2c[*]", &s->i2c[i], sizeof(s->i2c[i]), 7051dd12acSThomas Huth TYPE_IMX_I2C); 71ee708c99SJean-Christophe Dubois } 726abc7158SJean-Christophe Dubois 736abc7158SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_GPIOS; i++) { 7451dd12acSThomas Huth sysbus_init_child_obj(obj, "gpio[*]", &s->gpio[i], sizeof(s->gpio[i]), 7551dd12acSThomas Huth TYPE_IMX_GPIO); 766abc7158SJean-Christophe Dubois } 77bfae1772SGuenter Roeck 78bfae1772SGuenter Roeck for (i = 0; i < FSL_IMX25_NUM_ESDHCS; i++) { 79bfae1772SGuenter Roeck sysbus_init_child_obj(obj, "sdhc[*]", &s->esdhc[i], sizeof(s->esdhc[i]), 80bfae1772SGuenter Roeck TYPE_IMX_USDHC); 81bfae1772SGuenter Roeck } 8267f52ebeSGuenter Roeck 8367f52ebeSGuenter Roeck for (i = 0; i < FSL_IMX25_NUM_USBS; i++) { 8467f52ebeSGuenter Roeck sysbus_init_child_obj(obj, "usb[*]", &s->usb[i], sizeof(s->usb[i]), 8567f52ebeSGuenter Roeck TYPE_CHIPIDEA); 8667f52ebeSGuenter Roeck } 8767f52ebeSGuenter Roeck 884f0aff00SGuenter Roeck sysbus_init_child_obj(obj, "wdt", &s->wdt, sizeof(s->wdt), TYPE_IMX2_WDT); 89ee708c99SJean-Christophe Dubois } 90ee708c99SJean-Christophe Dubois 91ee708c99SJean-Christophe Dubois static void fsl_imx25_realize(DeviceState *dev, Error **errp) 92ee708c99SJean-Christophe Dubois { 93ee708c99SJean-Christophe Dubois FslIMX25State *s = FSL_IMX25(dev); 94ee708c99SJean-Christophe Dubois uint8_t i; 95ee708c99SJean-Christophe Dubois Error *err = NULL; 96ee708c99SJean-Christophe Dubois 97ee708c99SJean-Christophe Dubois object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); 98ee708c99SJean-Christophe Dubois if (err) { 99ee708c99SJean-Christophe Dubois error_propagate(errp, err); 100ee708c99SJean-Christophe Dubois return; 101ee708c99SJean-Christophe Dubois } 102ee708c99SJean-Christophe Dubois 103ee708c99SJean-Christophe Dubois object_property_set_bool(OBJECT(&s->avic), true, "realized", &err); 104ee708c99SJean-Christophe Dubois if (err) { 105ee708c99SJean-Christophe Dubois error_propagate(errp, err); 106ee708c99SJean-Christophe Dubois return; 107ee708c99SJean-Christophe Dubois } 108ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX25_AVIC_ADDR); 109ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 0, 110ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ)); 111ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 1, 112ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ)); 113ee708c99SJean-Christophe Dubois 114ee708c99SJean-Christophe Dubois object_property_set_bool(OBJECT(&s->ccm), true, "realized", &err); 115ee708c99SJean-Christophe Dubois if (err) { 116ee708c99SJean-Christophe Dubois error_propagate(errp, err); 117ee708c99SJean-Christophe Dubois return; 118ee708c99SJean-Christophe Dubois } 119ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX25_CCM_ADDR); 120ee708c99SJean-Christophe Dubois 121ee708c99SJean-Christophe Dubois /* Initialize all UARTs */ 122ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_UARTS; i++) { 123ee708c99SJean-Christophe Dubois static const struct { 124ee708c99SJean-Christophe Dubois hwaddr addr; 125ee708c99SJean-Christophe Dubois unsigned int irq; 126ee708c99SJean-Christophe Dubois } serial_table[FSL_IMX25_NUM_UARTS] = { 127ee708c99SJean-Christophe Dubois { FSL_IMX25_UART1_ADDR, FSL_IMX25_UART1_IRQ }, 128ee708c99SJean-Christophe Dubois { FSL_IMX25_UART2_ADDR, FSL_IMX25_UART2_IRQ }, 129ee708c99SJean-Christophe Dubois { FSL_IMX25_UART3_ADDR, FSL_IMX25_UART3_IRQ }, 130ee708c99SJean-Christophe Dubois { FSL_IMX25_UART4_ADDR, FSL_IMX25_UART4_IRQ }, 131ee708c99SJean-Christophe Dubois { FSL_IMX25_UART5_ADDR, FSL_IMX25_UART5_IRQ } 132ee708c99SJean-Christophe Dubois }; 133ee708c99SJean-Christophe Dubois 1349bca0edbSPeter Maydell qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i)); 135ee708c99SJean-Christophe Dubois 136ee708c99SJean-Christophe Dubois object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err); 137ee708c99SJean-Christophe Dubois if (err) { 138ee708c99SJean-Christophe Dubois error_propagate(errp, err); 139ee708c99SJean-Christophe Dubois return; 140ee708c99SJean-Christophe Dubois } 141ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr); 142ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0, 143ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->avic), 144ee708c99SJean-Christophe Dubois serial_table[i].irq)); 145ee708c99SJean-Christophe Dubois } 146ee708c99SJean-Christophe Dubois 147ee708c99SJean-Christophe Dubois /* Initialize all GPT timers */ 148ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_GPTS; i++) { 149ee708c99SJean-Christophe Dubois static const struct { 150ee708c99SJean-Christophe Dubois hwaddr addr; 151ee708c99SJean-Christophe Dubois unsigned int irq; 152ee708c99SJean-Christophe Dubois } gpt_table[FSL_IMX25_NUM_GPTS] = { 153ee708c99SJean-Christophe Dubois { FSL_IMX25_GPT1_ADDR, FSL_IMX25_GPT1_IRQ }, 154ee708c99SJean-Christophe Dubois { FSL_IMX25_GPT2_ADDR, FSL_IMX25_GPT2_IRQ }, 155ee708c99SJean-Christophe Dubois { FSL_IMX25_GPT3_ADDR, FSL_IMX25_GPT3_IRQ }, 156ee708c99SJean-Christophe Dubois { FSL_IMX25_GPT4_ADDR, FSL_IMX25_GPT4_IRQ } 157ee708c99SJean-Christophe Dubois }; 158ee708c99SJean-Christophe Dubois 159cb54d868SJean-Christophe Dubois s->gpt[i].ccm = IMX_CCM(&s->ccm); 160ee708c99SJean-Christophe Dubois 161ee708c99SJean-Christophe Dubois object_property_set_bool(OBJECT(&s->gpt[i]), true, "realized", &err); 162ee708c99SJean-Christophe Dubois if (err) { 163ee708c99SJean-Christophe Dubois error_propagate(errp, err); 164ee708c99SJean-Christophe Dubois return; 165ee708c99SJean-Christophe Dubois } 166ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, gpt_table[i].addr); 167ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0, 168ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->avic), 169ee708c99SJean-Christophe Dubois gpt_table[i].irq)); 170ee708c99SJean-Christophe Dubois } 171ee708c99SJean-Christophe Dubois 172ee708c99SJean-Christophe Dubois /* Initialize all EPIT timers */ 173ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_EPITS; i++) { 174ee708c99SJean-Christophe Dubois static const struct { 175ee708c99SJean-Christophe Dubois hwaddr addr; 176ee708c99SJean-Christophe Dubois unsigned int irq; 177ee708c99SJean-Christophe Dubois } epit_table[FSL_IMX25_NUM_EPITS] = { 178ee708c99SJean-Christophe Dubois { FSL_IMX25_EPIT1_ADDR, FSL_IMX25_EPIT1_IRQ }, 179ee708c99SJean-Christophe Dubois { FSL_IMX25_EPIT2_ADDR, FSL_IMX25_EPIT2_IRQ } 180ee708c99SJean-Christophe Dubois }; 181ee708c99SJean-Christophe Dubois 182cb54d868SJean-Christophe Dubois s->epit[i].ccm = IMX_CCM(&s->ccm); 183ee708c99SJean-Christophe Dubois 184ee708c99SJean-Christophe Dubois object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", &err); 185ee708c99SJean-Christophe Dubois if (err) { 186ee708c99SJean-Christophe Dubois error_propagate(errp, err); 187ee708c99SJean-Christophe Dubois return; 188ee708c99SJean-Christophe Dubois } 189ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr); 190ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0, 191ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->avic), 192ee708c99SJean-Christophe Dubois epit_table[i].irq)); 193ee708c99SJean-Christophe Dubois } 194ee708c99SJean-Christophe Dubois 195ee708c99SJean-Christophe Dubois qdev_set_nic_properties(DEVICE(&s->fec), &nd_table[0]); 196a699b410SJean-Christophe Dubois 197ee708c99SJean-Christophe Dubois object_property_set_bool(OBJECT(&s->fec), true, "realized", &err); 198ee708c99SJean-Christophe Dubois if (err) { 199ee708c99SJean-Christophe Dubois error_propagate(errp, err); 200ee708c99SJean-Christophe Dubois return; 201ee708c99SJean-Christophe Dubois } 202ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->fec), 0, FSL_IMX25_FEC_ADDR); 203ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->fec), 0, 204ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX25_FEC_IRQ)); 205ee708c99SJean-Christophe Dubois 206f0396549SMartin Kaiser object_property_set_bool(OBJECT(&s->rngc), true, "realized", &err); 207f0396549SMartin Kaiser if (err) { 208f0396549SMartin Kaiser error_propagate(errp, err); 209f0396549SMartin Kaiser return; 210f0396549SMartin Kaiser } 211f0396549SMartin Kaiser sysbus_mmio_map(SYS_BUS_DEVICE(&s->rngc), 0, FSL_IMX25_RNGC_ADDR); 212f0396549SMartin Kaiser sysbus_connect_irq(SYS_BUS_DEVICE(&s->rngc), 0, 213f0396549SMartin Kaiser qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX25_RNGC_IRQ)); 214ee708c99SJean-Christophe Dubois 215ee708c99SJean-Christophe Dubois /* Initialize all I2C */ 216ee708c99SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_I2CS; i++) { 217ee708c99SJean-Christophe Dubois static const struct { 218ee708c99SJean-Christophe Dubois hwaddr addr; 219ee708c99SJean-Christophe Dubois unsigned int irq; 220ee708c99SJean-Christophe Dubois } i2c_table[FSL_IMX25_NUM_I2CS] = { 221ee708c99SJean-Christophe Dubois { FSL_IMX25_I2C1_ADDR, FSL_IMX25_I2C1_IRQ }, 222ee708c99SJean-Christophe Dubois { FSL_IMX25_I2C2_ADDR, FSL_IMX25_I2C2_IRQ }, 223ee708c99SJean-Christophe Dubois { FSL_IMX25_I2C3_ADDR, FSL_IMX25_I2C3_IRQ } 224ee708c99SJean-Christophe Dubois }; 225ee708c99SJean-Christophe Dubois 226ee708c99SJean-Christophe Dubois object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", &err); 227ee708c99SJean-Christophe Dubois if (err) { 228ee708c99SJean-Christophe Dubois error_propagate(errp, err); 229ee708c99SJean-Christophe Dubois return; 230ee708c99SJean-Christophe Dubois } 231ee708c99SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr); 232ee708c99SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0, 233ee708c99SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->avic), 234ee708c99SJean-Christophe Dubois i2c_table[i].irq)); 235ee708c99SJean-Christophe Dubois } 236ee708c99SJean-Christophe Dubois 2376abc7158SJean-Christophe Dubois /* Initialize all GPIOs */ 2386abc7158SJean-Christophe Dubois for (i = 0; i < FSL_IMX25_NUM_GPIOS; i++) { 2396abc7158SJean-Christophe Dubois static const struct { 2406abc7158SJean-Christophe Dubois hwaddr addr; 2416abc7158SJean-Christophe Dubois unsigned int irq; 2426abc7158SJean-Christophe Dubois } gpio_table[FSL_IMX25_NUM_GPIOS] = { 2436abc7158SJean-Christophe Dubois { FSL_IMX25_GPIO1_ADDR, FSL_IMX25_GPIO1_IRQ }, 2446abc7158SJean-Christophe Dubois { FSL_IMX25_GPIO2_ADDR, FSL_IMX25_GPIO2_IRQ }, 2456abc7158SJean-Christophe Dubois { FSL_IMX25_GPIO3_ADDR, FSL_IMX25_GPIO3_IRQ }, 2466abc7158SJean-Christophe Dubois { FSL_IMX25_GPIO4_ADDR, FSL_IMX25_GPIO4_IRQ } 2476abc7158SJean-Christophe Dubois }; 2486abc7158SJean-Christophe Dubois 2496abc7158SJean-Christophe Dubois object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", &err); 2506abc7158SJean-Christophe Dubois if (err) { 2516abc7158SJean-Christophe Dubois error_propagate(errp, err); 2526abc7158SJean-Christophe Dubois return; 2536abc7158SJean-Christophe Dubois } 2546abc7158SJean-Christophe Dubois sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr); 2556abc7158SJean-Christophe Dubois /* Connect GPIO IRQ to PIC */ 2566abc7158SJean-Christophe Dubois sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0, 2576abc7158SJean-Christophe Dubois qdev_get_gpio_in(DEVICE(&s->avic), 2586abc7158SJean-Christophe Dubois gpio_table[i].irq)); 2596abc7158SJean-Christophe Dubois } 2606abc7158SJean-Christophe Dubois 261bfae1772SGuenter Roeck /* Initialize all SDHC */ 262bfae1772SGuenter Roeck for (i = 0; i < FSL_IMX25_NUM_ESDHCS; i++) { 263bfae1772SGuenter Roeck static const struct { 264bfae1772SGuenter Roeck hwaddr addr; 265bfae1772SGuenter Roeck unsigned int irq; 266bfae1772SGuenter Roeck } esdhc_table[FSL_IMX25_NUM_ESDHCS] = { 267bfae1772SGuenter Roeck { FSL_IMX25_ESDHC1_ADDR, FSL_IMX25_ESDHC1_IRQ }, 268bfae1772SGuenter Roeck { FSL_IMX25_ESDHC2_ADDR, FSL_IMX25_ESDHC2_IRQ }, 269bfae1772SGuenter Roeck }; 270bfae1772SGuenter Roeck 271bfae1772SGuenter Roeck object_property_set_uint(OBJECT(&s->esdhc[i]), 2, "sd-spec-version", 272bfae1772SGuenter Roeck &err); 273bfae1772SGuenter Roeck object_property_set_uint(OBJECT(&s->esdhc[i]), IMX25_ESDHC_CAPABILITIES, 274bfae1772SGuenter Roeck "capareg", &err); 275bfae1772SGuenter Roeck object_property_set_bool(OBJECT(&s->esdhc[i]), true, "realized", &err); 276bfae1772SGuenter Roeck if (err) { 277bfae1772SGuenter Roeck error_propagate(errp, err); 278bfae1772SGuenter Roeck return; 279bfae1772SGuenter Roeck } 280bfae1772SGuenter Roeck sysbus_mmio_map(SYS_BUS_DEVICE(&s->esdhc[i]), 0, esdhc_table[i].addr); 281bfae1772SGuenter Roeck sysbus_connect_irq(SYS_BUS_DEVICE(&s->esdhc[i]), 0, 282bfae1772SGuenter Roeck qdev_get_gpio_in(DEVICE(&s->avic), 283bfae1772SGuenter Roeck esdhc_table[i].irq)); 284bfae1772SGuenter Roeck } 285bfae1772SGuenter Roeck 28667f52ebeSGuenter Roeck /* USB */ 28767f52ebeSGuenter Roeck for (i = 0; i < FSL_IMX25_NUM_USBS; i++) { 28867f52ebeSGuenter Roeck static const struct { 28967f52ebeSGuenter Roeck hwaddr addr; 29067f52ebeSGuenter Roeck unsigned int irq; 29167f52ebeSGuenter Roeck } usb_table[FSL_IMX25_NUM_USBS] = { 29267f52ebeSGuenter Roeck { FSL_IMX25_USB1_ADDR, FSL_IMX25_USB1_IRQ }, 29367f52ebeSGuenter Roeck { FSL_IMX25_USB2_ADDR, FSL_IMX25_USB2_IRQ }, 29467f52ebeSGuenter Roeck }; 29567f52ebeSGuenter Roeck 29667f52ebeSGuenter Roeck object_property_set_bool(OBJECT(&s->usb[i]), true, "realized", 29767f52ebeSGuenter Roeck &error_abort); 29867f52ebeSGuenter Roeck sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, usb_table[i].addr); 29967f52ebeSGuenter Roeck sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, 30067f52ebeSGuenter Roeck qdev_get_gpio_in(DEVICE(&s->avic), 30167f52ebeSGuenter Roeck usb_table[i].irq)); 30267f52ebeSGuenter Roeck } 30367f52ebeSGuenter Roeck 3044f0aff00SGuenter Roeck /* Watchdog */ 3054f0aff00SGuenter Roeck object_property_set_bool(OBJECT(&s->wdt), true, "pretimeout-support", 3064f0aff00SGuenter Roeck &error_abort); 3074f0aff00SGuenter Roeck object_property_set_bool(OBJECT(&s->wdt), true, "realized", &error_abort); 3084f0aff00SGuenter Roeck sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt), 0, FSL_IMX25_WDT_ADDR); 3094f0aff00SGuenter Roeck sysbus_connect_irq(SYS_BUS_DEVICE(&s->wdt), 0, 3104f0aff00SGuenter Roeck qdev_get_gpio_in(DEVICE(&s->avic), 3114f0aff00SGuenter Roeck FSL_IMX25_WDT_IRQ)); 3124f0aff00SGuenter Roeck 313ee708c99SJean-Christophe Dubois /* initialize 2 x 16 KB ROM */ 31432b9523aSPhilippe Mathieu-Daudé memory_region_init_rom(&s->rom[0], OBJECT(dev), "imx25.rom0", 31532b9523aSPhilippe Mathieu-Daudé FSL_IMX25_ROM0_SIZE, &err); 316ee708c99SJean-Christophe Dubois if (err) { 317ee708c99SJean-Christophe Dubois error_propagate(errp, err); 318ee708c99SJean-Christophe Dubois return; 319ee708c99SJean-Christophe Dubois } 320ee708c99SJean-Christophe Dubois memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM0_ADDR, 321ee708c99SJean-Christophe Dubois &s->rom[0]); 32232b9523aSPhilippe Mathieu-Daudé memory_region_init_rom(&s->rom[1], OBJECT(dev), "imx25.rom1", 32332b9523aSPhilippe Mathieu-Daudé FSL_IMX25_ROM1_SIZE, &err); 324ee708c99SJean-Christophe Dubois if (err) { 325ee708c99SJean-Christophe Dubois error_propagate(errp, err); 326ee708c99SJean-Christophe Dubois return; 327ee708c99SJean-Christophe Dubois } 328ee708c99SJean-Christophe Dubois memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM1_ADDR, 329ee708c99SJean-Christophe Dubois &s->rom[1]); 330ee708c99SJean-Christophe Dubois 331ee708c99SJean-Christophe Dubois /* initialize internal RAM (128 KB) */ 33298a99ce0SPeter Maydell memory_region_init_ram(&s->iram, NULL, "imx25.iram", FSL_IMX25_IRAM_SIZE, 333ee708c99SJean-Christophe Dubois &err); 334ee708c99SJean-Christophe Dubois if (err) { 335ee708c99SJean-Christophe Dubois error_propagate(errp, err); 336ee708c99SJean-Christophe Dubois return; 337ee708c99SJean-Christophe Dubois } 338ee708c99SJean-Christophe Dubois memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ADDR, 339ee708c99SJean-Christophe Dubois &s->iram); 340ee708c99SJean-Christophe Dubois 341ee708c99SJean-Christophe Dubois /* internal RAM (128 KB) is aliased over 128 MB - 128 KB */ 34232b9523aSPhilippe Mathieu-Daudé memory_region_init_alias(&s->iram_alias, OBJECT(dev), "imx25.iram_alias", 343ee708c99SJean-Christophe Dubois &s->iram, 0, FSL_IMX25_IRAM_ALIAS_SIZE); 344ee708c99SJean-Christophe Dubois memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ALIAS_ADDR, 345ee708c99SJean-Christophe Dubois &s->iram_alias); 346ee708c99SJean-Christophe Dubois } 347ee708c99SJean-Christophe Dubois 348ee708c99SJean-Christophe Dubois static void fsl_imx25_class_init(ObjectClass *oc, void *data) 349ee708c99SJean-Christophe Dubois { 350ee708c99SJean-Christophe Dubois DeviceClass *dc = DEVICE_CLASS(oc); 351ee708c99SJean-Christophe Dubois 352ee708c99SJean-Christophe Dubois dc->realize = fsl_imx25_realize; 353eccfa35eSJean-Christophe Dubois dc->desc = "i.MX25 SOC"; 3545e0c7044SThomas Huth /* 3555e0c7044SThomas Huth * Reason: uses serial_hds in realize and the imx25 board does not 3565e0c7044SThomas Huth * support multiple CPUs 3575e0c7044SThomas Huth */ 3585e0c7044SThomas Huth dc->user_creatable = false; 359ee708c99SJean-Christophe Dubois } 360ee708c99SJean-Christophe Dubois 361ee708c99SJean-Christophe Dubois static const TypeInfo fsl_imx25_type_info = { 362ee708c99SJean-Christophe Dubois .name = TYPE_FSL_IMX25, 363ee708c99SJean-Christophe Dubois .parent = TYPE_DEVICE, 364ee708c99SJean-Christophe Dubois .instance_size = sizeof(FslIMX25State), 365ee708c99SJean-Christophe Dubois .instance_init = fsl_imx25_init, 366ee708c99SJean-Christophe Dubois .class_init = fsl_imx25_class_init, 367ee708c99SJean-Christophe Dubois }; 368ee708c99SJean-Christophe Dubois 369ee708c99SJean-Christophe Dubois static void fsl_imx25_register_types(void) 370ee708c99SJean-Christophe Dubois { 371ee708c99SJean-Christophe Dubois type_register_static(&fsl_imx25_type_info); 372ee708c99SJean-Christophe Dubois } 373ee708c99SJean-Christophe Dubois 374ee708c99SJean-Christophe Dubois type_init(fsl_imx25_register_types) 375