]>
Commit | Line | Data |
---|---|---|
0550e3bf JCD |
1 | /* |
2 | * Copyright (c) 2018 Jean-Christophe Dubois <[email protected]> | |
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 "qemu-common.h" | |
16 | #include "hw/arm/fsl-imx6ul.h" | |
17 | #include "hw/boards.h" | |
18 | #include "sysemu/sysemu.h" | |
19 | #include "qemu/error-report.h" | |
20 | #include "sysemu/qtest.h" | |
21 | ||
22 | typedef struct { | |
23 | FslIMX6ULState soc; | |
24 | MemoryRegion ram; | |
25 | } MCIMX6ULEVK; | |
26 | ||
27 | static void mcimx6ul_evk_init(MachineState *machine) | |
28 | { | |
29 | static struct arm_boot_info boot_info; | |
30 | MCIMX6ULEVK *s = g_new0(MCIMX6ULEVK, 1); | |
31 | int i; | |
32 | ||
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); | |
36 | exit(1); | |
37 | } | |
38 | ||
39 | boot_info = (struct arm_boot_info) { | |
40 | .loader_start = FSL_IMX6UL_MMDC_ADDR, | |
41 | .board_id = -1, | |
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 = smp_cpus, | |
47 | }; | |
48 | ||
49 | object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), | |
50 | TYPE_FSL_IMX6UL, &error_fatal, NULL); | |
51 | ||
52 | object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal); | |
53 | ||
54 | memory_region_allocate_system_memory(&s->ram, NULL, "mcimx6ul-evk.ram", | |
55 | machine->ram_size); | |
56 | memory_region_add_subregion(get_system_memory(), | |
57 | FSL_IMX6UL_MMDC_ADDR, &s->ram); | |
58 | ||
59 | for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { | |
60 | BusState *bus; | |
61 | DeviceState *carddev; | |
62 | DriveInfo *di; | |
63 | BlockBackend *blk; | |
64 | ||
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); | |
72 | } | |
73 | ||
74 | if (!qtest_enabled()) { | |
75 | arm_load_kernel(&s->soc.cpu[0], &boot_info); | |
76 | } | |
77 | } | |
78 | ||
79 | static void mcimx6ul_evk_machine_init(MachineClass *mc) | |
80 | { | |
81 | mc->desc = "Freescale i.MX6UL Evaluation Kit (Cortex A7)"; | |
82 | mc->init = mcimx6ul_evk_init; | |
83 | mc->max_cpus = FSL_IMX6UL_NUM_CPUS; | |
84 | } | |
85 | DEFINE_MACHINE("mcimx6ul-evk", mcimx6ul_evk_machine_init) |