arm: xlnx-ep108: Add external RAM
[qemu/ar7.git] / hw / arm / xlnx-ep108.c
blob46f145b97d2e369a815df95f12b5c89a83e6f0a7
1 /*
2 * Xilinx ZynqMP EP108 board
4 * Copyright (C) 2015 Xilinx Inc
5 * Written by Peter Crosthwaite <peter.crosthwaite@xilinx.com>
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.
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.
18 #include "hw/arm/xlnx-zynqmp.h"
19 #include "hw/boards.h"
20 #include "qemu/error-report.h"
21 #include "exec/address-spaces.h"
23 typedef struct XlnxEP108 {
24 XlnxZynqMPState soc;
25 MemoryRegion ddr_ram;
26 } XlnxEP108;
28 /* Max 2GB RAM */
29 #define EP108_MAX_RAM_SIZE 0x80000000ull
31 static void xlnx_ep108_init(MachineState *machine)
33 XlnxEP108 *s = g_new0(XlnxEP108, 1);
34 Error *err = NULL;
36 object_initialize(&s->soc, sizeof(s->soc), TYPE_XLNX_ZYNQMP);
37 object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
38 &error_abort);
40 object_property_set_bool(OBJECT(&s->soc), true, "realized", &err);
41 if (err) {
42 error_report("%s", error_get_pretty(err));
43 exit(1);
46 if (machine->ram_size > EP108_MAX_RAM_SIZE) {
47 error_report("WARNING: RAM size " RAM_ADDR_FMT " above max supported, "
48 "reduced to %llx", machine->ram_size, EP108_MAX_RAM_SIZE);
49 machine->ram_size = EP108_MAX_RAM_SIZE;
52 if (machine->ram_size <= 0x08000000) {
53 qemu_log("WARNING: RAM size " RAM_ADDR_FMT " is small for EP108",
54 machine->ram_size);
57 memory_region_allocate_system_memory(&s->ddr_ram, NULL, "ddr-ram",
58 machine->ram_size);
59 memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram);
62 static QEMUMachine xlnx_ep108_machine = {
63 .name = "xlnx-ep108",
64 .desc = "Xilinx ZynqMP EP108 board",
65 .init = xlnx_ep108_init,
68 static void xlnx_ep108_machine_init(void)
70 qemu_register_machine(&xlnx_ep108_machine);
73 machine_init(xlnx_ep108_machine_init);