master
c 92 lines 3.84 KB
Raw
1 /*
2 * Bytedance G220A
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 #define G220A_BMC_HW_STRAP1 ( \
17 SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \
18 SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \
19 SCU_AST2500_HW_STRAP_UART_DEBUG | \
20 SCU_AST2500_HW_STRAP_RESERVED28 | \
21 SCU_AST2500_HW_STRAP_DDR4_ENABLE | \
22 SCU_HW_STRAP_2ND_BOOT_WDT | \
23 SCU_HW_STRAP_VGA_CLASS_CODE | \
24 SCU_HW_STRAP_LPC_RESET_PIN | \
25 SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER) | \
26 SCU_AST2500_HW_STRAP_SET_AXI_AHB_RATIO(AXI_AHB_RATIO_2_1) | \
27 SCU_HW_STRAP_VGA_SIZE_SET(VGA_64M_DRAM) | \
28 SCU_AST2500_HW_STRAP_RESERVED1)
29
30 static void g220a_bmc_i2c_init(AspeedMachineState *bmc)
31 {
32 AspeedSoCState *soc = bmc->soc;
33 DeviceState *dev;
34
35 dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 3),
36 "emc1413", 0x4c));
37 object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abort);
38 object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abort);
39 object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abort);
40
41 dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 12),
42 "emc1413", 0x4c));
43 object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abort);
44 object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abort);
45 object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abort);
46
47 dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 13),
48 "emc1413", 0x4c));
49 object_property_set_int(OBJECT(dev), "temperature0", 31000, &error_abort);
50 object_property_set_int(OBJECT(dev), "temperature1", 28000, &error_abort);
51 object_property_set_int(OBJECT(dev), "temperature2", 20000, &error_abort);
52
53 static uint8_t eeprom_buf[2 * 1024] = {
54 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xfe,
55 0x01, 0x06, 0x00, 0xc9, 0x42, 0x79, 0x74, 0x65,
56 0x64, 0x61, 0x6e, 0x63, 0x65, 0xc5, 0x47, 0x32,
57 0x32, 0x30, 0x41, 0xc4, 0x41, 0x41, 0x42, 0x42,
58 0xc4, 0x43, 0x43, 0x44, 0x44, 0xc4, 0x45, 0x45,
59 0x46, 0x46, 0xc4, 0x48, 0x48, 0x47, 0x47, 0xc1,
60 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7,
61 };
62 smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 4), 0x57,
63 eeprom_buf);
64 }
65
66 static void aspeed_machine_g220a_class_init(ObjectClass *oc, const void *data)
67 {
68 MachineClass *mc = MACHINE_CLASS(oc);
69 AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
70
71 mc->desc = "Bytedance G220A BMC (ARM1176)";
72 amc->soc_name = "ast2500-a1";
73 amc->hw_strap1 = G220A_BMC_HW_STRAP1;
74 amc->fmc_model = "n25q512a";
75 amc->spi_model = "mx25l25635e";
76 amc->num_cs = 2;
77 amc->macs_mask = ASPEED_MAC0_ON | ASPEED_MAC1_ON;
78 amc->i2c_init = g220a_bmc_i2c_init;
79 mc->default_ram_size = 1024 * MiB;
80 aspeed_machine_class_init_cpus_defaults(mc);
81 };
82
83 static const TypeInfo aspeed_ast2500_g220a_types[] = {
84 {
85 .name = MACHINE_TYPE_NAME("g220a-bmc"),
86 .parent = TYPE_ASPEED_MACHINE,
87 .class_init = aspeed_machine_g220a_class_init,
88 .interfaces = arm_machine_interfaces,
89 }
90 };
91
92 DEFINE_TYPES(aspeed_ast2500_g220a_types)