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
18 #include "qemu/osdep.h"
19 #include "qapi/error.h"
20 #include "qemu-common.h"
22 #include "hw/arm/xlnx-zynqmp.h"
23 #include "hw/boards.h"
24 #include "qemu/error-report.h"
25 #include "exec/address-spaces.h"
27 typedef struct XlnxEP108
{
32 static struct arm_boot_info xlnx_ep108_binfo
;
34 static void xlnx_ep108_init(MachineState
*machine
)
36 XlnxEP108
*s
= g_new0(XlnxEP108
, 1);
38 uint64_t ram_size
= machine
->ram_size
;
40 /* Create the memory region to pass to the SoC */
41 if (ram_size
> XLNX_ZYNQMP_MAX_RAM_SIZE
) {
42 error_report("ERROR: RAM size 0x%" PRIx64
" above max supported of "
44 XLNX_ZYNQMP_MAX_RAM_SIZE
);
48 if (ram_size
< 0x08000000) {
49 qemu_log("WARNING: RAM size 0x%" PRIx64
" is small for EP108",
53 memory_region_allocate_system_memory(&s
->ddr_ram
, NULL
, "ddr-ram",
56 object_initialize(&s
->soc
, sizeof(s
->soc
), TYPE_XLNX_ZYNQMP
);
57 object_property_add_child(OBJECT(machine
), "soc", OBJECT(&s
->soc
),
60 object_property_set_link(OBJECT(&s
->soc
), OBJECT(&s
->ddr_ram
),
61 "ddr-ram", &error_abort
);
63 object_property_set_bool(OBJECT(&s
->soc
), true, "realized", &error_fatal
);
65 /* Create and plug in the SD cards */
66 for (i
= 0; i
< XLNX_ZYNQMP_NUM_SDHCI
; i
++) {
68 DriveInfo
*di
= drive_get_next(IF_SD
);
69 BlockBackend
*blk
= di
? blk_by_legacy_dinfo(di
) : NULL
;
73 bus_name
= g_strdup_printf("sd-bus%d", i
);
74 bus
= qdev_get_child_bus(DEVICE(&s
->soc
), bus_name
);
77 error_report("No SD bus found for SD card %d", i
);
80 carddev
= qdev_create(bus
, TYPE_SD_CARD
);
81 qdev_prop_set_drive(carddev
, "drive", blk
, &error_fatal
);
82 object_property_set_bool(OBJECT(carddev
), true, "realized",
86 for (i
= 0; i
< XLNX_ZYNQMP_NUM_SPIS
; i
++) {
88 DeviceState
*flash_dev
;
90 gchar
*bus_name
= g_strdup_printf("spi%d", i
);
92 spi_bus
= (SSIBus
*)qdev_get_child_bus(DEVICE(&s
->soc
), bus_name
);
95 flash_dev
= ssi_create_slave(spi_bus
, "sst25wf080");
96 cs_line
= qdev_get_gpio_in_named(flash_dev
, SSI_GPIO_CS
, 0);
98 sysbus_connect_irq(SYS_BUS_DEVICE(&s
->soc
.spi
[i
]), 1, cs_line
);
101 xlnx_ep108_binfo
.ram_size
= ram_size
;
102 xlnx_ep108_binfo
.kernel_filename
= machine
->kernel_filename
;
103 xlnx_ep108_binfo
.kernel_cmdline
= machine
->kernel_cmdline
;
104 xlnx_ep108_binfo
.initrd_filename
= machine
->initrd_filename
;
105 xlnx_ep108_binfo
.loader_start
= 0;
106 arm_load_kernel(s
->soc
.boot_cpu_ptr
, &xlnx_ep108_binfo
);
109 static void xlnx_ep108_machine_init(MachineClass
*mc
)
111 mc
->desc
= "Xilinx ZynqMP EP108 board";
112 mc
->init
= xlnx_ep108_init
;
115 DEFINE_MACHINE("xlnx-ep108", xlnx_ep108_machine_init
)