2 * Copyright (c) 2018 Jean-Christophe Dubois <jcd@tribudubois.net>
4 * MCIMX6UL_EVK Board System emulation.
6 * This code is licensed under the GPL, version 2 or later.
7 * See the file `COPYING' in the top level directory.
9 * It (partially) emulates a mcimx6ul_evk board, with a Freescale
13 #include "qemu/osdep.h"
14 #include "qapi/error.h"
15 #include "hw/arm/fsl-imx6ul.h"
16 #include "hw/boards.h"
17 #include "hw/qdev-properties.h"
18 #include "sysemu/sysemu.h"
19 #include "qemu/error-report.h"
20 #include "sysemu/qtest.h"
27 static void mcimx6ul_evk_init(MachineState
*machine
)
29 static struct arm_boot_info boot_info
;
30 MCIMX6ULEVK
*s
= g_new0(MCIMX6ULEVK
, 1);
33 if (machine
->ram_size
> FSL_IMX6UL_MMDC_SIZE
) {
34 error_report("RAM size " RAM_ADDR_FMT
" above max supported (%08x)",
35 machine
->ram_size
, FSL_IMX6UL_MMDC_SIZE
);
39 boot_info
= (struct arm_boot_info
) {
40 .loader_start
= FSL_IMX6UL_MMDC_ADDR
,
42 .ram_size
= machine
->ram_size
,
43 .nb_cpus
= machine
->smp
.cpus
,
46 object_initialize_child(OBJECT(machine
), "soc", &s
->soc
, sizeof(s
->soc
),
47 TYPE_FSL_IMX6UL
, &error_fatal
, NULL
);
49 object_property_set_bool(OBJECT(&s
->soc
), true, "realized", &error_fatal
);
51 memory_region_allocate_system_memory(&s
->ram
, NULL
, "mcimx6ul-evk.ram",
53 memory_region_add_subregion(get_system_memory(),
54 FSL_IMX6UL_MMDC_ADDR
, &s
->ram
);
56 for (i
= 0; i
< FSL_IMX6UL_NUM_USDHCS
; i
++) {
62 di
= drive_get_next(IF_SD
);
63 blk
= di
? blk_by_legacy_dinfo(di
) : NULL
;
64 bus
= qdev_get_child_bus(DEVICE(&s
->soc
.usdhc
[i
]), "sd-bus");
65 carddev
= qdev_create(bus
, TYPE_SD_CARD
);
66 qdev_prop_set_drive(carddev
, "drive", blk
, &error_fatal
);
67 object_property_set_bool(OBJECT(carddev
), true,
68 "realized", &error_fatal
);
71 if (!qtest_enabled()) {
72 arm_load_kernel(&s
->soc
.cpu
, machine
, &boot_info
);
76 static void mcimx6ul_evk_machine_init(MachineClass
*mc
)
78 mc
->desc
= "Freescale i.MX6UL Evaluation Kit (Cortex A7)";
79 mc
->init
= mcimx6ul_evk_init
;
80 mc
->max_cpus
= FSL_IMX6UL_NUM_CPUS
;
82 DEFINE_MACHINE("mcimx6ul-evk", mcimx6ul_evk_machine_init
)