xref: /qemu/hw/arm/fsl-imx6ul.c (revision 06b40d250ecfa1633209c2e431a7a38acfd03a98)
131cbf933SJean-Christophe Dubois /*
231cbf933SJean-Christophe Dubois  * Copyright (c) 2018 Jean-Christophe Dubois <jcd@tribudubois.net>
331cbf933SJean-Christophe Dubois  *
431cbf933SJean-Christophe Dubois  * i.MX6UL SOC emulation.
531cbf933SJean-Christophe Dubois  *
631cbf933SJean-Christophe Dubois  * Based on hw/arm/fsl-imx7.c
731cbf933SJean-Christophe Dubois  *
831cbf933SJean-Christophe Dubois  * This program is free software; you can redistribute it and/or modify
931cbf933SJean-Christophe Dubois  * it under the terms of the GNU General Public License as published by
1031cbf933SJean-Christophe Dubois  * the Free Software Foundation; either version 2 of the License, or
1131cbf933SJean-Christophe Dubois  * (at your option) any later version.
1231cbf933SJean-Christophe Dubois  *
1331cbf933SJean-Christophe Dubois  * This program is distributed in the hope that it will be useful,
1431cbf933SJean-Christophe Dubois  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1531cbf933SJean-Christophe Dubois  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1631cbf933SJean-Christophe Dubois  * GNU General Public License for more details.
1731cbf933SJean-Christophe Dubois  */
1831cbf933SJean-Christophe Dubois 
1931cbf933SJean-Christophe Dubois #include "qemu/osdep.h"
2031cbf933SJean-Christophe Dubois #include "qapi/error.h"
2131cbf933SJean-Christophe Dubois #include "hw/arm/fsl-imx6ul.h"
2231cbf933SJean-Christophe Dubois #include "hw/misc/unimp.h"
2317372bd8SGuenter Roeck #include "hw/usb/imx-usb-phy.h"
24cc7d44c2SLike Xu #include "hw/boards.h"
2532cad1ffSPhilippe Mathieu-Daudé #include "system/system.h"
2631cbf933SJean-Christophe Dubois #include "qemu/error-report.h"
270b8fa32fSMarkus Armbruster #include "qemu/module.h"
28d780d056SPhilippe Mathieu-Daudé #include "target/arm/cpu-qom.h"
2931cbf933SJean-Christophe Dubois 
3031cbf933SJean-Christophe Dubois #define NAME_SIZE 20
3131cbf933SJean-Christophe Dubois 
fsl_imx6ul_init(Object * obj)3231cbf933SJean-Christophe Dubois static void fsl_imx6ul_init(Object *obj)
3331cbf933SJean-Christophe Dubois {
3431cbf933SJean-Christophe Dubois     FslIMX6ULState *s = FSL_IMX6UL(obj);
3531cbf933SJean-Christophe Dubois     char name[NAME_SIZE];
3631cbf933SJean-Christophe Dubois     int i;
3731cbf933SJean-Christophe Dubois 
389fc7fc4dSMarkus Armbruster     object_initialize_child(obj, "cpu0", &s->cpu,
399fc7fc4dSMarkus Armbruster                             ARM_CPU_TYPE_NAME("cortex-a7"));
4031cbf933SJean-Christophe Dubois 
4131cbf933SJean-Christophe Dubois     /*
4231cbf933SJean-Christophe Dubois      * A7MPCORE
4331cbf933SJean-Christophe Dubois      */
44db873cc5SMarkus Armbruster     object_initialize_child(obj, "a7mpcore", &s->a7mpcore,
4531cbf933SJean-Christophe Dubois                             TYPE_A15MPCORE_PRIV);
4631cbf933SJean-Christophe Dubois 
4731cbf933SJean-Christophe Dubois     /*
4831cbf933SJean-Christophe Dubois      * CCM
4931cbf933SJean-Christophe Dubois      */
50db873cc5SMarkus Armbruster     object_initialize_child(obj, "ccm", &s->ccm, TYPE_IMX6UL_CCM);
5131cbf933SJean-Christophe Dubois 
5231cbf933SJean-Christophe Dubois     /*
5331cbf933SJean-Christophe Dubois      * SRC
5431cbf933SJean-Christophe Dubois      */
55db873cc5SMarkus Armbruster     object_initialize_child(obj, "src", &s->src, TYPE_IMX6_SRC);
5631cbf933SJean-Christophe Dubois 
5731cbf933SJean-Christophe Dubois     /*
5831cbf933SJean-Christophe Dubois      * GPCv2
5931cbf933SJean-Christophe Dubois      */
60db873cc5SMarkus Armbruster     object_initialize_child(obj, "gpcv2", &s->gpcv2, TYPE_IMX_GPCV2);
6131cbf933SJean-Christophe Dubois 
6231cbf933SJean-Christophe Dubois     /*
6331cbf933SJean-Christophe Dubois      * SNVS
6431cbf933SJean-Christophe Dubois      */
65db873cc5SMarkus Armbruster     object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS);
6631cbf933SJean-Christophe Dubois 
6731cbf933SJean-Christophe Dubois     /*
680cd4926bSJean-Christophe Dubois      * GPIOs
6931cbf933SJean-Christophe Dubois      */
7031cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) {
7131cbf933SJean-Christophe Dubois         snprintf(name, NAME_SIZE, "gpio%d", i);
72db873cc5SMarkus Armbruster         object_initialize_child(obj, name, &s->gpio[i], TYPE_IMX_GPIO);
7331cbf933SJean-Christophe Dubois     }
7431cbf933SJean-Christophe Dubois 
7531cbf933SJean-Christophe Dubois     /*
760cd4926bSJean-Christophe Dubois      * GPTs
7731cbf933SJean-Christophe Dubois      */
7831cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) {
7931cbf933SJean-Christophe Dubois         snprintf(name, NAME_SIZE, "gpt%d", i);
80a1e03956SJean-Christophe Dubois         object_initialize_child(obj, name, &s->gpt[i], TYPE_IMX6UL_GPT);
8131cbf933SJean-Christophe Dubois     }
8231cbf933SJean-Christophe Dubois 
8331cbf933SJean-Christophe Dubois     /*
840cd4926bSJean-Christophe Dubois      * EPITs
8531cbf933SJean-Christophe Dubois      */
8631cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) {
8731cbf933SJean-Christophe Dubois         snprintf(name, NAME_SIZE, "epit%d", i + 1);
88db873cc5SMarkus Armbruster         object_initialize_child(obj, name, &s->epit[i], TYPE_IMX_EPIT);
8931cbf933SJean-Christophe Dubois     }
9031cbf933SJean-Christophe Dubois 
9131cbf933SJean-Christophe Dubois     /*
920cd4926bSJean-Christophe Dubois      * eCSPIs
9331cbf933SJean-Christophe Dubois      */
9431cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) {
9531cbf933SJean-Christophe Dubois         snprintf(name, NAME_SIZE, "spi%d", i + 1);
96db873cc5SMarkus Armbruster         object_initialize_child(obj, name, &s->spi[i], TYPE_IMX_SPI);
9731cbf933SJean-Christophe Dubois     }
9831cbf933SJean-Christophe Dubois 
9931cbf933SJean-Christophe Dubois     /*
1000cd4926bSJean-Christophe Dubois      * I2Cs
10131cbf933SJean-Christophe Dubois      */
10231cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) {
10331cbf933SJean-Christophe Dubois         snprintf(name, NAME_SIZE, "i2c%d", i + 1);
104db873cc5SMarkus Armbruster         object_initialize_child(obj, name, &s->i2c[i], TYPE_IMX_I2C);
10531cbf933SJean-Christophe Dubois     }
10631cbf933SJean-Christophe Dubois 
10731cbf933SJean-Christophe Dubois     /*
1080cd4926bSJean-Christophe Dubois      * UARTs
10931cbf933SJean-Christophe Dubois      */
11031cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) {
11131cbf933SJean-Christophe Dubois         snprintf(name, NAME_SIZE, "uart%d", i);
112db873cc5SMarkus Armbruster         object_initialize_child(obj, name, &s->uart[i], TYPE_IMX_SERIAL);
11331cbf933SJean-Christophe Dubois     }
11431cbf933SJean-Christophe Dubois 
11531cbf933SJean-Christophe Dubois     /*
1160cd4926bSJean-Christophe Dubois      * Ethernets
11731cbf933SJean-Christophe Dubois      */
11831cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_ETHS; i++) {
11931cbf933SJean-Christophe Dubois         snprintf(name, NAME_SIZE, "eth%d", i);
120db873cc5SMarkus Armbruster         object_initialize_child(obj, name, &s->eth[i], TYPE_IMX_ENET);
12131cbf933SJean-Christophe Dubois     }
12231cbf933SJean-Christophe Dubois 
1230cd4926bSJean-Christophe Dubois     /*
1240cd4926bSJean-Christophe Dubois      * USB PHYs
1250cd4926bSJean-Christophe Dubois      */
12617372bd8SGuenter Roeck     for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) {
12717372bd8SGuenter Roeck         snprintf(name, NAME_SIZE, "usbphy%d", i);
128db873cc5SMarkus Armbruster         object_initialize_child(obj, name, &s->usbphy[i], TYPE_IMX_USBPHY);
12917372bd8SGuenter Roeck     }
1300cd4926bSJean-Christophe Dubois 
1310cd4926bSJean-Christophe Dubois     /*
1320cd4926bSJean-Christophe Dubois      * USBs
1330cd4926bSJean-Christophe Dubois      */
13417372bd8SGuenter Roeck     for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) {
13517372bd8SGuenter Roeck         snprintf(name, NAME_SIZE, "usb%d", i);
136db873cc5SMarkus Armbruster         object_initialize_child(obj, name, &s->usb[i], TYPE_CHIPIDEA);
13717372bd8SGuenter Roeck     }
13817372bd8SGuenter Roeck 
13931cbf933SJean-Christophe Dubois     /*
1400cd4926bSJean-Christophe Dubois      * SDHCIs
14131cbf933SJean-Christophe Dubois      */
14231cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) {
14331cbf933SJean-Christophe Dubois         snprintf(name, NAME_SIZE, "usdhc%d", i);
144db873cc5SMarkus Armbruster         object_initialize_child(obj, name, &s->usdhc[i], TYPE_IMX_USDHC);
14531cbf933SJean-Christophe Dubois     }
14631cbf933SJean-Christophe Dubois 
14731cbf933SJean-Christophe Dubois     /*
1480cd4926bSJean-Christophe Dubois      * Watchdogs
14931cbf933SJean-Christophe Dubois      */
15031cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) {
15131cbf933SJean-Christophe Dubois         snprintf(name, NAME_SIZE, "wdt%d", i);
152db873cc5SMarkus Armbruster         object_initialize_child(obj, name, &s->wdt[i], TYPE_IMX2_WDT);
15331cbf933SJean-Christophe Dubois     }
15431cbf933SJean-Christophe Dubois }
15531cbf933SJean-Christophe Dubois 
fsl_imx6ul_realize(DeviceState * dev,Error ** errp)15631cbf933SJean-Christophe Dubois static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
15731cbf933SJean-Christophe Dubois {
158cc7d44c2SLike Xu     MachineState *ms = MACHINE(qdev_get_machine());
15931cbf933SJean-Christophe Dubois     FslIMX6ULState *s = FSL_IMX6UL(dev);
1604033d1d5SPhilippe Mathieu-Daudé     DeviceState *mpcore = DEVICE(&s->a7mpcore);
16131cbf933SJean-Christophe Dubois     int i;
16231cbf933SJean-Christophe Dubois     char name[NAME_SIZE];
1634033d1d5SPhilippe Mathieu-Daudé     DeviceState *gic;
1644033d1d5SPhilippe Mathieu-Daudé     SysBusDevice *gicsbd;
1654033d1d5SPhilippe Mathieu-Daudé     DeviceState *cpu;
16631cbf933SJean-Christophe Dubois 
167bc8c2ecfSPeter Maydell     if (ms->smp.cpus > 1) {
168bc8c2ecfSPeter Maydell         error_setg(errp, "%s: Only a single CPU is supported (%d requested)",
169bc8c2ecfSPeter Maydell                    TYPE_FSL_IMX6UL, ms->smp.cpus);
17031cbf933SJean-Christophe Dubois         return;
17131cbf933SJean-Christophe Dubois     }
17231cbf933SJean-Christophe Dubois 
173ce189ab2SMarkus Armbruster     qdev_realize(DEVICE(&s->cpu), NULL, &error_abort);
17431cbf933SJean-Christophe Dubois 
17531cbf933SJean-Christophe Dubois     /*
17631cbf933SJean-Christophe Dubois      * A7MPCORE
17731cbf933SJean-Christophe Dubois      */
1784033d1d5SPhilippe Mathieu-Daudé     object_property_set_int(OBJECT(mpcore), "num-cpu", 1, &error_abort);
1794033d1d5SPhilippe Mathieu-Daudé     object_property_set_int(OBJECT(mpcore), "num-irq",
1805325cc34SMarkus Armbruster                             FSL_IMX6UL_MAX_IRQ + GIC_INTERNAL, &error_abort);
1814033d1d5SPhilippe Mathieu-Daudé     sysbus_realize(SYS_BUS_DEVICE(mpcore), &error_abort);
1824033d1d5SPhilippe Mathieu-Daudé     sysbus_mmio_map(SYS_BUS_DEVICE(mpcore), 0, FSL_IMX6UL_A7MPCORE_ADDR);
18331cbf933SJean-Christophe Dubois 
1844033d1d5SPhilippe Mathieu-Daudé     gic = mpcore;
1854033d1d5SPhilippe Mathieu-Daudé     gicsbd = SYS_BUS_DEVICE(gic);
1864033d1d5SPhilippe Mathieu-Daudé     cpu = DEVICE(&s->cpu);
1874033d1d5SPhilippe Mathieu-Daudé     sysbus_connect_irq(gicsbd, 0, qdev_get_gpio_in(cpu, ARM_CPU_IRQ));
1884033d1d5SPhilippe Mathieu-Daudé     sysbus_connect_irq(gicsbd, 1, qdev_get_gpio_in(cpu, ARM_CPU_FIQ));
1894033d1d5SPhilippe Mathieu-Daudé     sysbus_connect_irq(gicsbd, 2, qdev_get_gpio_in(cpu, ARM_CPU_VIRQ));
1904033d1d5SPhilippe Mathieu-Daudé     sysbus_connect_irq(gicsbd, 3, qdev_get_gpio_in(cpu, ARM_CPU_VFIQ));
19131cbf933SJean-Christophe Dubois 
19231cbf933SJean-Christophe Dubois     /*
19331cbf933SJean-Christophe Dubois      * A7MPCORE DAP
19431cbf933SJean-Christophe Dubois      */
19531cbf933SJean-Christophe Dubois     create_unimplemented_device("a7mpcore-dap", FSL_IMX6UL_A7MPCORE_DAP_ADDR,
1960cd4926bSJean-Christophe Dubois                                 FSL_IMX6UL_A7MPCORE_DAP_SIZE);
19731cbf933SJean-Christophe Dubois 
19831cbf933SJean-Christophe Dubois     /*
199b0d1021eSGuenter Roeck      * MMDC
200b0d1021eSGuenter Roeck      */
201b0d1021eSGuenter Roeck     create_unimplemented_device("a7mpcore-mmdc", FSL_IMX6UL_MMDC_CFG_ADDR,
202b0d1021eSGuenter Roeck                                 FSL_IMX6UL_MMDC_CFG_SIZE);
203b0d1021eSGuenter Roeck 
204b0d1021eSGuenter Roeck     /*
205b0d1021eSGuenter Roeck      * OCOTP
206b0d1021eSGuenter Roeck      */
207b0d1021eSGuenter Roeck     create_unimplemented_device("a7mpcore-ocotp", FSL_IMX6UL_OCOTP_CTRL_ADDR,
208b0d1021eSGuenter Roeck                                 FSL_IMX6UL_OCOTP_CTRL_SIZE);
209b0d1021eSGuenter Roeck 
210b0d1021eSGuenter Roeck     /*
211b0d1021eSGuenter Roeck      * QSPI
212b0d1021eSGuenter Roeck      */
213b0d1021eSGuenter Roeck     create_unimplemented_device("a7mpcore-qspi", FSL_IMX6UL_QSPI_ADDR,
214b0d1021eSGuenter Roeck                                 FSL_IMX6UL_QSPI_SIZE);
215b0d1021eSGuenter Roeck 
216b0d1021eSGuenter Roeck     /*
217b0d1021eSGuenter Roeck      * CAAM
218b0d1021eSGuenter Roeck      */
219b0d1021eSGuenter Roeck     create_unimplemented_device("a7mpcore-qspi", FSL_IMX6UL_CAAM_ADDR,
220b0d1021eSGuenter Roeck                                 FSL_IMX6UL_CAAM_SIZE);
221b0d1021eSGuenter Roeck 
222b0d1021eSGuenter Roeck     /*
223b0d1021eSGuenter Roeck      * USBMISC
224b0d1021eSGuenter Roeck      */
225b0d1021eSGuenter Roeck     create_unimplemented_device("a7mpcore-usbmisc", FSL_IMX6UL_USBO2_USBMISC_ADDR,
226b0d1021eSGuenter Roeck                                 FSL_IMX6UL_USBO2_USBMISC_SIZE);
227b0d1021eSGuenter Roeck 
228b0d1021eSGuenter Roeck     /*
2290cd4926bSJean-Christophe Dubois      * GPTs
23031cbf933SJean-Christophe Dubois      */
23131cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) {
23231cbf933SJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_GPTn_ADDR[FSL_IMX6UL_NUM_GPTS] = {
23331cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPT1_ADDR,
23431cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPT2_ADDR,
23531cbf933SJean-Christophe Dubois         };
23631cbf933SJean-Christophe Dubois 
23731cbf933SJean-Christophe Dubois         static const int FSL_IMX6UL_GPTn_IRQ[FSL_IMX6UL_NUM_GPTS] = {
23831cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPT1_IRQ,
23931cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPT2_IRQ,
24031cbf933SJean-Christophe Dubois         };
24131cbf933SJean-Christophe Dubois 
24231cbf933SJean-Christophe Dubois         s->gpt[i].ccm = IMX_CCM(&s->ccm);
243db873cc5SMarkus Armbruster         sysbus_realize(SYS_BUS_DEVICE(&s->gpt[i]), &error_abort);
24431cbf933SJean-Christophe Dubois 
24531cbf933SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0,
24631cbf933SJean-Christophe Dubois                         FSL_IMX6UL_GPTn_ADDR[i]);
24731cbf933SJean-Christophe Dubois 
24831cbf933SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0,
2494033d1d5SPhilippe Mathieu-Daudé                            qdev_get_gpio_in(gic, FSL_IMX6UL_GPTn_IRQ[i]));
25031cbf933SJean-Christophe Dubois     }
25131cbf933SJean-Christophe Dubois 
25231cbf933SJean-Christophe Dubois     /*
2530cd4926bSJean-Christophe Dubois      * EPITs
25431cbf933SJean-Christophe Dubois      */
25531cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) {
25631cbf933SJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_EPITn_ADDR[FSL_IMX6UL_NUM_EPITS] = {
25731cbf933SJean-Christophe Dubois             FSL_IMX6UL_EPIT1_ADDR,
25831cbf933SJean-Christophe Dubois             FSL_IMX6UL_EPIT2_ADDR,
25931cbf933SJean-Christophe Dubois         };
26031cbf933SJean-Christophe Dubois 
26131cbf933SJean-Christophe Dubois         static const int FSL_IMX6UL_EPITn_IRQ[FSL_IMX6UL_NUM_EPITS] = {
26231cbf933SJean-Christophe Dubois             FSL_IMX6UL_EPIT1_IRQ,
26331cbf933SJean-Christophe Dubois             FSL_IMX6UL_EPIT2_IRQ,
26431cbf933SJean-Christophe Dubois         };
26531cbf933SJean-Christophe Dubois 
26631cbf933SJean-Christophe Dubois         s->epit[i].ccm = IMX_CCM(&s->ccm);
267db873cc5SMarkus Armbruster         sysbus_realize(SYS_BUS_DEVICE(&s->epit[i]), &error_abort);
26831cbf933SJean-Christophe Dubois 
26931cbf933SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0,
27031cbf933SJean-Christophe Dubois                         FSL_IMX6UL_EPITn_ADDR[i]);
27131cbf933SJean-Christophe Dubois 
27231cbf933SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0,
2734033d1d5SPhilippe Mathieu-Daudé                            qdev_get_gpio_in(gic, FSL_IMX6UL_EPITn_IRQ[i]));
27431cbf933SJean-Christophe Dubois     }
27531cbf933SJean-Christophe Dubois 
27631cbf933SJean-Christophe Dubois     /*
2770cd4926bSJean-Christophe Dubois      * GPIOs
27831cbf933SJean-Christophe Dubois      */
27931cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) {
28031cbf933SJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_GPIOn_ADDR[FSL_IMX6UL_NUM_GPIOS] = {
28131cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO1_ADDR,
28231cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO2_ADDR,
28331cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO3_ADDR,
28431cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO4_ADDR,
28531cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO5_ADDR,
28631cbf933SJean-Christophe Dubois         };
28731cbf933SJean-Christophe Dubois 
28831cbf933SJean-Christophe Dubois         static const int FSL_IMX6UL_GPIOn_LOW_IRQ[FSL_IMX6UL_NUM_GPIOS] = {
28931cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO1_LOW_IRQ,
29031cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO2_LOW_IRQ,
29131cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO3_LOW_IRQ,
29231cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO4_LOW_IRQ,
29331cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO5_LOW_IRQ,
29431cbf933SJean-Christophe Dubois         };
29531cbf933SJean-Christophe Dubois 
29631cbf933SJean-Christophe Dubois         static const int FSL_IMX6UL_GPIOn_HIGH_IRQ[FSL_IMX6UL_NUM_GPIOS] = {
29731cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO1_HIGH_IRQ,
29831cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO2_HIGH_IRQ,
29931cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO3_HIGH_IRQ,
30031cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO4_HIGH_IRQ,
30131cbf933SJean-Christophe Dubois             FSL_IMX6UL_GPIO5_HIGH_IRQ,
30231cbf933SJean-Christophe Dubois         };
30331cbf933SJean-Christophe Dubois 
304db873cc5SMarkus Armbruster         sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), &error_abort);
30531cbf933SJean-Christophe Dubois 
30631cbf933SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0,
30731cbf933SJean-Christophe Dubois                         FSL_IMX6UL_GPIOn_ADDR[i]);
30831cbf933SJean-Christophe Dubois 
30931cbf933SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,
3104033d1d5SPhilippe Mathieu-Daudé                            qdev_get_gpio_in(gic, FSL_IMX6UL_GPIOn_LOW_IRQ[i]));
31131cbf933SJean-Christophe Dubois 
31231cbf933SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 1,
3134033d1d5SPhilippe Mathieu-Daudé                            qdev_get_gpio_in(gic, FSL_IMX6UL_GPIOn_HIGH_IRQ[i]));
31431cbf933SJean-Christophe Dubois     }
31531cbf933SJean-Christophe Dubois 
31631cbf933SJean-Christophe Dubois     /*
3170cd4926bSJean-Christophe Dubois      * IOMUXC
31831cbf933SJean-Christophe Dubois      */
3190cd4926bSJean-Christophe Dubois     create_unimplemented_device("iomuxc", FSL_IMX6UL_IOMUXC_ADDR,
3200cd4926bSJean-Christophe Dubois                                 FSL_IMX6UL_IOMUXC_SIZE);
3210cd4926bSJean-Christophe Dubois     create_unimplemented_device("iomuxc_gpr", FSL_IMX6UL_IOMUXC_GPR_ADDR,
3220cd4926bSJean-Christophe Dubois                                 FSL_IMX6UL_IOMUXC_GPR_SIZE);
32331cbf933SJean-Christophe Dubois 
32431cbf933SJean-Christophe Dubois     /*
32531cbf933SJean-Christophe Dubois      * CCM
32631cbf933SJean-Christophe Dubois      */
327db873cc5SMarkus Armbruster     sysbus_realize(SYS_BUS_DEVICE(&s->ccm), &error_abort);
32831cbf933SJean-Christophe Dubois     sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX6UL_CCM_ADDR);
32931cbf933SJean-Christophe Dubois 
33031cbf933SJean-Christophe Dubois     /*
33131cbf933SJean-Christophe Dubois      * SRC
33231cbf933SJean-Christophe Dubois      */
333db873cc5SMarkus Armbruster     sysbus_realize(SYS_BUS_DEVICE(&s->src), &error_abort);
33431cbf933SJean-Christophe Dubois     sysbus_mmio_map(SYS_BUS_DEVICE(&s->src), 0, FSL_IMX6UL_SRC_ADDR);
33531cbf933SJean-Christophe Dubois 
33631cbf933SJean-Christophe Dubois     /*
33731cbf933SJean-Christophe Dubois      * GPCv2
33831cbf933SJean-Christophe Dubois      */
339db873cc5SMarkus Armbruster     sysbus_realize(SYS_BUS_DEVICE(&s->gpcv2), &error_abort);
34031cbf933SJean-Christophe Dubois     sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX6UL_GPC_ADDR);
34131cbf933SJean-Christophe Dubois 
3420cd4926bSJean-Christophe Dubois     /*
3430cd4926bSJean-Christophe Dubois      * ECSPIs
3440cd4926bSJean-Christophe Dubois      */
34531cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) {
34631cbf933SJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_SPIn_ADDR[FSL_IMX6UL_NUM_ECSPIS] = {
34731cbf933SJean-Christophe Dubois             FSL_IMX6UL_ECSPI1_ADDR,
34831cbf933SJean-Christophe Dubois             FSL_IMX6UL_ECSPI2_ADDR,
34931cbf933SJean-Christophe Dubois             FSL_IMX6UL_ECSPI3_ADDR,
35031cbf933SJean-Christophe Dubois             FSL_IMX6UL_ECSPI4_ADDR,
35131cbf933SJean-Christophe Dubois         };
35231cbf933SJean-Christophe Dubois 
35331cbf933SJean-Christophe Dubois         static const int FSL_IMX6UL_SPIn_IRQ[FSL_IMX6UL_NUM_ECSPIS] = {
35431cbf933SJean-Christophe Dubois             FSL_IMX6UL_ECSPI1_IRQ,
35531cbf933SJean-Christophe Dubois             FSL_IMX6UL_ECSPI2_IRQ,
35631cbf933SJean-Christophe Dubois             FSL_IMX6UL_ECSPI3_IRQ,
35731cbf933SJean-Christophe Dubois             FSL_IMX6UL_ECSPI4_IRQ,
35831cbf933SJean-Christophe Dubois         };
35931cbf933SJean-Christophe Dubois 
36031cbf933SJean-Christophe Dubois         /* Initialize the SPI */
361db873cc5SMarkus Armbruster         sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), &error_abort);
36231cbf933SJean-Christophe Dubois 
36331cbf933SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0,
36431cbf933SJean-Christophe Dubois                         FSL_IMX6UL_SPIn_ADDR[i]);
36531cbf933SJean-Christophe Dubois 
36631cbf933SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
3674033d1d5SPhilippe Mathieu-Daudé                            qdev_get_gpio_in(gic, FSL_IMX6UL_SPIn_IRQ[i]));
36831cbf933SJean-Christophe Dubois     }
36931cbf933SJean-Christophe Dubois 
37031cbf933SJean-Christophe Dubois     /*
3710cd4926bSJean-Christophe Dubois      * I2Cs
37231cbf933SJean-Christophe Dubois      */
37331cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) {
37431cbf933SJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_I2Cn_ADDR[FSL_IMX6UL_NUM_I2CS] = {
37531cbf933SJean-Christophe Dubois             FSL_IMX6UL_I2C1_ADDR,
37631cbf933SJean-Christophe Dubois             FSL_IMX6UL_I2C2_ADDR,
37731cbf933SJean-Christophe Dubois             FSL_IMX6UL_I2C3_ADDR,
37831cbf933SJean-Christophe Dubois             FSL_IMX6UL_I2C4_ADDR,
37931cbf933SJean-Christophe Dubois         };
38031cbf933SJean-Christophe Dubois 
38131cbf933SJean-Christophe Dubois         static const int FSL_IMX6UL_I2Cn_IRQ[FSL_IMX6UL_NUM_I2CS] = {
38231cbf933SJean-Christophe Dubois             FSL_IMX6UL_I2C1_IRQ,
38331cbf933SJean-Christophe Dubois             FSL_IMX6UL_I2C2_IRQ,
38431cbf933SJean-Christophe Dubois             FSL_IMX6UL_I2C3_IRQ,
38531cbf933SJean-Christophe Dubois             FSL_IMX6UL_I2C4_IRQ,
38631cbf933SJean-Christophe Dubois         };
38731cbf933SJean-Christophe Dubois 
388db873cc5SMarkus Armbruster         sysbus_realize(SYS_BUS_DEVICE(&s->i2c[i]), &error_abort);
38931cbf933SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, FSL_IMX6UL_I2Cn_ADDR[i]);
39031cbf933SJean-Christophe Dubois 
39131cbf933SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0,
3924033d1d5SPhilippe Mathieu-Daudé                            qdev_get_gpio_in(gic, FSL_IMX6UL_I2Cn_IRQ[i]));
39331cbf933SJean-Christophe Dubois     }
39431cbf933SJean-Christophe Dubois 
39531cbf933SJean-Christophe Dubois     /*
3960cd4926bSJean-Christophe Dubois      * UARTs
39731cbf933SJean-Christophe Dubois      */
39831cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) {
39931cbf933SJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_UARTn_ADDR[FSL_IMX6UL_NUM_UARTS] = {
40031cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART1_ADDR,
40131cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART2_ADDR,
40231cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART3_ADDR,
40331cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART4_ADDR,
40431cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART5_ADDR,
40531cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART6_ADDR,
40631cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART7_ADDR,
40731cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART8_ADDR,
40831cbf933SJean-Christophe Dubois         };
40931cbf933SJean-Christophe Dubois 
41031cbf933SJean-Christophe Dubois         static const int FSL_IMX6UL_UARTn_IRQ[FSL_IMX6UL_NUM_UARTS] = {
41131cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART1_IRQ,
41231cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART2_IRQ,
41331cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART3_IRQ,
41431cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART4_IRQ,
41531cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART5_IRQ,
41631cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART6_IRQ,
41731cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART7_IRQ,
41831cbf933SJean-Christophe Dubois             FSL_IMX6UL_UART8_IRQ,
41931cbf933SJean-Christophe Dubois         };
42031cbf933SJean-Christophe Dubois 
42131cbf933SJean-Christophe Dubois         qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
42231cbf933SJean-Christophe Dubois 
423db873cc5SMarkus Armbruster         sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), &error_abort);
42431cbf933SJean-Christophe Dubois 
42531cbf933SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0,
42631cbf933SJean-Christophe Dubois                         FSL_IMX6UL_UARTn_ADDR[i]);
42731cbf933SJean-Christophe Dubois 
42831cbf933SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
4294033d1d5SPhilippe Mathieu-Daudé                            qdev_get_gpio_in(gic, FSL_IMX6UL_UARTn_IRQ[i]));
43031cbf933SJean-Christophe Dubois     }
43131cbf933SJean-Christophe Dubois 
43231cbf933SJean-Christophe Dubois     /*
4330cd4926bSJean-Christophe Dubois      * Ethernets
434bc14018cSGuenter Roeck      *
435bc14018cSGuenter Roeck      * We must use two loops since phy_connected affects the other interface
436bc14018cSGuenter Roeck      * and we have to set all properties before calling sysbus_realize().
43731cbf933SJean-Christophe Dubois      */
43831cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_ETHS; i++) {
439bc14018cSGuenter Roeck         object_property_set_bool(OBJECT(&s->eth[i]), "phy-connected",
440bc14018cSGuenter Roeck                                  s->phy_connected[i], &error_abort);
441bc14018cSGuenter Roeck         /*
442bc14018cSGuenter Roeck          * If the MDIO bus on this controller is not connected, assume the
443bc14018cSGuenter Roeck          * other controller provides support for it.
444bc14018cSGuenter Roeck          */
445bc14018cSGuenter Roeck         if (!s->phy_connected[i]) {
446bc14018cSGuenter Roeck             object_property_set_link(OBJECT(&s->eth[1 - i]), "phy-consumer",
447bc14018cSGuenter Roeck                                      OBJECT(&s->eth[i]), &error_abort);
448bc14018cSGuenter Roeck         }
449bc14018cSGuenter Roeck     }
450bc14018cSGuenter Roeck 
451bc14018cSGuenter Roeck     for (i = 0; i < FSL_IMX6UL_NUM_ETHS; i++) {
45231cbf933SJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_ENETn_ADDR[FSL_IMX6UL_NUM_ETHS] = {
45331cbf933SJean-Christophe Dubois             FSL_IMX6UL_ENET1_ADDR,
45431cbf933SJean-Christophe Dubois             FSL_IMX6UL_ENET2_ADDR,
45531cbf933SJean-Christophe Dubois         };
45631cbf933SJean-Christophe Dubois 
45731cbf933SJean-Christophe Dubois         static const int FSL_IMX6UL_ENETn_IRQ[FSL_IMX6UL_NUM_ETHS] = {
45831cbf933SJean-Christophe Dubois             FSL_IMX6UL_ENET1_IRQ,
45931cbf933SJean-Christophe Dubois             FSL_IMX6UL_ENET2_IRQ,
46031cbf933SJean-Christophe Dubois         };
46131cbf933SJean-Christophe Dubois 
46231cbf933SJean-Christophe Dubois         static const int FSL_IMX6UL_ENETn_TIMER_IRQ[FSL_IMX6UL_NUM_ETHS] = {
46331cbf933SJean-Christophe Dubois             FSL_IMX6UL_ENET1_TIMER_IRQ,
46431cbf933SJean-Christophe Dubois             FSL_IMX6UL_ENET2_TIMER_IRQ,
46531cbf933SJean-Christophe Dubois         };
46631cbf933SJean-Christophe Dubois 
4675325cc34SMarkus Armbruster         object_property_set_uint(OBJECT(&s->eth[i]), "phy-num",
4685325cc34SMarkus Armbruster                                  s->phy_num[i], &error_abort);
4695325cc34SMarkus Armbruster         object_property_set_uint(OBJECT(&s->eth[i]), "tx-ring-num",
4705325cc34SMarkus Armbruster                                  FSL_IMX6UL_ETH_NUM_TX_RINGS, &error_abort);
4718cef839cSDavid Woodhouse         qemu_configure_nic_device(DEVICE(&s->eth[i]), true, NULL);
472db873cc5SMarkus Armbruster         sysbus_realize(SYS_BUS_DEVICE(&s->eth[i]), &error_abort);
47331cbf933SJean-Christophe Dubois 
47431cbf933SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->eth[i]), 0,
47531cbf933SJean-Christophe Dubois                         FSL_IMX6UL_ENETn_ADDR[i]);
47631cbf933SJean-Christophe Dubois 
47731cbf933SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth[i]), 0,
4784033d1d5SPhilippe Mathieu-Daudé                            qdev_get_gpio_in(gic, FSL_IMX6UL_ENETn_IRQ[i]));
47931cbf933SJean-Christophe Dubois 
48031cbf933SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth[i]), 1,
4814033d1d5SPhilippe Mathieu-Daudé                            qdev_get_gpio_in(gic, FSL_IMX6UL_ENETn_TIMER_IRQ[i]));
48231cbf933SJean-Christophe Dubois     }
48331cbf933SJean-Christophe Dubois 
4840cd4926bSJean-Christophe Dubois     /*
4850cd4926bSJean-Christophe Dubois      * USB PHYs
4860cd4926bSJean-Christophe Dubois      */
48717372bd8SGuenter Roeck     for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) {
4880cd4926bSJean-Christophe Dubois         static const hwaddr
4890cd4926bSJean-Christophe Dubois                      FSL_IMX6UL_USB_PHYn_ADDR[FSL_IMX6UL_NUM_USB_PHYS] = {
4900cd4926bSJean-Christophe Dubois             FSL_IMX6UL_USBPHY1_ADDR,
4910cd4926bSJean-Christophe Dubois             FSL_IMX6UL_USBPHY2_ADDR,
4920cd4926bSJean-Christophe Dubois         };
4930cd4926bSJean-Christophe Dubois 
494db873cc5SMarkus Armbruster         sysbus_realize(SYS_BUS_DEVICE(&s->usbphy[i]), &error_abort);
49517372bd8SGuenter Roeck         sysbus_mmio_map(SYS_BUS_DEVICE(&s->usbphy[i]), 0,
4960cd4926bSJean-Christophe Dubois                         FSL_IMX6UL_USB_PHYn_ADDR[i]);
49717372bd8SGuenter Roeck     }
49817372bd8SGuenter Roeck 
4990cd4926bSJean-Christophe Dubois     /*
5000cd4926bSJean-Christophe Dubois      * USBs
5010cd4926bSJean-Christophe Dubois      */
50217372bd8SGuenter Roeck     for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) {
5030cd4926bSJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_USB02_USBn_ADDR[FSL_IMX6UL_NUM_USBS] = {
5040cd4926bSJean-Christophe Dubois             FSL_IMX6UL_USBO2_USB1_ADDR,
5050cd4926bSJean-Christophe Dubois             FSL_IMX6UL_USBO2_USB2_ADDR,
5060cd4926bSJean-Christophe Dubois         };
5070cd4926bSJean-Christophe Dubois 
50817372bd8SGuenter Roeck         static const int FSL_IMX6UL_USBn_IRQ[] = {
50917372bd8SGuenter Roeck             FSL_IMX6UL_USB1_IRQ,
51017372bd8SGuenter Roeck             FSL_IMX6UL_USB2_IRQ,
51117372bd8SGuenter Roeck         };
5120cd4926bSJean-Christophe Dubois 
513db873cc5SMarkus Armbruster         sysbus_realize(SYS_BUS_DEVICE(&s->usb[i]), &error_abort);
51417372bd8SGuenter Roeck         sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0,
5150cd4926bSJean-Christophe Dubois                         FSL_IMX6UL_USB02_USBn_ADDR[i]);
51617372bd8SGuenter Roeck         sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0,
5174033d1d5SPhilippe Mathieu-Daudé                            qdev_get_gpio_in(gic, FSL_IMX6UL_USBn_IRQ[i]));
51817372bd8SGuenter Roeck     }
51917372bd8SGuenter Roeck 
52031cbf933SJean-Christophe Dubois     /*
5210cd4926bSJean-Christophe Dubois      * USDHCs
52231cbf933SJean-Christophe Dubois      */
52331cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) {
52431cbf933SJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_USDHCn_ADDR[FSL_IMX6UL_NUM_USDHCS] = {
52531cbf933SJean-Christophe Dubois             FSL_IMX6UL_USDHC1_ADDR,
52631cbf933SJean-Christophe Dubois             FSL_IMX6UL_USDHC2_ADDR,
52731cbf933SJean-Christophe Dubois         };
52831cbf933SJean-Christophe Dubois 
52931cbf933SJean-Christophe Dubois         static const int FSL_IMX6UL_USDHCn_IRQ[FSL_IMX6UL_NUM_USDHCS] = {
53031cbf933SJean-Christophe Dubois             FSL_IMX6UL_USDHC1_IRQ,
53131cbf933SJean-Christophe Dubois             FSL_IMX6UL_USDHC2_IRQ,
53231cbf933SJean-Christophe Dubois         };
53331cbf933SJean-Christophe Dubois 
534db873cc5SMarkus Armbruster         sysbus_realize(SYS_BUS_DEVICE(&s->usdhc[i]), &error_abort);
53531cbf933SJean-Christophe Dubois 
53631cbf933SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->usdhc[i]), 0,
53731cbf933SJean-Christophe Dubois                         FSL_IMX6UL_USDHCn_ADDR[i]);
53831cbf933SJean-Christophe Dubois 
53931cbf933SJean-Christophe Dubois         sysbus_connect_irq(SYS_BUS_DEVICE(&s->usdhc[i]), 0,
5404033d1d5SPhilippe Mathieu-Daudé                            qdev_get_gpio_in(gic, FSL_IMX6UL_USDHCn_IRQ[i]));
54131cbf933SJean-Christophe Dubois     }
54231cbf933SJean-Christophe Dubois 
54331cbf933SJean-Christophe Dubois     /*
54431cbf933SJean-Christophe Dubois      * SNVS
54531cbf933SJean-Christophe Dubois      */
546db873cc5SMarkus Armbruster     sysbus_realize(SYS_BUS_DEVICE(&s->snvs), &error_abort);
54731cbf933SJean-Christophe Dubois     sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX6UL_SNVS_HP_ADDR);
54831cbf933SJean-Christophe Dubois 
54931cbf933SJean-Christophe Dubois     /*
5500cd4926bSJean-Christophe Dubois      * Watchdogs
55131cbf933SJean-Christophe Dubois      */
55231cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) {
55331cbf933SJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_WDOGn_ADDR[FSL_IMX6UL_NUM_WDTS] = {
55431cbf933SJean-Christophe Dubois             FSL_IMX6UL_WDOG1_ADDR,
55531cbf933SJean-Christophe Dubois             FSL_IMX6UL_WDOG2_ADDR,
55631cbf933SJean-Christophe Dubois             FSL_IMX6UL_WDOG3_ADDR,
55731cbf933SJean-Christophe Dubois         };
5580cd4926bSJean-Christophe Dubois 
5595671e960SGuenter Roeck         static const int FSL_IMX6UL_WDOGn_IRQ[FSL_IMX6UL_NUM_WDTS] = {
5605671e960SGuenter Roeck             FSL_IMX6UL_WDOG1_IRQ,
5615671e960SGuenter Roeck             FSL_IMX6UL_WDOG2_IRQ,
5625671e960SGuenter Roeck             FSL_IMX6UL_WDOG3_IRQ,
5635671e960SGuenter Roeck         };
56431cbf933SJean-Christophe Dubois 
5655325cc34SMarkus Armbruster         object_property_set_bool(OBJECT(&s->wdt[i]), "pretimeout-support",
5665325cc34SMarkus Armbruster                                  true, &error_abort);
567db873cc5SMarkus Armbruster         sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), &error_abort);
56831cbf933SJean-Christophe Dubois 
56931cbf933SJean-Christophe Dubois         sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0,
57031cbf933SJean-Christophe Dubois                         FSL_IMX6UL_WDOGn_ADDR[i]);
5715671e960SGuenter Roeck         sysbus_connect_irq(SYS_BUS_DEVICE(&s->wdt[i]), 0,
5724033d1d5SPhilippe Mathieu-Daudé                            qdev_get_gpio_in(gic, FSL_IMX6UL_WDOGn_IRQ[i]));
57331cbf933SJean-Christophe Dubois     }
57431cbf933SJean-Christophe Dubois 
57531cbf933SJean-Christophe Dubois     /*
57631cbf933SJean-Christophe Dubois      * SDMA
57731cbf933SJean-Christophe Dubois      */
5780cd4926bSJean-Christophe Dubois     create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR,
5790cd4926bSJean-Christophe Dubois                                 FSL_IMX6UL_SDMA_SIZE);
58031cbf933SJean-Christophe Dubois 
58131cbf933SJean-Christophe Dubois     /*
5820cd4926bSJean-Christophe Dubois      * SAIs (Audio SSI (Synchronous Serial Interface))
583ff31cca7SGuenter Roeck      */
5840cd4926bSJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_SAIS; i++) {
5850cd4926bSJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_SAIn_ADDR[FSL_IMX6UL_NUM_SAIS] = {
5860cd4926bSJean-Christophe Dubois             FSL_IMX6UL_SAI1_ADDR,
5870cd4926bSJean-Christophe Dubois             FSL_IMX6UL_SAI2_ADDR,
5880cd4926bSJean-Christophe Dubois             FSL_IMX6UL_SAI3_ADDR,
5890cd4926bSJean-Christophe Dubois         };
5900cd4926bSJean-Christophe Dubois 
5910cd4926bSJean-Christophe Dubois         snprintf(name, NAME_SIZE, "sai%d", i);
5920cd4926bSJean-Christophe Dubois         create_unimplemented_device(name, FSL_IMX6UL_SAIn_ADDR[i],
5930cd4926bSJean-Christophe Dubois                                     FSL_IMX6UL_SAIn_SIZE);
5940cd4926bSJean-Christophe Dubois     }
595ff31cca7SGuenter Roeck 
596ff31cca7SGuenter Roeck     /*
5970cd4926bSJean-Christophe Dubois      * PWMs
5988e0c1585SGuenter Roeck      */
5990cd4926bSJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_PWMS; i++) {
6000cd4926bSJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_PWMn_ADDR[FSL_IMX6UL_NUM_PWMS] = {
6010cd4926bSJean-Christophe Dubois             FSL_IMX6UL_PWM1_ADDR,
6020cd4926bSJean-Christophe Dubois             FSL_IMX6UL_PWM2_ADDR,
6030cd4926bSJean-Christophe Dubois             FSL_IMX6UL_PWM3_ADDR,
6040cd4926bSJean-Christophe Dubois             FSL_IMX6UL_PWM4_ADDR,
605f6020845SJean-Christophe Dubois             FSL_IMX6UL_PWM5_ADDR,
606f6020845SJean-Christophe Dubois             FSL_IMX6UL_PWM6_ADDR,
607f6020845SJean-Christophe Dubois             FSL_IMX6UL_PWM7_ADDR,
608f6020845SJean-Christophe Dubois             FSL_IMX6UL_PWM8_ADDR,
6090cd4926bSJean-Christophe Dubois         };
6100cd4926bSJean-Christophe Dubois 
6110cd4926bSJean-Christophe Dubois         snprintf(name, NAME_SIZE, "pwm%d", i);
6120cd4926bSJean-Christophe Dubois         create_unimplemented_device(name, FSL_IMX6UL_PWMn_ADDR[i],
6130cd4926bSJean-Christophe Dubois                                     FSL_IMX6UL_PWMn_SIZE);
6140cd4926bSJean-Christophe Dubois     }
6158e0c1585SGuenter Roeck 
6168e0c1585SGuenter Roeck     /*
617ff31cca7SGuenter Roeck      * Audio ASRC (asynchronous sample rate converter)
618ff31cca7SGuenter Roeck      */
6190cd4926bSJean-Christophe Dubois     create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR,
6200cd4926bSJean-Christophe Dubois                                 FSL_IMX6UL_ASRC_SIZE);
621ff31cca7SGuenter Roeck 
622ff31cca7SGuenter Roeck     /*
6230cd4926bSJean-Christophe Dubois      * CANs
6248e0c1585SGuenter Roeck      */
6250cd4926bSJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_CANS; i++) {
6260cd4926bSJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_CANn_ADDR[FSL_IMX6UL_NUM_CANS] = {
6270cd4926bSJean-Christophe Dubois             FSL_IMX6UL_CAN1_ADDR,
6280cd4926bSJean-Christophe Dubois             FSL_IMX6UL_CAN2_ADDR,
6290cd4926bSJean-Christophe Dubois         };
6300cd4926bSJean-Christophe Dubois 
6310cd4926bSJean-Christophe Dubois         snprintf(name, NAME_SIZE, "can%d", i);
6320cd4926bSJean-Christophe Dubois         create_unimplemented_device(name, FSL_IMX6UL_CANn_ADDR[i],
6330cd4926bSJean-Christophe Dubois                                     FSL_IMX6UL_CANn_SIZE);
6340cd4926bSJean-Christophe Dubois     }
6358e0c1585SGuenter Roeck 
6368e0c1585SGuenter Roeck     /*
63731cbf933SJean-Christophe Dubois      * APHB_DMA
63831cbf933SJean-Christophe Dubois      */
63931cbf933SJean-Christophe Dubois     create_unimplemented_device("aphb_dma", FSL_IMX6UL_APBH_DMA_ADDR,
64031cbf933SJean-Christophe Dubois                                 FSL_IMX6UL_APBH_DMA_SIZE);
64131cbf933SJean-Christophe Dubois 
64231cbf933SJean-Christophe Dubois     /*
64331cbf933SJean-Christophe Dubois      * ADCs
64431cbf933SJean-Christophe Dubois      */
64531cbf933SJean-Christophe Dubois     for (i = 0; i < FSL_IMX6UL_NUM_ADCS; i++) {
64631cbf933SJean-Christophe Dubois         static const hwaddr FSL_IMX6UL_ADCn_ADDR[FSL_IMX6UL_NUM_ADCS] = {
64731cbf933SJean-Christophe Dubois             FSL_IMX6UL_ADC1_ADDR,
64831cbf933SJean-Christophe Dubois             FSL_IMX6UL_ADC2_ADDR,
64931cbf933SJean-Christophe Dubois         };
65031cbf933SJean-Christophe Dubois 
65131cbf933SJean-Christophe Dubois         snprintf(name, NAME_SIZE, "adc%d", i);
6520cd4926bSJean-Christophe Dubois         create_unimplemented_device(name, FSL_IMX6UL_ADCn_ADDR[i],
6530cd4926bSJean-Christophe Dubois                                     FSL_IMX6UL_ADCn_SIZE);
65431cbf933SJean-Christophe Dubois     }
65531cbf933SJean-Christophe Dubois 
65631cbf933SJean-Christophe Dubois     /*
65731cbf933SJean-Christophe Dubois      * LCD
65831cbf933SJean-Christophe Dubois      */
6590cd4926bSJean-Christophe Dubois     create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR,
6600cd4926bSJean-Christophe Dubois                                 FSL_IMX6UL_LCDIF_SIZE);
66131cbf933SJean-Christophe Dubois 
66231cbf933SJean-Christophe Dubois     /*
663f6020845SJean-Christophe Dubois      * CSU
664f6020845SJean-Christophe Dubois      */
665f6020845SJean-Christophe Dubois     create_unimplemented_device("csu", FSL_IMX6UL_CSU_ADDR,
666f6020845SJean-Christophe Dubois                                 FSL_IMX6UL_CSU_SIZE);
667f6020845SJean-Christophe Dubois 
668f6020845SJean-Christophe Dubois     /*
669f6020845SJean-Christophe Dubois      * TZASC
670f6020845SJean-Christophe Dubois      */
671f6020845SJean-Christophe Dubois     create_unimplemented_device("tzasc", FSL_IMX6UL_TZASC_ADDR,
672f6020845SJean-Christophe Dubois                                 FSL_IMX6UL_TZASC_SIZE);
673f6020845SJean-Christophe Dubois 
674f6020845SJean-Christophe Dubois     /*
67531cbf933SJean-Christophe Dubois      * ROM memory
67631cbf933SJean-Christophe Dubois      */
67732b9523aSPhilippe Mathieu-Daudé     memory_region_init_rom(&s->rom, OBJECT(dev), "imx6ul.rom",
67831cbf933SJean-Christophe Dubois                            FSL_IMX6UL_ROM_SIZE, &error_abort);
67931cbf933SJean-Christophe Dubois     memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_ROM_ADDR,
68031cbf933SJean-Christophe Dubois                                 &s->rom);
68131cbf933SJean-Christophe Dubois 
68231cbf933SJean-Christophe Dubois     /*
68331cbf933SJean-Christophe Dubois      * CAAM memory
68431cbf933SJean-Christophe Dubois      */
68532b9523aSPhilippe Mathieu-Daudé     memory_region_init_rom(&s->caam, OBJECT(dev), "imx6ul.caam",
68631cbf933SJean-Christophe Dubois                            FSL_IMX6UL_CAAM_MEM_SIZE, &error_abort);
68731cbf933SJean-Christophe Dubois     memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_CAAM_MEM_ADDR,
68831cbf933SJean-Christophe Dubois                                 &s->caam);
68931cbf933SJean-Christophe Dubois 
69031cbf933SJean-Christophe Dubois     /*
69131cbf933SJean-Christophe Dubois      * OCRAM memory
69231cbf933SJean-Christophe Dubois      */
69331cbf933SJean-Christophe Dubois     memory_region_init_ram(&s->ocram, NULL, "imx6ul.ocram",
69431cbf933SJean-Christophe Dubois                            FSL_IMX6UL_OCRAM_MEM_SIZE,
69531cbf933SJean-Christophe Dubois                            &error_abort);
69631cbf933SJean-Christophe Dubois     memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_OCRAM_MEM_ADDR,
69731cbf933SJean-Christophe Dubois                                 &s->ocram);
69831cbf933SJean-Christophe Dubois 
69931cbf933SJean-Christophe Dubois     /*
70031cbf933SJean-Christophe Dubois      * internal OCRAM (128 KB) is aliased over 512 KB
70131cbf933SJean-Christophe Dubois      */
70232b9523aSPhilippe Mathieu-Daudé     memory_region_init_alias(&s->ocram_alias, OBJECT(dev),
70332b9523aSPhilippe Mathieu-Daudé                              "imx6ul.ocram_alias", &s->ocram, 0,
70432b9523aSPhilippe Mathieu-Daudé                              FSL_IMX6UL_OCRAM_ALIAS_SIZE);
70531cbf933SJean-Christophe Dubois     memory_region_add_subregion(get_system_memory(),
70631cbf933SJean-Christophe Dubois                                 FSL_IMX6UL_OCRAM_ALIAS_ADDR, &s->ocram_alias);
70731cbf933SJean-Christophe Dubois }
70831cbf933SJean-Christophe Dubois 
709e15bd5ddSRichard Henderson static const Property fsl_imx6ul_properties[] = {
710456914afSJean-Christophe Dubois     DEFINE_PROP_UINT32("fec1-phy-num", FslIMX6ULState, phy_num[0], 0),
711456914afSJean-Christophe Dubois     DEFINE_PROP_UINT32("fec2-phy-num", FslIMX6ULState, phy_num[1], 1),
712bc14018cSGuenter Roeck     DEFINE_PROP_BOOL("fec1-phy-connected", FslIMX6ULState, phy_connected[0],
713bc14018cSGuenter Roeck                      true),
714bc14018cSGuenter Roeck     DEFINE_PROP_BOOL("fec2-phy-connected", FslIMX6ULState, phy_connected[1],
715bc14018cSGuenter Roeck                      true),
716456914afSJean-Christophe Dubois };
717456914afSJean-Christophe Dubois 
fsl_imx6ul_class_init(ObjectClass * oc,const void * data)718*12d1a768SPhilippe Mathieu-Daudé static void fsl_imx6ul_class_init(ObjectClass *oc, const void *data)
71931cbf933SJean-Christophe Dubois {
72031cbf933SJean-Christophe Dubois     DeviceClass *dc = DEVICE_CLASS(oc);
72131cbf933SJean-Christophe Dubois 
722456914afSJean-Christophe Dubois     device_class_set_props(dc, fsl_imx6ul_properties);
72331cbf933SJean-Christophe Dubois     dc->realize = fsl_imx6ul_realize;
72431cbf933SJean-Christophe Dubois     dc->desc = "i.MX6UL SOC";
72531cbf933SJean-Christophe Dubois     /* Reason: Uses serial_hds and nd_table in realize() directly */
72631cbf933SJean-Christophe Dubois     dc->user_creatable = false;
72731cbf933SJean-Christophe Dubois }
72831cbf933SJean-Christophe Dubois 
72931cbf933SJean-Christophe Dubois static const TypeInfo fsl_imx6ul_type_info = {
73031cbf933SJean-Christophe Dubois     .name = TYPE_FSL_IMX6UL,
73131cbf933SJean-Christophe Dubois     .parent = TYPE_DEVICE,
73231cbf933SJean-Christophe Dubois     .instance_size = sizeof(FslIMX6ULState),
73331cbf933SJean-Christophe Dubois     .instance_init = fsl_imx6ul_init,
73431cbf933SJean-Christophe Dubois     .class_init = fsl_imx6ul_class_init,
73531cbf933SJean-Christophe Dubois };
73631cbf933SJean-Christophe Dubois 
fsl_imx6ul_register_types(void)73731cbf933SJean-Christophe Dubois static void fsl_imx6ul_register_types(void)
73831cbf933SJean-Christophe Dubois {
73931cbf933SJean-Christophe Dubois     type_register_static(&fsl_imx6ul_type_info);
74031cbf933SJean-Christophe Dubois }
74131cbf933SJean-Christophe Dubois type_init(fsl_imx6ul_register_types)
742