master
c 81 lines 3.16 KB
Raw
1 /*
2 * Supermicro X11
3 *
4 * Copyright 2016 IBM Corp.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9 #include "qemu/osdep.h"
10 #include "qapi/error.h"
11 #include "hw/arm/machines-qom.h"
12 #include "hw/arm/aspeed.h"
13 #include "hw/arm/aspeed_soc.h"
14 #include "hw/i2c/smbus_eeprom.h"
15
16 /* TODO: Find the actual hardware value */
17 #define SUPERMICROX11_BMC_HW_STRAP1 ( \
18 SCU_AST2400_HW_STRAP_DRAM_SIZE(DRAM_SIZE_128MB) | \
19 SCU_AST2400_HW_STRAP_DRAM_CONFIG(2) | \
20 SCU_AST2400_HW_STRAP_ACPI_DIS | \
21 SCU_AST2400_HW_STRAP_SET_CLK_SOURCE(AST2400_CLK_48M_IN) | \
22 SCU_HW_STRAP_VGA_CLASS_CODE | \
23 SCU_HW_STRAP_LPC_RESET_PIN | \
24 SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_M_S_EN) | \
25 SCU_AST2400_HW_STRAP_SET_CPU_AHB_RATIO(AST2400_CPU_AHB_RATIO_2_1) | \
26 SCU_HW_STRAP_SPI_WIDTH | \
27 SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) | \
28 SCU_AST2400_HW_STRAP_BOOT_MODE(AST2400_SPI_BOOT))
29
30 static void supermicrox11_bmc_i2c_init(AspeedMachineState *bmc)
31 {
32 AspeedSoCState *soc = bmc->soc;
33 DeviceState *dev;
34 uint8_t *eeprom_buf = g_malloc0(32 * 1024);
35
36 /*
37 * The palmetto platform expects a ds3231 RTC but a ds1338 is
38 * enough to provide basic RTC features. Alarms will be missing
39 */
40 i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 0), "ds1338", 0x68);
41
42 smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50,
43 eeprom_buf);
44
45 /* add a TMP423 temperature sensor */
46 dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2),
47 "tmp423", 0x4c));
48 object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abort);
49 object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abort);
50 object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abort);
51 object_property_set_int(OBJECT(dev), "temperature3", 110000, &error_abort);
52 }
53
54 static void aspeed_machine_supermicrox11_bmc_class_init(ObjectClass *oc,
55 const void *data)
56 {
57 MachineClass *mc = MACHINE_CLASS(oc);
58 AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
59
60 mc->desc = "Supermicro X11 BMC (ARM926EJ-S)";
61 amc->soc_name = "ast2400-a1";
62 amc->hw_strap1 = SUPERMICROX11_BMC_HW_STRAP1;
63 amc->fmc_model = "mx25l25635e";
64 amc->spi_model = "mx25l25635e";
65 amc->num_cs = 1;
66 amc->macs_mask = ASPEED_MAC0_ON | ASPEED_MAC1_ON;
67 amc->i2c_init = supermicrox11_bmc_i2c_init;
68 mc->default_ram_size = 256 * MiB;
69 aspeed_machine_class_init_cpus_defaults(mc);
70 }
71
72 static const TypeInfo aspeed_ast2400_supermicrox11_types[] = {
73 {
74 .name = MACHINE_TYPE_NAME("supermicrox11-bmc"),
75 .parent = TYPE_ASPEED_MACHINE,
76 .class_init = aspeed_machine_supermicrox11_bmc_class_init,
77 .interfaces = arm_machine_interfaces,
78 }
79 };
80
81 DEFINE_TYPES(aspeed_ast2400_supermicrox11_types)