1327d8e4eSAndrew Jeffery /* 2327d8e4eSAndrew Jeffery * OpenPOWER Palmetto BMC 3327d8e4eSAndrew Jeffery * 4327d8e4eSAndrew Jeffery * Andrew Jeffery <andrew@aj.id.au> 5327d8e4eSAndrew Jeffery * 6327d8e4eSAndrew Jeffery * Copyright 2016 IBM Corp. 7327d8e4eSAndrew Jeffery * 8327d8e4eSAndrew Jeffery * This code is licensed under the GPL version 2 or later. See 9327d8e4eSAndrew Jeffery * the COPYING file in the top-level directory. 10327d8e4eSAndrew Jeffery */ 11327d8e4eSAndrew Jeffery 12327d8e4eSAndrew Jeffery #include "qemu/osdep.h" 13da34e65cSMarkus Armbruster #include "qapi/error.h" 144771d756SPaolo Bonzini #include "cpu.h" 15327d8e4eSAndrew Jeffery #include "exec/address-spaces.h" 1612ec8bd5SPeter Maydell #include "hw/arm/boot.h" 17fca9ca1bSCédric Le Goater #include "hw/arm/aspeed.h" 1800442402SCédric Le Goater #include "hw/arm/aspeed_soc.h" 19327d8e4eSAndrew Jeffery #include "hw/boards.h" 2093198b6cSCorey Minyard #include "hw/i2c/smbus_eeprom.h" 21044475f3SPhilippe Mathieu-Daudé #include "hw/misc/pca9552.h" 22044475f3SPhilippe Mathieu-Daudé #include "hw/misc/tmp105.h" 23a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h" 2403dd024fSPaolo Bonzini #include "qemu/log.h" 25e1ad9bc4SCédric Le Goater #include "sysemu/block-backend.h" 26ece09beeSCédric Le Goater #include "sysemu/sysemu.h" 27d769a1daSCédric Le Goater #include "hw/loader.h" 28d769a1daSCédric Le Goater #include "qemu/error-report.h" 29a9df9622SJoel Stanley #include "qemu/units.h" 30327d8e4eSAndrew Jeffery 3174fb1f38SCédric Le Goater static struct arm_boot_info aspeed_board_binfo = { 32b033271fSCédric Le Goater .board_id = -1, /* device-tree-only board */ 33327d8e4eSAndrew Jeffery }; 34327d8e4eSAndrew Jeffery 35ea066d39SThomas Huth struct AspeedBoardState { 36ff90606fSCédric Le Goater AspeedSoCState soc; 37ad1a9782SCédric Le Goater MemoryRegion ram_container; 38ebe31c0aSCédric Le Goater MemoryRegion max_ram; 39ea066d39SThomas Huth }; 40327d8e4eSAndrew Jeffery 41ef17f836SCédric Le Goater /* Palmetto hardware value: 0x120CE416 */ 428da33ef7SCédric Le Goater #define PALMETTO_BMC_HW_STRAP1 ( \ 438da33ef7SCédric Le Goater SCU_AST2400_HW_STRAP_DRAM_SIZE(DRAM_SIZE_256MB) | \ 448da33ef7SCédric Le Goater SCU_AST2400_HW_STRAP_DRAM_CONFIG(2 /* DDR3 with CL=6, CWL=5 */) | \ 458da33ef7SCédric Le Goater SCU_AST2400_HW_STRAP_ACPI_DIS | \ 468da33ef7SCédric Le Goater SCU_AST2400_HW_STRAP_SET_CLK_SOURCE(AST2400_CLK_48M_IN) | \ 478da33ef7SCédric Le Goater SCU_HW_STRAP_VGA_CLASS_CODE | \ 488da33ef7SCédric Le Goater SCU_HW_STRAP_LPC_RESET_PIN | \ 498da33ef7SCédric Le Goater SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_M_S_EN) | \ 508da33ef7SCédric Le Goater SCU_AST2400_HW_STRAP_SET_CPU_AHB_RATIO(AST2400_CPU_AHB_RATIO_2_1) | \ 518da33ef7SCédric Le Goater SCU_HW_STRAP_SPI_WIDTH | \ 528da33ef7SCédric Le Goater SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) | \ 538da33ef7SCédric Le Goater SCU_AST2400_HW_STRAP_BOOT_MODE(AST2400_SPI_BOOT)) 548da33ef7SCédric Le Goater 55ef17f836SCédric Le Goater /* AST2500 evb hardware value: 0xF100C2E6 */ 569a7c1750SCédric Le Goater #define AST2500_EVB_HW_STRAP1 (( \ 579a7c1750SCédric Le Goater AST2500_HW_STRAP1_DEFAULTS | \ 589a7c1750SCédric Le Goater SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \ 599a7c1750SCédric Le Goater SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \ 609a7c1750SCédric Le Goater SCU_AST2500_HW_STRAP_UART_DEBUG | \ 619a7c1750SCédric Le Goater SCU_AST2500_HW_STRAP_DDR4_ENABLE | \ 629a7c1750SCédric Le Goater SCU_HW_STRAP_MAC1_RGMII | \ 639a7c1750SCédric Le Goater SCU_HW_STRAP_MAC0_RGMII) & \ 649a7c1750SCédric Le Goater ~SCU_HW_STRAP_2ND_BOOT_WDT) 659a7c1750SCédric Le Goater 66ef17f836SCédric Le Goater /* Romulus hardware value: 0xF10AD206 */ 67ef17f836SCédric Le Goater #define ROMULUS_BMC_HW_STRAP1 ( \ 68ef17f836SCédric Le Goater AST2500_HW_STRAP1_DEFAULTS | \ 69ef17f836SCédric Le Goater SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \ 70ef17f836SCédric Le Goater SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \ 71ef17f836SCédric Le Goater SCU_AST2500_HW_STRAP_UART_DEBUG | \ 72ef17f836SCédric Le Goater SCU_AST2500_HW_STRAP_DDR4_ENABLE | \ 73ef17f836SCédric Le Goater SCU_AST2500_HW_STRAP_ACPI_ENABLE | \ 74ef17f836SCédric Le Goater SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER)) 75ef17f836SCédric Le Goater 76143b040fSPatrick Williams /* Sonorapass hardware value: 0xF100D216 */ 77143b040fSPatrick Williams #define SONORAPASS_BMC_HW_STRAP1 ( \ 78143b040fSPatrick Williams SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \ 79143b040fSPatrick Williams SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \ 80143b040fSPatrick Williams SCU_AST2500_HW_STRAP_UART_DEBUG | \ 81143b040fSPatrick Williams SCU_AST2500_HW_STRAP_RESERVED28 | \ 82143b040fSPatrick Williams SCU_AST2500_HW_STRAP_DDR4_ENABLE | \ 83143b040fSPatrick Williams SCU_HW_STRAP_VGA_CLASS_CODE | \ 84143b040fSPatrick Williams SCU_HW_STRAP_LPC_RESET_PIN | \ 85143b040fSPatrick Williams SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER) | \ 86143b040fSPatrick Williams SCU_AST2500_HW_STRAP_SET_AXI_AHB_RATIO(AXI_AHB_RATIO_2_1) | \ 87143b040fSPatrick Williams SCU_HW_STRAP_VGA_BIOS_ROM | \ 88143b040fSPatrick Williams SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) | \ 89143b040fSPatrick Williams SCU_AST2500_HW_STRAP_RESERVED1) 90143b040fSPatrick Williams 91aae7a18dSAdriana Kobylak /* Swift hardware value: 0xF11AD206 */ 92aae7a18dSAdriana Kobylak #define SWIFT_BMC_HW_STRAP1 ( \ 93aae7a18dSAdriana Kobylak AST2500_HW_STRAP1_DEFAULTS | \ 94aae7a18dSAdriana Kobylak SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \ 95aae7a18dSAdriana Kobylak SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \ 96aae7a18dSAdriana Kobylak SCU_AST2500_HW_STRAP_UART_DEBUG | \ 97aae7a18dSAdriana Kobylak SCU_AST2500_HW_STRAP_DDR4_ENABLE | \ 98aae7a18dSAdriana Kobylak SCU_H_PLL_BYPASS_EN | \ 99aae7a18dSAdriana Kobylak SCU_AST2500_HW_STRAP_ACPI_ENABLE | \ 100aae7a18dSAdriana Kobylak SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER)) 101aae7a18dSAdriana Kobylak 10262c2c2ebSCédric Le Goater /* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */ 10362c2c2ebSCédric Le Goater #define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1 10462c2c2ebSCédric Le Goater 105ccc2c418SCédric Le Goater /* AST2600 evb hardware value */ 106ccc2c418SCédric Le Goater #define AST2600_EVB_HW_STRAP1 0x000000C0 107ccc2c418SCédric Le Goater #define AST2600_EVB_HW_STRAP2 0x00000003 108ccc2c418SCédric Le Goater 10963ceb818SCédric Le Goater /* Tacoma hardware value */ 11063ceb818SCédric Le Goater #define TACOMA_BMC_HW_STRAP1 0x00000000 1117582591aSJoel Stanley #define TACOMA_BMC_HW_STRAP2 0x00000040 11263ceb818SCédric Le Goater 113ebe31c0aSCédric Le Goater /* 114ebe31c0aSCédric Le Goater * The max ram region is for firmwares that scan the address space 115ebe31c0aSCédric Le Goater * with load/store to guess how much RAM the SoC has. 116ebe31c0aSCédric Le Goater */ 117ebe31c0aSCédric Le Goater static uint64_t max_ram_read(void *opaque, hwaddr offset, unsigned size) 118ebe31c0aSCédric Le Goater { 119ebe31c0aSCédric Le Goater return 0; 120ebe31c0aSCédric Le Goater } 121ebe31c0aSCédric Le Goater 122ebe31c0aSCédric Le Goater static void max_ram_write(void *opaque, hwaddr offset, uint64_t value, 123ebe31c0aSCédric Le Goater unsigned size) 124ebe31c0aSCédric Le Goater { 125ebe31c0aSCédric Le Goater /* Discard writes */ 126ebe31c0aSCédric Le Goater } 127ebe31c0aSCédric Le Goater 128ebe31c0aSCédric Le Goater static const MemoryRegionOps max_ram_ops = { 129ebe31c0aSCédric Le Goater .read = max_ram_read, 130ebe31c0aSCédric Le Goater .write = max_ram_write, 131ebe31c0aSCédric Le Goater .endianness = DEVICE_NATIVE_ENDIAN, 132ebe31c0aSCédric Le Goater }; 133ebe31c0aSCédric Le Goater 1349bb6d140SJoel Stanley #define AST_SMP_MAILBOX_BASE 0x1e6e2180 1359bb6d140SJoel Stanley #define AST_SMP_MBOX_FIELD_ENTRY (AST_SMP_MAILBOX_BASE + 0x0) 1369bb6d140SJoel Stanley #define AST_SMP_MBOX_FIELD_GOSIGN (AST_SMP_MAILBOX_BASE + 0x4) 1379bb6d140SJoel Stanley #define AST_SMP_MBOX_FIELD_READY (AST_SMP_MAILBOX_BASE + 0x8) 1389bb6d140SJoel Stanley #define AST_SMP_MBOX_FIELD_POLLINSN (AST_SMP_MAILBOX_BASE + 0xc) 1399bb6d140SJoel Stanley #define AST_SMP_MBOX_CODE (AST_SMP_MAILBOX_BASE + 0x10) 1409bb6d140SJoel Stanley #define AST_SMP_MBOX_GOSIGN 0xabbaab00 1419bb6d140SJoel Stanley 1429bb6d140SJoel Stanley static void aspeed_write_smpboot(ARMCPU *cpu, 1439bb6d140SJoel Stanley const struct arm_boot_info *info) 1449bb6d140SJoel Stanley { 1459bb6d140SJoel Stanley static const uint32_t poll_mailbox_ready[] = { 1469bb6d140SJoel Stanley /* 1479bb6d140SJoel Stanley * r2 = per-cpu go sign value 1489bb6d140SJoel Stanley * r1 = AST_SMP_MBOX_FIELD_ENTRY 1499bb6d140SJoel Stanley * r0 = AST_SMP_MBOX_FIELD_GOSIGN 1509bb6d140SJoel Stanley */ 1519bb6d140SJoel Stanley 0xee100fb0, /* mrc p15, 0, r0, c0, c0, 5 */ 1529bb6d140SJoel Stanley 0xe21000ff, /* ands r0, r0, #255 */ 1539bb6d140SJoel Stanley 0xe59f201c, /* ldr r2, [pc, #28] */ 1549bb6d140SJoel Stanley 0xe1822000, /* orr r2, r2, r0 */ 1559bb6d140SJoel Stanley 1569bb6d140SJoel Stanley 0xe59f1018, /* ldr r1, [pc, #24] */ 1579bb6d140SJoel Stanley 0xe59f0018, /* ldr r0, [pc, #24] */ 1589bb6d140SJoel Stanley 1599bb6d140SJoel Stanley 0xe320f002, /* wfe */ 1609bb6d140SJoel Stanley 0xe5904000, /* ldr r4, [r0] */ 1619bb6d140SJoel Stanley 0xe1520004, /* cmp r2, r4 */ 1629bb6d140SJoel Stanley 0x1afffffb, /* bne <wfe> */ 1639bb6d140SJoel Stanley 0xe591f000, /* ldr pc, [r1] */ 1649bb6d140SJoel Stanley AST_SMP_MBOX_GOSIGN, 1659bb6d140SJoel Stanley AST_SMP_MBOX_FIELD_ENTRY, 1669bb6d140SJoel Stanley AST_SMP_MBOX_FIELD_GOSIGN, 1679bb6d140SJoel Stanley }; 1689bb6d140SJoel Stanley 1699bb6d140SJoel Stanley rom_add_blob_fixed("aspeed.smpboot", poll_mailbox_ready, 1709bb6d140SJoel Stanley sizeof(poll_mailbox_ready), 1719bb6d140SJoel Stanley info->smp_loader_start); 1729bb6d140SJoel Stanley } 1739bb6d140SJoel Stanley 1749bb6d140SJoel Stanley static void aspeed_reset_secondary(ARMCPU *cpu, 1759bb6d140SJoel Stanley const struct arm_boot_info *info) 1769bb6d140SJoel Stanley { 1779bb6d140SJoel Stanley AddressSpace *as = arm_boot_address_space(cpu, info); 1789bb6d140SJoel Stanley CPUState *cs = CPU(cpu); 1799bb6d140SJoel Stanley 1809bb6d140SJoel Stanley /* info->smp_bootreg_addr */ 1819bb6d140SJoel Stanley address_space_stl_notdirty(as, AST_SMP_MBOX_FIELD_GOSIGN, 0, 1829bb6d140SJoel Stanley MEMTXATTRS_UNSPECIFIED, NULL); 1839bb6d140SJoel Stanley cpu_set_pc(cs, info->smp_loader_start); 1849bb6d140SJoel Stanley } 1859bb6d140SJoel Stanley 186d769a1daSCédric Le Goater #define FIRMWARE_ADDR 0x0 187d769a1daSCédric Le Goater 188d769a1daSCédric Le Goater static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size, 189d769a1daSCédric Le Goater Error **errp) 190d769a1daSCédric Le Goater { 191d769a1daSCédric Le Goater BlockBackend *blk = blk_by_legacy_dinfo(dinfo); 192d769a1daSCédric Le Goater uint8_t *storage; 1930c7209beSCédric Le Goater int64_t size; 194d769a1daSCédric Le Goater 1950c7209beSCédric Le Goater /* The block backend size should have already been 'validated' by 1960c7209beSCédric Le Goater * the creation of the m25p80 object. 1970c7209beSCédric Le Goater */ 1980c7209beSCédric Le Goater size = blk_getlength(blk); 1990c7209beSCédric Le Goater if (size <= 0) { 2000c7209beSCédric Le Goater error_setg(errp, "failed to get flash size"); 2010c7209beSCédric Le Goater return; 2020c7209beSCédric Le Goater } 2030c7209beSCédric Le Goater 2040c7209beSCédric Le Goater if (rom_size > size) { 2050c7209beSCédric Le Goater rom_size = size; 206d769a1daSCédric Le Goater } 207d769a1daSCédric Le Goater 208d769a1daSCédric Le Goater storage = g_new0(uint8_t, rom_size); 209d769a1daSCédric Le Goater if (blk_pread(blk, 0, storage, rom_size) < 0) { 210d769a1daSCédric Le Goater error_setg(errp, "failed to read the initial flash content"); 211d769a1daSCédric Le Goater return; 212d769a1daSCédric Le Goater } 213d769a1daSCédric Le Goater 214d769a1daSCédric Le Goater rom_add_blob_fixed("aspeed.boot_rom", storage, rom_size, addr); 215d769a1daSCédric Le Goater g_free(storage); 216d769a1daSCédric Le Goater } 217d769a1daSCédric Le Goater 21874fb1f38SCédric Le Goater static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, 219e1ad9bc4SCédric Le Goater Error **errp) 220e1ad9bc4SCédric Le Goater { 221e1ad9bc4SCédric Le Goater int i ; 222e1ad9bc4SCédric Le Goater 223e1ad9bc4SCédric Le Goater for (i = 0; i < s->num_cs; ++i) { 224e1ad9bc4SCédric Le Goater AspeedSMCFlash *fl = &s->flashes[i]; 225e1ad9bc4SCédric Le Goater DriveInfo *dinfo = drive_get_next(IF_MTD); 226e1ad9bc4SCédric Le Goater qemu_irq cs_line; 227e1ad9bc4SCédric Le Goater 228e1ad9bc4SCédric Le Goater fl->flash = ssi_create_slave_no_init(s->spi, flashtype); 229e1ad9bc4SCédric Le Goater if (dinfo) { 230e1ad9bc4SCédric Le Goater qdev_prop_set_drive(fl->flash, "drive", blk_by_legacy_dinfo(dinfo), 231e1ad9bc4SCédric Le Goater errp); 232e1ad9bc4SCédric Le Goater } 233e1ad9bc4SCédric Le Goater qdev_init_nofail(fl->flash); 234e1ad9bc4SCédric Le Goater 235e1ad9bc4SCédric Le Goater cs_line = qdev_get_gpio_in_named(fl->flash, SSI_GPIO_CS, 0); 236e1ad9bc4SCédric Le Goater sysbus_connect_irq(SYS_BUS_DEVICE(s), i + 1, cs_line); 237e1ad9bc4SCédric Le Goater } 238e1ad9bc4SCédric Le Goater } 239e1ad9bc4SCédric Le Goater 240a29e3e12SAndrew Jeffery static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo) 241a29e3e12SAndrew Jeffery { 242a29e3e12SAndrew Jeffery DeviceState *card; 243a29e3e12SAndrew Jeffery 244a29e3e12SAndrew Jeffery card = qdev_create(qdev_get_child_bus(DEVICE(sdhci), "sd-bus"), 245a29e3e12SAndrew Jeffery TYPE_SD_CARD); 246a29e3e12SAndrew Jeffery if (dinfo) { 247a29e3e12SAndrew Jeffery qdev_prop_set_drive(card, "drive", blk_by_legacy_dinfo(dinfo), 248a29e3e12SAndrew Jeffery &error_fatal); 249a29e3e12SAndrew Jeffery } 250a29e3e12SAndrew Jeffery object_property_set_bool(OBJECT(card), true, "realized", &error_fatal); 251a29e3e12SAndrew Jeffery } 252a29e3e12SAndrew Jeffery 253baa4732bSCédric Le Goater static void aspeed_machine_init(MachineState *machine) 254327d8e4eSAndrew Jeffery { 25574fb1f38SCédric Le Goater AspeedBoardState *bmc; 256baa4732bSCédric Le Goater AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(machine); 257b033271fSCédric Le Goater AspeedSoCClass *sc; 258d769a1daSCédric Le Goater DriveInfo *drive0 = drive_get(IF_MTD, 0, 0); 259ebe31c0aSCédric Le Goater ram_addr_t max_ram_size; 2602bea128cSEddie James int i; 261327d8e4eSAndrew Jeffery 26274fb1f38SCédric Le Goater bmc = g_new0(AspeedBoardState, 1); 263ad1a9782SCédric Le Goater 264ad1a9782SCédric Le Goater memory_region_init(&bmc->ram_container, NULL, "aspeed-ram-container", 2657df9f028SPhilippe Mathieu-Daudé 4 * GiB); 266afcbaed6SIgor Mammedov memory_region_add_subregion(&bmc->ram_container, 0, machine->ram); 267ad1a9782SCédric Le Goater 2681b0ad567SPhilippe Mathieu-Daudé object_initialize_child(OBJECT(machine), "soc", &bmc->soc, 269baa4732bSCédric Le Goater (sizeof(bmc->soc)), amc->soc_name, &error_abort, 2701b0ad567SPhilippe Mathieu-Daudé NULL); 271327d8e4eSAndrew Jeffery 272b033271fSCédric Le Goater sc = ASPEED_SOC_GET_CLASS(&bmc->soc); 273b033271fSCédric Le Goater 274533eb415SIgor Mammedov /* 275533eb415SIgor Mammedov * This will error out if isize is not supported by memory controller. 276533eb415SIgor Mammedov */ 27719e9cdf0SMarc-André Lureau object_property_set_uint(OBJECT(&bmc->soc), ram_size, "ram-size", 278533eb415SIgor Mammedov &error_fatal); 279533eb415SIgor Mammedov 280baa4732bSCédric Le Goater object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap1, "hw-strap1", 28187e79af0SAndrew Jeffery &error_abort); 282baa4732bSCédric Le Goater object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap2, "hw-strap2", 283ccc2c418SCédric Le Goater &error_abort); 284baa4732bSCédric Le Goater object_property_set_int(OBJECT(&bmc->soc), amc->num_cs, "num-cs", 28526d5df95SCédric Le Goater &error_abort); 286c4e1f0b4SCédric Le Goater object_property_set_link(OBJECT(&bmc->soc), OBJECT(&bmc->ram_container), 287c4e1f0b4SCédric Le Goater "dram", &error_abort); 288b6e70d1dSJoel Stanley if (machine->kernel_filename) { 289b6e70d1dSJoel Stanley /* 290b6e70d1dSJoel Stanley * When booting with a -kernel command line there is no u-boot 291b6e70d1dSJoel Stanley * that runs to unlock the SCU. In this case set the default to 292b6e70d1dSJoel Stanley * be unlocked as the kernel expects 293b6e70d1dSJoel Stanley */ 294b6e70d1dSJoel Stanley object_property_set_int(OBJECT(&bmc->soc), ASPEED_SCU_PROT_KEY, 295b6e70d1dSJoel Stanley "hw-prot-key", &error_abort); 296b6e70d1dSJoel Stanley } 297327d8e4eSAndrew Jeffery object_property_set_bool(OBJECT(&bmc->soc), true, "realized", 298327d8e4eSAndrew Jeffery &error_abort); 299327d8e4eSAndrew Jeffery 300d783d1feSCédric Le Goater memory_region_add_subregion(get_system_memory(), 30154ecafb7SCédric Le Goater sc->memmap[ASPEED_SDRAM], 302ad1a9782SCédric Le Goater &bmc->ram_container); 303de46f5f4SCédric Le Goater 304ebe31c0aSCédric Le Goater max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size", 305ebe31c0aSCédric Le Goater &error_abort); 306ebe31c0aSCédric Le Goater memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL, 307ebe31c0aSCédric Le Goater "max_ram", max_ram_size - ram_size); 308ad1a9782SCédric Le Goater memory_region_add_subregion(&bmc->ram_container, ram_size, &bmc->max_ram); 309ebe31c0aSCédric Le Goater 310baa4732bSCédric Le Goater aspeed_board_init_flashes(&bmc->soc.fmc, amc->fmc_model, &error_abort); 311baa4732bSCédric Le Goater aspeed_board_init_flashes(&bmc->soc.spi[0], amc->spi_model, &error_abort); 312e1ad9bc4SCédric Le Goater 313d769a1daSCédric Le Goater /* Install first FMC flash content as a boot rom. */ 314d769a1daSCédric Le Goater if (drive0) { 315d769a1daSCédric Le Goater AspeedSMCFlash *fl = &bmc->soc.fmc.flashes[0]; 316d769a1daSCédric Le Goater MemoryRegion *boot_rom = g_new(MemoryRegion, 1); 317d769a1daSCédric Le Goater 318d769a1daSCédric Le Goater /* 319d769a1daSCédric Le Goater * create a ROM region using the default mapping window size of 32093bf276dSCédric Le Goater * the flash module. The window size is 64MB for the AST2400 32193bf276dSCédric Le Goater * SoC and 128MB for the AST2500 SoC, which is twice as big as 32293bf276dSCédric Le Goater * needed by the flash modules of the Aspeed machines. 323d769a1daSCédric Le Goater */ 3241a15311aSCédric Le Goater if (ASPEED_MACHINE(machine)->mmio_exec) { 3251a15311aSCédric Le Goater memory_region_init_alias(boot_rom, OBJECT(bmc), "aspeed.boot_rom", 3261a15311aSCédric Le Goater &fl->mmio, 0, fl->size); 3271a15311aSCédric Le Goater memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR, 3281a15311aSCédric Le Goater boot_rom); 3291a15311aSCédric Le Goater } else { 33044cf837dSPeter Maydell memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom", 331d769a1daSCédric Le Goater fl->size, &error_abort); 332d769a1daSCédric Le Goater memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR, 333d769a1daSCédric Le Goater boot_rom); 334d769a1daSCédric Le Goater write_boot_rom(drive0, FIRMWARE_ADDR, fl->size, &error_abort); 335d769a1daSCédric Le Goater } 3361a15311aSCédric Le Goater } 337d769a1daSCédric Le Goater 338*b7f1a0cbSCédric Le Goater if (machine->kernel_filename && sc->num_cpus > 1) { 3399bb6d140SJoel Stanley /* With no u-boot we must set up a boot stub for the secondary CPU */ 3409bb6d140SJoel Stanley MemoryRegion *smpboot = g_new(MemoryRegion, 1); 3419bb6d140SJoel Stanley memory_region_init_ram(smpboot, OBJECT(bmc), "aspeed.smpboot", 3429bb6d140SJoel Stanley 0x80, &error_abort); 3439bb6d140SJoel Stanley memory_region_add_subregion(get_system_memory(), 3449bb6d140SJoel Stanley AST_SMP_MAILBOX_BASE, smpboot); 3459bb6d140SJoel Stanley 3469bb6d140SJoel Stanley aspeed_board_binfo.write_secondary_boot = aspeed_write_smpboot; 3479bb6d140SJoel Stanley aspeed_board_binfo.secondary_cpu_reset_hook = aspeed_reset_secondary; 3489bb6d140SJoel Stanley aspeed_board_binfo.smp_loader_start = AST_SMP_MBOX_CODE; 3499bb6d140SJoel Stanley } 3509bb6d140SJoel Stanley 35174fb1f38SCédric Le Goater aspeed_board_binfo.ram_size = ram_size; 35254ecafb7SCédric Le Goater aspeed_board_binfo.loader_start = sc->memmap[ASPEED_SDRAM]; 353*b7f1a0cbSCédric Le Goater aspeed_board_binfo.nb_cpus = sc->num_cpus; 354b033271fSCédric Le Goater 355baa4732bSCédric Le Goater if (amc->i2c_init) { 356baa4732bSCédric Le Goater amc->i2c_init(bmc); 3572cf6cb50SCédric Le Goater } 3582cf6cb50SCédric Le Goater 3590e2c24c6SAndrew Jeffery for (i = 0; i < bmc->soc.sdhci.num_slots; i++) { 360a29e3e12SAndrew Jeffery sdhci_attach_drive(&bmc->soc.sdhci.slots[i], drive_get_next(IF_SD)); 361a29e3e12SAndrew Jeffery } 3622bea128cSEddie James 363a29e3e12SAndrew Jeffery if (bmc->soc.emmc.num_slots) { 364a29e3e12SAndrew Jeffery sdhci_attach_drive(&bmc->soc.emmc.slots[0], drive_get_next(IF_SD)); 3652bea128cSEddie James } 3662bea128cSEddie James 3672744ece8STao Xu arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo); 368327d8e4eSAndrew Jeffery } 369327d8e4eSAndrew Jeffery 3702cf6cb50SCédric Le Goater static void palmetto_bmc_i2c_init(AspeedBoardState *bmc) 3712cf6cb50SCédric Le Goater { 3722cf6cb50SCédric Le Goater AspeedSoCState *soc = &bmc->soc; 373a87e81b9SCédric Le Goater DeviceState *dev; 3743d165f12SCédric Le Goater uint8_t *eeprom_buf = g_malloc0(32 * 1024); 3752cf6cb50SCédric Le Goater 3762cf6cb50SCédric Le Goater /* The palmetto platform expects a ds3231 RTC but a ds1338 is 3772cf6cb50SCédric Le Goater * enough to provide basic RTC features. Alarms will be missing */ 3782cf6cb50SCédric Le Goater i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68); 379a87e81b9SCédric Le Goater 3803d165f12SCédric Le Goater smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50, 3813d165f12SCédric Le Goater eeprom_buf); 3823d165f12SCédric Le Goater 383a87e81b9SCédric Le Goater /* add a TMP423 temperature sensor */ 384a87e81b9SCédric Le Goater dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), 385a87e81b9SCédric Le Goater "tmp423", 0x4c); 386a87e81b9SCédric Le Goater object_property_set_int(OBJECT(dev), 31000, "temperature0", &error_abort); 387a87e81b9SCédric Le Goater object_property_set_int(OBJECT(dev), 28000, "temperature1", &error_abort); 388a87e81b9SCédric Le Goater object_property_set_int(OBJECT(dev), 20000, "temperature2", &error_abort); 389a87e81b9SCédric Le Goater object_property_set_int(OBJECT(dev), 110000, "temperature3", &error_abort); 3902cf6cb50SCédric Le Goater } 3912cf6cb50SCédric Le Goater 3922cf6cb50SCédric Le Goater static void ast2500_evb_i2c_init(AspeedBoardState *bmc) 3932cf6cb50SCédric Le Goater { 3942cf6cb50SCédric Le Goater AspeedSoCState *soc = &bmc->soc; 3953d165f12SCédric Le Goater uint8_t *eeprom_buf = g_malloc0(8 * 1024); 3963d165f12SCédric Le Goater 3973d165f12SCédric Le Goater smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50, 3983d165f12SCédric Le Goater eeprom_buf); 3992cf6cb50SCédric Le Goater 4002cf6cb50SCédric Le Goater /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ 401044475f3SPhilippe Mathieu-Daudé i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), 402044475f3SPhilippe Mathieu-Daudé TYPE_TMP105, 0x4d); 4036c4567c7SCédric Le Goater 4046c4567c7SCédric Le Goater /* The AST2500 EVB does not have an RTC. Let's pretend that one is 4056c4567c7SCédric Le Goater * plugged on the I2C bus header */ 4066c4567c7SCédric Le Goater i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); 4072cf6cb50SCédric Le Goater } 4082cf6cb50SCédric Le Goater 409ccc2c418SCédric Le Goater static void ast2600_evb_i2c_init(AspeedBoardState *bmc) 410ccc2c418SCédric Le Goater { 411ccc2c418SCédric Le Goater /* Start with some devices on our I2C busses */ 412ccc2c418SCédric Le Goater ast2500_evb_i2c_init(bmc); 413ccc2c418SCédric Le Goater } 414ccc2c418SCédric Le Goater 4156c4567c7SCédric Le Goater static void romulus_bmc_i2c_init(AspeedBoardState *bmc) 4166c4567c7SCédric Le Goater { 4176c4567c7SCédric Le Goater AspeedSoCState *soc = &bmc->soc; 4186c4567c7SCédric Le Goater 4196c4567c7SCédric Le Goater /* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is 4206c4567c7SCédric Le Goater * good enough */ 4216c4567c7SCédric Le Goater i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); 4226c4567c7SCédric Le Goater } 4236c4567c7SCédric Le Goater 424aae7a18dSAdriana Kobylak static void swift_bmc_i2c_init(AspeedBoardState *bmc) 425aae7a18dSAdriana Kobylak { 426aae7a18dSAdriana Kobylak AspeedSoCState *soc = &bmc->soc; 427aae7a18dSAdriana Kobylak 428aae7a18dSAdriana Kobylak i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60); 429aae7a18dSAdriana Kobylak 430aae7a18dSAdriana Kobylak /* The swift board expects a TMP275 but a TMP105 is compatible */ 431aae7a18dSAdriana Kobylak i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x48); 432aae7a18dSAdriana Kobylak /* The swift board expects a pca9551 but a pca9552 is compatible */ 433aae7a18dSAdriana Kobylak i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "pca9552", 0x60); 434aae7a18dSAdriana Kobylak 435aae7a18dSAdriana Kobylak /* The swift board expects an Epson RX8900 RTC but a ds1338 is compatible */ 436aae7a18dSAdriana Kobylak i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "ds1338", 0x32); 437aae7a18dSAdriana Kobylak i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60); 438aae7a18dSAdriana Kobylak 439aae7a18dSAdriana Kobylak i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp423", 0x4c); 440aae7a18dSAdriana Kobylak /* The swift board expects a pca9539 but a pca9552 is compatible */ 441aae7a18dSAdriana Kobylak i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "pca9552", 0x74); 442aae7a18dSAdriana Kobylak 443aae7a18dSAdriana Kobylak i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "tmp423", 0x4c); 444aae7a18dSAdriana Kobylak /* The swift board expects a pca9539 but a pca9552 is compatible */ 445aae7a18dSAdriana Kobylak i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "pca9552", 446aae7a18dSAdriana Kobylak 0x74); 447aae7a18dSAdriana Kobylak 448aae7a18dSAdriana Kobylak /* The swift board expects a TMP275 but a TMP105 is compatible */ 449aae7a18dSAdriana Kobylak i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x48); 450aae7a18dSAdriana Kobylak i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x4a); 451aae7a18dSAdriana Kobylak } 452aae7a18dSAdriana Kobylak 453143b040fSPatrick Williams static void sonorapass_bmc_i2c_init(AspeedBoardState *bmc) 454143b040fSPatrick Williams { 455143b040fSPatrick Williams AspeedSoCState *soc = &bmc->soc; 456143b040fSPatrick Williams 457143b040fSPatrick Williams /* bus 2 : */ 458143b040fSPatrick Williams i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), "tmp105", 0x48); 459143b040fSPatrick Williams i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), "tmp105", 0x49); 460143b040fSPatrick Williams /* bus 2 : pca9546 @ 0x73 */ 461143b040fSPatrick Williams 462143b040fSPatrick Williams /* bus 3 : pca9548 @ 0x70 */ 463143b040fSPatrick Williams 464143b040fSPatrick Williams /* bus 4 : */ 465143b040fSPatrick Williams uint8_t *eeprom4_54 = g_malloc0(8 * 1024); 466143b040fSPatrick Williams smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), 0x54, 467143b040fSPatrick Williams eeprom4_54); 468143b040fSPatrick Williams /* PCA9539 @ 0x76, but PCA9552 is compatible */ 469143b040fSPatrick Williams i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "pca9552", 0x76); 470143b040fSPatrick Williams /* PCA9539 @ 0x77, but PCA9552 is compatible */ 471143b040fSPatrick Williams i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "pca9552", 0x77); 472143b040fSPatrick Williams 473143b040fSPatrick Williams /* bus 6 : */ 474143b040fSPatrick Williams i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 6), "tmp105", 0x48); 475143b040fSPatrick Williams i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 6), "tmp105", 0x49); 476143b040fSPatrick Williams /* bus 6 : pca9546 @ 0x73 */ 477143b040fSPatrick Williams 478143b040fSPatrick Williams /* bus 8 : */ 479143b040fSPatrick Williams uint8_t *eeprom8_56 = g_malloc0(8 * 1024); 480143b040fSPatrick Williams smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), 0x56, 481143b040fSPatrick Williams eeprom8_56); 482143b040fSPatrick Williams i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60); 483143b040fSPatrick Williams i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x61); 484143b040fSPatrick Williams /* bus 8 : adc128d818 @ 0x1d */ 485143b040fSPatrick Williams /* bus 8 : adc128d818 @ 0x1f */ 486143b040fSPatrick Williams 487143b040fSPatrick Williams /* 488143b040fSPatrick Williams * bus 13 : pca9548 @ 0x71 489143b040fSPatrick Williams * - channel 3: 490143b040fSPatrick Williams * - tmm421 @ 0x4c 491143b040fSPatrick Williams * - tmp421 @ 0x4e 492143b040fSPatrick Williams * - tmp421 @ 0x4f 493143b040fSPatrick Williams */ 494143b040fSPatrick Williams 495143b040fSPatrick Williams } 496143b040fSPatrick Williams 49762c2c2ebSCédric Le Goater static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) 49862c2c2ebSCédric Le Goater { 49962c2c2ebSCédric Le Goater AspeedSoCState *soc = &bmc->soc; 5003d165f12SCédric Le Goater uint8_t *eeprom_buf = g_malloc0(8 * 1024); 50162c2c2ebSCédric Le Goater 50263ceb818SCédric Le Goater /* Bus 3: TODO bmp280@77 */ 50363ceb818SCédric Le Goater /* Bus 3: TODO max31785@52 */ 50463ceb818SCédric Le Goater /* Bus 3: TODO dps310@76 */ 505044475f3SPhilippe Mathieu-Daudé i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), TYPE_PCA9552, 506044475f3SPhilippe Mathieu-Daudé 0x60); 5078c9a61d7SCédric Le Goater 50862c2c2ebSCédric Le Goater i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c); 50962c2c2ebSCédric Le Goater i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c); 51062c2c2ebSCédric Le Goater 51162c2c2ebSCédric Le Goater /* The Witherspoon expects a TMP275 but a TMP105 is compatible */ 512044475f3SPhilippe Mathieu-Daudé i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), TYPE_TMP105, 513044475f3SPhilippe Mathieu-Daudé 0x4a); 5146c4567c7SCédric Le Goater 5156c4567c7SCédric Le Goater /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is 5166c4567c7SCédric Le Goater * good enough */ 5176c4567c7SCédric Le Goater i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); 5183d165f12SCédric Le Goater 5193d165f12SCédric Le Goater smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51, 5203d165f12SCédric Le Goater eeprom_buf); 521044475f3SPhilippe Mathieu-Daudé i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), TYPE_PCA9552, 5228c9a61d7SCédric Le Goater 0x60); 52363ceb818SCédric Le Goater /* Bus 11: TODO ucd90160@64 */ 52462c2c2ebSCédric Le Goater } 52562c2c2ebSCédric Le Goater 5261a15311aSCédric Le Goater static bool aspeed_get_mmio_exec(Object *obj, Error **errp) 5271a15311aSCédric Le Goater { 5281a15311aSCédric Le Goater return ASPEED_MACHINE(obj)->mmio_exec; 5291a15311aSCédric Le Goater } 5301a15311aSCédric Le Goater 5311a15311aSCédric Le Goater static void aspeed_set_mmio_exec(Object *obj, bool value, Error **errp) 5321a15311aSCédric Le Goater { 5331a15311aSCédric Le Goater ASPEED_MACHINE(obj)->mmio_exec = value; 5341a15311aSCédric Le Goater } 5351a15311aSCédric Le Goater 5361a15311aSCédric Le Goater static void aspeed_machine_instance_init(Object *obj) 5371a15311aSCédric Le Goater { 5381a15311aSCédric Le Goater ASPEED_MACHINE(obj)->mmio_exec = false; 5391a15311aSCédric Le Goater } 5401a15311aSCédric Le Goater 5411a15311aSCédric Le Goater static void aspeed_machine_class_props_init(ObjectClass *oc) 5421a15311aSCédric Le Goater { 5431a15311aSCédric Le Goater object_class_property_add_bool(oc, "execute-in-place", 5441a15311aSCédric Le Goater aspeed_get_mmio_exec, 545d2623129SMarkus Armbruster aspeed_set_mmio_exec); 5461a15311aSCédric Le Goater object_class_property_set_description(oc, "execute-in-place", 5477eecec7dSMarkus Armbruster "boot directly from CE0 flash device"); 5481a15311aSCédric Le Goater } 5491a15311aSCédric Le Goater 550*b7f1a0cbSCédric Le Goater static int aspeed_soc_num_cpus(const char *soc_name) 551*b7f1a0cbSCédric Le Goater { 552*b7f1a0cbSCédric Le Goater AspeedSoCClass *sc = ASPEED_SOC_CLASS(object_class_by_name(soc_name)); 553*b7f1a0cbSCédric Le Goater return sc->num_cpus; 554*b7f1a0cbSCédric Le Goater } 555*b7f1a0cbSCédric Le Goater 556fca9ca1bSCédric Le Goater static void aspeed_machine_class_init(ObjectClass *oc, void *data) 55762c2c2ebSCédric Le Goater { 55862c2c2ebSCédric Le Goater MachineClass *mc = MACHINE_CLASS(oc); 55962c2c2ebSCédric Le Goater 560fca9ca1bSCédric Le Goater mc->init = aspeed_machine_init; 56162c2c2ebSCédric Le Goater mc->no_floppy = 1; 56262c2c2ebSCédric Le Goater mc->no_cdrom = 1; 56362c2c2ebSCédric Le Goater mc->no_parallel = 1; 564afcbaed6SIgor Mammedov mc->default_ram_id = "ram"; 5651a15311aSCédric Le Goater 5661a15311aSCédric Le Goater aspeed_machine_class_props_init(oc); 56762c2c2ebSCédric Le Goater } 56862c2c2ebSCédric Le Goater 569baa4732bSCédric Le Goater static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data) 570baa4732bSCédric Le Goater { 571baa4732bSCédric Le Goater MachineClass *mc = MACHINE_CLASS(oc); 572baa4732bSCédric Le Goater AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); 573baa4732bSCédric Le Goater 574baa4732bSCédric Le Goater mc->desc = "OpenPOWER Palmetto BMC (ARM926EJ-S)"; 575baa4732bSCédric Le Goater amc->soc_name = "ast2400-a1"; 576baa4732bSCédric Le Goater amc->hw_strap1 = PALMETTO_BMC_HW_STRAP1; 577baa4732bSCédric Le Goater amc->fmc_model = "n25q256a"; 578baa4732bSCédric Le Goater amc->spi_model = "mx25l25635e"; 579baa4732bSCédric Le Goater amc->num_cs = 1; 580baa4732bSCédric Le Goater amc->i2c_init = palmetto_bmc_i2c_init; 581baa4732bSCédric Le Goater mc->default_ram_size = 256 * MiB; 582*b7f1a0cbSCédric Le Goater mc->default_cpus = mc->min_cpus = mc->max_cpus = 583*b7f1a0cbSCédric Le Goater aspeed_soc_num_cpus(amc->soc_name); 584baa4732bSCédric Le Goater }; 585baa4732bSCédric Le Goater 586baa4732bSCédric Le Goater static void aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data) 587baa4732bSCédric Le Goater { 588baa4732bSCédric Le Goater MachineClass *mc = MACHINE_CLASS(oc); 589baa4732bSCédric Le Goater AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); 590baa4732bSCédric Le Goater 591baa4732bSCédric Le Goater mc->desc = "Aspeed AST2500 EVB (ARM1176)"; 592baa4732bSCédric Le Goater amc->soc_name = "ast2500-a1"; 593baa4732bSCédric Le Goater amc->hw_strap1 = AST2500_EVB_HW_STRAP1; 594baa4732bSCédric Le Goater amc->fmc_model = "w25q256"; 595baa4732bSCédric Le Goater amc->spi_model = "mx25l25635e"; 596baa4732bSCédric Le Goater amc->num_cs = 1; 597baa4732bSCédric Le Goater amc->i2c_init = ast2500_evb_i2c_init; 598baa4732bSCédric Le Goater mc->default_ram_size = 512 * MiB; 599*b7f1a0cbSCédric Le Goater mc->default_cpus = mc->min_cpus = mc->max_cpus = 600*b7f1a0cbSCédric Le Goater aspeed_soc_num_cpus(amc->soc_name); 601baa4732bSCédric Le Goater }; 602baa4732bSCédric Le Goater 603baa4732bSCédric Le Goater static void aspeed_machine_romulus_class_init(ObjectClass *oc, void *data) 604baa4732bSCédric Le Goater { 605baa4732bSCédric Le Goater MachineClass *mc = MACHINE_CLASS(oc); 606baa4732bSCédric Le Goater AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); 607baa4732bSCédric Le Goater 608baa4732bSCédric Le Goater mc->desc = "OpenPOWER Romulus BMC (ARM1176)"; 609baa4732bSCédric Le Goater amc->soc_name = "ast2500-a1"; 610baa4732bSCédric Le Goater amc->hw_strap1 = ROMULUS_BMC_HW_STRAP1; 611baa4732bSCédric Le Goater amc->fmc_model = "n25q256a"; 612baa4732bSCédric Le Goater amc->spi_model = "mx66l1g45g"; 613baa4732bSCédric Le Goater amc->num_cs = 2; 614baa4732bSCédric Le Goater amc->i2c_init = romulus_bmc_i2c_init; 615baa4732bSCédric Le Goater mc->default_ram_size = 512 * MiB; 616*b7f1a0cbSCédric Le Goater mc->default_cpus = mc->min_cpus = mc->max_cpus = 617*b7f1a0cbSCédric Le Goater aspeed_soc_num_cpus(amc->soc_name); 618baa4732bSCédric Le Goater }; 619baa4732bSCédric Le Goater 620143b040fSPatrick Williams static void aspeed_machine_sonorapass_class_init(ObjectClass *oc, void *data) 621143b040fSPatrick Williams { 622143b040fSPatrick Williams MachineClass *mc = MACHINE_CLASS(oc); 623143b040fSPatrick Williams AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); 624143b040fSPatrick Williams 625143b040fSPatrick Williams mc->desc = "OCP SonoraPass BMC (ARM1176)"; 626143b040fSPatrick Williams amc->soc_name = "ast2500-a1"; 627143b040fSPatrick Williams amc->hw_strap1 = SONORAPASS_BMC_HW_STRAP1; 628143b040fSPatrick Williams amc->fmc_model = "mx66l1g45g"; 629143b040fSPatrick Williams amc->spi_model = "mx66l1g45g"; 630143b040fSPatrick Williams amc->num_cs = 2; 631143b040fSPatrick Williams amc->i2c_init = sonorapass_bmc_i2c_init; 632143b040fSPatrick Williams mc->default_ram_size = 512 * MiB; 633*b7f1a0cbSCédric Le Goater mc->default_cpus = mc->min_cpus = mc->max_cpus = 634*b7f1a0cbSCédric Le Goater aspeed_soc_num_cpus(amc->soc_name); 635143b040fSPatrick Williams }; 636143b040fSPatrick Williams 637baa4732bSCédric Le Goater static void aspeed_machine_swift_class_init(ObjectClass *oc, void *data) 638baa4732bSCédric Le Goater { 639baa4732bSCédric Le Goater MachineClass *mc = MACHINE_CLASS(oc); 640baa4732bSCédric Le Goater AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); 641baa4732bSCédric Le Goater 642baa4732bSCédric Le Goater mc->desc = "OpenPOWER Swift BMC (ARM1176)"; 643baa4732bSCédric Le Goater amc->soc_name = "ast2500-a1"; 644baa4732bSCédric Le Goater amc->hw_strap1 = SWIFT_BMC_HW_STRAP1; 645baa4732bSCédric Le Goater amc->fmc_model = "mx66l1g45g"; 646baa4732bSCédric Le Goater amc->spi_model = "mx66l1g45g"; 647baa4732bSCédric Le Goater amc->num_cs = 2; 648baa4732bSCédric Le Goater amc->i2c_init = swift_bmc_i2c_init; 649baa4732bSCédric Le Goater mc->default_ram_size = 512 * MiB; 650*b7f1a0cbSCédric Le Goater mc->default_cpus = mc->min_cpus = mc->max_cpus = 651*b7f1a0cbSCédric Le Goater aspeed_soc_num_cpus(amc->soc_name); 652baa4732bSCédric Le Goater }; 653baa4732bSCédric Le Goater 654baa4732bSCédric Le Goater static void aspeed_machine_witherspoon_class_init(ObjectClass *oc, void *data) 655baa4732bSCédric Le Goater { 656baa4732bSCédric Le Goater MachineClass *mc = MACHINE_CLASS(oc); 657baa4732bSCédric Le Goater AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); 658baa4732bSCédric Le Goater 659baa4732bSCédric Le Goater mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)"; 660baa4732bSCédric Le Goater amc->soc_name = "ast2500-a1"; 661baa4732bSCédric Le Goater amc->hw_strap1 = WITHERSPOON_BMC_HW_STRAP1; 662baa4732bSCédric Le Goater amc->fmc_model = "mx25l25635e"; 663baa4732bSCédric Le Goater amc->spi_model = "mx66l1g45g"; 664baa4732bSCédric Le Goater amc->num_cs = 2; 665baa4732bSCédric Le Goater amc->i2c_init = witherspoon_bmc_i2c_init; 666baa4732bSCédric Le Goater mc->default_ram_size = 512 * MiB; 667*b7f1a0cbSCédric Le Goater mc->default_cpus = mc->min_cpus = mc->max_cpus = 668*b7f1a0cbSCédric Le Goater aspeed_soc_num_cpus(amc->soc_name); 669baa4732bSCédric Le Goater }; 670baa4732bSCédric Le Goater 671baa4732bSCédric Le Goater static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data) 672baa4732bSCédric Le Goater { 673baa4732bSCédric Le Goater MachineClass *mc = MACHINE_CLASS(oc); 674baa4732bSCédric Le Goater AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); 675baa4732bSCédric Le Goater 676baa4732bSCédric Le Goater mc->desc = "Aspeed AST2600 EVB (Cortex A7)"; 6777582591aSJoel Stanley amc->soc_name = "ast2600-a1"; 678baa4732bSCédric Le Goater amc->hw_strap1 = AST2600_EVB_HW_STRAP1; 679baa4732bSCédric Le Goater amc->hw_strap2 = AST2600_EVB_HW_STRAP2; 680baa4732bSCédric Le Goater amc->fmc_model = "w25q512jv"; 681baa4732bSCédric Le Goater amc->spi_model = "mx66u51235f"; 682baa4732bSCédric Le Goater amc->num_cs = 1; 683baa4732bSCédric Le Goater amc->i2c_init = ast2600_evb_i2c_init; 684baa4732bSCédric Le Goater mc->default_ram_size = 1 * GiB; 685*b7f1a0cbSCédric Le Goater mc->default_cpus = mc->min_cpus = mc->max_cpus = 686*b7f1a0cbSCédric Le Goater aspeed_soc_num_cpus(amc->soc_name); 687baa4732bSCédric Le Goater }; 688baa4732bSCédric Le Goater 68963ceb818SCédric Le Goater static void aspeed_machine_tacoma_class_init(ObjectClass *oc, void *data) 69063ceb818SCédric Le Goater { 69163ceb818SCédric Le Goater MachineClass *mc = MACHINE_CLASS(oc); 69263ceb818SCédric Le Goater AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); 69363ceb818SCédric Le Goater 6947582591aSJoel Stanley mc->desc = "OpenPOWER Tacoma BMC (Cortex A7)"; 6957582591aSJoel Stanley amc->soc_name = "ast2600-a1"; 69663ceb818SCédric Le Goater amc->hw_strap1 = TACOMA_BMC_HW_STRAP1; 69763ceb818SCédric Le Goater amc->hw_strap2 = TACOMA_BMC_HW_STRAP2; 69863ceb818SCédric Le Goater amc->fmc_model = "mx66l1g45g"; 69963ceb818SCédric Le Goater amc->spi_model = "mx66l1g45g"; 70063ceb818SCédric Le Goater amc->num_cs = 2; 70163ceb818SCédric Le Goater amc->i2c_init = witherspoon_bmc_i2c_init; /* Same board layout */ 70263ceb818SCédric Le Goater mc->default_ram_size = 1 * GiB; 703*b7f1a0cbSCédric Le Goater mc->default_cpus = mc->min_cpus = mc->max_cpus = 704*b7f1a0cbSCédric Le Goater aspeed_soc_num_cpus(amc->soc_name); 70563ceb818SCédric Le Goater }; 70663ceb818SCédric Le Goater 707baa4732bSCédric Le Goater static const TypeInfo aspeed_machine_types[] = { 708baa4732bSCédric Le Goater { 709baa4732bSCédric Le Goater .name = MACHINE_TYPE_NAME("palmetto-bmc"), 710baa4732bSCédric Le Goater .parent = TYPE_ASPEED_MACHINE, 711baa4732bSCédric Le Goater .class_init = aspeed_machine_palmetto_class_init, 712baa4732bSCédric Le Goater }, { 713baa4732bSCédric Le Goater .name = MACHINE_TYPE_NAME("ast2500-evb"), 714baa4732bSCédric Le Goater .parent = TYPE_ASPEED_MACHINE, 715baa4732bSCédric Le Goater .class_init = aspeed_machine_ast2500_evb_class_init, 716baa4732bSCédric Le Goater }, { 717baa4732bSCédric Le Goater .name = MACHINE_TYPE_NAME("romulus-bmc"), 718baa4732bSCédric Le Goater .parent = TYPE_ASPEED_MACHINE, 719baa4732bSCédric Le Goater .class_init = aspeed_machine_romulus_class_init, 720baa4732bSCédric Le Goater }, { 721baa4732bSCédric Le Goater .name = MACHINE_TYPE_NAME("swift-bmc"), 722baa4732bSCédric Le Goater .parent = TYPE_ASPEED_MACHINE, 723baa4732bSCédric Le Goater .class_init = aspeed_machine_swift_class_init, 724baa4732bSCédric Le Goater }, { 725143b040fSPatrick Williams .name = MACHINE_TYPE_NAME("sonorapass-bmc"), 726143b040fSPatrick Williams .parent = TYPE_ASPEED_MACHINE, 727143b040fSPatrick Williams .class_init = aspeed_machine_sonorapass_class_init, 728143b040fSPatrick Williams }, { 729baa4732bSCédric Le Goater .name = MACHINE_TYPE_NAME("witherspoon-bmc"), 730baa4732bSCédric Le Goater .parent = TYPE_ASPEED_MACHINE, 731baa4732bSCédric Le Goater .class_init = aspeed_machine_witherspoon_class_init, 732baa4732bSCédric Le Goater }, { 733baa4732bSCédric Le Goater .name = MACHINE_TYPE_NAME("ast2600-evb"), 734baa4732bSCédric Le Goater .parent = TYPE_ASPEED_MACHINE, 735baa4732bSCédric Le Goater .class_init = aspeed_machine_ast2600_evb_class_init, 736baa4732bSCédric Le Goater }, { 73763ceb818SCédric Le Goater .name = MACHINE_TYPE_NAME("tacoma-bmc"), 73863ceb818SCédric Le Goater .parent = TYPE_ASPEED_MACHINE, 73963ceb818SCédric Le Goater .class_init = aspeed_machine_tacoma_class_init, 74063ceb818SCédric Le Goater }, { 741fca9ca1bSCédric Le Goater .name = TYPE_ASPEED_MACHINE, 74262c2c2ebSCédric Le Goater .parent = TYPE_MACHINE, 743fca9ca1bSCédric Le Goater .instance_size = sizeof(AspeedMachine), 7441a15311aSCédric Le Goater .instance_init = aspeed_machine_instance_init, 745fca9ca1bSCédric Le Goater .class_size = sizeof(AspeedMachineClass), 746fca9ca1bSCédric Le Goater .class_init = aspeed_machine_class_init, 747baa4732bSCédric Le Goater .abstract = true, 748baa4732bSCédric Le Goater } 749fca9ca1bSCédric Le Goater }; 75074fb1f38SCédric Le Goater 751baa4732bSCédric Le Goater DEFINE_TYPES(aspeed_machine_types) 752