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 "qemu-common.h" 154771d756SPaolo Bonzini #include "cpu.h" 16327d8e4eSAndrew Jeffery #include "exec/address-spaces.h" 17327d8e4eSAndrew Jeffery #include "hw/arm/arm.h" 18fca9ca1bSCédric Le Goater #include "hw/arm/aspeed.h" 1900442402SCédric Le Goater #include "hw/arm/aspeed_soc.h" 20327d8e4eSAndrew Jeffery #include "hw/boards.h" 2193198b6cSCorey Minyard #include "hw/i2c/smbus_eeprom.h" 22044475f3SPhilippe Mathieu-Daudé #include "hw/misc/pca9552.h" 23044475f3SPhilippe Mathieu-Daudé #include "hw/misc/tmp105.h" 2403dd024fSPaolo Bonzini #include "qemu/log.h" 25e1ad9bc4SCédric Le Goater #include "sysemu/block-backend.h" 26d769a1daSCédric Le Goater #include "hw/loader.h" 27d769a1daSCédric Le Goater #include "qemu/error-report.h" 28*a9df9622SJoel Stanley #include "qemu/units.h" 29327d8e4eSAndrew Jeffery 3074fb1f38SCédric Le Goater static struct arm_boot_info aspeed_board_binfo = { 31b033271fSCédric Le Goater .board_id = -1, /* device-tree-only board */ 32327d8e4eSAndrew Jeffery .nb_cpus = 1, 33327d8e4eSAndrew Jeffery }; 34327d8e4eSAndrew Jeffery 35ea066d39SThomas Huth struct AspeedBoardState { 36ff90606fSCédric Le Goater AspeedSoCState soc; 37327d8e4eSAndrew Jeffery MemoryRegion ram; 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 7662c2c2ebSCédric Le Goater /* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */ 7762c2c2ebSCédric Le Goater #define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1 7862c2c2ebSCédric Le Goater 79ebe31c0aSCédric Le Goater /* 80ebe31c0aSCédric Le Goater * The max ram region is for firmwares that scan the address space 81ebe31c0aSCédric Le Goater * with load/store to guess how much RAM the SoC has. 82ebe31c0aSCédric Le Goater */ 83ebe31c0aSCédric Le Goater static uint64_t max_ram_read(void *opaque, hwaddr offset, unsigned size) 84ebe31c0aSCédric Le Goater { 85ebe31c0aSCédric Le Goater return 0; 86ebe31c0aSCédric Le Goater } 87ebe31c0aSCédric Le Goater 88ebe31c0aSCédric Le Goater static void max_ram_write(void *opaque, hwaddr offset, uint64_t value, 89ebe31c0aSCédric Le Goater unsigned size) 90ebe31c0aSCédric Le Goater { 91ebe31c0aSCédric Le Goater /* Discard writes */ 92ebe31c0aSCédric Le Goater } 93ebe31c0aSCédric Le Goater 94ebe31c0aSCédric Le Goater static const MemoryRegionOps max_ram_ops = { 95ebe31c0aSCédric Le Goater .read = max_ram_read, 96ebe31c0aSCédric Le Goater .write = max_ram_write, 97ebe31c0aSCédric Le Goater .endianness = DEVICE_NATIVE_ENDIAN, 98ebe31c0aSCédric Le Goater }; 99ebe31c0aSCédric Le Goater 100d769a1daSCédric Le Goater #define FIRMWARE_ADDR 0x0 101d769a1daSCédric Le Goater 102d769a1daSCédric Le Goater static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size, 103d769a1daSCédric Le Goater Error **errp) 104d769a1daSCédric Le Goater { 105d769a1daSCédric Le Goater BlockBackend *blk = blk_by_legacy_dinfo(dinfo); 106d769a1daSCédric Le Goater uint8_t *storage; 1070c7209beSCédric Le Goater int64_t size; 108d769a1daSCédric Le Goater 1090c7209beSCédric Le Goater /* The block backend size should have already been 'validated' by 1100c7209beSCédric Le Goater * the creation of the m25p80 object. 1110c7209beSCédric Le Goater */ 1120c7209beSCédric Le Goater size = blk_getlength(blk); 1130c7209beSCédric Le Goater if (size <= 0) { 1140c7209beSCédric Le Goater error_setg(errp, "failed to get flash size"); 1150c7209beSCédric Le Goater return; 1160c7209beSCédric Le Goater } 1170c7209beSCédric Le Goater 1180c7209beSCédric Le Goater if (rom_size > size) { 1190c7209beSCédric Le Goater rom_size = size; 120d769a1daSCédric Le Goater } 121d769a1daSCédric Le Goater 122d769a1daSCédric Le Goater storage = g_new0(uint8_t, rom_size); 123d769a1daSCédric Le Goater if (blk_pread(blk, 0, storage, rom_size) < 0) { 124d769a1daSCédric Le Goater error_setg(errp, "failed to read the initial flash content"); 125d769a1daSCédric Le Goater return; 126d769a1daSCédric Le Goater } 127d769a1daSCédric Le Goater 128d769a1daSCédric Le Goater rom_add_blob_fixed("aspeed.boot_rom", storage, rom_size, addr); 129d769a1daSCédric Le Goater g_free(storage); 130d769a1daSCédric Le Goater } 131d769a1daSCédric Le Goater 13274fb1f38SCédric Le Goater static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, 133e1ad9bc4SCédric Le Goater Error **errp) 134e1ad9bc4SCédric Le Goater { 135e1ad9bc4SCédric Le Goater int i ; 136e1ad9bc4SCédric Le Goater 137e1ad9bc4SCédric Le Goater for (i = 0; i < s->num_cs; ++i) { 138e1ad9bc4SCédric Le Goater AspeedSMCFlash *fl = &s->flashes[i]; 139e1ad9bc4SCédric Le Goater DriveInfo *dinfo = drive_get_next(IF_MTD); 140e1ad9bc4SCédric Le Goater qemu_irq cs_line; 141e1ad9bc4SCédric Le Goater 142e1ad9bc4SCédric Le Goater fl->flash = ssi_create_slave_no_init(s->spi, flashtype); 143e1ad9bc4SCédric Le Goater if (dinfo) { 144e1ad9bc4SCédric Le Goater qdev_prop_set_drive(fl->flash, "drive", blk_by_legacy_dinfo(dinfo), 145e1ad9bc4SCédric Le Goater errp); 146e1ad9bc4SCédric Le Goater } 147e1ad9bc4SCédric Le Goater qdev_init_nofail(fl->flash); 148e1ad9bc4SCédric Le Goater 149e1ad9bc4SCédric Le Goater cs_line = qdev_get_gpio_in_named(fl->flash, SSI_GPIO_CS, 0); 150e1ad9bc4SCédric Le Goater sysbus_connect_irq(SYS_BUS_DEVICE(s), i + 1, cs_line); 151e1ad9bc4SCédric Le Goater } 152e1ad9bc4SCédric Le Goater } 153e1ad9bc4SCédric Le Goater 154c3ba99f7SCédric Le Goater static void aspeed_board_init(MachineState *machine, 155c3ba99f7SCédric Le Goater const AspeedBoardConfig *cfg) 156327d8e4eSAndrew Jeffery { 15774fb1f38SCédric Le Goater AspeedBoardState *bmc; 158b033271fSCédric Le Goater AspeedSoCClass *sc; 159d769a1daSCédric Le Goater DriveInfo *drive0 = drive_get(IF_MTD, 0, 0); 160ebe31c0aSCédric Le Goater ram_addr_t max_ram_size; 161327d8e4eSAndrew Jeffery 16274fb1f38SCédric Le Goater bmc = g_new0(AspeedBoardState, 1); 163c3ba99f7SCédric Le Goater object_initialize(&bmc->soc, (sizeof(bmc->soc)), cfg->soc_name); 164327d8e4eSAndrew Jeffery object_property_add_child(OBJECT(machine), "soc", OBJECT(&bmc->soc), 165327d8e4eSAndrew Jeffery &error_abort); 166327d8e4eSAndrew Jeffery 167b033271fSCédric Le Goater sc = ASPEED_SOC_GET_CLASS(&bmc->soc); 168b033271fSCédric Le Goater 16919e9cdf0SMarc-André Lureau object_property_set_uint(OBJECT(&bmc->soc), ram_size, "ram-size", 170c6c7cfb0SCédric Le Goater &error_abort); 171c3ba99f7SCédric Le Goater object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap1, "hw-strap1", 17287e79af0SAndrew Jeffery &error_abort); 17326d5df95SCédric Le Goater object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs", 17426d5df95SCédric Le Goater &error_abort); 175b6e70d1dSJoel Stanley if (machine->kernel_filename) { 176b6e70d1dSJoel Stanley /* 177b6e70d1dSJoel Stanley * When booting with a -kernel command line there is no u-boot 178b6e70d1dSJoel Stanley * that runs to unlock the SCU. In this case set the default to 179b6e70d1dSJoel Stanley * be unlocked as the kernel expects 180b6e70d1dSJoel Stanley */ 181b6e70d1dSJoel Stanley object_property_set_int(OBJECT(&bmc->soc), ASPEED_SCU_PROT_KEY, 182b6e70d1dSJoel Stanley "hw-prot-key", &error_abort); 183b6e70d1dSJoel Stanley } 184327d8e4eSAndrew Jeffery object_property_set_bool(OBJECT(&bmc->soc), true, "realized", 185327d8e4eSAndrew Jeffery &error_abort); 186327d8e4eSAndrew Jeffery 187de46f5f4SCédric Le Goater /* 188de46f5f4SCédric Le Goater * Allocate RAM after the memory controller has checked the size 189de46f5f4SCédric Le Goater * was valid. If not, a default value is used. 190de46f5f4SCédric Le Goater */ 19119e9cdf0SMarc-André Lureau ram_size = object_property_get_uint(OBJECT(&bmc->soc), "ram-size", 192de46f5f4SCédric Le Goater &error_abort); 193de46f5f4SCédric Le Goater 194de46f5f4SCédric Le Goater memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); 195de46f5f4SCédric Le Goater memory_region_add_subregion(get_system_memory(), sc->info->sdram_base, 196de46f5f4SCédric Le Goater &bmc->ram); 197de46f5f4SCédric Le Goater object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram), 198de46f5f4SCédric Le Goater &error_abort); 199de46f5f4SCédric Le Goater 200ebe31c0aSCédric Le Goater max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size", 201ebe31c0aSCédric Le Goater &error_abort); 202ebe31c0aSCédric Le Goater memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL, 203ebe31c0aSCédric Le Goater "max_ram", max_ram_size - ram_size); 204ebe31c0aSCédric Le Goater memory_region_add_subregion(get_system_memory(), 205ebe31c0aSCédric Le Goater sc->info->sdram_base + ram_size, 206ebe31c0aSCédric Le Goater &bmc->max_ram); 207ebe31c0aSCédric Le Goater 2086a0e947bSCédric Le Goater aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort); 2096a0e947bSCédric Le Goater aspeed_board_init_flashes(&bmc->soc.spi[0], cfg->spi_model, &error_abort); 210e1ad9bc4SCédric Le Goater 211d769a1daSCédric Le Goater /* Install first FMC flash content as a boot rom. */ 212d769a1daSCédric Le Goater if (drive0) { 213d769a1daSCédric Le Goater AspeedSMCFlash *fl = &bmc->soc.fmc.flashes[0]; 214d769a1daSCédric Le Goater MemoryRegion *boot_rom = g_new(MemoryRegion, 1); 215d769a1daSCédric Le Goater 216d769a1daSCédric Le Goater /* 217d769a1daSCédric Le Goater * create a ROM region using the default mapping window size of 21893bf276dSCédric Le Goater * the flash module. The window size is 64MB for the AST2400 21993bf276dSCédric Le Goater * SoC and 128MB for the AST2500 SoC, which is twice as big as 22093bf276dSCédric Le Goater * needed by the flash modules of the Aspeed machines. 221d769a1daSCédric Le Goater */ 22244cf837dSPeter Maydell memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom", 223d769a1daSCédric Le Goater fl->size, &error_abort); 224d769a1daSCédric Le Goater memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR, 225d769a1daSCédric Le Goater boot_rom); 226d769a1daSCédric Le Goater write_boot_rom(drive0, FIRMWARE_ADDR, fl->size, &error_abort); 227d769a1daSCédric Le Goater } 228d769a1daSCédric Le Goater 22974fb1f38SCédric Le Goater aspeed_board_binfo.kernel_filename = machine->kernel_filename; 23074fb1f38SCédric Le Goater aspeed_board_binfo.initrd_filename = machine->initrd_filename; 23174fb1f38SCédric Le Goater aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline; 23274fb1f38SCédric Le Goater aspeed_board_binfo.ram_size = ram_size; 23374fb1f38SCédric Le Goater aspeed_board_binfo.loader_start = sc->info->sdram_base; 234b033271fSCédric Le Goater 2352cf6cb50SCédric Le Goater if (cfg->i2c_init) { 2362cf6cb50SCédric Le Goater cfg->i2c_init(bmc); 2372cf6cb50SCédric Le Goater } 2382cf6cb50SCédric Le Goater 23974fb1f38SCédric Le Goater arm_load_kernel(ARM_CPU(first_cpu), &aspeed_board_binfo); 240327d8e4eSAndrew Jeffery } 241327d8e4eSAndrew Jeffery 2422cf6cb50SCédric Le Goater static void palmetto_bmc_i2c_init(AspeedBoardState *bmc) 2432cf6cb50SCédric Le Goater { 2442cf6cb50SCédric Le Goater AspeedSoCState *soc = &bmc->soc; 245a87e81b9SCédric Le Goater DeviceState *dev; 2463d165f12SCédric Le Goater uint8_t *eeprom_buf = g_malloc0(32 * 1024); 2472cf6cb50SCédric Le Goater 2482cf6cb50SCédric Le Goater /* The palmetto platform expects a ds3231 RTC but a ds1338 is 2492cf6cb50SCédric Le Goater * enough to provide basic RTC features. Alarms will be missing */ 2502cf6cb50SCédric Le Goater i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68); 251a87e81b9SCédric Le Goater 2523d165f12SCédric Le Goater smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50, 2533d165f12SCédric Le Goater eeprom_buf); 2543d165f12SCédric Le Goater 255a87e81b9SCédric Le Goater /* add a TMP423 temperature sensor */ 256a87e81b9SCédric Le Goater dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), 257a87e81b9SCédric Le Goater "tmp423", 0x4c); 258a87e81b9SCédric Le Goater object_property_set_int(OBJECT(dev), 31000, "temperature0", &error_abort); 259a87e81b9SCédric Le Goater object_property_set_int(OBJECT(dev), 28000, "temperature1", &error_abort); 260a87e81b9SCédric Le Goater object_property_set_int(OBJECT(dev), 20000, "temperature2", &error_abort); 261a87e81b9SCédric Le Goater object_property_set_int(OBJECT(dev), 110000, "temperature3", &error_abort); 2622cf6cb50SCédric Le Goater } 2632cf6cb50SCédric Le Goater 2642cf6cb50SCédric Le Goater static void ast2500_evb_i2c_init(AspeedBoardState *bmc) 2652cf6cb50SCédric Le Goater { 2662cf6cb50SCédric Le Goater AspeedSoCState *soc = &bmc->soc; 2673d165f12SCédric Le Goater uint8_t *eeprom_buf = g_malloc0(8 * 1024); 2683d165f12SCédric Le Goater 2693d165f12SCédric Le Goater smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50, 2703d165f12SCédric Le Goater eeprom_buf); 2712cf6cb50SCédric Le Goater 2722cf6cb50SCédric Le Goater /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ 273044475f3SPhilippe Mathieu-Daudé i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), 274044475f3SPhilippe Mathieu-Daudé TYPE_TMP105, 0x4d); 2756c4567c7SCédric Le Goater 2766c4567c7SCédric Le Goater /* The AST2500 EVB does not have an RTC. Let's pretend that one is 2776c4567c7SCédric Le Goater * plugged on the I2C bus header */ 2786c4567c7SCédric Le Goater i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); 2792cf6cb50SCédric Le Goater } 2802cf6cb50SCédric Le Goater 2816c4567c7SCédric Le Goater static void romulus_bmc_i2c_init(AspeedBoardState *bmc) 2826c4567c7SCédric Le Goater { 2836c4567c7SCédric Le Goater AspeedSoCState *soc = &bmc->soc; 2846c4567c7SCédric Le Goater 2856c4567c7SCédric Le Goater /* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is 2866c4567c7SCédric Le Goater * good enough */ 2876c4567c7SCédric Le Goater i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); 2886c4567c7SCédric Le Goater } 2896c4567c7SCédric Le Goater 29062c2c2ebSCédric Le Goater static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) 29162c2c2ebSCédric Le Goater { 29262c2c2ebSCédric Le Goater AspeedSoCState *soc = &bmc->soc; 2933d165f12SCédric Le Goater uint8_t *eeprom_buf = g_malloc0(8 * 1024); 29462c2c2ebSCédric Le Goater 295044475f3SPhilippe Mathieu-Daudé i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), TYPE_PCA9552, 296044475f3SPhilippe Mathieu-Daudé 0x60); 2978c9a61d7SCédric Le Goater 29862c2c2ebSCédric Le Goater i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c); 29962c2c2ebSCédric Le Goater i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c); 30062c2c2ebSCédric Le Goater 30162c2c2ebSCédric Le Goater /* The Witherspoon expects a TMP275 but a TMP105 is compatible */ 302044475f3SPhilippe Mathieu-Daudé i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), TYPE_TMP105, 303044475f3SPhilippe Mathieu-Daudé 0x4a); 3046c4567c7SCédric Le Goater 3056c4567c7SCédric Le Goater /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is 3066c4567c7SCédric Le Goater * good enough */ 3076c4567c7SCédric Le Goater i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); 3083d165f12SCédric Le Goater 3093d165f12SCédric Le Goater smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51, 3103d165f12SCédric Le Goater eeprom_buf); 311044475f3SPhilippe Mathieu-Daudé i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), TYPE_PCA9552, 3128c9a61d7SCédric Le Goater 0x60); 31362c2c2ebSCédric Le Goater } 31462c2c2ebSCédric Le Goater 315fca9ca1bSCédric Le Goater static void aspeed_machine_init(MachineState *machine) 31662c2c2ebSCédric Le Goater { 317fca9ca1bSCédric Le Goater AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(machine); 318fca9ca1bSCédric Le Goater 319fca9ca1bSCédric Le Goater aspeed_board_init(machine, amc->board); 32062c2c2ebSCédric Le Goater } 32162c2c2ebSCédric Le Goater 322fca9ca1bSCédric Le Goater static void aspeed_machine_class_init(ObjectClass *oc, void *data) 32362c2c2ebSCédric Le Goater { 32462c2c2ebSCédric Le Goater MachineClass *mc = MACHINE_CLASS(oc); 325fca9ca1bSCédric Le Goater AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); 326fca9ca1bSCédric Le Goater const AspeedBoardConfig *board = data; 32762c2c2ebSCédric Le Goater 328fca9ca1bSCédric Le Goater mc->desc = board->desc; 329fca9ca1bSCédric Le Goater mc->init = aspeed_machine_init; 33062c2c2ebSCédric Le Goater mc->max_cpus = 1; 33162c2c2ebSCédric Le Goater mc->no_sdcard = 1; 33262c2c2ebSCédric Le Goater mc->no_floppy = 1; 33362c2c2ebSCédric Le Goater mc->no_cdrom = 1; 33462c2c2ebSCédric Le Goater mc->no_parallel = 1; 335*a9df9622SJoel Stanley if (board->ram) { 336*a9df9622SJoel Stanley mc->default_ram_size = board->ram; 337*a9df9622SJoel Stanley } 338fca9ca1bSCédric Le Goater amc->board = board; 33962c2c2ebSCédric Le Goater } 34062c2c2ebSCédric Le Goater 341fca9ca1bSCédric Le Goater static const TypeInfo aspeed_machine_type = { 342fca9ca1bSCédric Le Goater .name = TYPE_ASPEED_MACHINE, 34362c2c2ebSCédric Le Goater .parent = TYPE_MACHINE, 344fca9ca1bSCédric Le Goater .instance_size = sizeof(AspeedMachine), 345fca9ca1bSCédric Le Goater .class_size = sizeof(AspeedMachineClass), 346fca9ca1bSCédric Le Goater .abstract = true, 34762c2c2ebSCédric Le Goater }; 34862c2c2ebSCédric Le Goater 349fca9ca1bSCédric Le Goater static const AspeedBoardConfig aspeed_boards[] = { 35074fb1f38SCédric Le Goater { 351fca9ca1bSCédric Le Goater .name = MACHINE_TYPE_NAME("palmetto-bmc"), 352fca9ca1bSCédric Le Goater .desc = "OpenPOWER Palmetto BMC (ARM926EJ-S)", 353fca9ca1bSCédric Le Goater .soc_name = "ast2400-a1", 354fca9ca1bSCédric Le Goater .hw_strap1 = PALMETTO_BMC_HW_STRAP1, 355fca9ca1bSCédric Le Goater .fmc_model = "n25q256a", 356fca9ca1bSCédric Le Goater .spi_model = "mx25l25635e", 357fca9ca1bSCédric Le Goater .num_cs = 1, 358fca9ca1bSCédric Le Goater .i2c_init = palmetto_bmc_i2c_init, 359*a9df9622SJoel Stanley .ram = 256 * MiB, 360fca9ca1bSCédric Le Goater }, { 361fca9ca1bSCédric Le Goater .name = MACHINE_TYPE_NAME("ast2500-evb"), 362fca9ca1bSCédric Le Goater .desc = "Aspeed AST2500 EVB (ARM1176)", 363fca9ca1bSCédric Le Goater .soc_name = "ast2500-a1", 364fca9ca1bSCédric Le Goater .hw_strap1 = AST2500_EVB_HW_STRAP1, 365fca9ca1bSCédric Le Goater .fmc_model = "w25q256", 366fca9ca1bSCédric Le Goater .spi_model = "mx25l25635e", 367fca9ca1bSCédric Le Goater .num_cs = 1, 368fca9ca1bSCédric Le Goater .i2c_init = ast2500_evb_i2c_init, 369*a9df9622SJoel Stanley .ram = 512 * MiB, 370fca9ca1bSCédric Le Goater }, { 371fca9ca1bSCédric Le Goater .name = MACHINE_TYPE_NAME("romulus-bmc"), 372fca9ca1bSCédric Le Goater .desc = "OpenPOWER Romulus BMC (ARM1176)", 373fca9ca1bSCédric Le Goater .soc_name = "ast2500-a1", 374fca9ca1bSCédric Le Goater .hw_strap1 = ROMULUS_BMC_HW_STRAP1, 375fca9ca1bSCédric Le Goater .fmc_model = "n25q256a", 376fca9ca1bSCédric Le Goater .spi_model = "mx66l1g45g", 377fca9ca1bSCédric Le Goater .num_cs = 2, 378fca9ca1bSCédric Le Goater .i2c_init = romulus_bmc_i2c_init, 379*a9df9622SJoel Stanley .ram = 512 * MiB, 380fca9ca1bSCédric Le Goater }, { 381fca9ca1bSCédric Le Goater .name = MACHINE_TYPE_NAME("witherspoon-bmc"), 382fca9ca1bSCédric Le Goater .desc = "OpenPOWER Witherspoon BMC (ARM1176)", 383fca9ca1bSCédric Le Goater .soc_name = "ast2500-a1", 384fca9ca1bSCédric Le Goater .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1, 385fca9ca1bSCédric Le Goater .fmc_model = "mx25l25635e", 386fca9ca1bSCédric Le Goater .spi_model = "mx66l1g45g", 387fca9ca1bSCédric Le Goater .num_cs = 2, 388fca9ca1bSCédric Le Goater .i2c_init = witherspoon_bmc_i2c_init, 389*a9df9622SJoel Stanley .ram = 512 * MiB, 390fca9ca1bSCédric Le Goater }, 391fca9ca1bSCédric Le Goater }; 392fca9ca1bSCédric Le Goater 393fca9ca1bSCédric Le Goater static void aspeed_machine_types(void) 394fca9ca1bSCédric Le Goater { 395fca9ca1bSCédric Le Goater int i; 396fca9ca1bSCédric Le Goater 397fca9ca1bSCédric Le Goater type_register_static(&aspeed_machine_type); 398fca9ca1bSCédric Le Goater for (i = 0; i < ARRAY_SIZE(aspeed_boards); ++i) { 399fca9ca1bSCédric Le Goater TypeInfo ti = { 400fca9ca1bSCédric Le Goater .name = aspeed_boards[i].name, 401fca9ca1bSCédric Le Goater .parent = TYPE_ASPEED_MACHINE, 402fca9ca1bSCédric Le Goater .class_init = aspeed_machine_class_init, 403fca9ca1bSCédric Le Goater .class_data = (void *)&aspeed_boards[i], 404fca9ca1bSCédric Le Goater }; 405fca9ca1bSCédric Le Goater type_register(&ti); 406fca9ca1bSCédric Le Goater } 40774fb1f38SCédric Le Goater } 40874fb1f38SCédric Le Goater 409fca9ca1bSCédric Le Goater type_init(aspeed_machine_types) 410