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 .kernel_filename
= machine
->kernel_filename
,
44 .kernel_cmdline
= machine
->kernel_cmdline
,
45 .initrd_filename
= machine
->initrd_filename
,
46 .nb_cpus
= machine
->smp
.cpus
,
49 object_initialize_child(OBJECT(machine
), "soc", &s
->soc
, sizeof(s
->soc
),
50 TYPE_FSL_IMX6UL
, &error_fatal
, NULL
);
52 object_property_set_bool(OBJECT(&s
->soc
), true, "realized", &error_fatal
);
54 memory_region_allocate_system_memory(&s
->ram
, NULL
, "mcimx6ul-evk.ram",
56 memory_region_add_subregion(get_system_memory(),
57 FSL_IMX6UL_MMDC_ADDR
, &s
->ram
);
59 for (i
= 0; i
< FSL_IMX6UL_NUM_USDHCS
; i
++) {
65 di
= drive_get_next(IF_SD
);
66 blk
= di
? blk_by_legacy_dinfo(di
) : NULL
;
67 bus
= qdev_get_child_bus(DEVICE(&s
->soc
.usdhc
[i
]), "sd-bus");
68 carddev
= qdev_create(bus
, TYPE_SD_CARD
);
69 qdev_prop_set_drive(carddev
, "drive", blk
, &error_fatal
);
70 object_property_set_bool(OBJECT(carddev
), true,
71 "realized", &error_fatal
);
74 if (!qtest_enabled()) {
75 arm_load_kernel(&s
->soc
.cpu
, &boot_info
);
79 static void mcimx6ul_evk_machine_init(MachineClass
*mc
)
81 mc
->desc
= "Freescale i.MX6UL Evaluation Kit (Cortex A7)";
82 mc
->init
= mcimx6ul_evk_init
;
83 mc
->max_cpus
= FSL_IMX6UL_NUM_CPUS
;
85 DEFINE_MACHINE("mcimx6ul-evk", mcimx6ul_evk_machine_init
)