| 1 | /* |
| 2 | * IBM Rainier |
| 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/nvram/eeprom_at24c.h" |
| 15 | #include "hw/i2c/i2c_mux_pca954x.h" |
| 16 | #include "hw/sensor/tmp105.h" |
| 17 | |
| 18 | /* Rainier hardware value: (QEMU prototype) */ |
| 19 | #define RAINIER_BMC_HW_STRAP1 (0x00422016 | SCU_AST2600_HW_STRAP_BOOT_SRC_EMMC) |
| 20 | #define RAINIER_BMC_HW_STRAP2 0x80000848 |
| 21 | |
| 22 | static const uint8_t rainier_bb_fruid[] = { |
| 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, |
| 24 | 0x28, 0x00, 0x52, 0x54, 0x04, 0x56, 0x48, 0x44, 0x52, 0x56, 0x44, 0x02, |
| 25 | 0x01, 0x00, 0x50, 0x54, 0x0e, 0x56, 0x54, 0x4f, 0x43, 0x00, 0x00, 0x37, |
| 26 | 0x00, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x46, 0x08, 0x00, 0x00, |
| 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x52, 0x54, |
| 28 | 0x04, 0x56, 0x54, 0x4f, 0x43, 0x50, 0x54, 0x38, 0x56, 0x49, 0x4e, 0x49, |
| 29 | 0x00, 0x00, 0x81, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x53, |
| 30 | 0x59, 0x53, 0x00, 0x00, 0xbb, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 31 | 0x56, 0x43, 0x45, 0x4e, 0x00, 0x00, 0xe2, 0x00, 0x27, 0x00, 0x00, 0x00, |
| 32 | 0x00, 0x00, 0x56, 0x53, 0x42, 0x50, 0x00, 0x00, 0x09, 0x01, 0x19, 0x00, |
| 33 | 0x00, 0x00, 0x00, 0x00, 0x50, 0x46, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, |
| 34 | 0x52, 0x54, 0x04, 0x56, 0x49, 0x4e, 0x49, 0x44, 0x52, 0x04, 0x44, 0x45, |
| 35 | 0x53, 0x43, 0x48, 0x57, 0x02, 0x30, 0x31, 0x43, 0x43, 0x04, 0x33, 0x34, |
| 36 | 0x35, 0x36, 0x46, 0x4e, 0x04, 0x46, 0x52, 0x34, 0x39, 0x53, 0x4e, 0x04, |
| 37 | 0x53, 0x52, 0x31, 0x32, 0x50, 0x4e, 0x04, 0x50, 0x52, 0x39, 0x39, 0x50, |
| 38 | 0x46, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x52, 0x54, |
| 39 | 0x04, 0x56, 0x53, 0x59, 0x53, 0x53, 0x45, 0x07, 0x49, 0x42, 0x4d, 0x53, |
| 40 | 0x59, 0x53, 0x31, 0x54, 0x4d, 0x08, 0x32, 0x32, 0x32, 0x32, 0x2d, 0x32, |
| 41 | 0x32, 0x32, 0x50, 0x46, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, |
| 42 | 0x00, 0x52, 0x54, 0x04, 0x56, 0x43, 0x45, 0x4e, 0x53, 0x45, 0x07, 0x31, |
| 43 | 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x46, 0x43, 0x08, 0x31, 0x31, 0x31, |
| 44 | 0x31, 0x2d, 0x31, 0x31, 0x31, 0x50, 0x46, 0x04, 0x00, 0x00, 0x00, 0x00, |
| 45 | 0x00, 0x00, 0x15, 0x00, 0x52, 0x54, 0x04, 0x56, 0x53, 0x42, 0x50, 0x49, |
| 46 | 0x4d, 0x04, 0x50, 0x00, 0x10, 0x01, 0x50, 0x46, 0x04, 0x00, 0x00, 0x00, |
| 47 | 0x00, 0x00, |
| 48 | }; |
| 49 | static const size_t rainier_bb_fruid_len = sizeof(rainier_bb_fruid); |
| 50 | |
| 51 | /* Rainier BMC FRU */ |
| 52 | static const uint8_t rainier_bmc_fruid[] = { |
| 53 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, |
| 54 | 0x28, 0x00, 0x52, 0x54, 0x04, 0x56, 0x48, 0x44, 0x52, 0x56, 0x44, 0x02, |
| 55 | 0x01, 0x00, 0x50, 0x54, 0x0e, 0x56, 0x54, 0x4f, 0x43, 0x00, 0x00, 0x37, |
| 56 | 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x46, 0x08, 0x00, 0x00, |
| 57 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x52, 0x54, |
| 58 | 0x04, 0x56, 0x54, 0x4f, 0x43, 0x50, 0x54, 0x0e, 0x56, 0x49, 0x4e, 0x49, |
| 59 | 0x00, 0x00, 0x57, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x46, |
| 60 | 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x52, 0x54, 0x04, 0x56, 0x49, 0x4e, |
| 61 | 0x49, 0x44, 0x52, 0x04, 0x44, 0x45, 0x53, 0x43, 0x48, 0x57, 0x02, 0x30, |
| 62 | 0x31, 0x50, 0x46, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 63 | }; |
| 64 | static const size_t rainier_bmc_fruid_len = sizeof(rainier_bmc_fruid); |
| 65 | |
| 66 | static void rainier_bmc_i2c_init(AspeedMachineState *bmc) |
| 67 | { |
| 68 | AspeedSoCState *soc = bmc->soc; |
| 69 | I2CSlave *i2c_mux; |
| 70 | |
| 71 | at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 0), 0x51, 32 * KiB); |
| 72 | |
| 73 | aspeed_create_pca9552(soc, 3, 0x61); |
| 74 | |
| 75 | /* The rainier expects a TMP275 but a TMP105 is compatible */ |
| 76 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), TYPE_TMP105, |
| 77 | 0x48); |
| 78 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), TYPE_TMP105, |
| 79 | 0x49); |
| 80 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), TYPE_TMP105, |
| 81 | 0x4a); |
| 82 | i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), |
| 83 | "pca9546", 0x70); |
| 84 | at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); |
| 85 | at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB); |
| 86 | at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x52, 64 * KiB); |
| 87 | aspeed_create_pca9552(soc, 4, 0x60); |
| 88 | |
| 89 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), TYPE_TMP105, |
| 90 | 0x48); |
| 91 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), TYPE_TMP105, |
| 92 | 0x49); |
| 93 | aspeed_create_pca9552(soc, 5, 0x60); |
| 94 | aspeed_create_pca9552(soc, 5, 0x61); |
| 95 | i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), |
| 96 | "pca9546", 0x70); |
| 97 | at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); |
| 98 | at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB); |
| 99 | |
| 100 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105, |
| 101 | 0x48); |
| 102 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105, |
| 103 | 0x4a); |
| 104 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105, |
| 105 | 0x4b); |
| 106 | i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), |
| 107 | "pca9546", 0x70); |
| 108 | at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); |
| 109 | at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB); |
| 110 | at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x50, 64 * KiB); |
| 111 | at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 3), 0x51, 64 * KiB); |
| 112 | |
| 113 | aspeed_create_pca9552(soc, 7, 0x30); |
| 114 | aspeed_create_pca9552(soc, 7, 0x31); |
| 115 | aspeed_create_pca9552(soc, 7, 0x32); |
| 116 | aspeed_create_pca9552(soc, 7, 0x33); |
| 117 | aspeed_create_pca9552(soc, 7, 0x60); |
| 118 | aspeed_create_pca9552(soc, 7, 0x61); |
| 119 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "dps310", 0x76); |
| 120 | /* Bus 7: TODO si7021-a20@20 */ |
| 121 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), TYPE_TMP105, |
| 122 | 0x48); |
| 123 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "max31785", 0x52); |
| 124 | at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x50, 64 * KiB); |
| 125 | at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x51, 64 * KiB); |
| 126 | |
| 127 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_TMP105, |
| 128 | 0x48); |
| 129 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_TMP105, |
| 130 | 0x4a); |
| 131 | at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x50, |
| 132 | 64 * KiB, rainier_bb_fruid, rainier_bb_fruid_len); |
| 133 | at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, |
| 134 | 64 * KiB, rainier_bmc_fruid, rainier_bmc_fruid_len); |
| 135 | aspeed_create_pca9552(soc, 8, 0x60); |
| 136 | aspeed_create_pca9552(soc, 8, 0x61); |
| 137 | /* Bus 8: ucd90320@11 */ |
| 138 | /* Bus 8: ucd90320@b */ |
| 139 | /* Bus 8: ucd90320@c */ |
| 140 | |
| 141 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x4c); |
| 142 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x4d); |
| 143 | at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 9), 0x50, 128 * KiB); |
| 144 | |
| 145 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0x4c); |
| 146 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0x4d); |
| 147 | at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 10), 0x50, 128 * KiB); |
| 148 | |
| 149 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), TYPE_TMP105, |
| 150 | 0x48); |
| 151 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), TYPE_TMP105, |
| 152 | 0x49); |
| 153 | i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), |
| 154 | "pca9546", 0x70); |
| 155 | at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); |
| 156 | at24c_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB); |
| 157 | aspeed_create_pca9552(soc, 11, 0x60); |
| 158 | |
| 159 | |
| 160 | at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 13), 0x50, 64 * KiB); |
| 161 | aspeed_create_pca9552(soc, 13, 0x60); |
| 162 | |
| 163 | at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 14), 0x50, 64 * KiB); |
| 164 | aspeed_create_pca9552(soc, 14, 0x60); |
| 165 | |
| 166 | at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 15), 0x50, 64 * KiB); |
| 167 | aspeed_create_pca9552(soc, 15, 0x60); |
| 168 | } |
| 169 | |
| 170 | static void aspeed_machine_rainier_class_init(ObjectClass *oc, const void *data) |
| 171 | { |
| 172 | MachineClass *mc = MACHINE_CLASS(oc); |
| 173 | AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); |
| 174 | |
| 175 | mc->desc = "IBM Rainier BMC (Cortex-A7)"; |
| 176 | amc->soc_name = "ast2600-a3"; |
| 177 | amc->hw_strap1 = RAINIER_BMC_HW_STRAP1; |
| 178 | amc->hw_strap2 = RAINIER_BMC_HW_STRAP2; |
| 179 | amc->fmc_model = "mx66l1g45g"; |
| 180 | amc->spi_model = "mx66l1g45g"; |
| 181 | amc->num_cs = 2; |
| 182 | amc->macs_mask = ASPEED_MAC2_ON | ASPEED_MAC3_ON; |
| 183 | amc->i2c_init = rainier_bmc_i2c_init; |
| 184 | mc->default_ram_size = 1 * GiB; |
| 185 | aspeed_machine_class_init_cpus_defaults(mc); |
| 186 | aspeed_machine_ast2600_class_emmc_init(oc); |
| 187 | }; |
| 188 | |
| 189 | static const TypeInfo aspeed_ast2600_rainier_types[] = { |
| 190 | { |
| 191 | .name = MACHINE_TYPE_NAME("rainier-bmc"), |
| 192 | .parent = TYPE_ASPEED_MACHINE, |
| 193 | .class_init = aspeed_machine_rainier_class_init, |
| 194 | .interfaces = arm_machine_interfaces, |
| 195 | } |
| 196 | }; |
| 197 | |
| 198 | DEFINE_TYPES(aspeed_ast2600_rainier_types) |