master
c 81 lines 2.54 KB
Raw
1 /*
2 * Copyright (c) 2018 Jean-Christophe Dubois <jcd@tribudubois.net>
3 *
4 * MCIMX6UL_EVK Board System emulation.
5 *
6 * This code is licensed under the GPL, version 2 or later.
7 * See the file `COPYING' in the top level directory.
8 *
9 * It (partially) emulates a mcimx6ul_evk board, with a Freescale
10 * i.MX6ul SoC
11 */
12
13 #include "qemu/osdep.h"
14 #include "qapi/error.h"
15 #include "hw/arm/fsl-imx6ul.h"
16 #include "hw/arm/boot.h"
17 #include "hw/arm/machines-qom.h"
18 #include "hw/core/boards.h"
19 #include "hw/core/qdev-properties.h"
20 #include "qemu/error-report.h"
21 #include "system/qtest.h"
22
23 static void mcimx6ul_evk_init(MachineState *machine)
24 {
25 static struct arm_boot_info boot_info;
26 FslIMX6ULState *s;
27 int i;
28
29 if (machine->ram_size > FSL_IMX6UL_MMDC_SIZE) {
30 error_report("RAM size " RAM_ADDR_FMT " above max supported (%08x)",
31 machine->ram_size, FSL_IMX6UL_MMDC_SIZE);
32 exit(1);
33 }
34
35 boot_info = (struct arm_boot_info) {
36 .loader_start = FSL_IMX6UL_MMDC_ADDR,
37 .board_id = -1,
38 .ram_size = machine->ram_size,
39 .psci_conduit = QEMU_PSCI_CONDUIT_SMC,
40 };
41
42 s = FSL_IMX6UL(object_new(TYPE_FSL_IMX6UL));
43 object_property_add_child(OBJECT(machine), "soc", OBJECT(s));
44 object_property_set_uint(OBJECT(s), "fec1-phy-num", 2, &error_fatal);
45 object_property_set_uint(OBJECT(s), "fec2-phy-num", 1, &error_fatal);
46 object_property_set_bool(OBJECT(s), "fec1-phy-connected", false,
47 &error_fatal);
48 qdev_realize(DEVICE(s), NULL, &error_fatal);
49
50 memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_MMDC_ADDR,
51 machine->ram);
52
53 for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) {
54 BusState *bus;
55 DeviceState *carddev;
56 DriveInfo *di;
57 BlockBackend *blk;
58
59 di = drive_get(IF_SD, 0, i);
60 blk = di ? blk_by_legacy_dinfo(di) : NULL;
61 bus = qdev_get_child_bus(DEVICE(&s->usdhc[i]), "sd-bus");
62 carddev = qdev_new(TYPE_SD_CARD);
63 qdev_prop_set_drive_err(carddev, "drive", blk, &error_fatal);
64 qdev_realize_and_unref(carddev, bus, &error_fatal);
65 }
66
67 if (!qtest_enabled()) {
68 arm_load_kernel(&s->cpu, machine, &boot_info);
69 }
70 }
71
72 static void mcimx6ul_evk_machine_init(MachineClass *mc)
73 {
74 mc->desc = "Freescale i.MX6UL Evaluation Kit (Cortex-A7)";
75 mc->init = mcimx6ul_evk_init;
76 mc->max_cpus = FSL_IMX6UL_NUM_CPUS;
77 mc->default_ram_id = "mcimx6ul-evk.ram";
78 mc->auto_create_sdcard = true;
79 }
80
81 DEFINE_MACHINE_ARM("mcimx6ul-evk", mcimx6ul_evk_machine_init)