master
c 77 lines 2.91 KB
Raw
1 /*
2 * Supermicro X11 SPI
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 SUPERMICRO_X11SPI_BMC_HW_STRAP1 ( \
18 AST2500_HW_STRAP1_DEFAULTS | \
19 SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \
20 SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \
21 SCU_AST2500_HW_STRAP_UART_DEBUG | \
22 SCU_AST2500_HW_STRAP_DDR4_ENABLE | \
23 SCU_HW_STRAP_SPI_WIDTH | \
24 SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_M_S_EN))
25
26 static void supermicro_x11spi_bmc_i2c_init(AspeedMachineState *bmc)
27 {
28 AspeedSoCState *soc = bmc->soc;
29 DeviceState *dev;
30 uint8_t *eeprom_buf = g_malloc0(32 * 1024);
31
32 /*
33 * The palmetto platform expects a ds3231 RTC but a ds1338 is
34 * enough to provide basic RTC features. Alarms will be missing
35 */
36 i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 0), "ds1338", 0x68);
37
38 smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50,
39 eeprom_buf);
40
41 /* add a TMP423 temperature sensor */
42 dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2),
43 "tmp423", 0x4c));
44 object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abort);
45 object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abort);
46 object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abort);
47 object_property_set_int(OBJECT(dev), "temperature3", 110000, &error_abort);
48 }
49
50 static void aspeed_machine_supermicro_x11spi_bmc_class_init(ObjectClass *oc,
51 const void *data)
52 {
53 MachineClass *mc = MACHINE_CLASS(oc);
54 AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
55
56 mc->desc = "Supermicro X11 SPI BMC (ARM1176)";
57 amc->soc_name = "ast2500-a1";
58 amc->hw_strap1 = SUPERMICRO_X11SPI_BMC_HW_STRAP1;
59 amc->fmc_model = "mx25l25635e";
60 amc->spi_model = "mx25l25635e";
61 amc->num_cs = 1;
62 amc->macs_mask = ASPEED_MAC0_ON | ASPEED_MAC1_ON;
63 amc->i2c_init = supermicro_x11spi_bmc_i2c_init;
64 mc->default_ram_size = 512 * MiB;
65 aspeed_machine_class_init_cpus_defaults(mc);
66 }
67
68 static const TypeInfo aspeed_ast2500_supermicro_x11spi_types[] = {
69 {
70 .name = MACHINE_TYPE_NAME("supermicro-x11spi-bmc"),
71 .parent = TYPE_ASPEED_MACHINE,
72 .class_init = aspeed_machine_supermicro_x11spi_bmc_class_init,
73 .interfaces = arm_machine_interfaces,
74 }
75 };
76
77 DEFINE_TYPES(aspeed_ast2500_supermicro_x11spi_types)