]> git.proxmox.com Git - mirror_qemu.git/blob - hw/arm/xlnx-ep108.c
include/qemu/osdep.h: Don't include qapi/error.h
[mirror_qemu.git] / hw / arm / xlnx-ep108.c
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
18 #include "qemu/osdep.h"
19 #include "qapi/error.h"
20 #include "hw/arm/xlnx-zynqmp.h"
21 #include "hw/boards.h"
22 #include "qemu/error-report.h"
23 #include "exec/address-spaces.h"
24
25 typedef struct XlnxEP108 {
26 XlnxZynqMPState soc;
27 MemoryRegion ddr_ram;
28 } XlnxEP108;
29
30 static struct arm_boot_info xlnx_ep108_binfo;
31
32 static void xlnx_ep108_init(MachineState *machine)
33 {
34 XlnxEP108 *s = g_new0(XlnxEP108, 1);
35 int i;
36 uint64_t ram_size = machine->ram_size;
37
38 /* Create the memory region to pass to the SoC */
39 if (ram_size > XLNX_ZYNQMP_MAX_RAM_SIZE) {
40 error_report("ERROR: RAM size 0x%" PRIx64 " above max supported of "
41 "0x%llx", ram_size,
42 XLNX_ZYNQMP_MAX_RAM_SIZE);
43 exit(1);
44 }
45
46 if (ram_size < 0x08000000) {
47 qemu_log("WARNING: RAM size 0x%" PRIx64 " is small for EP108",
48 ram_size);
49 }
50
51 memory_region_allocate_system_memory(&s->ddr_ram, NULL, "ddr-ram",
52 ram_size);
53
54 object_initialize(&s->soc, sizeof(s->soc), TYPE_XLNX_ZYNQMP);
55 object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
56 &error_abort);
57
58 object_property_set_link(OBJECT(&s->soc), OBJECT(&s->ddr_ram),
59 "ddr-ram", &error_abort);
60
61 object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal);
62
63 /* Create and plug in the SD cards */
64 for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) {
65 BusState *bus;
66 DriveInfo *di = drive_get_next(IF_SD);
67 BlockBackend *blk = di ? blk_by_legacy_dinfo(di) : NULL;
68 DeviceState *carddev;
69 char *bus_name;
70
71 bus_name = g_strdup_printf("sd-bus%d", i);
72 bus = qdev_get_child_bus(DEVICE(&s->soc), bus_name);
73 g_free(bus_name);
74 if (!bus) {
75 error_report("No SD bus found for SD card %d", i);
76 exit(1);
77 }
78 carddev = qdev_create(bus, TYPE_SD_CARD);
79 qdev_prop_set_drive(carddev, "drive", blk, &error_fatal);
80 object_property_set_bool(OBJECT(carddev), true, "realized",
81 &error_fatal);
82 }
83
84 for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
85 SSIBus *spi_bus;
86 DeviceState *flash_dev;
87 qemu_irq cs_line;
88 gchar *bus_name = g_strdup_printf("spi%d", i);
89
90 spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc), bus_name);
91 g_free(bus_name);
92
93 flash_dev = ssi_create_slave(spi_bus, "sst25wf080");
94 cs_line = qdev_get_gpio_in_named(flash_dev, SSI_GPIO_CS, 0);
95
96 sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[i]), 1, cs_line);
97 }
98
99 xlnx_ep108_binfo.ram_size = ram_size;
100 xlnx_ep108_binfo.kernel_filename = machine->kernel_filename;
101 xlnx_ep108_binfo.kernel_cmdline = machine->kernel_cmdline;
102 xlnx_ep108_binfo.initrd_filename = machine->initrd_filename;
103 xlnx_ep108_binfo.loader_start = 0;
104 arm_load_kernel(s->soc.boot_cpu_ptr, &xlnx_ep108_binfo);
105 }
106
107 static void xlnx_ep108_machine_init(MachineClass *mc)
108 {
109 mc->desc = "Xilinx ZynqMP EP108 board";
110 mc->init = xlnx_ep108_init;
111 }
112
113 DEFINE_MACHINE("xlnx-ep108", xlnx_ep108_machine_init)