hw/scsi/scsi-disk: Disallow block sizes smaller than 512 [CVE-2023-42467]
[qemu/ar7.git] / hw / arm / fsl-imx7.c
blob474cfdc87c6f2ebc6c443d20a464332661e0052b
1 /*
2 * Copyright (c) 2018, Impinj, Inc.
4 * i.MX7 SoC definitions
6 * Author: Andrey Smirnov <andrew.smirnov@gmail.com>
8 * Based on hw/arm/fsl-imx6.c
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #include "qemu/osdep.h"
22 #include "qapi/error.h"
23 #include "hw/arm/fsl-imx7.h"
24 #include "hw/misc/unimp.h"
25 #include "hw/boards.h"
26 #include "sysemu/sysemu.h"
27 #include "qemu/error-report.h"
28 #include "qemu/module.h"
30 #define NAME_SIZE 20
32 static void fsl_imx7_init(Object *obj)
34 MachineState *ms = MACHINE(qdev_get_machine());
35 FslIMX7State *s = FSL_IMX7(obj);
36 char name[NAME_SIZE];
37 int i;
40 * CPUs
42 for (i = 0; i < MIN(ms->smp.cpus, FSL_IMX7_NUM_CPUS); i++) {
43 snprintf(name, NAME_SIZE, "cpu%d", i);
44 object_initialize_child(obj, name, &s->cpu[i],
45 ARM_CPU_TYPE_NAME("cortex-a7"));
49 * A7MPCORE
51 object_initialize_child(obj, "a7mpcore", &s->a7mpcore,
52 TYPE_A15MPCORE_PRIV);
55 * GPIOs
57 for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) {
58 snprintf(name, NAME_SIZE, "gpio%d", i);
59 object_initialize_child(obj, name, &s->gpio[i], TYPE_IMX_GPIO);
63 * GPTs
65 for (i = 0; i < FSL_IMX7_NUM_GPTS; i++) {
66 snprintf(name, NAME_SIZE, "gpt%d", i);
67 object_initialize_child(obj, name, &s->gpt[i], TYPE_IMX7_GPT);
71 * CCM
73 object_initialize_child(obj, "ccm", &s->ccm, TYPE_IMX7_CCM);
76 * Analog
78 object_initialize_child(obj, "analog", &s->analog, TYPE_IMX7_ANALOG);
81 * GPCv2
83 object_initialize_child(obj, "gpcv2", &s->gpcv2, TYPE_IMX_GPCV2);
86 * SRC
88 object_initialize_child(obj, "src", &s->src, TYPE_IMX7_SRC);
91 * ECSPIs
93 for (i = 0; i < FSL_IMX7_NUM_ECSPIS; i++) {
94 snprintf(name, NAME_SIZE, "spi%d", i + 1);
95 object_initialize_child(obj, name, &s->spi[i], TYPE_IMX_SPI);
99 * I2Cs
101 for (i = 0; i < FSL_IMX7_NUM_I2CS; i++) {
102 snprintf(name, NAME_SIZE, "i2c%d", i + 1);
103 object_initialize_child(obj, name, &s->i2c[i], TYPE_IMX_I2C);
107 * UARTs
109 for (i = 0; i < FSL_IMX7_NUM_UARTS; i++) {
110 snprintf(name, NAME_SIZE, "uart%d", i);
111 object_initialize_child(obj, name, &s->uart[i], TYPE_IMX_SERIAL);
115 * Ethernets
117 for (i = 0; i < FSL_IMX7_NUM_ETHS; i++) {
118 snprintf(name, NAME_SIZE, "eth%d", i);
119 object_initialize_child(obj, name, &s->eth[i], TYPE_IMX_ENET);
123 * SDHCIs
125 for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) {
126 snprintf(name, NAME_SIZE, "usdhc%d", i);
127 object_initialize_child(obj, name, &s->usdhc[i], TYPE_IMX_USDHC);
131 * SNVS
133 object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS);
136 * Watchdogs
138 for (i = 0; i < FSL_IMX7_NUM_WDTS; i++) {
139 snprintf(name, NAME_SIZE, "wdt%d", i);
140 object_initialize_child(obj, name, &s->wdt[i], TYPE_IMX2_WDT);
144 * GPR
146 object_initialize_child(obj, "gpr", &s->gpr, TYPE_IMX7_GPR);
149 * PCIE
151 object_initialize_child(obj, "pcie", &s->pcie, TYPE_DESIGNWARE_PCIE_HOST);
154 * USBs
156 for (i = 0; i < FSL_IMX7_NUM_USBS; i++) {
157 snprintf(name, NAME_SIZE, "usb%d", i);
158 object_initialize_child(obj, name, &s->usb[i], TYPE_CHIPIDEA);
162 static void fsl_imx7_realize(DeviceState *dev, Error **errp)
164 MachineState *ms = MACHINE(qdev_get_machine());
165 FslIMX7State *s = FSL_IMX7(dev);
166 Object *o;
167 int i;
168 qemu_irq irq;
169 char name[NAME_SIZE];
170 unsigned int smp_cpus = ms->smp.cpus;
172 if (smp_cpus > FSL_IMX7_NUM_CPUS) {
173 error_setg(errp, "%s: Only %d CPUs are supported (%d requested)",
174 TYPE_FSL_IMX7, FSL_IMX7_NUM_CPUS, smp_cpus);
175 return;
179 * CPUs
181 for (i = 0; i < smp_cpus; i++) {
182 o = OBJECT(&s->cpu[i]);
184 /* On uniprocessor, the CBAR is set to 0 */
185 if (smp_cpus > 1) {
186 object_property_set_int(o, "reset-cbar", FSL_IMX7_A7MPCORE_ADDR,
187 &error_abort);
190 if (i) {
192 * Secondary CPUs start in powered-down state (and can be
193 * powered up via the SRC system reset controller)
195 object_property_set_bool(o, "start-powered-off", true,
196 &error_abort);
199 qdev_realize(DEVICE(o), NULL, &error_abort);
203 * A7MPCORE
205 object_property_set_int(OBJECT(&s->a7mpcore), "num-cpu", smp_cpus,
206 &error_abort);
207 object_property_set_int(OBJECT(&s->a7mpcore), "num-irq",
208 FSL_IMX7_MAX_IRQ + GIC_INTERNAL, &error_abort);
210 sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort);
211 sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, FSL_IMX7_A7MPCORE_ADDR);
213 for (i = 0; i < smp_cpus; i++) {
214 SysBusDevice *sbd = SYS_BUS_DEVICE(&s->a7mpcore);
215 DeviceState *d = DEVICE(qemu_get_cpu(i));
217 irq = qdev_get_gpio_in(d, ARM_CPU_IRQ);
218 sysbus_connect_irq(sbd, i, irq);
219 irq = qdev_get_gpio_in(d, ARM_CPU_FIQ);
220 sysbus_connect_irq(sbd, i + smp_cpus, irq);
221 irq = qdev_get_gpio_in(d, ARM_CPU_VIRQ);
222 sysbus_connect_irq(sbd, i + 2 * smp_cpus, irq);
223 irq = qdev_get_gpio_in(d, ARM_CPU_VFIQ);
224 sysbus_connect_irq(sbd, i + 3 * smp_cpus, irq);
228 * A7MPCORE DAP
230 create_unimplemented_device("a7mpcore-dap", FSL_IMX7_A7MPCORE_DAP_ADDR,
231 FSL_IMX7_A7MPCORE_DAP_SIZE);
234 * GPTs
236 for (i = 0; i < FSL_IMX7_NUM_GPTS; i++) {
237 static const hwaddr FSL_IMX7_GPTn_ADDR[FSL_IMX7_NUM_GPTS] = {
238 FSL_IMX7_GPT1_ADDR,
239 FSL_IMX7_GPT2_ADDR,
240 FSL_IMX7_GPT3_ADDR,
241 FSL_IMX7_GPT4_ADDR,
244 static const int FSL_IMX7_GPTn_IRQ[FSL_IMX7_NUM_GPTS] = {
245 FSL_IMX7_GPT1_IRQ,
246 FSL_IMX7_GPT2_IRQ,
247 FSL_IMX7_GPT3_IRQ,
248 FSL_IMX7_GPT4_IRQ,
251 s->gpt[i].ccm = IMX_CCM(&s->ccm);
252 sysbus_realize(SYS_BUS_DEVICE(&s->gpt[i]), &error_abort);
253 sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, FSL_IMX7_GPTn_ADDR[i]);
254 sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0,
255 qdev_get_gpio_in(DEVICE(&s->a7mpcore),
256 FSL_IMX7_GPTn_IRQ[i]));
260 * GPIOs
262 for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) {
263 static const hwaddr FSL_IMX7_GPIOn_ADDR[FSL_IMX7_NUM_GPIOS] = {
264 FSL_IMX7_GPIO1_ADDR,
265 FSL_IMX7_GPIO2_ADDR,
266 FSL_IMX7_GPIO3_ADDR,
267 FSL_IMX7_GPIO4_ADDR,
268 FSL_IMX7_GPIO5_ADDR,
269 FSL_IMX7_GPIO6_ADDR,
270 FSL_IMX7_GPIO7_ADDR,
273 static const int FSL_IMX7_GPIOn_LOW_IRQ[FSL_IMX7_NUM_GPIOS] = {
274 FSL_IMX7_GPIO1_LOW_IRQ,
275 FSL_IMX7_GPIO2_LOW_IRQ,
276 FSL_IMX7_GPIO3_LOW_IRQ,
277 FSL_IMX7_GPIO4_LOW_IRQ,
278 FSL_IMX7_GPIO5_LOW_IRQ,
279 FSL_IMX7_GPIO6_LOW_IRQ,
280 FSL_IMX7_GPIO7_LOW_IRQ,
283 static const int FSL_IMX7_GPIOn_HIGH_IRQ[FSL_IMX7_NUM_GPIOS] = {
284 FSL_IMX7_GPIO1_HIGH_IRQ,
285 FSL_IMX7_GPIO2_HIGH_IRQ,
286 FSL_IMX7_GPIO3_HIGH_IRQ,
287 FSL_IMX7_GPIO4_HIGH_IRQ,
288 FSL_IMX7_GPIO5_HIGH_IRQ,
289 FSL_IMX7_GPIO6_HIGH_IRQ,
290 FSL_IMX7_GPIO7_HIGH_IRQ,
293 sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), &error_abort);
294 sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0,
295 FSL_IMX7_GPIOn_ADDR[i]);
297 sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,
298 qdev_get_gpio_in(DEVICE(&s->a7mpcore),
299 FSL_IMX7_GPIOn_LOW_IRQ[i]));
301 sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 1,
302 qdev_get_gpio_in(DEVICE(&s->a7mpcore),
303 FSL_IMX7_GPIOn_HIGH_IRQ[i]));
307 * IOMUXC and IOMUXC_LPSR
309 create_unimplemented_device("iomuxc", FSL_IMX7_IOMUXC_ADDR,
310 FSL_IMX7_IOMUXC_SIZE);
311 create_unimplemented_device("iomuxc_lspr", FSL_IMX7_IOMUXC_LPSR_ADDR,
312 FSL_IMX7_IOMUXC_LPSR_SIZE);
315 * CCM
317 sysbus_realize(SYS_BUS_DEVICE(&s->ccm), &error_abort);
318 sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX7_CCM_ADDR);
321 * Analog
323 sysbus_realize(SYS_BUS_DEVICE(&s->analog), &error_abort);
324 sysbus_mmio_map(SYS_BUS_DEVICE(&s->analog), 0, FSL_IMX7_ANALOG_ADDR);
327 * GPCv2
329 sysbus_realize(SYS_BUS_DEVICE(&s->gpcv2), &error_abort);
330 sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX7_GPC_ADDR);
333 * ECSPIs
335 for (i = 0; i < FSL_IMX7_NUM_ECSPIS; i++) {
336 static const hwaddr FSL_IMX7_SPIn_ADDR[FSL_IMX7_NUM_ECSPIS] = {
337 FSL_IMX7_ECSPI1_ADDR,
338 FSL_IMX7_ECSPI2_ADDR,
339 FSL_IMX7_ECSPI3_ADDR,
340 FSL_IMX7_ECSPI4_ADDR,
343 static const int FSL_IMX7_SPIn_IRQ[FSL_IMX7_NUM_ECSPIS] = {
344 FSL_IMX7_ECSPI1_IRQ,
345 FSL_IMX7_ECSPI2_IRQ,
346 FSL_IMX7_ECSPI3_IRQ,
347 FSL_IMX7_ECSPI4_IRQ,
350 /* Initialize the SPI */
351 sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), &error_abort);
352 sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0,
353 FSL_IMX7_SPIn_ADDR[i]);
354 sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
355 qdev_get_gpio_in(DEVICE(&s->a7mpcore),
356 FSL_IMX7_SPIn_IRQ[i]));
360 * I2Cs
362 for (i = 0; i < FSL_IMX7_NUM_I2CS; i++) {
363 static const hwaddr FSL_IMX7_I2Cn_ADDR[FSL_IMX7_NUM_I2CS] = {
364 FSL_IMX7_I2C1_ADDR,
365 FSL_IMX7_I2C2_ADDR,
366 FSL_IMX7_I2C3_ADDR,
367 FSL_IMX7_I2C4_ADDR,
370 static const int FSL_IMX7_I2Cn_IRQ[FSL_IMX7_NUM_I2CS] = {
371 FSL_IMX7_I2C1_IRQ,
372 FSL_IMX7_I2C2_IRQ,
373 FSL_IMX7_I2C3_IRQ,
374 FSL_IMX7_I2C4_IRQ,
377 sysbus_realize(SYS_BUS_DEVICE(&s->i2c[i]), &error_abort);
378 sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, FSL_IMX7_I2Cn_ADDR[i]);
380 sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0,
381 qdev_get_gpio_in(DEVICE(&s->a7mpcore),
382 FSL_IMX7_I2Cn_IRQ[i]));
386 * UARTs
388 for (i = 0; i < FSL_IMX7_NUM_UARTS; i++) {
389 static const hwaddr FSL_IMX7_UARTn_ADDR[FSL_IMX7_NUM_UARTS] = {
390 FSL_IMX7_UART1_ADDR,
391 FSL_IMX7_UART2_ADDR,
392 FSL_IMX7_UART3_ADDR,
393 FSL_IMX7_UART4_ADDR,
394 FSL_IMX7_UART5_ADDR,
395 FSL_IMX7_UART6_ADDR,
396 FSL_IMX7_UART7_ADDR,
399 static const int FSL_IMX7_UARTn_IRQ[FSL_IMX7_NUM_UARTS] = {
400 FSL_IMX7_UART1_IRQ,
401 FSL_IMX7_UART2_IRQ,
402 FSL_IMX7_UART3_IRQ,
403 FSL_IMX7_UART4_IRQ,
404 FSL_IMX7_UART5_IRQ,
405 FSL_IMX7_UART6_IRQ,
406 FSL_IMX7_UART7_IRQ,
410 qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
412 sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), &error_abort);
414 sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, FSL_IMX7_UARTn_ADDR[i]);
416 irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_UARTn_IRQ[i]);
417 sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0, irq);
421 * Ethernets
423 * We must use two loops since phy_connected affects the other interface
424 * and we have to set all properties before calling sysbus_realize().
426 for (i = 0; i < FSL_IMX7_NUM_ETHS; i++) {
427 object_property_set_bool(OBJECT(&s->eth[i]), "phy-connected",
428 s->phy_connected[i], &error_abort);
430 * If the MDIO bus on this controller is not connected, assume the
431 * other controller provides support for it.
433 if (!s->phy_connected[i]) {
434 object_property_set_link(OBJECT(&s->eth[1 - i]), "phy-consumer",
435 OBJECT(&s->eth[i]), &error_abort);
439 for (i = 0; i < FSL_IMX7_NUM_ETHS; i++) {
440 static const hwaddr FSL_IMX7_ENETn_ADDR[FSL_IMX7_NUM_ETHS] = {
441 FSL_IMX7_ENET1_ADDR,
442 FSL_IMX7_ENET2_ADDR,
445 object_property_set_uint(OBJECT(&s->eth[i]), "phy-num",
446 s->phy_num[i], &error_abort);
447 object_property_set_uint(OBJECT(&s->eth[i]), "tx-ring-num",
448 FSL_IMX7_ETH_NUM_TX_RINGS, &error_abort);
449 qdev_set_nic_properties(DEVICE(&s->eth[i]), &nd_table[i]);
450 sysbus_realize(SYS_BUS_DEVICE(&s->eth[i]), &error_abort);
452 sysbus_mmio_map(SYS_BUS_DEVICE(&s->eth[i]), 0, FSL_IMX7_ENETn_ADDR[i]);
454 irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_ENET_IRQ(i, 0));
455 sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth[i]), 0, irq);
456 irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_ENET_IRQ(i, 3));
457 sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth[i]), 1, irq);
461 * USDHCs
463 for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) {
464 static const hwaddr FSL_IMX7_USDHCn_ADDR[FSL_IMX7_NUM_USDHCS] = {
465 FSL_IMX7_USDHC1_ADDR,
466 FSL_IMX7_USDHC2_ADDR,
467 FSL_IMX7_USDHC3_ADDR,
470 static const int FSL_IMX7_USDHCn_IRQ[FSL_IMX7_NUM_USDHCS] = {
471 FSL_IMX7_USDHC1_IRQ,
472 FSL_IMX7_USDHC2_IRQ,
473 FSL_IMX7_USDHC3_IRQ,
476 object_property_set_uint(OBJECT(&s->usdhc[i]), "vendor",
477 SDHCI_VENDOR_IMX, &error_abort);
478 sysbus_realize(SYS_BUS_DEVICE(&s->usdhc[i]), &error_abort);
480 sysbus_mmio_map(SYS_BUS_DEVICE(&s->usdhc[i]), 0,
481 FSL_IMX7_USDHCn_ADDR[i]);
483 irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_USDHCn_IRQ[i]);
484 sysbus_connect_irq(SYS_BUS_DEVICE(&s->usdhc[i]), 0, irq);
488 * SNVS
490 sysbus_realize(SYS_BUS_DEVICE(&s->snvs), &error_abort);
491 sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX7_SNVS_HP_ADDR);
494 * SRC
496 sysbus_realize(SYS_BUS_DEVICE(&s->src), &error_abort);
497 sysbus_mmio_map(SYS_BUS_DEVICE(&s->src), 0, FSL_IMX7_SRC_ADDR);
500 * Watchdogs
502 for (i = 0; i < FSL_IMX7_NUM_WDTS; i++) {
503 static const hwaddr FSL_IMX7_WDOGn_ADDR[FSL_IMX7_NUM_WDTS] = {
504 FSL_IMX7_WDOG1_ADDR,
505 FSL_IMX7_WDOG2_ADDR,
506 FSL_IMX7_WDOG3_ADDR,
507 FSL_IMX7_WDOG4_ADDR,
509 static const int FSL_IMX7_WDOGn_IRQ[FSL_IMX7_NUM_WDTS] = {
510 FSL_IMX7_WDOG1_IRQ,
511 FSL_IMX7_WDOG2_IRQ,
512 FSL_IMX7_WDOG3_IRQ,
513 FSL_IMX7_WDOG4_IRQ,
516 object_property_set_bool(OBJECT(&s->wdt[i]), "pretimeout-support",
517 true, &error_abort);
518 sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), &error_abort);
520 sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, FSL_IMX7_WDOGn_ADDR[i]);
521 sysbus_connect_irq(SYS_BUS_DEVICE(&s->wdt[i]), 0,
522 qdev_get_gpio_in(DEVICE(&s->a7mpcore),
523 FSL_IMX7_WDOGn_IRQ[i]));
527 * SDMA
529 create_unimplemented_device("sdma", FSL_IMX7_SDMA_ADDR, FSL_IMX7_SDMA_SIZE);
532 * CAAM
534 create_unimplemented_device("caam", FSL_IMX7_CAAM_ADDR, FSL_IMX7_CAAM_SIZE);
537 * PWMs
539 for (i = 0; i < FSL_IMX7_NUM_PWMS; i++) {
540 static const hwaddr FSL_IMX7_PWMn_ADDR[FSL_IMX7_NUM_PWMS] = {
541 FSL_IMX7_PWM1_ADDR,
542 FSL_IMX7_PWM2_ADDR,
543 FSL_IMX7_PWM3_ADDR,
544 FSL_IMX7_PWM4_ADDR,
547 snprintf(name, NAME_SIZE, "pwm%d", i);
548 create_unimplemented_device(name, FSL_IMX7_PWMn_ADDR[i],
549 FSL_IMX7_PWMn_SIZE);
553 * CANs
555 for (i = 0; i < FSL_IMX7_NUM_CANS; i++) {
556 static const hwaddr FSL_IMX7_CANn_ADDR[FSL_IMX7_NUM_CANS] = {
557 FSL_IMX7_CAN1_ADDR,
558 FSL_IMX7_CAN2_ADDR,
561 snprintf(name, NAME_SIZE, "can%d", i);
562 create_unimplemented_device(name, FSL_IMX7_CANn_ADDR[i],
563 FSL_IMX7_CANn_SIZE);
567 * SAIs (Audio SSI (Synchronous Serial Interface))
569 for (i = 0; i < FSL_IMX7_NUM_SAIS; i++) {
570 static const hwaddr FSL_IMX7_SAIn_ADDR[FSL_IMX7_NUM_SAIS] = {
571 FSL_IMX7_SAI1_ADDR,
572 FSL_IMX7_SAI2_ADDR,
573 FSL_IMX7_SAI3_ADDR,
576 snprintf(name, NAME_SIZE, "sai%d", i);
577 create_unimplemented_device(name, FSL_IMX7_SAIn_ADDR[i],
578 FSL_IMX7_SAIn_SIZE);
582 * OCOTP
584 create_unimplemented_device("ocotp", FSL_IMX7_OCOTP_ADDR,
585 FSL_IMX7_OCOTP_SIZE);
588 * GPR
590 sysbus_realize(SYS_BUS_DEVICE(&s->gpr), &error_abort);
591 sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX7_IOMUXC_GPR_ADDR);
594 * PCIE
596 sysbus_realize(SYS_BUS_DEVICE(&s->pcie), &error_abort);
597 sysbus_mmio_map(SYS_BUS_DEVICE(&s->pcie), 0, FSL_IMX7_PCIE_REG_ADDR);
599 irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTA_IRQ);
600 sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 0, irq);
601 irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTB_IRQ);
602 sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 1, irq);
603 irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTC_IRQ);
604 sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 2, irq);
605 irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTD_IRQ);
606 sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 3, irq);
609 * USBs
611 for (i = 0; i < FSL_IMX7_NUM_USBS; i++) {
612 static const hwaddr FSL_IMX7_USBMISCn_ADDR[FSL_IMX7_NUM_USBS] = {
613 FSL_IMX7_USBMISC1_ADDR,
614 FSL_IMX7_USBMISC2_ADDR,
615 FSL_IMX7_USBMISC3_ADDR,
618 static const hwaddr FSL_IMX7_USBn_ADDR[FSL_IMX7_NUM_USBS] = {
619 FSL_IMX7_USB1_ADDR,
620 FSL_IMX7_USB2_ADDR,
621 FSL_IMX7_USB3_ADDR,
624 static const int FSL_IMX7_USBn_IRQ[FSL_IMX7_NUM_USBS] = {
625 FSL_IMX7_USB1_IRQ,
626 FSL_IMX7_USB2_IRQ,
627 FSL_IMX7_USB3_IRQ,
630 sysbus_realize(SYS_BUS_DEVICE(&s->usb[i]), &error_abort);
631 sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0,
632 FSL_IMX7_USBn_ADDR[i]);
634 irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_USBn_IRQ[i]);
635 sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, irq);
637 snprintf(name, NAME_SIZE, "usbmisc%d", i);
638 create_unimplemented_device(name, FSL_IMX7_USBMISCn_ADDR[i],
639 FSL_IMX7_USBMISCn_SIZE);
643 * ADCs
645 for (i = 0; i < FSL_IMX7_NUM_ADCS; i++) {
646 static const hwaddr FSL_IMX7_ADCn_ADDR[FSL_IMX7_NUM_ADCS] = {
647 FSL_IMX7_ADC1_ADDR,
648 FSL_IMX7_ADC2_ADDR,
651 snprintf(name, NAME_SIZE, "adc%d", i);
652 create_unimplemented_device(name, FSL_IMX7_ADCn_ADDR[i],
653 FSL_IMX7_ADCn_SIZE);
657 * LCD
659 create_unimplemented_device("lcdif", FSL_IMX7_LCDIF_ADDR,
660 FSL_IMX7_LCDIF_SIZE);
663 * DMA APBH
665 create_unimplemented_device("dma-apbh", FSL_IMX7_DMA_APBH_ADDR,
666 FSL_IMX7_DMA_APBH_SIZE);
668 * PCIe PHY
670 create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR,
671 FSL_IMX7_PCIE_PHY_SIZE);
674 * CSU
676 create_unimplemented_device("csu", FSL_IMX7_CSU_ADDR,
677 FSL_IMX7_CSU_SIZE);
680 * TZASC
682 create_unimplemented_device("tzasc", FSL_IMX7_TZASC_ADDR,
683 FSL_IMX7_TZASC_SIZE);
686 * OCRAM memory
688 memory_region_init_ram(&s->ocram, NULL, "imx7.ocram",
689 FSL_IMX7_OCRAM_MEM_SIZE,
690 &error_abort);
691 memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_MEM_ADDR,
692 &s->ocram);
695 * OCRAM EPDC memory
697 memory_region_init_ram(&s->ocram_epdc, NULL, "imx7.ocram_epdc",
698 FSL_IMX7_OCRAM_EPDC_SIZE,
699 &error_abort);
700 memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_EPDC_ADDR,
701 &s->ocram_epdc);
704 * OCRAM PXP memory
706 memory_region_init_ram(&s->ocram_pxp, NULL, "imx7.ocram_pxp",
707 FSL_IMX7_OCRAM_PXP_SIZE,
708 &error_abort);
709 memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_PXP_ADDR,
710 &s->ocram_pxp);
713 * OCRAM_S memory
715 memory_region_init_ram(&s->ocram_s, NULL, "imx7.ocram_s",
716 FSL_IMX7_OCRAM_S_SIZE,
717 &error_abort);
718 memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_S_ADDR,
719 &s->ocram_s);
722 * ROM memory
724 memory_region_init_rom(&s->rom, OBJECT(dev), "imx7.rom",
725 FSL_IMX7_ROM_SIZE, &error_abort);
726 memory_region_add_subregion(get_system_memory(), FSL_IMX7_ROM_ADDR,
727 &s->rom);
730 * CAAM memory
732 memory_region_init_rom(&s->caam, OBJECT(dev), "imx7.caam",
733 FSL_IMX7_CAAM_MEM_SIZE, &error_abort);
734 memory_region_add_subregion(get_system_memory(), FSL_IMX7_CAAM_MEM_ADDR,
735 &s->caam);
738 static Property fsl_imx7_properties[] = {
739 DEFINE_PROP_UINT32("fec1-phy-num", FslIMX7State, phy_num[0], 0),
740 DEFINE_PROP_UINT32("fec2-phy-num", FslIMX7State, phy_num[1], 1),
741 DEFINE_PROP_BOOL("fec1-phy-connected", FslIMX7State, phy_connected[0],
742 true),
743 DEFINE_PROP_BOOL("fec2-phy-connected", FslIMX7State, phy_connected[1],
744 true),
745 DEFINE_PROP_END_OF_LIST(),
748 static void fsl_imx7_class_init(ObjectClass *oc, void *data)
750 DeviceClass *dc = DEVICE_CLASS(oc);
752 device_class_set_props(dc, fsl_imx7_properties);
753 dc->realize = fsl_imx7_realize;
755 /* Reason: Uses serial_hds and nd_table in realize() directly */
756 dc->user_creatable = false;
757 dc->desc = "i.MX7 SOC";
760 static const TypeInfo fsl_imx7_type_info = {
761 .name = TYPE_FSL_IMX7,
762 .parent = TYPE_DEVICE,
763 .instance_size = sizeof(FslIMX7State),
764 .instance_init = fsl_imx7_init,
765 .class_init = fsl_imx7_class_init,
768 static void fsl_imx7_register_types(void)
770 type_register_static(&fsl_imx7_type_info);
772 type_init(fsl_imx7_register_types)