1 /* 2 * Copyright (c) Meta Platforms, Inc. and affiliates. (http://www.meta.com) 3 * 4 * This code is licensed under the GPL version 2 or later. See the COPYING 5 * file in the top-level directory. 6 */ 7 8 #include "qemu/osdep.h" 9 #include "qemu/units.h" 10 #include "qapi/error.h" 11 #include "sysemu/sysemu.h" 12 #include "hw/boards.h" 13 #include "hw/arm/aspeed_soc.h" 14 15 #define TYPE_FBY35 MACHINE_TYPE_NAME("fby35") 16 OBJECT_DECLARE_SIMPLE_TYPE(Fby35State, FBY35); 17 18 struct Fby35State { 19 MachineState parent_obj; 20 21 MemoryRegion bmc_memory; 22 MemoryRegion bmc_dram; 23 MemoryRegion bmc_boot_rom; 24 25 AspeedSoCState bmc; 26 }; 27 28 #define FBY35_BMC_RAM_SIZE (2 * GiB) 29 30 static void fby35_bmc_init(Fby35State *s) 31 { 32 memory_region_init(&s->bmc_memory, OBJECT(s), "bmc-memory", UINT64_MAX); 33 memory_region_init_ram(&s->bmc_dram, OBJECT(s), "bmc-dram", 34 FBY35_BMC_RAM_SIZE, &error_abort); 35 36 object_initialize_child(OBJECT(s), "bmc", &s->bmc, "ast2600-a3"); 37 object_property_set_int(OBJECT(&s->bmc), "ram-size", FBY35_BMC_RAM_SIZE, 38 &error_abort); 39 object_property_set_link(OBJECT(&s->bmc), "memory", OBJECT(&s->bmc_memory), 40 &error_abort); 41 object_property_set_link(OBJECT(&s->bmc), "dram", OBJECT(&s->bmc_dram), 42 &error_abort); 43 object_property_set_int(OBJECT(&s->bmc), "hw-strap1", 0x000000C0, 44 &error_abort); 45 object_property_set_int(OBJECT(&s->bmc), "hw-strap2", 0x00000003, 46 &error_abort); 47 aspeed_soc_uart_set_chr(&s->bmc, ASPEED_DEV_UART5, serial_hd(0)); 48 qdev_realize(DEVICE(&s->bmc), NULL, &error_abort); 49 50 aspeed_board_init_flashes(&s->bmc.fmc, "n25q00", 2, 0); 51 } 52 53 static void fby35_init(MachineState *machine) 54 { 55 Fby35State *s = FBY35(machine); 56 57 fby35_bmc_init(s); 58 } 59 60 static void fby35_class_init(ObjectClass *oc, void *data) 61 { 62 MachineClass *mc = MACHINE_CLASS(oc); 63 64 mc->desc = "Meta Platforms fby35"; 65 mc->init = fby35_init; 66 mc->no_floppy = 1; 67 mc->no_cdrom = 1; 68 mc->min_cpus = mc->max_cpus = mc->default_cpus = 2; 69 } 70 71 static const TypeInfo fby35_types[] = { 72 { 73 .name = MACHINE_TYPE_NAME("fby35"), 74 .parent = TYPE_MACHINE, 75 .class_init = fby35_class_init, 76 .instance_size = sizeof(Fby35State), 77 }, 78 }; 79 80 DEFINE_TYPES(fby35_types); 81