| 1 | /* |
| 2 | * Facebook Bletchley |
| 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/gpio/pca9552.h" |
| 15 | #include "hw/nvram/eeprom_at24c.h" |
| 16 | |
| 17 | #define TYPE_TMP421 "tmp421" |
| 18 | /* Bletchley hardware value */ |
| 19 | #define BLETCHLEY_BMC_HW_STRAP1 0x00002000 |
| 20 | #define BLETCHLEY_BMC_HW_STRAP2 0x00000801 |
| 21 | #define BLETCHLEY_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB) |
| 22 | |
| 23 | static void bletchley_bmc_i2c_init(AspeedMachineState *bmc) |
| 24 | { |
| 25 | AspeedSoCState *soc = bmc->soc; |
| 26 | I2CBus *i2c[13] = {}; |
| 27 | for (int i = 0; i < 13; i++) { |
| 28 | if ((i == 8) || (i == 11)) { |
| 29 | continue; |
| 30 | } |
| 31 | i2c[i] = aspeed_i2c_get_bus(&soc->i2c, i); |
| 32 | } |
| 33 | |
| 34 | /* Bus 0 - 5 all have the same config. */ |
| 35 | for (int i = 0; i < 6; i++) { |
| 36 | /* Missing model: ti,ina230 @ 0x45 */ |
| 37 | /* Missing model: mps,mp5023 @ 0x40 */ |
| 38 | i2c_slave_create_simple(i2c[i], TYPE_TMP421, 0x4f); |
| 39 | /* Missing model: nxp,pca9539 @ 0x76, but PCA9552 works enough */ |
| 40 | i2c_slave_create_simple(i2c[i], TYPE_PCA9552, 0x76); |
| 41 | i2c_slave_create_simple(i2c[i], TYPE_PCA9552, 0x67); |
| 42 | /* Missing model: fsc,fusb302 @ 0x22 */ |
| 43 | } |
| 44 | |
| 45 | /* Bus 6 */ |
| 46 | at24c_eeprom_init(i2c[6], 0x56, 65536); |
| 47 | /* Missing model: nxp,pcf85263 @ 0x51 , but ds1338 works enough */ |
| 48 | i2c_slave_create_simple(i2c[6], "ds1338", 0x51); |
| 49 | |
| 50 | |
| 51 | /* Bus 7 */ |
| 52 | at24c_eeprom_init(i2c[7], 0x54, 65536); |
| 53 | |
| 54 | /* Bus 9 */ |
| 55 | i2c_slave_create_simple(i2c[9], TYPE_TMP421, 0x4f); |
| 56 | |
| 57 | /* Bus 10 */ |
| 58 | i2c_slave_create_simple(i2c[10], TYPE_TMP421, 0x4f); |
| 59 | /* Missing model: ti,hdc1080 @ 0x40 */ |
| 60 | i2c_slave_create_simple(i2c[10], TYPE_PCA9552, 0x67); |
| 61 | |
| 62 | /* Bus 12 */ |
| 63 | /* Missing model: adi,adm1278 @ 0x11 */ |
| 64 | i2c_slave_create_simple(i2c[12], TYPE_TMP421, 0x4c); |
| 65 | i2c_slave_create_simple(i2c[12], TYPE_TMP421, 0x4d); |
| 66 | i2c_slave_create_simple(i2c[12], TYPE_PCA9552, 0x67); |
| 67 | } |
| 68 | |
| 69 | static void aspeed_machine_bletchley_class_init(ObjectClass *oc, |
| 70 | const void *data) |
| 71 | { |
| 72 | MachineClass *mc = MACHINE_CLASS(oc); |
| 73 | AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); |
| 74 | |
| 75 | mc->desc = "Facebook Bletchley BMC (Cortex-A7)"; |
| 76 | amc->soc_name = "ast2600-a3"; |
| 77 | amc->hw_strap1 = BLETCHLEY_BMC_HW_STRAP1; |
| 78 | amc->hw_strap2 = BLETCHLEY_BMC_HW_STRAP2; |
| 79 | amc->fmc_model = "w25q01jvq"; |
| 80 | amc->spi_model = NULL; |
| 81 | amc->num_cs = 2; |
| 82 | amc->macs_mask = ASPEED_MAC2_ON; |
| 83 | amc->i2c_init = bletchley_bmc_i2c_init; |
| 84 | mc->default_ram_size = BLETCHLEY_BMC_RAM_SIZE; |
| 85 | aspeed_machine_class_init_cpus_defaults(mc); |
| 86 | } |
| 87 | |
| 88 | static const TypeInfo aspeed_ast2600_bletchley_types[] = { |
| 89 | { |
| 90 | .name = MACHINE_TYPE_NAME("bletchley-bmc"), |
| 91 | .parent = TYPE_ASPEED_MACHINE, |
| 92 | .class_init = aspeed_machine_bletchley_class_init, |
| 93 | .interfaces = arm_machine_interfaces, |
| 94 | } |
| 95 | }; |
| 96 | |
| 97 | DEFINE_TYPES(aspeed_ast2600_bletchley_types) |