20
#include "qemu/error-report.h"
21
#include "system/qtest.h"
22
23
+struct SabreliteMachineState {
24
+ MachineState parent_obj;
25
+
26
+ FslIMX6State soc;
27
+};
28
+
29
+#define TYPE_SABRELITE_MACHINE MACHINE_TYPE_NAME("sabrelite")
30
+OBJECT_DECLARE_SIMPLE_TYPE(SabreliteMachineState, SABRELITE_MACHINE)
31
+
32
static struct arm_boot_info sabrelite_binfo = {
33
/* DDR memory start */
34
.loader_start = FSL_IMX6_MMDC_ADDR,
50
51
static void sabrelite_init(MachineState *machine)
52
{
44
- FslIMX6State *s;
53
+ SabreliteMachineState *s = SABRELITE_MACHINE(machine);
54
55
/* Check the amount of memory is compatible with the SOC */
56
if (machine->ram_size > FSL_IMX6_MMDC_SIZE) {
59
exit(1);
60
}
61
53
- s = FSL_IMX6(object_new(TYPE_FSL_IMX6));
54
- object_property_add_child(OBJECT(machine), "soc", OBJECT(s));
62
+ object_initialize_child(OBJECT(machine), "soc", &s->soc, TYPE_FSL_IMX6);
63
64
/* Ethernet PHY address is 6 */
57
- object_property_set_int(OBJECT(s), "fec-phy-num", 6, &error_fatal);
65
+ object_property_set_int(OBJECT(&s->soc), "fec-phy-num", 6, &error_fatal);
66
59
- qdev_realize(DEVICE(s), NULL, &error_fatal);
67
+ qdev_realize(DEVICE(&s->soc), NULL, &error_fatal);
68
69
memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR,
70
machine->ram);
78
/* Add the sst25vf016b NOR FLASH memory to first SPI */
79
Object *spi_dev;
80
73
- spi_dev = object_resolve_path_component(OBJECT(s), "spi1");
81
+ spi_dev = object_resolve_path_component(OBJECT(&s->soc), "spi1");
82
if (spi_dev) {
83
SSIBus *spi_bus;
84
97
qdev_realize_and_unref(flash_dev, BUS(spi_bus), &error_fatal);
98
99
cs_line = qdev_get_gpio_in_named(flash_dev, SSI_GPIO_CS, 0);
92
- qdev_connect_gpio_out(DEVICE(&s->gpio[2]), 19, cs_line);
100
+ qdev_connect_gpio_out(DEVICE(&s->soc.gpio[2]), 19, cs_line);
101
}
102
}
103
}
108
sabrelite_binfo.secondary_cpu_reset_hook = sabrelite_reset_secondary;
109
110
if (!qtest_enabled()) {
103
- arm_load_kernel(&s->cpu[0], machine, &sabrelite_binfo);
111
+ arm_load_kernel(&s->soc.cpu[0], machine, &sabrelite_binfo);
112
}
113
}
114
125
}
126
127
static const TypeInfo sabrelite_machine_init_typeinfo = {
120
- .name = MACHINE_TYPE_NAME("sabrelite"),
128
+ .name = TYPE_SABRELITE_MACHINE,
129
.parent = TYPE_MACHINE,
130
.class_init = sabrelite_machine_class_init,
123
- .instance_size = sizeof(MachineState),
131
+ .instance_size = sizeof(SabreliteMachineState),
132
.abstract = false,
133
.interfaces = arm_machine_interfaces,
134
};