]> git.proxmox.com Git - mirror_qemu.git/blame - hw/arm/xlnx-ep108.c
trace: Fix incorrect megasas trace parameters
[mirror_qemu.git] / hw / arm / xlnx-ep108.c
CommitLineData
859a0c5b
PC
1/*
2 * Xilinx ZynqMP EP108 board
3 *
4 * Copyright (C) 2015 Xilinx Inc
5 * Written by Peter Crosthwaite <peter.crosthwaite@xilinx.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 */
17
12b16722 18#include "qemu/osdep.h"
da34e65c 19#include "qapi/error.h"
4771d756
PB
20#include "qemu-common.h"
21#include "cpu.h"
859a0c5b
PC
22#include "hw/arm/xlnx-zynqmp.h"
23#include "hw/boards.h"
24#include "qemu/error-report.h"
b79b9d28 25#include "exec/address-spaces.h"
03dd024f 26#include "qemu/log.h"
859a0c5b
PC
27
28typedef struct XlnxEP108 {
29 XlnxZynqMPState soc;
b79b9d28 30 MemoryRegion ddr_ram;
859a0c5b
PC
31} XlnxEP108;
32
082587b7
PC
33static struct arm_boot_info xlnx_ep108_binfo;
34
859a0c5b
PC
35static void xlnx_ep108_init(MachineState *machine)
36{
37 XlnxEP108 *s = g_new0(XlnxEP108, 1);
a4b26335 38 int i;
dc3b89ef
AF
39 uint64_t ram_size = machine->ram_size;
40
41 /* Create the memory region to pass to the SoC */
42 if (ram_size > XLNX_ZYNQMP_MAX_RAM_SIZE) {
43 error_report("ERROR: RAM size 0x%" PRIx64 " above max supported of "
44 "0x%llx", ram_size,
45 XLNX_ZYNQMP_MAX_RAM_SIZE);
46 exit(1);
47 }
48
49 if (ram_size < 0x08000000) {
50 qemu_log("WARNING: RAM size 0x%" PRIx64 " is small for EP108",
51 ram_size);
52 }
53
54 memory_region_allocate_system_memory(&s->ddr_ram, NULL, "ddr-ram",
55 ram_size);
859a0c5b
PC
56
57 object_initialize(&s->soc, sizeof(s->soc), TYPE_XLNX_ZYNQMP);
58 object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
59 &error_abort);
60
dc3b89ef
AF
61 object_property_set_link(OBJECT(&s->soc), OBJECT(&s->ddr_ram),
62 "ddr-ram", &error_abort);
63
07d04a02 64 object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal);
b79b9d28 65
eb4f566b
PM
66 /* Create and plug in the SD cards */
67 for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) {
68 BusState *bus;
69 DriveInfo *di = drive_get_next(IF_SD);
70 BlockBackend *blk = di ? blk_by_legacy_dinfo(di) : NULL;
71 DeviceState *carddev;
72 char *bus_name;
73
74 bus_name = g_strdup_printf("sd-bus%d", i);
75 bus = qdev_get_child_bus(DEVICE(&s->soc), bus_name);
76 g_free(bus_name);
77 if (!bus) {
78 error_report("No SD bus found for SD card %d", i);
79 exit(1);
80 }
81 carddev = qdev_create(bus, TYPE_SD_CARD);
82 qdev_prop_set_drive(carddev, "drive", blk, &error_fatal);
83 object_property_set_bool(OBJECT(carddev), true, "realized",
84 &error_fatal);
85 }
86
a4b26335
AF
87 for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
88 SSIBus *spi_bus;
89 DeviceState *flash_dev;
90 qemu_irq cs_line;
73bce518 91 DriveInfo *dinfo = drive_get_next(IF_MTD);
a4b26335
AF
92 gchar *bus_name = g_strdup_printf("spi%d", i);
93
94 spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc), bus_name);
95 g_free(bus_name);
96
73bce518
PB
97 flash_dev = ssi_create_slave_no_init(spi_bus, "sst25wf080");
98 if (dinfo) {
99 qdev_prop_set_drive(flash_dev, "drive", blk_by_legacy_dinfo(dinfo),
100 &error_fatal);
101 }
102 qdev_init_nofail(flash_dev);
103
a4b26335
AF
104 cs_line = qdev_get_gpio_in_named(flash_dev, SSI_GPIO_CS, 0);
105
106 sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[i]), 1, cs_line);
107 }
108
e0319b03
MA
109 /* TODO create and connect IDE devices for ide_drive_get() */
110
dc3b89ef 111 xlnx_ep108_binfo.ram_size = ram_size;
082587b7
PC
112 xlnx_ep108_binfo.kernel_filename = machine->kernel_filename;
113 xlnx_ep108_binfo.kernel_cmdline = machine->kernel_cmdline;
114 xlnx_ep108_binfo.initrd_filename = machine->initrd_filename;
115 xlnx_ep108_binfo.loader_start = 0;
6396a193 116 arm_load_kernel(s->soc.boot_cpu_ptr, &xlnx_ep108_binfo);
859a0c5b
PC
117}
118
e264d29d 119static void xlnx_ep108_machine_init(MachineClass *mc)
859a0c5b 120{
e264d29d
EH
121 mc->desc = "Xilinx ZynqMP EP108 board";
122 mc->init = xlnx_ep108_init;
e0319b03
MA
123 mc->block_default_type = IF_IDE;
124 mc->units_per_default_bus = 1;
859a0c5b
PC
125}
126
e264d29d 127DEFINE_MACHINE("xlnx-ep108", xlnx_ep108_machine_init)
0c18c6c6
AF
128
129static void xlnx_zcu102_machine_init(MachineClass *mc)
130{
131 mc->desc = "Xilinx ZynqMP ZCU102 board";
132 mc->init = xlnx_ep108_init;
e0319b03
MA
133 mc->block_default_type = IF_IDE;
134 mc->units_per_default_bus = 1;
0c18c6c6
AF
135}
136
137DEFINE_MACHINE("xlnx-zcu102", xlnx_zcu102_machine_init)