xref: /qemu/hw/arm/xlnx-zynqmp.c (revision e8c003c4)
1f0a902f7SPeter Crosthwaite /*
2f0a902f7SPeter Crosthwaite  * Xilinx Zynq MPSoC emulation
3f0a902f7SPeter Crosthwaite  *
4f0a902f7SPeter Crosthwaite  * Copyright (C) 2015 Xilinx Inc
5f0a902f7SPeter Crosthwaite  * Written by Peter Crosthwaite <peter.crosthwaite@xilinx.com>
6f0a902f7SPeter Crosthwaite  *
7f0a902f7SPeter Crosthwaite  * This program is free software; you can redistribute it and/or modify it
8f0a902f7SPeter Crosthwaite  * under the terms of the GNU General Public License as published by the
9f0a902f7SPeter Crosthwaite  * Free Software Foundation; either version 2 of the License, or
10f0a902f7SPeter Crosthwaite  * (at your option) any later version.
11f0a902f7SPeter Crosthwaite  *
12f0a902f7SPeter Crosthwaite  * This program is distributed in the hope that it will be useful, but WITHOUT
13f0a902f7SPeter Crosthwaite  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14f0a902f7SPeter Crosthwaite  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15f0a902f7SPeter Crosthwaite  * for more details.
16f0a902f7SPeter Crosthwaite  */
17f0a902f7SPeter Crosthwaite 
1812b16722SPeter Maydell #include "qemu/osdep.h"
19da34e65cSMarkus Armbruster #include "qapi/error.h"
200b8fa32fSMarkus Armbruster #include "qemu/module.h"
21f0a902f7SPeter Crosthwaite #include "hw/arm/xlnx-zynqmp.h"
22bf4cb109SPeter Crosthwaite #include "hw/intc/arm_gic_common.h"
23d2e6f370STong Ho #include "hw/misc/unimp.h"
24cc7d44c2SLike Xu #include "hw/boards.h"
252a0ee672SEdgar E. Iglesias #include "sysemu/kvm.h"
265a720b1eSMarkus Armbruster #include "sysemu/sysemu.h"
272a0ee672SEdgar E. Iglesias #include "kvm_arm.h"
28d780d056SPhilippe Mathieu-Daudé #include "target/arm/cpu-qom.h"
29f4f318b4SPhilippe Mathieu-Daudé #include "target/arm/gtimer.h"
307729e1f4SPeter Crosthwaite 
317729e1f4SPeter Crosthwaite #define GIC_NUM_SPI_INTR 160
327729e1f4SPeter Crosthwaite 
33bf4cb109SPeter Crosthwaite #define ARM_PHYS_TIMER_PPI  30
34bf4cb109SPeter Crosthwaite #define ARM_VIRT_TIMER_PPI  27
3575b749afSLuc Michel #define ARM_HYP_TIMER_PPI   26
3675b749afSLuc Michel #define ARM_SEC_TIMER_PPI   29
3775b749afSLuc Michel #define GIC_MAINTENANCE_PPI 25
38bf4cb109SPeter Crosthwaite 
3920bff213SAlistair Francis #define GEM_REVISION        0x40070106
4020bff213SAlistair Francis 
417729e1f4SPeter Crosthwaite #define GIC_BASE_ADDR       0xf9000000
427729e1f4SPeter Crosthwaite #define GIC_DIST_ADDR       0xf9010000
437729e1f4SPeter Crosthwaite #define GIC_CPU_ADDR        0xf9020000
4475b749afSLuc Michel #define GIC_VIFACE_ADDR     0xf9040000
4575b749afSLuc Michel #define GIC_VCPU_ADDR       0xf9060000
467729e1f4SPeter Crosthwaite 
476fdf3282SAlistair Francis #define SATA_INTR           133
486fdf3282SAlistair Francis #define SATA_ADDR           0xFD0C0000
496fdf3282SAlistair Francis #define SATA_NUM_PORTS      2
506fdf3282SAlistair Francis 
51babc1f30SFrancisco Iglesias #define QSPI_ADDR           0xff0f0000
52babc1f30SFrancisco Iglesias #define LQSPI_ADDR          0xc0000000
53babc1f30SFrancisco Iglesias #define QSPI_IRQ            15
54668351a5SXuzhou Cheng #define QSPI_DMA_ADDR       0xff0f0800
55c74ccb5dSFrancisco Iglesias #define NUM_QSPI_IRQ_LINES  2
56babc1f30SFrancisco Iglesias 
5763320bcaSEdgar E. Iglesias #define CRF_ADDR            0xfd1a0000
5863320bcaSEdgar E. Iglesias #define CRF_IRQ             120
5963320bcaSEdgar E. Iglesias 
60c28d4b86SEdgar E. Iglesias /* Serializer/Deserializer.  */
61c28d4b86SEdgar E. Iglesias #define SERDES_ADDR         0xfd400000
62c28d4b86SEdgar E. Iglesias #define SERDES_SIZE         0x20000
63c28d4b86SEdgar E. Iglesias 
64b93dbcddSKONRAD Frederic #define DP_ADDR             0xfd4a0000
65b3f5cc3fSFrederic Konrad #define DP_IRQ              0x77
66b93dbcddSKONRAD Frederic 
67b93dbcddSKONRAD Frederic #define DPDMA_ADDR          0xfd4c0000
68b3f5cc3fSFrederic Konrad #define DPDMA_IRQ           0x7a
69b93dbcddSKONRAD Frederic 
70d2e6f370STong Ho #define APU_ADDR            0xfd5c0000
71eb7a38baSEdgar E. Iglesias #define APU_IRQ             153
72d2e6f370STong Ho 
7351af6231SEdgar E. Iglesias #define TTC0_ADDR           0xFF110000
7451af6231SEdgar E. Iglesias #define TTC0_IRQ            36
7551af6231SEdgar E. Iglesias 
760ab7bbc7SAlistair Francis #define IPI_ADDR            0xFF300000
770ab7bbc7SAlistair Francis #define IPI_IRQ             64
780ab7bbc7SAlistair Francis 
7908b2f15eSAlistair Francis #define RTC_ADDR            0xffa60000
8008b2f15eSAlistair Francis #define RTC_IRQ             26
8108b2f15eSAlistair Francis 
827e47e15cSTong Ho #define BBRAM_ADDR          0xffcd0000
837e47e15cSTong Ho #define BBRAM_IRQ           11
847e47e15cSTong Ho 
85db1264dfSTong Ho #define EFUSE_ADDR          0xffcc0000
86db1264dfSTong Ho #define EFUSE_IRQ           87
87db1264dfSTong Ho 
88b630d3d4SPhilippe Mathieu-Daudé #define SDHCI_CAPABILITIES  0x280737ec6481 /* Datasheet: UG1085 (v1.7) */
89b630d3d4SPhilippe Mathieu-Daudé 
9014ca2e46SPeter Crosthwaite static const uint64_t gem_addr[XLNX_ZYNQMP_NUM_GEMS] = {
9114ca2e46SPeter Crosthwaite     0xFF0B0000, 0xFF0C0000, 0xFF0D0000, 0xFF0E0000,
9214ca2e46SPeter Crosthwaite };
9314ca2e46SPeter Crosthwaite 
9414ca2e46SPeter Crosthwaite static const int gem_intr[XLNX_ZYNQMP_NUM_GEMS] = {
9514ca2e46SPeter Crosthwaite     57, 59, 61, 63,
9614ca2e46SPeter Crosthwaite };
9714ca2e46SPeter Crosthwaite 
983bade2a9SPeter Crosthwaite static const uint64_t uart_addr[XLNX_ZYNQMP_NUM_UARTS] = {
993bade2a9SPeter Crosthwaite     0xFF000000, 0xFF010000,
1003bade2a9SPeter Crosthwaite };
1013bade2a9SPeter Crosthwaite 
1023bade2a9SPeter Crosthwaite static const int uart_intr[XLNX_ZYNQMP_NUM_UARTS] = {
1033bade2a9SPeter Crosthwaite     21, 22,
1043bade2a9SPeter Crosthwaite };
1053bade2a9SPeter Crosthwaite 
106840c22cdSVikram Garhwal static const uint64_t can_addr[XLNX_ZYNQMP_NUM_CAN] = {
107840c22cdSVikram Garhwal     0xFF060000, 0xFF070000,
108840c22cdSVikram Garhwal };
109840c22cdSVikram Garhwal 
110840c22cdSVikram Garhwal static const int can_intr[XLNX_ZYNQMP_NUM_CAN] = {
111840c22cdSVikram Garhwal     23, 24,
112840c22cdSVikram Garhwal };
113840c22cdSVikram Garhwal 
11433108e9fSSai Pavan Boddu static const uint64_t sdhci_addr[XLNX_ZYNQMP_NUM_SDHCI] = {
11533108e9fSSai Pavan Boddu     0xFF160000, 0xFF170000,
11633108e9fSSai Pavan Boddu };
11733108e9fSSai Pavan Boddu 
11833108e9fSSai Pavan Boddu static const int sdhci_intr[XLNX_ZYNQMP_NUM_SDHCI] = {
11933108e9fSSai Pavan Boddu     48, 49,
12033108e9fSSai Pavan Boddu };
12133108e9fSSai Pavan Boddu 
12202d07eb4SAlistair Francis static const uint64_t spi_addr[XLNX_ZYNQMP_NUM_SPIS] = {
12302d07eb4SAlistair Francis     0xFF040000, 0xFF050000,
12402d07eb4SAlistair Francis };
12502d07eb4SAlistair Francis 
12602d07eb4SAlistair Francis static const int spi_intr[XLNX_ZYNQMP_NUM_SPIS] = {
12702d07eb4SAlistair Francis     19, 20,
12802d07eb4SAlistair Francis };
12902d07eb4SAlistair Francis 
13004965bcaSFrancisco Iglesias static const uint64_t gdma_ch_addr[XLNX_ZYNQMP_NUM_GDMA_CH] = {
13104965bcaSFrancisco Iglesias     0xFD500000, 0xFD510000, 0xFD520000, 0xFD530000,
13204965bcaSFrancisco Iglesias     0xFD540000, 0xFD550000, 0xFD560000, 0xFD570000
13304965bcaSFrancisco Iglesias };
13404965bcaSFrancisco Iglesias 
13504965bcaSFrancisco Iglesias static const int gdma_ch_intr[XLNX_ZYNQMP_NUM_GDMA_CH] = {
13604965bcaSFrancisco Iglesias     124, 125, 126, 127, 128, 129, 130, 131
13704965bcaSFrancisco Iglesias };
13804965bcaSFrancisco Iglesias 
13904965bcaSFrancisco Iglesias static const uint64_t adma_ch_addr[XLNX_ZYNQMP_NUM_ADMA_CH] = {
14004965bcaSFrancisco Iglesias     0xFFA80000, 0xFFA90000, 0xFFAA0000, 0xFFAB0000,
14104965bcaSFrancisco Iglesias     0xFFAC0000, 0xFFAD0000, 0xFFAE0000, 0xFFAF0000
14204965bcaSFrancisco Iglesias };
14304965bcaSFrancisco Iglesias 
14404965bcaSFrancisco Iglesias static const int adma_ch_intr[XLNX_ZYNQMP_NUM_ADMA_CH] = {
14504965bcaSFrancisco Iglesias     77, 78, 79, 80, 81, 82, 83, 84
14604965bcaSFrancisco Iglesias };
14704965bcaSFrancisco Iglesias 
148acc0b8b0SFrancisco Iglesias static const uint64_t usb_addr[XLNX_ZYNQMP_NUM_USB] = {
149acc0b8b0SFrancisco Iglesias     0xFE200000, 0xFE300000
150acc0b8b0SFrancisco Iglesias };
151acc0b8b0SFrancisco Iglesias 
152acc0b8b0SFrancisco Iglesias static const int usb_intr[XLNX_ZYNQMP_NUM_USB] = {
153acc0b8b0SFrancisco Iglesias     65, 70
154acc0b8b0SFrancisco Iglesias };
155acc0b8b0SFrancisco Iglesias 
1567729e1f4SPeter Crosthwaite typedef struct XlnxZynqMPGICRegion {
1577729e1f4SPeter Crosthwaite     int region_index;
1587729e1f4SPeter Crosthwaite     uint32_t address;
15975b749afSLuc Michel     uint32_t offset;
16075b749afSLuc Michel     bool virt;
1617729e1f4SPeter Crosthwaite } XlnxZynqMPGICRegion;
1627729e1f4SPeter Crosthwaite 
1637729e1f4SPeter Crosthwaite static const XlnxZynqMPGICRegion xlnx_zynqmp_gic_regions[] = {
16475b749afSLuc Michel     /* Distributor */
16575b749afSLuc Michel     {
16675b749afSLuc Michel         .region_index = 0,
16775b749afSLuc Michel         .address = GIC_DIST_ADDR,
16875b749afSLuc Michel         .offset = 0,
16975b749afSLuc Michel         .virt = false
17075b749afSLuc Michel     },
17175b749afSLuc Michel 
17275b749afSLuc Michel     /* CPU interface */
17375b749afSLuc Michel     {
17475b749afSLuc Michel         .region_index = 1,
17575b749afSLuc Michel         .address = GIC_CPU_ADDR,
17675b749afSLuc Michel         .offset = 0,
17775b749afSLuc Michel         .virt = false
17875b749afSLuc Michel     },
17975b749afSLuc Michel     {
18075b749afSLuc Michel         .region_index = 1,
18175b749afSLuc Michel         .address = GIC_CPU_ADDR + 0x10000,
18275b749afSLuc Michel         .offset = 0x1000,
18375b749afSLuc Michel         .virt = false
18475b749afSLuc Michel     },
18575b749afSLuc Michel 
18675b749afSLuc Michel     /* Virtual interface */
18775b749afSLuc Michel     {
18875b749afSLuc Michel         .region_index = 2,
18975b749afSLuc Michel         .address = GIC_VIFACE_ADDR,
19075b749afSLuc Michel         .offset = 0,
19175b749afSLuc Michel         .virt = true
19275b749afSLuc Michel     },
19375b749afSLuc Michel 
19475b749afSLuc Michel     /* Virtual CPU interface */
19575b749afSLuc Michel     {
19675b749afSLuc Michel         .region_index = 3,
19775b749afSLuc Michel         .address = GIC_VCPU_ADDR,
19875b749afSLuc Michel         .offset = 0,
19975b749afSLuc Michel         .virt = true
20075b749afSLuc Michel     },
20175b749afSLuc Michel     {
20275b749afSLuc Michel         .region_index = 3,
20375b749afSLuc Michel         .address = GIC_VCPU_ADDR + 0x10000,
20475b749afSLuc Michel         .offset = 0x1000,
20575b749afSLuc Michel         .virt = true
20675b749afSLuc Michel     },
2077729e1f4SPeter Crosthwaite };
208f0a902f7SPeter Crosthwaite 
209bf4cb109SPeter Crosthwaite static inline int arm_gic_ppi_index(int cpu_nr, int ppi_index)
210bf4cb109SPeter Crosthwaite {
211bf4cb109SPeter Crosthwaite     return GIC_NUM_SPI_INTR + cpu_nr * GIC_INTERNAL + ppi_index;
212bf4cb109SPeter Crosthwaite }
213bf4cb109SPeter Crosthwaite 
214cc7d44c2SLike Xu static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,
215cc7d44c2SLike Xu                                    const char *boot_cpu, Error **errp)
2166ed92b14SEdgar E. Iglesias {
2176ed92b14SEdgar E. Iglesias     int i;
218c9ba1c9fSClément Chigot     int num_rpus = MIN((int)(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS),
219cc7d44c2SLike Xu                        XLNX_ZYNQMP_NUM_RPU_CPUS);
2206ed92b14SEdgar E. Iglesias 
221e5b51753SPeter Maydell     if (num_rpus <= 0) {
222e5b51753SPeter Maydell         /* Don't create rpu-cluster object if there's nothing to put in it */
223e5b51753SPeter Maydell         return;
224e5b51753SPeter Maydell     }
225e5b51753SPeter Maydell 
226816fd397SLuc Michel     object_initialize_child(OBJECT(s), "rpu-cluster", &s->rpu_cluster,
2279fc7fc4dSMarkus Armbruster                             TYPE_CPU_CLUSTER);
228816fd397SLuc Michel     qdev_prop_set_uint32(DEVICE(&s->rpu_cluster), "cluster-id", 1);
229816fd397SLuc Michel 
2306908ec44SAlistair Francis     for (i = 0; i < num_rpus; i++) {
2317a309cc9SMarkus Armbruster         const char *name;
2326ed92b14SEdgar E. Iglesias 
233d0313798SPhilippe Mathieu-Daudé         object_initialize_child(OBJECT(&s->rpu_cluster), "rpu-cpu[*]",
2349fc7fc4dSMarkus Armbruster                                 &s->rpu_cpu[i],
2359fc7fc4dSMarkus Armbruster                                 ARM_CPU_TYPE_NAME("cortex-r5f"));
2366ed92b14SEdgar E. Iglesias 
2376ed92b14SEdgar E. Iglesias         name = object_get_canonical_path_component(OBJECT(&s->rpu_cpu[i]));
2386ed92b14SEdgar E. Iglesias         if (strcmp(name, boot_cpu)) {
23950c785f2SPeter Maydell             /*
24050c785f2SPeter Maydell              * Secondary CPUs start in powered-down state.
24150c785f2SPeter Maydell              */
2425325cc34SMarkus Armbruster             object_property_set_bool(OBJECT(&s->rpu_cpu[i]),
2435325cc34SMarkus Armbruster                                      "start-powered-off", true, &error_abort);
2446ed92b14SEdgar E. Iglesias         } else {
2456ed92b14SEdgar E. Iglesias             s->boot_cpu_ptr = &s->rpu_cpu[i];
2466ed92b14SEdgar E. Iglesias         }
2476ed92b14SEdgar E. Iglesias 
2485325cc34SMarkus Armbruster         object_property_set_bool(OBJECT(&s->rpu_cpu[i]), "reset-hivecs", true,
2496ed92b14SEdgar E. Iglesias                                  &error_abort);
250668f62ecSMarkus Armbruster         if (!qdev_realize(DEVICE(&s->rpu_cpu[i]), NULL, errp)) {
2516ed92b14SEdgar E. Iglesias             return;
2526ed92b14SEdgar E. Iglesias         }
2536ed92b14SEdgar E. Iglesias     }
254fa434424SPeter Maydell 
255ce189ab2SMarkus Armbruster     qdev_realize(DEVICE(&s->rpu_cluster), NULL, &error_fatal);
2566ed92b14SEdgar E. Iglesias }
2576ed92b14SEdgar E. Iglesias 
2587e47e15cSTong Ho static void xlnx_zynqmp_create_bbram(XlnxZynqMPState *s, qemu_irq *gic)
2597e47e15cSTong Ho {
2607e47e15cSTong Ho     SysBusDevice *sbd;
2617e47e15cSTong Ho 
2627e47e15cSTong Ho     object_initialize_child_with_props(OBJECT(s), "bbram", &s->bbram,
2637e47e15cSTong Ho                                        sizeof(s->bbram), TYPE_XLNX_BBRAM,
2647e47e15cSTong Ho                                        &error_fatal,
2657e47e15cSTong Ho                                        "crc-zpads", "1",
2667e47e15cSTong Ho                                        NULL);
2677e47e15cSTong Ho     sbd = SYS_BUS_DEVICE(&s->bbram);
2687e47e15cSTong Ho 
2697e47e15cSTong Ho     sysbus_realize(sbd, &error_fatal);
2707e47e15cSTong Ho     sysbus_mmio_map(sbd, 0, BBRAM_ADDR);
2717e47e15cSTong Ho     sysbus_connect_irq(sbd, 0, gic[BBRAM_IRQ]);
2727e47e15cSTong Ho }
2737e47e15cSTong Ho 
274db1264dfSTong Ho static void xlnx_zynqmp_create_efuse(XlnxZynqMPState *s, qemu_irq *gic)
275db1264dfSTong Ho {
276db1264dfSTong Ho     Object *bits = OBJECT(&s->efuse);
277db1264dfSTong Ho     Object *ctrl = OBJECT(&s->efuse_ctrl);
278db1264dfSTong Ho     SysBusDevice *sbd;
279db1264dfSTong Ho 
280db1264dfSTong Ho     object_initialize_child(OBJECT(s), "efuse-ctrl", &s->efuse_ctrl,
281db1264dfSTong Ho                             TYPE_XLNX_ZYNQMP_EFUSE);
282db1264dfSTong Ho 
283db1264dfSTong Ho     object_initialize_child_with_props(ctrl, "xlnx-efuse@0", bits,
284db1264dfSTong Ho                                        sizeof(s->efuse),
285db1264dfSTong Ho                                        TYPE_XLNX_EFUSE, &error_abort,
286db1264dfSTong Ho                                        "efuse-nr", "3",
287db1264dfSTong Ho                                        "efuse-size", "2048",
288db1264dfSTong Ho                                        NULL);
289db1264dfSTong Ho 
290db1264dfSTong Ho     qdev_realize(DEVICE(bits), NULL, &error_abort);
291db1264dfSTong Ho     object_property_set_link(ctrl, "efuse", bits, &error_abort);
292db1264dfSTong Ho 
293db1264dfSTong Ho     sbd = SYS_BUS_DEVICE(ctrl);
294db1264dfSTong Ho     sysbus_realize(sbd, &error_abort);
295db1264dfSTong Ho     sysbus_mmio_map(sbd, 0, EFUSE_ADDR);
296db1264dfSTong Ho     sysbus_connect_irq(sbd, 0, gic[EFUSE_IRQ]);
297db1264dfSTong Ho }
298db1264dfSTong Ho 
299eb7a38baSEdgar E. Iglesias static void xlnx_zynqmp_create_apu_ctrl(XlnxZynqMPState *s, qemu_irq *gic)
300eb7a38baSEdgar E. Iglesias {
301eb7a38baSEdgar E. Iglesias     SysBusDevice *sbd;
302eb7a38baSEdgar E. Iglesias     int i;
303eb7a38baSEdgar E. Iglesias 
304eb7a38baSEdgar E. Iglesias     object_initialize_child(OBJECT(s), "apu-ctrl", &s->apu_ctrl,
305eb7a38baSEdgar E. Iglesias                             TYPE_XLNX_ZYNQMP_APU_CTRL);
306eb7a38baSEdgar E. Iglesias     sbd = SYS_BUS_DEVICE(&s->apu_ctrl);
307eb7a38baSEdgar E. Iglesias 
308eb7a38baSEdgar E. Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_APU_CPUS; i++) {
309eb7a38baSEdgar E. Iglesias         g_autofree gchar *name = g_strdup_printf("cpu%d", i);
310eb7a38baSEdgar E. Iglesias 
311eb7a38baSEdgar E. Iglesias         object_property_set_link(OBJECT(&s->apu_ctrl), name,
312eb7a38baSEdgar E. Iglesias                                  OBJECT(&s->apu_cpu[i]), &error_abort);
313eb7a38baSEdgar E. Iglesias     }
314eb7a38baSEdgar E. Iglesias 
315eb7a38baSEdgar E. Iglesias     sysbus_realize(sbd, &error_fatal);
316eb7a38baSEdgar E. Iglesias     sysbus_mmio_map(sbd, 0, APU_ADDR);
317eb7a38baSEdgar E. Iglesias     sysbus_connect_irq(sbd, 0, gic[APU_IRQ]);
318eb7a38baSEdgar E. Iglesias }
319eb7a38baSEdgar E. Iglesias 
32063320bcaSEdgar E. Iglesias static void xlnx_zynqmp_create_crf(XlnxZynqMPState *s, qemu_irq *gic)
32163320bcaSEdgar E. Iglesias {
32263320bcaSEdgar E. Iglesias     SysBusDevice *sbd;
32363320bcaSEdgar E. Iglesias 
32463320bcaSEdgar E. Iglesias     object_initialize_child(OBJECT(s), "crf", &s->crf, TYPE_XLNX_ZYNQMP_CRF);
32563320bcaSEdgar E. Iglesias     sbd = SYS_BUS_DEVICE(&s->crf);
32663320bcaSEdgar E. Iglesias 
32763320bcaSEdgar E. Iglesias     sysbus_realize(sbd, &error_fatal);
32863320bcaSEdgar E. Iglesias     sysbus_mmio_map(sbd, 0, CRF_ADDR);
32963320bcaSEdgar E. Iglesias     sysbus_connect_irq(sbd, 0, gic[CRF_IRQ]);
33063320bcaSEdgar E. Iglesias }
33163320bcaSEdgar E. Iglesias 
33251af6231SEdgar E. Iglesias static void xlnx_zynqmp_create_ttc(XlnxZynqMPState *s, qemu_irq *gic)
33351af6231SEdgar E. Iglesias {
33451af6231SEdgar E. Iglesias     SysBusDevice *sbd;
33551af6231SEdgar E. Iglesias     int i, irq;
33651af6231SEdgar E. Iglesias 
33751af6231SEdgar E. Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_TTC; i++) {
33851af6231SEdgar E. Iglesias         object_initialize_child(OBJECT(s), "ttc[*]", &s->ttc[i],
33951af6231SEdgar E. Iglesias                                 TYPE_CADENCE_TTC);
34051af6231SEdgar E. Iglesias         sbd = SYS_BUS_DEVICE(&s->ttc[i]);
34151af6231SEdgar E. Iglesias 
34251af6231SEdgar E. Iglesias         sysbus_realize(sbd, &error_fatal);
34351af6231SEdgar E. Iglesias         sysbus_mmio_map(sbd, 0, TTC0_ADDR + i * 0x10000);
34451af6231SEdgar E. Iglesias         for (irq = 0; irq < 3; irq++) {
34551af6231SEdgar E. Iglesias             sysbus_connect_irq(sbd, irq, gic[TTC0_IRQ + i * 3 + irq]);
34651af6231SEdgar E. Iglesias         }
34751af6231SEdgar E. Iglesias     }
34851af6231SEdgar E. Iglesias }
34951af6231SEdgar E. Iglesias 
350d2e6f370STong Ho static void xlnx_zynqmp_create_unimp_mmio(XlnxZynqMPState *s)
351d2e6f370STong Ho {
352d2e6f370STong Ho     static const struct UnimpInfo {
353d2e6f370STong Ho         const char *name;
354d2e6f370STong Ho         hwaddr base;
355d2e6f370STong Ho         hwaddr size;
356d2e6f370STong Ho     } unimp_areas[ARRAY_SIZE(s->mr_unimp)] = {
357c28d4b86SEdgar E. Iglesias         { .name = "serdes", SERDES_ADDR, SERDES_SIZE },
358d2e6f370STong Ho     };
359d2e6f370STong Ho     unsigned int nr;
360d2e6f370STong Ho 
361d2e6f370STong Ho     for (nr = 0; nr < ARRAY_SIZE(unimp_areas); nr++) {
362d2e6f370STong Ho         const struct UnimpInfo *info = &unimp_areas[nr];
363d2e6f370STong Ho         DeviceState *dev = qdev_new(TYPE_UNIMPLEMENTED_DEVICE);
364d2e6f370STong Ho         SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
365d2e6f370STong Ho 
366d2e6f370STong Ho         assert(info->name && info->base && info->size > 0);
367d2e6f370STong Ho         qdev_prop_set_string(dev, "name", info->name);
368d2e6f370STong Ho         qdev_prop_set_uint64(dev, "size", info->size);
369d2e6f370STong Ho         object_property_add_child(OBJECT(s), info->name, OBJECT(dev));
370d2e6f370STong Ho 
371d2e6f370STong Ho         sysbus_realize_and_unref(sbd, &error_fatal);
372d2e6f370STong Ho         sysbus_mmio_map(sbd, 0, info->base);
373d2e6f370STong Ho     }
374d2e6f370STong Ho }
375d2e6f370STong Ho 
376f0a902f7SPeter Crosthwaite static void xlnx_zynqmp_init(Object *obj)
377f0a902f7SPeter Crosthwaite {
378cc7d44c2SLike Xu     MachineState *ms = MACHINE(qdev_get_machine());
379f0a902f7SPeter Crosthwaite     XlnxZynqMPState *s = XLNX_ZYNQMP(obj);
380f0a902f7SPeter Crosthwaite     int i;
381cc7d44c2SLike Xu     int num_apus = MIN(ms->smp.cpus, XLNX_ZYNQMP_NUM_APU_CPUS);
382f0a902f7SPeter Crosthwaite 
383816fd397SLuc Michel     object_initialize_child(obj, "apu-cluster", &s->apu_cluster,
3849fc7fc4dSMarkus Armbruster                             TYPE_CPU_CLUSTER);
385816fd397SLuc Michel     qdev_prop_set_uint32(DEVICE(&s->apu_cluster), "cluster-id", 0);
386816fd397SLuc Michel 
3876908ec44SAlistair Francis     for (i = 0; i < num_apus; i++) {
388816fd397SLuc Michel         object_initialize_child(OBJECT(&s->apu_cluster), "apu-cpu[*]",
3899fc7fc4dSMarkus Armbruster                                 &s->apu_cpu[i],
3909fc7fc4dSMarkus Armbruster                                 ARM_CPU_TYPE_NAME("cortex-a53"));
391f0a902f7SPeter Crosthwaite     }
3927729e1f4SPeter Crosthwaite 
393db873cc5SMarkus Armbruster     object_initialize_child(obj, "gic", &s->gic, gic_class_name());
39414ca2e46SPeter Crosthwaite 
39514ca2e46SPeter Crosthwaite     for (i = 0; i < XLNX_ZYNQMP_NUM_GEMS; i++) {
396db873cc5SMarkus Armbruster         object_initialize_child(obj, "gem[*]", &s->gem[i], TYPE_CADENCE_GEM);
39714ca2e46SPeter Crosthwaite     }
3983bade2a9SPeter Crosthwaite 
3993bade2a9SPeter Crosthwaite     for (i = 0; i < XLNX_ZYNQMP_NUM_UARTS; i++) {
400db873cc5SMarkus Armbruster         object_initialize_child(obj, "uart[*]", &s->uart[i],
401ccf02d73SThomas Huth                                 TYPE_CADENCE_UART);
4023bade2a9SPeter Crosthwaite     }
4036fdf3282SAlistair Francis 
404840c22cdSVikram Garhwal     for (i = 0; i < XLNX_ZYNQMP_NUM_CAN; i++) {
405840c22cdSVikram Garhwal         object_initialize_child(obj, "can[*]", &s->can[i],
406840c22cdSVikram Garhwal                                 TYPE_XLNX_ZYNQMP_CAN);
407840c22cdSVikram Garhwal     }
408840c22cdSVikram Garhwal 
409db873cc5SMarkus Armbruster     object_initialize_child(obj, "sata", &s->sata, TYPE_SYSBUS_AHCI);
41033108e9fSSai Pavan Boddu 
41133108e9fSSai Pavan Boddu     for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) {
4125a147c8cSMarkus Armbruster         object_initialize_child(obj, "sdhci[*]", &s->sdhci[i],
4135a147c8cSMarkus Armbruster                                 TYPE_SYSBUS_SDHCI);
41433108e9fSSai Pavan Boddu     }
41502d07eb4SAlistair Francis 
41602d07eb4SAlistair Francis     for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
417db873cc5SMarkus Armbruster         object_initialize_child(obj, "spi[*]", &s->spi[i], TYPE_XILINX_SPIPS);
41802d07eb4SAlistair Francis     }
419b93dbcddSKONRAD Frederic 
420db873cc5SMarkus Armbruster     object_initialize_child(obj, "qspi", &s->qspi, TYPE_XLNX_ZYNQMP_QSPIPS);
421babc1f30SFrancisco Iglesias 
422db873cc5SMarkus Armbruster     object_initialize_child(obj, "xxxdp", &s->dp, TYPE_XLNX_DP);
423b93dbcddSKONRAD Frederic 
424db873cc5SMarkus Armbruster     object_initialize_child(obj, "dp-dma", &s->dpdma, TYPE_XLNX_DPDMA);
4250ab7bbc7SAlistair Francis 
426db873cc5SMarkus Armbruster     object_initialize_child(obj, "ipi", &s->ipi, TYPE_XLNX_ZYNQMP_IPI);
42708b2f15eSAlistair Francis 
428db873cc5SMarkus Armbruster     object_initialize_child(obj, "rtc", &s->rtc, TYPE_XLNX_ZYNQMP_RTC);
42904965bcaSFrancisco Iglesias 
43004965bcaSFrancisco Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) {
431db873cc5SMarkus Armbruster         object_initialize_child(obj, "gdma[*]", &s->gdma[i], TYPE_XLNX_ZDMA);
43204965bcaSFrancisco Iglesias     }
43304965bcaSFrancisco Iglesias 
43404965bcaSFrancisco Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_ADMA_CH; i++) {
435db873cc5SMarkus Armbruster         object_initialize_child(obj, "adma[*]", &s->adma[i], TYPE_XLNX_ZDMA);
43604965bcaSFrancisco Iglesias     }
437668351a5SXuzhou Cheng 
438668351a5SXuzhou Cheng     object_initialize_child(obj, "qspi-dma", &s->qspi_dma, TYPE_XLNX_CSU_DMA);
439c74ccb5dSFrancisco Iglesias     object_initialize_child(obj, "qspi-irq-orgate",
440c74ccb5dSFrancisco Iglesias                             &s->qspi_irq_orgate, TYPE_OR_IRQ);
441acc0b8b0SFrancisco Iglesias 
442acc0b8b0SFrancisco Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_USB; i++) {
443acc0b8b0SFrancisco Iglesias         object_initialize_child(obj, "usb[*]", &s->usb[i], TYPE_USB_DWC3);
444acc0b8b0SFrancisco Iglesias     }
445f0a902f7SPeter Crosthwaite }
446f0a902f7SPeter Crosthwaite 
447f0a902f7SPeter Crosthwaite static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
448f0a902f7SPeter Crosthwaite {
449cc7d44c2SLike Xu     MachineState *ms = MACHINE(qdev_get_machine());
450f0a902f7SPeter Crosthwaite     XlnxZynqMPState *s = XLNX_ZYNQMP(dev);
4517729e1f4SPeter Crosthwaite     MemoryRegion *system_memory = get_system_memory();
452f0a902f7SPeter Crosthwaite     uint8_t i;
453dc3b89efSAlistair Francis     uint64_t ram_size;
454cc7d44c2SLike Xu     int num_apus = MIN(ms->smp.cpus, XLNX_ZYNQMP_NUM_APU_CPUS);
4556396a193SPeter Crosthwaite     const char *boot_cpu = s->boot_cpu ? s->boot_cpu : "apu-cpu[0]";
456dc3b89efSAlistair Francis     ram_addr_t ddr_low_size, ddr_high_size;
45714ca2e46SPeter Crosthwaite     qemu_irq gic_spi[GIC_NUM_SPI_INTR];
458f0a902f7SPeter Crosthwaite     Error *err = NULL;
459f0a902f7SPeter Crosthwaite 
460dc3b89efSAlistair Francis     ram_size = memory_region_size(s->ddr_ram);
461dc3b89efSAlistair Francis 
46221bce371SXuzhou Cheng     /*
46321bce371SXuzhou Cheng      * Create the DDR Memory Regions. User friendly checks should happen at
464dc3b89efSAlistair Francis      * the board level
465dc3b89efSAlistair Francis      */
466dc3b89efSAlistair Francis     if (ram_size > XLNX_ZYNQMP_MAX_LOW_RAM_SIZE) {
46721bce371SXuzhou Cheng         /*
46821bce371SXuzhou Cheng          * The RAM size is above the maximum available for the low DDR.
469dc3b89efSAlistair Francis          * Create the high DDR memory region as well.
470dc3b89efSAlistair Francis          */
471dc3b89efSAlistair Francis         assert(ram_size <= XLNX_ZYNQMP_MAX_RAM_SIZE);
472dc3b89efSAlistair Francis         ddr_low_size = XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
473dc3b89efSAlistair Francis         ddr_high_size = ram_size - XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
474dc3b89efSAlistair Francis 
47532b9523aSPhilippe Mathieu-Daudé         memory_region_init_alias(&s->ddr_ram_high, OBJECT(dev),
47632b9523aSPhilippe Mathieu-Daudé                                  "ddr-ram-high", s->ddr_ram, ddr_low_size,
47732b9523aSPhilippe Mathieu-Daudé                                  ddr_high_size);
478dc3b89efSAlistair Francis         memory_region_add_subregion(get_system_memory(),
479dc3b89efSAlistair Francis                                     XLNX_ZYNQMP_HIGH_RAM_START,
480dc3b89efSAlistair Francis                                     &s->ddr_ram_high);
481dc3b89efSAlistair Francis     } else {
482dc3b89efSAlistair Francis         /* RAM must be non-zero */
483dc3b89efSAlistair Francis         assert(ram_size);
484dc3b89efSAlistair Francis         ddr_low_size = ram_size;
485dc3b89efSAlistair Francis     }
486dc3b89efSAlistair Francis 
48732b9523aSPhilippe Mathieu-Daudé     memory_region_init_alias(&s->ddr_ram_low, OBJECT(dev), "ddr-ram-low",
48832b9523aSPhilippe Mathieu-Daudé                              s->ddr_ram, 0, ddr_low_size);
489dc3b89efSAlistair Francis     memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram_low);
490dc3b89efSAlistair Francis 
4916675d719SAlistair Francis     /* Create the four OCM banks */
4926675d719SAlistair Francis     for (i = 0; i < XLNX_ZYNQMP_NUM_OCM_BANKS; i++) {
4936675d719SAlistair Francis         char *ocm_name = g_strdup_printf("zynqmp.ocm_ram_bank_%d", i);
4946675d719SAlistair Francis 
49598a99ce0SPeter Maydell         memory_region_init_ram(&s->ocm_ram[i], NULL, ocm_name,
496f8ed85acSMarkus Armbruster                                XLNX_ZYNQMP_OCM_RAM_SIZE, &error_fatal);
4976675d719SAlistair Francis         memory_region_add_subregion(get_system_memory(),
4986675d719SAlistair Francis                                     XLNX_ZYNQMP_OCM_RAM_0_ADDRESS +
4996675d719SAlistair Francis                                         i * XLNX_ZYNQMP_OCM_RAM_SIZE,
5006675d719SAlistair Francis                                     &s->ocm_ram[i]);
5016675d719SAlistair Francis 
5026675d719SAlistair Francis         g_free(ocm_name);
5036675d719SAlistair Francis     }
5046675d719SAlistair Francis 
5057729e1f4SPeter Crosthwaite     qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", GIC_NUM_SPI_INTR + 32);
5067729e1f4SPeter Crosthwaite     qdev_prop_set_uint32(DEVICE(&s->gic), "revision", 2);
5076908ec44SAlistair Francis     qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", num_apus);
50875b749afSLuc Michel     qdev_prop_set_bit(DEVICE(&s->gic), "has-security-extensions", s->secure);
50975b749afSLuc Michel     qdev_prop_set_bit(DEVICE(&s->gic),
51075b749afSLuc Michel                       "has-virtualization-extensions", s->virt);
5117729e1f4SPeter Crosthwaite 
512ce189ab2SMarkus Armbruster     qdev_realize(DEVICE(&s->apu_cluster), NULL, &error_fatal);
513816fd397SLuc Michel 
5140776d967SEdgar E. Iglesias     /* Realize APUs before realizing the GIC. KVM requires this.  */
5156908ec44SAlistair Francis     for (i = 0; i < num_apus; i++) {
5167a309cc9SMarkus Armbruster         const char *name;
517bf4cb109SPeter Crosthwaite 
5186396a193SPeter Crosthwaite         name = object_get_canonical_path_component(OBJECT(&s->apu_cpu[i]));
5196396a193SPeter Crosthwaite         if (strcmp(name, boot_cpu)) {
52050c785f2SPeter Maydell             /*
52150c785f2SPeter Maydell              * Secondary CPUs start in powered-down state.
52250c785f2SPeter Maydell              */
5235325cc34SMarkus Armbruster             object_property_set_bool(OBJECT(&s->apu_cpu[i]),
5245325cc34SMarkus Armbruster                                      "start-powered-off", true, &error_abort);
5256396a193SPeter Crosthwaite         } else {
5266396a193SPeter Crosthwaite             s->boot_cpu_ptr = &s->apu_cpu[i];
527f0a902f7SPeter Crosthwaite         }
528f0a902f7SPeter Crosthwaite 
5295325cc34SMarkus Armbruster         object_property_set_bool(OBJECT(&s->apu_cpu[i]), "has_el3", s->secure,
5305325cc34SMarkus Armbruster                                  NULL);
5315325cc34SMarkus Armbruster         object_property_set_bool(OBJECT(&s->apu_cpu[i]), "has_el2", s->virt,
5325325cc34SMarkus Armbruster                                  NULL);
5335325cc34SMarkus Armbruster         object_property_set_int(OBJECT(&s->apu_cpu[i]), "reset-cbar",
5345325cc34SMarkus Armbruster                                 GIC_BASE_ADDR, &error_abort);
5355325cc34SMarkus Armbruster         object_property_set_int(OBJECT(&s->apu_cpu[i]), "core-count",
5365325cc34SMarkus Armbruster                                 num_apus, &error_abort);
537668f62ecSMarkus Armbruster         if (!qdev_realize(DEVICE(&s->apu_cpu[i]), NULL, errp)) {
538f0a902f7SPeter Crosthwaite             return;
539f0a902f7SPeter Crosthwaite         }
5400776d967SEdgar E. Iglesias     }
5410776d967SEdgar E. Iglesias 
542668f62ecSMarkus Armbruster     if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) {
5430776d967SEdgar E. Iglesias         return;
5440776d967SEdgar E. Iglesias     }
5450776d967SEdgar E. Iglesias 
5460776d967SEdgar E. Iglesias     assert(ARRAY_SIZE(xlnx_zynqmp_gic_regions) == XLNX_ZYNQMP_GIC_REGIONS);
5470776d967SEdgar E. Iglesias     for (i = 0; i < XLNX_ZYNQMP_GIC_REGIONS; i++) {
5480776d967SEdgar E. Iglesias         SysBusDevice *gic = SYS_BUS_DEVICE(&s->gic);
5490776d967SEdgar E. Iglesias         const XlnxZynqMPGICRegion *r = &xlnx_zynqmp_gic_regions[i];
55075b749afSLuc Michel         MemoryRegion *mr;
5510776d967SEdgar E. Iglesias         uint32_t addr = r->address;
5520776d967SEdgar E. Iglesias         int j;
5530776d967SEdgar E. Iglesias 
55475b749afSLuc Michel         if (r->virt && !s->virt) {
55575b749afSLuc Michel             continue;
55675b749afSLuc Michel         }
5570776d967SEdgar E. Iglesias 
55875b749afSLuc Michel         mr = sysbus_mmio_get_region(gic, r->region_index);
5590776d967SEdgar E. Iglesias         for (j = 0; j < XLNX_ZYNQMP_GIC_ALIASES; j++) {
5600776d967SEdgar E. Iglesias             MemoryRegion *alias = &s->gic_mr[i][j];
5610776d967SEdgar E. Iglesias 
5620776d967SEdgar E. Iglesias             memory_region_init_alias(alias, OBJECT(s), "zynqmp-gic-alias", mr,
56375b749afSLuc Michel                                      r->offset, XLNX_ZYNQMP_GIC_REGION_SIZE);
5640776d967SEdgar E. Iglesias             memory_region_add_subregion(system_memory, addr, alias);
56575b749afSLuc Michel 
56675b749afSLuc Michel             addr += XLNX_ZYNQMP_GIC_REGION_SIZE;
5670776d967SEdgar E. Iglesias         }
5680776d967SEdgar E. Iglesias     }
5690776d967SEdgar E. Iglesias 
5706908ec44SAlistair Francis     for (i = 0; i < num_apus; i++) {
5710776d967SEdgar E. Iglesias         qemu_irq irq;
5727729e1f4SPeter Crosthwaite 
5737729e1f4SPeter Crosthwaite         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i,
5742e5577bcSPeter Crosthwaite                            qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
5752e5577bcSPeter Crosthwaite                                             ARM_CPU_IRQ));
57675b749afSLuc Michel         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i + num_apus,
57775b749afSLuc Michel                            qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
57875b749afSLuc Michel                                             ARM_CPU_FIQ));
57975b749afSLuc Michel         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i + num_apus * 2,
58075b749afSLuc Michel                            qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
58175b749afSLuc Michel                                             ARM_CPU_VIRQ));
58275b749afSLuc Michel         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i + num_apus * 3,
58375b749afSLuc Michel                            qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
58475b749afSLuc Michel                                             ARM_CPU_VFIQ));
585bf4cb109SPeter Crosthwaite         irq = qdev_get_gpio_in(DEVICE(&s->gic),
586bf4cb109SPeter Crosthwaite                                arm_gic_ppi_index(i, ARM_PHYS_TIMER_PPI));
58775b749afSLuc Michel         qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), GTIMER_PHYS, irq);
588bf4cb109SPeter Crosthwaite         irq = qdev_get_gpio_in(DEVICE(&s->gic),
589bf4cb109SPeter Crosthwaite                                arm_gic_ppi_index(i, ARM_VIRT_TIMER_PPI));
59075b749afSLuc Michel         qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), GTIMER_VIRT, irq);
59175b749afSLuc Michel         irq = qdev_get_gpio_in(DEVICE(&s->gic),
59275b749afSLuc Michel                                arm_gic_ppi_index(i, ARM_HYP_TIMER_PPI));
59375b749afSLuc Michel         qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), GTIMER_HYP, irq);
59475b749afSLuc Michel         irq = qdev_get_gpio_in(DEVICE(&s->gic),
59575b749afSLuc Michel                                arm_gic_ppi_index(i, ARM_SEC_TIMER_PPI));
59675b749afSLuc Michel         qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), GTIMER_SEC, irq);
59775b749afSLuc Michel 
59875b749afSLuc Michel         if (s->virt) {
59975b749afSLuc Michel             irq = qdev_get_gpio_in(DEVICE(&s->gic),
60075b749afSLuc Michel                                    arm_gic_ppi_index(i, GIC_MAINTENANCE_PPI));
60175b749afSLuc Michel             sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i + num_apus * 4, irq);
60275b749afSLuc Michel         }
603f0a902f7SPeter Crosthwaite     }
60414ca2e46SPeter Crosthwaite 
605cc7d44c2SLike Xu     xlnx_zynqmp_create_rpu(ms, s, boot_cpu, &err);
606b58850e7SPeter Crosthwaite     if (err) {
60724cfc8dcSAlistair Francis         error_propagate(errp, err);
608b58850e7SPeter Crosthwaite         return;
609b58850e7SPeter Crosthwaite     }
610b58850e7SPeter Crosthwaite 
6116396a193SPeter Crosthwaite     if (!s->boot_cpu_ptr) {
6129af9e0feSMarkus Armbruster         error_setg(errp, "ZynqMP Boot cpu %s not found", boot_cpu);
6136396a193SPeter Crosthwaite         return;
6146396a193SPeter Crosthwaite     }
6156396a193SPeter Crosthwaite 
61614ca2e46SPeter Crosthwaite     for (i = 0; i < GIC_NUM_SPI_INTR; i++) {
61714ca2e46SPeter Crosthwaite         gic_spi[i] = qdev_get_gpio_in(DEVICE(&s->gic), i);
61814ca2e46SPeter Crosthwaite     }
61914ca2e46SPeter Crosthwaite 
62014ca2e46SPeter Crosthwaite     for (i = 0; i < XLNX_ZYNQMP_NUM_GEMS; i++) {
621*e8c003c4SDavid Woodhouse         qemu_configure_nic_device(DEVICE(&s->gem[i]), true, NULL);
6225325cc34SMarkus Armbruster         object_property_set_int(OBJECT(&s->gem[i]), "revision", GEM_REVISION,
62320bff213SAlistair Francis                                 &error_abort);
624dfc38879SBin Meng         object_property_set_int(OBJECT(&s->gem[i]), "phy-addr", 23,
625dfc38879SBin Meng                                 &error_abort);
6265325cc34SMarkus Armbruster         object_property_set_int(OBJECT(&s->gem[i]), "num-priority-queues", 2,
6271372fc0bSAlistair Francis                                 &error_abort);
628668f62ecSMarkus Armbruster         if (!sysbus_realize(SYS_BUS_DEVICE(&s->gem[i]), errp)) {
62914ca2e46SPeter Crosthwaite             return;
63014ca2e46SPeter Crosthwaite         }
63114ca2e46SPeter Crosthwaite         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem[i]), 0, gem_addr[i]);
63214ca2e46SPeter Crosthwaite         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem[i]), 0,
63314ca2e46SPeter Crosthwaite                            gic_spi[gem_intr[i]]);
63414ca2e46SPeter Crosthwaite     }
6353bade2a9SPeter Crosthwaite 
6363bade2a9SPeter Crosthwaite     for (i = 0; i < XLNX_ZYNQMP_NUM_UARTS; i++) {
6379bca0edbSPeter Maydell         qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
638668f62ecSMarkus Armbruster         if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), errp)) {
6393bade2a9SPeter Crosthwaite             return;
6403bade2a9SPeter Crosthwaite         }
6413bade2a9SPeter Crosthwaite         sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, uart_addr[i]);
6423bade2a9SPeter Crosthwaite         sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
6433bade2a9SPeter Crosthwaite                            gic_spi[uart_intr[i]]);
6443bade2a9SPeter Crosthwaite     }
6456fdf3282SAlistair Francis 
646840c22cdSVikram Garhwal     for (i = 0; i < XLNX_ZYNQMP_NUM_CAN; i++) {
647840c22cdSVikram Garhwal         object_property_set_int(OBJECT(&s->can[i]), "ext_clk_freq",
648840c22cdSVikram Garhwal                                 XLNX_ZYNQMP_CAN_REF_CLK, &error_abort);
649840c22cdSVikram Garhwal 
650840c22cdSVikram Garhwal         object_property_set_link(OBJECT(&s->can[i]), "canbus",
651840c22cdSVikram Garhwal                                  OBJECT(s->canbus[i]), &error_fatal);
652840c22cdSVikram Garhwal 
653840c22cdSVikram Garhwal         sysbus_realize(SYS_BUS_DEVICE(&s->can[i]), &err);
654840c22cdSVikram Garhwal         if (err) {
655840c22cdSVikram Garhwal             error_propagate(errp, err);
656840c22cdSVikram Garhwal             return;
657840c22cdSVikram Garhwal         }
658840c22cdSVikram Garhwal         sysbus_mmio_map(SYS_BUS_DEVICE(&s->can[i]), 0, can_addr[i]);
659840c22cdSVikram Garhwal         sysbus_connect_irq(SYS_BUS_DEVICE(&s->can[i]), 0,
660840c22cdSVikram Garhwal                            gic_spi[can_intr[i]]);
661840c22cdSVikram Garhwal     }
662840c22cdSVikram Garhwal 
6635325cc34SMarkus Armbruster     object_property_set_int(OBJECT(&s->sata), "num-ports", SATA_NUM_PORTS,
6646fdf3282SAlistair Francis                             &error_abort);
665668f62ecSMarkus Armbruster     if (!sysbus_realize(SYS_BUS_DEVICE(&s->sata), errp)) {
6666fdf3282SAlistair Francis         return;
6676fdf3282SAlistair Francis     }
6686fdf3282SAlistair Francis 
6696fdf3282SAlistair Francis     sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, SATA_ADDR);
6706fdf3282SAlistair Francis     sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, gic_spi[SATA_INTR]);
67133108e9fSSai Pavan Boddu 
67233108e9fSSai Pavan Boddu     for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) {
67363fef628SPeter Maydell         char *bus_name;
674b630d3d4SPhilippe Mathieu-Daudé         SysBusDevice *sbd = SYS_BUS_DEVICE(&s->sdhci[i]);
675b630d3d4SPhilippe Mathieu-Daudé         Object *sdhci = OBJECT(&s->sdhci[i]);
676eb4f566bSPeter Maydell 
67721bce371SXuzhou Cheng         /*
67821bce371SXuzhou Cheng          * Compatible with:
679b630d3d4SPhilippe Mathieu-Daudé          * - SD Host Controller Specification Version 3.00
680b630d3d4SPhilippe Mathieu-Daudé          * - SDIO Specification Version 3.0
681b630d3d4SPhilippe Mathieu-Daudé          * - eMMC Specification Version 4.51
682b630d3d4SPhilippe Mathieu-Daudé          */
683668f62ecSMarkus Armbruster         if (!object_property_set_uint(sdhci, "sd-spec-version", 3, errp)) {
684660b4e70SPeter Maydell             return;
685660b4e70SPeter Maydell         }
686778a2dc5SMarkus Armbruster         if (!object_property_set_uint(sdhci, "capareg", SDHCI_CAPABILITIES,
687668f62ecSMarkus Armbruster                                       errp)) {
688660b4e70SPeter Maydell             return;
689660b4e70SPeter Maydell         }
690668f62ecSMarkus Armbruster         if (!object_property_set_uint(sdhci, "uhs", UHS_I, errp)) {
691660b4e70SPeter Maydell             return;
692660b4e70SPeter Maydell         }
693668f62ecSMarkus Armbruster         if (!sysbus_realize(SYS_BUS_DEVICE(sdhci), errp)) {
69433108e9fSSai Pavan Boddu             return;
69533108e9fSSai Pavan Boddu         }
696b630d3d4SPhilippe Mathieu-Daudé         sysbus_mmio_map(sbd, 0, sdhci_addr[i]);
697b630d3d4SPhilippe Mathieu-Daudé         sysbus_connect_irq(sbd, 0, gic_spi[sdhci_intr[i]]);
698b630d3d4SPhilippe Mathieu-Daudé 
699eb4f566bSPeter Maydell         /* Alias controller SD bus to the SoC itself */
70063fef628SPeter Maydell         bus_name = g_strdup_printf("sd-bus%d", i);
701d2623129SMarkus Armbruster         object_property_add_alias(OBJECT(s), bus_name, sdhci, "sd-bus");
702eb4f566bSPeter Maydell         g_free(bus_name);
70333108e9fSSai Pavan Boddu     }
70402d07eb4SAlistair Francis 
70502d07eb4SAlistair Francis     for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
70602d07eb4SAlistair Francis         gchar *bus_name;
70702d07eb4SAlistair Francis 
708668f62ecSMarkus Armbruster         if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
709660b4e70SPeter Maydell             return;
710660b4e70SPeter Maydell         }
71102d07eb4SAlistair Francis 
71202d07eb4SAlistair Francis         sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]);
71302d07eb4SAlistair Francis         sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
71402d07eb4SAlistair Francis                            gic_spi[spi_intr[i]]);
71502d07eb4SAlistair Francis 
71602d07eb4SAlistair Francis         /* Alias controller SPI bus to the SoC itself */
71702d07eb4SAlistair Francis         bus_name = g_strdup_printf("spi%d", i);
71802d07eb4SAlistair Francis         object_property_add_alias(OBJECT(s), bus_name,
719d2623129SMarkus Armbruster                                   OBJECT(&s->spi[i]), "spi0");
72002d07eb4SAlistair Francis         g_free(bus_name);
72102d07eb4SAlistair Francis     }
722b93dbcddSKONRAD Frederic 
723668f62ecSMarkus Armbruster     if (!sysbus_realize(SYS_BUS_DEVICE(&s->dp), errp)) {
724b93dbcddSKONRAD Frederic         return;
725b93dbcddSKONRAD Frederic     }
726b93dbcddSKONRAD Frederic     sysbus_mmio_map(SYS_BUS_DEVICE(&s->dp), 0, DP_ADDR);
727b93dbcddSKONRAD Frederic     sysbus_connect_irq(SYS_BUS_DEVICE(&s->dp), 0, gic_spi[DP_IRQ]);
728b93dbcddSKONRAD Frederic 
729668f62ecSMarkus Armbruster     if (!sysbus_realize(SYS_BUS_DEVICE(&s->dpdma), errp)) {
730b93dbcddSKONRAD Frederic         return;
731b93dbcddSKONRAD Frederic     }
7325325cc34SMarkus Armbruster     object_property_set_link(OBJECT(&s->dp), "dpdma", OBJECT(&s->dpdma),
733b93dbcddSKONRAD Frederic                              &error_abort);
734b93dbcddSKONRAD Frederic     sysbus_mmio_map(SYS_BUS_DEVICE(&s->dpdma), 0, DPDMA_ADDR);
735b93dbcddSKONRAD Frederic     sysbus_connect_irq(SYS_BUS_DEVICE(&s->dpdma), 0, gic_spi[DPDMA_IRQ]);
7360ab7bbc7SAlistair Francis 
737668f62ecSMarkus Armbruster     if (!sysbus_realize(SYS_BUS_DEVICE(&s->ipi), errp)) {
7380ab7bbc7SAlistair Francis         return;
7390ab7bbc7SAlistair Francis     }
7400ab7bbc7SAlistair Francis     sysbus_mmio_map(SYS_BUS_DEVICE(&s->ipi), 0, IPI_ADDR);
7410ab7bbc7SAlistair Francis     sysbus_connect_irq(SYS_BUS_DEVICE(&s->ipi), 0, gic_spi[IPI_IRQ]);
74208b2f15eSAlistair Francis 
743668f62ecSMarkus Armbruster     if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) {
74408b2f15eSAlistair Francis         return;
74508b2f15eSAlistair Francis     }
74608b2f15eSAlistair Francis     sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, RTC_ADDR);
74708b2f15eSAlistair Francis     sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, gic_spi[RTC_IRQ]);
74804965bcaSFrancisco Iglesias 
7497e47e15cSTong Ho     xlnx_zynqmp_create_bbram(s, gic_spi);
750db1264dfSTong Ho     xlnx_zynqmp_create_efuse(s, gic_spi);
751eb7a38baSEdgar E. Iglesias     xlnx_zynqmp_create_apu_ctrl(s, gic_spi);
75263320bcaSEdgar E. Iglesias     xlnx_zynqmp_create_crf(s, gic_spi);
75351af6231SEdgar E. Iglesias     xlnx_zynqmp_create_ttc(s, gic_spi);
754d2e6f370STong Ho     xlnx_zynqmp_create_unimp_mmio(s);
755d2e6f370STong Ho 
75604965bcaSFrancisco Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) {
757778a2dc5SMarkus Armbruster         if (!object_property_set_uint(OBJECT(&s->gdma[i]), "bus-width", 128,
758668f62ecSMarkus Armbruster                                       errp)) {
759660b4e70SPeter Maydell             return;
760660b4e70SPeter Maydell         }
761783dbab1SPhilippe Mathieu-Daudé         if (!object_property_set_link(OBJECT(&s->gdma[i]), "dma",
762783dbab1SPhilippe Mathieu-Daudé                                       OBJECT(system_memory), errp)) {
763783dbab1SPhilippe Mathieu-Daudé             return;
764783dbab1SPhilippe Mathieu-Daudé         }
765668f62ecSMarkus Armbruster         if (!sysbus_realize(SYS_BUS_DEVICE(&s->gdma[i]), errp)) {
76604965bcaSFrancisco Iglesias             return;
76704965bcaSFrancisco Iglesias         }
76804965bcaSFrancisco Iglesias 
76904965bcaSFrancisco Iglesias         sysbus_mmio_map(SYS_BUS_DEVICE(&s->gdma[i]), 0, gdma_ch_addr[i]);
77004965bcaSFrancisco Iglesias         sysbus_connect_irq(SYS_BUS_DEVICE(&s->gdma[i]), 0,
77104965bcaSFrancisco Iglesias                            gic_spi[gdma_ch_intr[i]]);
77204965bcaSFrancisco Iglesias     }
77304965bcaSFrancisco Iglesias 
77404965bcaSFrancisco Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_ADMA_CH; i++) {
775783dbab1SPhilippe Mathieu-Daudé         if (!object_property_set_link(OBJECT(&s->adma[i]), "dma",
776783dbab1SPhilippe Mathieu-Daudé                                       OBJECT(system_memory), errp)) {
777783dbab1SPhilippe Mathieu-Daudé             return;
778783dbab1SPhilippe Mathieu-Daudé         }
779668f62ecSMarkus Armbruster         if (!sysbus_realize(SYS_BUS_DEVICE(&s->adma[i]), errp)) {
78004965bcaSFrancisco Iglesias             return;
78104965bcaSFrancisco Iglesias         }
78204965bcaSFrancisco Iglesias 
78304965bcaSFrancisco Iglesias         sysbus_mmio_map(SYS_BUS_DEVICE(&s->adma[i]), 0, adma_ch_addr[i]);
78404965bcaSFrancisco Iglesias         sysbus_connect_irq(SYS_BUS_DEVICE(&s->adma[i]), 0,
78504965bcaSFrancisco Iglesias                            gic_spi[adma_ch_intr[i]]);
78604965bcaSFrancisco Iglesias     }
787668351a5SXuzhou Cheng 
788c74ccb5dSFrancisco Iglesias     object_property_set_int(OBJECT(&s->qspi_irq_orgate),
789c74ccb5dSFrancisco Iglesias                             "num-lines", NUM_QSPI_IRQ_LINES, &error_fatal);
790c74ccb5dSFrancisco Iglesias     qdev_realize(DEVICE(&s->qspi_irq_orgate), NULL, &error_fatal);
791c74ccb5dSFrancisco Iglesias     qdev_connect_gpio_out(DEVICE(&s->qspi_irq_orgate), 0, gic_spi[QSPI_IRQ]);
792c74ccb5dSFrancisco Iglesias 
793c31b7f59SPhilippe Mathieu-Daudé     if (!object_property_set_link(OBJECT(&s->qspi_dma), "dma",
794c31b7f59SPhilippe Mathieu-Daudé                                   OBJECT(system_memory), errp)) {
795c31b7f59SPhilippe Mathieu-Daudé         return;
796c31b7f59SPhilippe Mathieu-Daudé     }
797668351a5SXuzhou Cheng     if (!sysbus_realize(SYS_BUS_DEVICE(&s->qspi_dma), errp)) {
798668351a5SXuzhou Cheng         return;
799668351a5SXuzhou Cheng     }
800668351a5SXuzhou Cheng 
801668351a5SXuzhou Cheng     sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi_dma), 0, QSPI_DMA_ADDR);
802c74ccb5dSFrancisco Iglesias     sysbus_connect_irq(SYS_BUS_DEVICE(&s->qspi_dma), 0,
803c74ccb5dSFrancisco Iglesias                        qdev_get_gpio_in(DEVICE(&s->qspi_irq_orgate), 0));
80434a3a71dSPhilippe Mathieu-Daudé 
80534a3a71dSPhilippe Mathieu-Daudé     if (!object_property_set_link(OBJECT(&s->qspi), "stream-connected-dma",
80634a3a71dSPhilippe Mathieu-Daudé                                   OBJECT(&s->qspi_dma), errp)) {
80734a3a71dSPhilippe Mathieu-Daudé          return;
80834a3a71dSPhilippe Mathieu-Daudé     }
80934a3a71dSPhilippe Mathieu-Daudé     if (!sysbus_realize(SYS_BUS_DEVICE(&s->qspi), errp)) {
81034a3a71dSPhilippe Mathieu-Daudé         return;
81134a3a71dSPhilippe Mathieu-Daudé     }
81234a3a71dSPhilippe Mathieu-Daudé     sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 0, QSPI_ADDR);
81334a3a71dSPhilippe Mathieu-Daudé     sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 1, LQSPI_ADDR);
814c74ccb5dSFrancisco Iglesias     sysbus_connect_irq(SYS_BUS_DEVICE(&s->qspi), 0,
815c74ccb5dSFrancisco Iglesias                        qdev_get_gpio_in(DEVICE(&s->qspi_irq_orgate), 1));
81634a3a71dSPhilippe Mathieu-Daudé 
81734a3a71dSPhilippe Mathieu-Daudé     for (i = 0; i < XLNX_ZYNQMP_NUM_QSPI_BUS; i++) {
81834a3a71dSPhilippe Mathieu-Daudé         g_autofree gchar *bus_name = g_strdup_printf("qspi%d", i);
81934a3a71dSPhilippe Mathieu-Daudé         g_autofree gchar *target_bus = g_strdup_printf("spi%d", i);
82034a3a71dSPhilippe Mathieu-Daudé 
82134a3a71dSPhilippe Mathieu-Daudé         /* Alias controller SPI bus to the SoC itself */
82234a3a71dSPhilippe Mathieu-Daudé         object_property_add_alias(OBJECT(s), bus_name,
82334a3a71dSPhilippe Mathieu-Daudé                                   OBJECT(&s->qspi), target_bus);
82434a3a71dSPhilippe Mathieu-Daudé     }
825acc0b8b0SFrancisco Iglesias 
826acc0b8b0SFrancisco Iglesias     for (i = 0; i < XLNX_ZYNQMP_NUM_USB; i++) {
827acc0b8b0SFrancisco Iglesias         if (!object_property_set_link(OBJECT(&s->usb[i].sysbus_xhci), "dma",
828acc0b8b0SFrancisco Iglesias                                       OBJECT(system_memory), errp)) {
829acc0b8b0SFrancisco Iglesias             return;
830acc0b8b0SFrancisco Iglesias         }
831acc0b8b0SFrancisco Iglesias 
832acc0b8b0SFrancisco Iglesias         qdev_prop_set_uint32(DEVICE(&s->usb[i].sysbus_xhci), "intrs", 4);
833acc0b8b0SFrancisco Iglesias         qdev_prop_set_uint32(DEVICE(&s->usb[i].sysbus_xhci), "slots", 2);
834acc0b8b0SFrancisco Iglesias 
835acc0b8b0SFrancisco Iglesias         if (!sysbus_realize(SYS_BUS_DEVICE(&s->usb[i]), errp)) {
836acc0b8b0SFrancisco Iglesias             return;
837acc0b8b0SFrancisco Iglesias         }
838acc0b8b0SFrancisco Iglesias 
839acc0b8b0SFrancisco Iglesias         sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, usb_addr[i]);
840acc0b8b0SFrancisco Iglesias         sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i].sysbus_xhci), 0,
841acc0b8b0SFrancisco Iglesias                            gic_spi[usb_intr[i]]);
842acc0b8b0SFrancisco Iglesias         sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i].sysbus_xhci), 1,
843acc0b8b0SFrancisco Iglesias                            gic_spi[usb_intr[i] + 1]);
844acc0b8b0SFrancisco Iglesias         sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i].sysbus_xhci), 2,
845acc0b8b0SFrancisco Iglesias                            gic_spi[usb_intr[i] + 2]);
846acc0b8b0SFrancisco Iglesias         sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i].sysbus_xhci), 3,
847acc0b8b0SFrancisco Iglesias                            gic_spi[usb_intr[i] + 3]);
848acc0b8b0SFrancisco Iglesias     }
849f0a902f7SPeter Crosthwaite }
850f0a902f7SPeter Crosthwaite 
8516396a193SPeter Crosthwaite static Property xlnx_zynqmp_props[] = {
8526396a193SPeter Crosthwaite     DEFINE_PROP_STRING("boot-cpu", XlnxZynqMPState, boot_cpu),
85337d42473SEdgar E. Iglesias     DEFINE_PROP_BOOL("secure", XlnxZynqMPState, secure, false),
8541946809eSAlistair Francis     DEFINE_PROP_BOOL("virtualization", XlnxZynqMPState, virt, false),
855c3acfa01SFam Zheng     DEFINE_PROP_LINK("ddr-ram", XlnxZynqMPState, ddr_ram, TYPE_MEMORY_REGION,
856c3acfa01SFam Zheng                      MemoryRegion *),
857840c22cdSVikram Garhwal     DEFINE_PROP_LINK("canbus0", XlnxZynqMPState, canbus[0], TYPE_CAN_BUS,
858840c22cdSVikram Garhwal                      CanBusState *),
859840c22cdSVikram Garhwal     DEFINE_PROP_LINK("canbus1", XlnxZynqMPState, canbus[1], TYPE_CAN_BUS,
860840c22cdSVikram Garhwal                      CanBusState *),
8616396a193SPeter Crosthwaite     DEFINE_PROP_END_OF_LIST()
8626396a193SPeter Crosthwaite };
8636396a193SPeter Crosthwaite 
864f0a902f7SPeter Crosthwaite static void xlnx_zynqmp_class_init(ObjectClass *oc, void *data)
865f0a902f7SPeter Crosthwaite {
866f0a902f7SPeter Crosthwaite     DeviceClass *dc = DEVICE_CLASS(oc);
867f0a902f7SPeter Crosthwaite 
8684f67d30bSMarc-André Lureau     device_class_set_props(dc, xlnx_zynqmp_props);
869f0a902f7SPeter Crosthwaite     dc->realize = xlnx_zynqmp_realize;
870d8589144SThomas Huth     /* Reason: Uses serial_hds in realize function, thus can't be used twice */
871d8589144SThomas Huth     dc->user_creatable = false;
872f0a902f7SPeter Crosthwaite }
873f0a902f7SPeter Crosthwaite 
874f0a902f7SPeter Crosthwaite static const TypeInfo xlnx_zynqmp_type_info = {
875f0a902f7SPeter Crosthwaite     .name = TYPE_XLNX_ZYNQMP,
876f0a902f7SPeter Crosthwaite     .parent = TYPE_DEVICE,
877f0a902f7SPeter Crosthwaite     .instance_size = sizeof(XlnxZynqMPState),
878f0a902f7SPeter Crosthwaite     .instance_init = xlnx_zynqmp_init,
879f0a902f7SPeter Crosthwaite     .class_init = xlnx_zynqmp_class_init,
880f0a902f7SPeter Crosthwaite };
881f0a902f7SPeter Crosthwaite 
882f0a902f7SPeter Crosthwaite static void xlnx_zynqmp_register_types(void)
883f0a902f7SPeter Crosthwaite {
884f0a902f7SPeter Crosthwaite     type_register_static(&xlnx_zynqmp_type_info);
885f0a902f7SPeter Crosthwaite }
886f0a902f7SPeter Crosthwaite 
887f0a902f7SPeter Crosthwaite type_init(xlnx_zynqmp_register_types)
888