xref: /qemu/hw/arm/aspeed.c (revision d3bad7e7c48f8c33b28cd5a472c89a53dfe56f9b)
1327d8e4eSAndrew Jeffery /*
2327d8e4eSAndrew Jeffery  * OpenPOWER Palmetto BMC
3327d8e4eSAndrew Jeffery  *
4327d8e4eSAndrew Jeffery  * Andrew Jeffery <andrew@aj.id.au>
5327d8e4eSAndrew Jeffery  *
6327d8e4eSAndrew Jeffery  * Copyright 2016 IBM Corp.
7327d8e4eSAndrew Jeffery  *
8327d8e4eSAndrew Jeffery  * This code is licensed under the GPL version 2 or later.  See
9327d8e4eSAndrew Jeffery  * the COPYING file in the top-level directory.
10327d8e4eSAndrew Jeffery  */
11327d8e4eSAndrew Jeffery 
12327d8e4eSAndrew Jeffery #include "qemu/osdep.h"
13da34e65cSMarkus Armbruster #include "qapi/error.h"
144771d756SPaolo Bonzini #include "cpu.h"
15327d8e4eSAndrew Jeffery #include "exec/address-spaces.h"
1612ec8bd5SPeter Maydell #include "hw/arm/boot.h"
17fca9ca1bSCédric Le Goater #include "hw/arm/aspeed.h"
1800442402SCédric Le Goater #include "hw/arm/aspeed_soc.h"
19327d8e4eSAndrew Jeffery #include "hw/boards.h"
2093198b6cSCorey Minyard #include "hw/i2c/smbus_eeprom.h"
21044475f3SPhilippe Mathieu-Daudé #include "hw/misc/pca9552.h"
22044475f3SPhilippe Mathieu-Daudé #include "hw/misc/tmp105.h"
23a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h"
2403dd024fSPaolo Bonzini #include "qemu/log.h"
25e1ad9bc4SCédric Le Goater #include "sysemu/block-backend.h"
26ece09beeSCédric Le Goater #include "sysemu/sysemu.h"
27d769a1daSCédric Le Goater #include "hw/loader.h"
28d769a1daSCédric Le Goater #include "qemu/error-report.h"
29a9df9622SJoel Stanley #include "qemu/units.h"
30327d8e4eSAndrew Jeffery 
3174fb1f38SCédric Le Goater static struct arm_boot_info aspeed_board_binfo = {
32b033271fSCédric Le Goater     .board_id = -1, /* device-tree-only board */
33327d8e4eSAndrew Jeffery };
34327d8e4eSAndrew Jeffery 
35ea066d39SThomas Huth struct AspeedBoardState {
36ff90606fSCédric Le Goater     AspeedSoCState soc;
37ad1a9782SCédric Le Goater     MemoryRegion ram_container;
38ebe31c0aSCédric Le Goater     MemoryRegion max_ram;
39ea066d39SThomas Huth };
40327d8e4eSAndrew Jeffery 
41ef17f836SCédric Le Goater /* Palmetto hardware value: 0x120CE416 */
428da33ef7SCédric Le Goater #define PALMETTO_BMC_HW_STRAP1 (                                        \
438da33ef7SCédric Le Goater         SCU_AST2400_HW_STRAP_DRAM_SIZE(DRAM_SIZE_256MB) |               \
448da33ef7SCédric Le Goater         SCU_AST2400_HW_STRAP_DRAM_CONFIG(2 /* DDR3 with CL=6, CWL=5 */) | \
458da33ef7SCédric Le Goater         SCU_AST2400_HW_STRAP_ACPI_DIS |                                 \
468da33ef7SCédric Le Goater         SCU_AST2400_HW_STRAP_SET_CLK_SOURCE(AST2400_CLK_48M_IN) |       \
478da33ef7SCédric Le Goater         SCU_HW_STRAP_VGA_CLASS_CODE |                                   \
488da33ef7SCédric Le Goater         SCU_HW_STRAP_LPC_RESET_PIN |                                    \
498da33ef7SCédric Le Goater         SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_M_S_EN) |                \
508da33ef7SCédric Le Goater         SCU_AST2400_HW_STRAP_SET_CPU_AHB_RATIO(AST2400_CPU_AHB_RATIO_2_1) | \
518da33ef7SCédric Le Goater         SCU_HW_STRAP_SPI_WIDTH |                                        \
528da33ef7SCédric Le Goater         SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) |                       \
538da33ef7SCédric Le Goater         SCU_AST2400_HW_STRAP_BOOT_MODE(AST2400_SPI_BOOT))
548da33ef7SCédric Le Goater 
55ef17f836SCédric Le Goater /* AST2500 evb hardware value: 0xF100C2E6 */
569a7c1750SCédric Le Goater #define AST2500_EVB_HW_STRAP1 ((                                        \
579a7c1750SCédric Le Goater         AST2500_HW_STRAP1_DEFAULTS |                                    \
589a7c1750SCédric Le Goater         SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE |                     \
599a7c1750SCédric Le Goater         SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE |                        \
609a7c1750SCédric Le Goater         SCU_AST2500_HW_STRAP_UART_DEBUG |                               \
619a7c1750SCédric Le Goater         SCU_AST2500_HW_STRAP_DDR4_ENABLE |                              \
629a7c1750SCédric Le Goater         SCU_HW_STRAP_MAC1_RGMII |                                       \
639a7c1750SCédric Le Goater         SCU_HW_STRAP_MAC0_RGMII) &                                      \
649a7c1750SCédric Le Goater         ~SCU_HW_STRAP_2ND_BOOT_WDT)
659a7c1750SCédric Le Goater 
66ef17f836SCédric Le Goater /* Romulus hardware value: 0xF10AD206 */
67ef17f836SCédric Le Goater #define ROMULUS_BMC_HW_STRAP1 (                                         \
68ef17f836SCédric Le Goater         AST2500_HW_STRAP1_DEFAULTS |                                    \
69ef17f836SCédric Le Goater         SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE |                     \
70ef17f836SCédric Le Goater         SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE |                        \
71ef17f836SCédric Le Goater         SCU_AST2500_HW_STRAP_UART_DEBUG |                               \
72ef17f836SCédric Le Goater         SCU_AST2500_HW_STRAP_DDR4_ENABLE |                              \
73ef17f836SCédric Le Goater         SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
74ef17f836SCédric Le Goater         SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
75ef17f836SCédric Le Goater 
76143b040fSPatrick Williams /* Sonorapass hardware value: 0xF100D216 */
77143b040fSPatrick Williams #define SONORAPASS_BMC_HW_STRAP1 (                                      \
78143b040fSPatrick Williams         SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE |                     \
79143b040fSPatrick Williams         SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE |                        \
80143b040fSPatrick Williams         SCU_AST2500_HW_STRAP_UART_DEBUG |                               \
81143b040fSPatrick Williams         SCU_AST2500_HW_STRAP_RESERVED28 |                               \
82143b040fSPatrick Williams         SCU_AST2500_HW_STRAP_DDR4_ENABLE |                              \
83143b040fSPatrick Williams         SCU_HW_STRAP_VGA_CLASS_CODE |                                   \
84143b040fSPatrick Williams         SCU_HW_STRAP_LPC_RESET_PIN |                                    \
85143b040fSPatrick Williams         SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER) |                \
86143b040fSPatrick Williams         SCU_AST2500_HW_STRAP_SET_AXI_AHB_RATIO(AXI_AHB_RATIO_2_1) |     \
87143b040fSPatrick Williams         SCU_HW_STRAP_VGA_BIOS_ROM |                                     \
88143b040fSPatrick Williams         SCU_HW_STRAP_VGA_SIZE_SET(VGA_16M_DRAM) |                       \
89143b040fSPatrick Williams         SCU_AST2500_HW_STRAP_RESERVED1)
90143b040fSPatrick Williams 
91aae7a18dSAdriana Kobylak /* Swift hardware value: 0xF11AD206 */
92aae7a18dSAdriana Kobylak #define SWIFT_BMC_HW_STRAP1 (                                           \
93aae7a18dSAdriana Kobylak         AST2500_HW_STRAP1_DEFAULTS |                                    \
94aae7a18dSAdriana Kobylak         SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE |                     \
95aae7a18dSAdriana Kobylak         SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE |                        \
96aae7a18dSAdriana Kobylak         SCU_AST2500_HW_STRAP_UART_DEBUG |                               \
97aae7a18dSAdriana Kobylak         SCU_AST2500_HW_STRAP_DDR4_ENABLE |                              \
98aae7a18dSAdriana Kobylak         SCU_H_PLL_BYPASS_EN |                                           \
99aae7a18dSAdriana Kobylak         SCU_AST2500_HW_STRAP_ACPI_ENABLE |                              \
100aae7a18dSAdriana Kobylak         SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
101aae7a18dSAdriana Kobylak 
10262c2c2ebSCédric Le Goater /* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
10362c2c2ebSCédric Le Goater #define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
10462c2c2ebSCédric Le Goater 
105ccc2c418SCédric Le Goater /* AST2600 evb hardware value */
106ccc2c418SCédric Le Goater #define AST2600_EVB_HW_STRAP1 0x000000C0
107ccc2c418SCédric Le Goater #define AST2600_EVB_HW_STRAP2 0x00000003
108ccc2c418SCédric Le Goater 
10963ceb818SCédric Le Goater /* Tacoma hardware value */
11063ceb818SCédric Le Goater #define TACOMA_BMC_HW_STRAP1  0x00000000
1117582591aSJoel Stanley #define TACOMA_BMC_HW_STRAP2  0x00000040
11263ceb818SCédric Le Goater 
113ebe31c0aSCédric Le Goater /*
114ebe31c0aSCédric Le Goater  * The max ram region is for firmwares that scan the address space
115ebe31c0aSCédric Le Goater  * with load/store to guess how much RAM the SoC has.
116ebe31c0aSCédric Le Goater  */
117ebe31c0aSCédric Le Goater static uint64_t max_ram_read(void *opaque, hwaddr offset, unsigned size)
118ebe31c0aSCédric Le Goater {
119ebe31c0aSCédric Le Goater     return 0;
120ebe31c0aSCédric Le Goater }
121ebe31c0aSCédric Le Goater 
122ebe31c0aSCédric Le Goater static void max_ram_write(void *opaque, hwaddr offset, uint64_t value,
123ebe31c0aSCédric Le Goater                            unsigned size)
124ebe31c0aSCédric Le Goater {
125ebe31c0aSCédric Le Goater     /* Discard writes */
126ebe31c0aSCédric Le Goater }
127ebe31c0aSCédric Le Goater 
128ebe31c0aSCédric Le Goater static const MemoryRegionOps max_ram_ops = {
129ebe31c0aSCédric Le Goater     .read = max_ram_read,
130ebe31c0aSCédric Le Goater     .write = max_ram_write,
131ebe31c0aSCédric Le Goater     .endianness = DEVICE_NATIVE_ENDIAN,
132ebe31c0aSCédric Le Goater };
133ebe31c0aSCédric Le Goater 
1349bb6d140SJoel Stanley #define AST_SMP_MAILBOX_BASE            0x1e6e2180
1359bb6d140SJoel Stanley #define AST_SMP_MBOX_FIELD_ENTRY        (AST_SMP_MAILBOX_BASE + 0x0)
1369bb6d140SJoel Stanley #define AST_SMP_MBOX_FIELD_GOSIGN       (AST_SMP_MAILBOX_BASE + 0x4)
1379bb6d140SJoel Stanley #define AST_SMP_MBOX_FIELD_READY        (AST_SMP_MAILBOX_BASE + 0x8)
1389bb6d140SJoel Stanley #define AST_SMP_MBOX_FIELD_POLLINSN     (AST_SMP_MAILBOX_BASE + 0xc)
1399bb6d140SJoel Stanley #define AST_SMP_MBOX_CODE               (AST_SMP_MAILBOX_BASE + 0x10)
1409bb6d140SJoel Stanley #define AST_SMP_MBOX_GOSIGN             0xabbaab00
1419bb6d140SJoel Stanley 
1429bb6d140SJoel Stanley static void aspeed_write_smpboot(ARMCPU *cpu,
1439bb6d140SJoel Stanley                                  const struct arm_boot_info *info)
1449bb6d140SJoel Stanley {
1459bb6d140SJoel Stanley     static const uint32_t poll_mailbox_ready[] = {
1469bb6d140SJoel Stanley         /*
1479bb6d140SJoel Stanley          * r2 = per-cpu go sign value
1489bb6d140SJoel Stanley          * r1 = AST_SMP_MBOX_FIELD_ENTRY
1499bb6d140SJoel Stanley          * r0 = AST_SMP_MBOX_FIELD_GOSIGN
1509bb6d140SJoel Stanley          */
1519bb6d140SJoel Stanley         0xee100fb0,  /* mrc     p15, 0, r0, c0, c0, 5 */
1529bb6d140SJoel Stanley         0xe21000ff,  /* ands    r0, r0, #255          */
1539bb6d140SJoel Stanley         0xe59f201c,  /* ldr     r2, [pc, #28]         */
1549bb6d140SJoel Stanley         0xe1822000,  /* orr     r2, r2, r0            */
1559bb6d140SJoel Stanley 
1569bb6d140SJoel Stanley         0xe59f1018,  /* ldr     r1, [pc, #24]         */
1579bb6d140SJoel Stanley         0xe59f0018,  /* ldr     r0, [pc, #24]         */
1589bb6d140SJoel Stanley 
1599bb6d140SJoel Stanley         0xe320f002,  /* wfe                           */
1609bb6d140SJoel Stanley         0xe5904000,  /* ldr     r4, [r0]              */
1619bb6d140SJoel Stanley         0xe1520004,  /* cmp     r2, r4                */
1629bb6d140SJoel Stanley         0x1afffffb,  /* bne     <wfe>                 */
1639bb6d140SJoel Stanley         0xe591f000,  /* ldr     pc, [r1]              */
1649bb6d140SJoel Stanley         AST_SMP_MBOX_GOSIGN,
1659bb6d140SJoel Stanley         AST_SMP_MBOX_FIELD_ENTRY,
1669bb6d140SJoel Stanley         AST_SMP_MBOX_FIELD_GOSIGN,
1679bb6d140SJoel Stanley     };
1689bb6d140SJoel Stanley 
1699bb6d140SJoel Stanley     rom_add_blob_fixed("aspeed.smpboot", poll_mailbox_ready,
1709bb6d140SJoel Stanley                        sizeof(poll_mailbox_ready),
1719bb6d140SJoel Stanley                        info->smp_loader_start);
1729bb6d140SJoel Stanley }
1739bb6d140SJoel Stanley 
1749bb6d140SJoel Stanley static void aspeed_reset_secondary(ARMCPU *cpu,
1759bb6d140SJoel Stanley                                    const struct arm_boot_info *info)
1769bb6d140SJoel Stanley {
1779bb6d140SJoel Stanley     AddressSpace *as = arm_boot_address_space(cpu, info);
1789bb6d140SJoel Stanley     CPUState *cs = CPU(cpu);
1799bb6d140SJoel Stanley 
1809bb6d140SJoel Stanley     /* info->smp_bootreg_addr */
1819bb6d140SJoel Stanley     address_space_stl_notdirty(as, AST_SMP_MBOX_FIELD_GOSIGN, 0,
1829bb6d140SJoel Stanley                                MEMTXATTRS_UNSPECIFIED, NULL);
1839bb6d140SJoel Stanley     cpu_set_pc(cs, info->smp_loader_start);
1849bb6d140SJoel Stanley }
1859bb6d140SJoel Stanley 
186d769a1daSCédric Le Goater #define FIRMWARE_ADDR 0x0
187d769a1daSCédric Le Goater 
188d769a1daSCédric Le Goater static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size,
189d769a1daSCédric Le Goater                            Error **errp)
190d769a1daSCédric Le Goater {
191d769a1daSCédric Le Goater     BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
192d769a1daSCédric Le Goater     uint8_t *storage;
1930c7209beSCédric Le Goater     int64_t size;
194d769a1daSCédric Le Goater 
1950c7209beSCédric Le Goater     /* The block backend size should have already been 'validated' by
1960c7209beSCédric Le Goater      * the creation of the m25p80 object.
1970c7209beSCédric Le Goater      */
1980c7209beSCédric Le Goater     size = blk_getlength(blk);
1990c7209beSCédric Le Goater     if (size <= 0) {
2000c7209beSCédric Le Goater         error_setg(errp, "failed to get flash size");
2010c7209beSCédric Le Goater         return;
2020c7209beSCédric Le Goater     }
2030c7209beSCédric Le Goater 
2040c7209beSCédric Le Goater     if (rom_size > size) {
2050c7209beSCédric Le Goater         rom_size = size;
206d769a1daSCédric Le Goater     }
207d769a1daSCédric Le Goater 
208d769a1daSCédric Le Goater     storage = g_new0(uint8_t, rom_size);
209d769a1daSCédric Le Goater     if (blk_pread(blk, 0, storage, rom_size) < 0) {
210d769a1daSCédric Le Goater         error_setg(errp, "failed to read the initial flash content");
211d769a1daSCédric Le Goater         return;
212d769a1daSCédric Le Goater     }
213d769a1daSCédric Le Goater 
214d769a1daSCédric Le Goater     rom_add_blob_fixed("aspeed.boot_rom", storage, rom_size, addr);
215d769a1daSCédric Le Goater     g_free(storage);
216d769a1daSCédric Le Goater }
217d769a1daSCédric Le Goater 
21874fb1f38SCédric Le Goater static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
219e1ad9bc4SCédric Le Goater                                       Error **errp)
220e1ad9bc4SCédric Le Goater {
221e1ad9bc4SCédric Le Goater     int i ;
222e1ad9bc4SCédric Le Goater 
223e1ad9bc4SCédric Le Goater     for (i = 0; i < s->num_cs; ++i) {
224e1ad9bc4SCédric Le Goater         AspeedSMCFlash *fl = &s->flashes[i];
225e1ad9bc4SCédric Le Goater         DriveInfo *dinfo = drive_get_next(IF_MTD);
226e1ad9bc4SCédric Le Goater         qemu_irq cs_line;
227e1ad9bc4SCédric Le Goater 
228e1ad9bc4SCédric Le Goater         fl->flash = ssi_create_slave_no_init(s->spi, flashtype);
229e1ad9bc4SCédric Le Goater         if (dinfo) {
230e1ad9bc4SCédric Le Goater             qdev_prop_set_drive(fl->flash, "drive", blk_by_legacy_dinfo(dinfo),
231e1ad9bc4SCédric Le Goater                                 errp);
232e1ad9bc4SCédric Le Goater         }
233e1ad9bc4SCédric Le Goater         qdev_init_nofail(fl->flash);
234e1ad9bc4SCédric Le Goater 
235e1ad9bc4SCédric Le Goater         cs_line = qdev_get_gpio_in_named(fl->flash, SSI_GPIO_CS, 0);
236e1ad9bc4SCédric Le Goater         sysbus_connect_irq(SYS_BUS_DEVICE(s), i + 1, cs_line);
237e1ad9bc4SCédric Le Goater     }
238e1ad9bc4SCédric Le Goater }
239e1ad9bc4SCédric Le Goater 
240a29e3e12SAndrew Jeffery static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo)
241a29e3e12SAndrew Jeffery {
242a29e3e12SAndrew Jeffery         DeviceState *card;
243a29e3e12SAndrew Jeffery 
244a29e3e12SAndrew Jeffery         card = qdev_create(qdev_get_child_bus(DEVICE(sdhci), "sd-bus"),
245a29e3e12SAndrew Jeffery                            TYPE_SD_CARD);
246a29e3e12SAndrew Jeffery         if (dinfo) {
247a29e3e12SAndrew Jeffery             qdev_prop_set_drive(card, "drive", blk_by_legacy_dinfo(dinfo),
248a29e3e12SAndrew Jeffery                                 &error_fatal);
249a29e3e12SAndrew Jeffery         }
250a29e3e12SAndrew Jeffery         object_property_set_bool(OBJECT(card), true, "realized", &error_fatal);
251a29e3e12SAndrew Jeffery }
252a29e3e12SAndrew Jeffery 
253baa4732bSCédric Le Goater static void aspeed_machine_init(MachineState *machine)
254327d8e4eSAndrew Jeffery {
25574fb1f38SCédric Le Goater     AspeedBoardState *bmc;
256baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(machine);
257b033271fSCédric Le Goater     AspeedSoCClass *sc;
258d769a1daSCédric Le Goater     DriveInfo *drive0 = drive_get(IF_MTD, 0, 0);
259ebe31c0aSCédric Le Goater     ram_addr_t max_ram_size;
2602bea128cSEddie James     int i;
261*d3bad7e7SCédric Le Goater     NICInfo *nd = &nd_table[0];
262327d8e4eSAndrew Jeffery 
26374fb1f38SCédric Le Goater     bmc = g_new0(AspeedBoardState, 1);
264ad1a9782SCédric Le Goater 
265ad1a9782SCédric Le Goater     memory_region_init(&bmc->ram_container, NULL, "aspeed-ram-container",
2667df9f028SPhilippe Mathieu-Daudé                        4 * GiB);
267afcbaed6SIgor Mammedov     memory_region_add_subregion(&bmc->ram_container, 0, machine->ram);
268ad1a9782SCédric Le Goater 
2691b0ad567SPhilippe Mathieu-Daudé     object_initialize_child(OBJECT(machine), "soc", &bmc->soc,
270baa4732bSCédric Le Goater                             (sizeof(bmc->soc)), amc->soc_name, &error_abort,
2711b0ad567SPhilippe Mathieu-Daudé                             NULL);
272327d8e4eSAndrew Jeffery 
273b033271fSCédric Le Goater     sc = ASPEED_SOC_GET_CLASS(&bmc->soc);
274b033271fSCédric Le Goater 
275533eb415SIgor Mammedov     /*
276533eb415SIgor Mammedov      * This will error out if isize is not supported by memory controller.
277533eb415SIgor Mammedov      */
27819e9cdf0SMarc-André Lureau     object_property_set_uint(OBJECT(&bmc->soc), ram_size, "ram-size",
279533eb415SIgor Mammedov                              &error_fatal);
280533eb415SIgor Mammedov 
281*d3bad7e7SCédric Le Goater     for (i = 0; i < sc->macs_num; i++) {
282*d3bad7e7SCédric Le Goater         if ((amc->macs_mask & (1 << i)) && nd->used) {
283*d3bad7e7SCédric Le Goater             qemu_check_nic_model(nd, TYPE_FTGMAC100);
284*d3bad7e7SCédric Le Goater             qdev_set_nic_properties(DEVICE(&bmc->soc.ftgmac100[i]), nd);
285*d3bad7e7SCédric Le Goater             nd++;
286*d3bad7e7SCédric Le Goater         }
287*d3bad7e7SCédric Le Goater     }
288*d3bad7e7SCédric Le Goater 
289baa4732bSCédric Le Goater     object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap1, "hw-strap1",
29087e79af0SAndrew Jeffery                             &error_abort);
291baa4732bSCédric Le Goater     object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap2, "hw-strap2",
292ccc2c418SCédric Le Goater                             &error_abort);
293baa4732bSCédric Le Goater     object_property_set_int(OBJECT(&bmc->soc), amc->num_cs, "num-cs",
29426d5df95SCédric Le Goater                             &error_abort);
295c4e1f0b4SCédric Le Goater     object_property_set_link(OBJECT(&bmc->soc), OBJECT(&bmc->ram_container),
296c4e1f0b4SCédric Le Goater                              "dram", &error_abort);
297b6e70d1dSJoel Stanley     if (machine->kernel_filename) {
298b6e70d1dSJoel Stanley         /*
299b6e70d1dSJoel Stanley          * When booting with a -kernel command line there is no u-boot
300b6e70d1dSJoel Stanley          * that runs to unlock the SCU. In this case set the default to
301b6e70d1dSJoel Stanley          * be unlocked as the kernel expects
302b6e70d1dSJoel Stanley          */
303b6e70d1dSJoel Stanley         object_property_set_int(OBJECT(&bmc->soc), ASPEED_SCU_PROT_KEY,
304b6e70d1dSJoel Stanley                                 "hw-prot-key", &error_abort);
305b6e70d1dSJoel Stanley     }
306327d8e4eSAndrew Jeffery     object_property_set_bool(OBJECT(&bmc->soc), true, "realized",
307327d8e4eSAndrew Jeffery                              &error_abort);
308327d8e4eSAndrew Jeffery 
309d783d1feSCédric Le Goater     memory_region_add_subregion(get_system_memory(),
31054ecafb7SCédric Le Goater                                 sc->memmap[ASPEED_SDRAM],
311ad1a9782SCédric Le Goater                                 &bmc->ram_container);
312de46f5f4SCédric Le Goater 
313ebe31c0aSCédric Le Goater     max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size",
314ebe31c0aSCédric Le Goater                                             &error_abort);
315ebe31c0aSCédric Le Goater     memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL,
316ebe31c0aSCédric Le Goater                           "max_ram", max_ram_size  - ram_size);
317ad1a9782SCédric Le Goater     memory_region_add_subregion(&bmc->ram_container, ram_size, &bmc->max_ram);
318ebe31c0aSCédric Le Goater 
319baa4732bSCédric Le Goater     aspeed_board_init_flashes(&bmc->soc.fmc, amc->fmc_model, &error_abort);
320baa4732bSCédric Le Goater     aspeed_board_init_flashes(&bmc->soc.spi[0], amc->spi_model, &error_abort);
321e1ad9bc4SCédric Le Goater 
322d769a1daSCédric Le Goater     /* Install first FMC flash content as a boot rom. */
323d769a1daSCédric Le Goater     if (drive0) {
324d769a1daSCédric Le Goater         AspeedSMCFlash *fl = &bmc->soc.fmc.flashes[0];
325d769a1daSCédric Le Goater         MemoryRegion *boot_rom = g_new(MemoryRegion, 1);
326d769a1daSCédric Le Goater 
327d769a1daSCédric Le Goater         /*
328d769a1daSCédric Le Goater          * create a ROM region using the default mapping window size of
32993bf276dSCédric Le Goater          * the flash module. The window size is 64MB for the AST2400
33093bf276dSCédric Le Goater          * SoC and 128MB for the AST2500 SoC, which is twice as big as
33193bf276dSCédric Le Goater          * needed by the flash modules of the Aspeed machines.
332d769a1daSCédric Le Goater          */
3331a15311aSCédric Le Goater         if (ASPEED_MACHINE(machine)->mmio_exec) {
3341a15311aSCédric Le Goater             memory_region_init_alias(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
3351a15311aSCédric Le Goater                                      &fl->mmio, 0, fl->size);
3361a15311aSCédric Le Goater             memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
3371a15311aSCédric Le Goater                                         boot_rom);
3381a15311aSCédric Le Goater         } else {
33944cf837dSPeter Maydell             memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
340d769a1daSCédric Le Goater                                    fl->size, &error_abort);
341d769a1daSCédric Le Goater             memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
342d769a1daSCédric Le Goater                                         boot_rom);
343d769a1daSCédric Le Goater             write_boot_rom(drive0, FIRMWARE_ADDR, fl->size, &error_abort);
344d769a1daSCédric Le Goater         }
3451a15311aSCédric Le Goater     }
346d769a1daSCédric Le Goater 
347b7f1a0cbSCédric Le Goater     if (machine->kernel_filename && sc->num_cpus > 1) {
3489bb6d140SJoel Stanley         /* With no u-boot we must set up a boot stub for the secondary CPU */
3499bb6d140SJoel Stanley         MemoryRegion *smpboot = g_new(MemoryRegion, 1);
3509bb6d140SJoel Stanley         memory_region_init_ram(smpboot, OBJECT(bmc), "aspeed.smpboot",
3519bb6d140SJoel Stanley                                0x80, &error_abort);
3529bb6d140SJoel Stanley         memory_region_add_subregion(get_system_memory(),
3539bb6d140SJoel Stanley                                     AST_SMP_MAILBOX_BASE, smpboot);
3549bb6d140SJoel Stanley 
3559bb6d140SJoel Stanley         aspeed_board_binfo.write_secondary_boot = aspeed_write_smpboot;
3569bb6d140SJoel Stanley         aspeed_board_binfo.secondary_cpu_reset_hook = aspeed_reset_secondary;
3579bb6d140SJoel Stanley         aspeed_board_binfo.smp_loader_start = AST_SMP_MBOX_CODE;
3589bb6d140SJoel Stanley     }
3599bb6d140SJoel Stanley 
36074fb1f38SCédric Le Goater     aspeed_board_binfo.ram_size = ram_size;
36154ecafb7SCédric Le Goater     aspeed_board_binfo.loader_start = sc->memmap[ASPEED_SDRAM];
362b7f1a0cbSCédric Le Goater     aspeed_board_binfo.nb_cpus = sc->num_cpus;
363b033271fSCédric Le Goater 
364baa4732bSCédric Le Goater     if (amc->i2c_init) {
365baa4732bSCédric Le Goater         amc->i2c_init(bmc);
3662cf6cb50SCédric Le Goater     }
3672cf6cb50SCédric Le Goater 
3680e2c24c6SAndrew Jeffery     for (i = 0; i < bmc->soc.sdhci.num_slots; i++) {
369a29e3e12SAndrew Jeffery         sdhci_attach_drive(&bmc->soc.sdhci.slots[i], drive_get_next(IF_SD));
370a29e3e12SAndrew Jeffery     }
3712bea128cSEddie James 
372a29e3e12SAndrew Jeffery     if (bmc->soc.emmc.num_slots) {
373a29e3e12SAndrew Jeffery         sdhci_attach_drive(&bmc->soc.emmc.slots[0], drive_get_next(IF_SD));
3742bea128cSEddie James     }
3752bea128cSEddie James 
3762744ece8STao Xu     arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo);
377327d8e4eSAndrew Jeffery }
378327d8e4eSAndrew Jeffery 
3792cf6cb50SCédric Le Goater static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)
3802cf6cb50SCédric Le Goater {
3812cf6cb50SCédric Le Goater     AspeedSoCState *soc = &bmc->soc;
382a87e81b9SCédric Le Goater     DeviceState *dev;
3833d165f12SCédric Le Goater     uint8_t *eeprom_buf = g_malloc0(32 * 1024);
3842cf6cb50SCédric Le Goater 
3852cf6cb50SCédric Le Goater     /* The palmetto platform expects a ds3231 RTC but a ds1338 is
3862cf6cb50SCédric Le Goater      * enough to provide basic RTC features. Alarms will be missing */
3872cf6cb50SCédric Le Goater     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68);
388a87e81b9SCédric Le Goater 
3893d165f12SCédric Le Goater     smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50,
3903d165f12SCédric Le Goater                           eeprom_buf);
3913d165f12SCédric Le Goater 
392a87e81b9SCédric Le Goater     /* add a TMP423 temperature sensor */
393a87e81b9SCédric Le Goater     dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2),
394a87e81b9SCédric Le Goater                            "tmp423", 0x4c);
395a87e81b9SCédric Le Goater     object_property_set_int(OBJECT(dev), 31000, "temperature0", &error_abort);
396a87e81b9SCédric Le Goater     object_property_set_int(OBJECT(dev), 28000, "temperature1", &error_abort);
397a87e81b9SCédric Le Goater     object_property_set_int(OBJECT(dev), 20000, "temperature2", &error_abort);
398a87e81b9SCédric Le Goater     object_property_set_int(OBJECT(dev), 110000, "temperature3", &error_abort);
3992cf6cb50SCédric Le Goater }
4002cf6cb50SCédric Le Goater 
4012cf6cb50SCédric Le Goater static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
4022cf6cb50SCédric Le Goater {
4032cf6cb50SCédric Le Goater     AspeedSoCState *soc = &bmc->soc;
4043d165f12SCédric Le Goater     uint8_t *eeprom_buf = g_malloc0(8 * 1024);
4053d165f12SCédric Le Goater 
4063d165f12SCédric Le Goater     smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50,
4073d165f12SCédric Le Goater                           eeprom_buf);
4082cf6cb50SCédric Le Goater 
4092cf6cb50SCédric Le Goater     /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
410044475f3SPhilippe Mathieu-Daudé     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7),
411044475f3SPhilippe Mathieu-Daudé                      TYPE_TMP105, 0x4d);
4126c4567c7SCédric Le Goater 
4136c4567c7SCédric Le Goater     /* The AST2500 EVB does not have an RTC. Let's pretend that one is
4146c4567c7SCédric Le Goater      * plugged on the I2C bus header */
4156c4567c7SCédric Le Goater     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
4162cf6cb50SCédric Le Goater }
4172cf6cb50SCédric Le Goater 
418ccc2c418SCédric Le Goater static void ast2600_evb_i2c_init(AspeedBoardState *bmc)
419ccc2c418SCédric Le Goater {
420ccc2c418SCédric Le Goater     /* Start with some devices on our I2C busses */
421ccc2c418SCédric Le Goater     ast2500_evb_i2c_init(bmc);
422ccc2c418SCédric Le Goater }
423ccc2c418SCédric Le Goater 
4246c4567c7SCédric Le Goater static void romulus_bmc_i2c_init(AspeedBoardState *bmc)
4256c4567c7SCédric Le Goater {
4266c4567c7SCédric Le Goater     AspeedSoCState *soc = &bmc->soc;
4276c4567c7SCédric Le Goater 
4286c4567c7SCédric Le Goater     /* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is
4296c4567c7SCédric Le Goater      * good enough */
4306c4567c7SCédric Le Goater     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
4316c4567c7SCédric Le Goater }
4326c4567c7SCédric Le Goater 
433aae7a18dSAdriana Kobylak static void swift_bmc_i2c_init(AspeedBoardState *bmc)
434aae7a18dSAdriana Kobylak {
435aae7a18dSAdriana Kobylak     AspeedSoCState *soc = &bmc->soc;
436aae7a18dSAdriana Kobylak 
437aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60);
438aae7a18dSAdriana Kobylak 
439aae7a18dSAdriana Kobylak     /* The swift board expects a TMP275 but a TMP105 is compatible */
440aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x48);
441aae7a18dSAdriana Kobylak     /* The swift board expects a pca9551 but a pca9552 is compatible */
442aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "pca9552", 0x60);
443aae7a18dSAdriana Kobylak 
444aae7a18dSAdriana Kobylak     /* The swift board expects an Epson RX8900 RTC but a ds1338 is compatible */
445aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "ds1338", 0x32);
446aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60);
447aae7a18dSAdriana Kobylak 
448aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp423", 0x4c);
449aae7a18dSAdriana Kobylak     /* The swift board expects a pca9539 but a pca9552 is compatible */
450aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "pca9552", 0x74);
451aae7a18dSAdriana Kobylak 
452aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "tmp423", 0x4c);
453aae7a18dSAdriana Kobylak     /* The swift board expects a pca9539 but a pca9552 is compatible */
454aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "pca9552",
455aae7a18dSAdriana Kobylak                      0x74);
456aae7a18dSAdriana Kobylak 
457aae7a18dSAdriana Kobylak     /* The swift board expects a TMP275 but a TMP105 is compatible */
458aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x48);
459aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x4a);
460aae7a18dSAdriana Kobylak }
461aae7a18dSAdriana Kobylak 
462143b040fSPatrick Williams static void sonorapass_bmc_i2c_init(AspeedBoardState *bmc)
463143b040fSPatrick Williams {
464143b040fSPatrick Williams     AspeedSoCState *soc = &bmc->soc;
465143b040fSPatrick Williams 
466143b040fSPatrick Williams     /* bus 2 : */
467143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), "tmp105", 0x48);
468143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), "tmp105", 0x49);
469143b040fSPatrick Williams     /* bus 2 : pca9546 @ 0x73 */
470143b040fSPatrick Williams 
471143b040fSPatrick Williams     /* bus 3 : pca9548 @ 0x70 */
472143b040fSPatrick Williams 
473143b040fSPatrick Williams     /* bus 4 : */
474143b040fSPatrick Williams     uint8_t *eeprom4_54 = g_malloc0(8 * 1024);
475143b040fSPatrick Williams     smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), 0x54,
476143b040fSPatrick Williams                           eeprom4_54);
477143b040fSPatrick Williams     /* PCA9539 @ 0x76, but PCA9552 is compatible */
478143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "pca9552", 0x76);
479143b040fSPatrick Williams     /* PCA9539 @ 0x77, but PCA9552 is compatible */
480143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "pca9552", 0x77);
481143b040fSPatrick Williams 
482143b040fSPatrick Williams     /* bus 6 : */
483143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 6), "tmp105", 0x48);
484143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 6), "tmp105", 0x49);
485143b040fSPatrick Williams     /* bus 6 : pca9546 @ 0x73 */
486143b040fSPatrick Williams 
487143b040fSPatrick Williams     /* bus 8 : */
488143b040fSPatrick Williams     uint8_t *eeprom8_56 = g_malloc0(8 * 1024);
489143b040fSPatrick Williams     smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), 0x56,
490143b040fSPatrick Williams                           eeprom8_56);
491143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60);
492143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x61);
493143b040fSPatrick Williams     /* bus 8 : adc128d818 @ 0x1d */
494143b040fSPatrick Williams     /* bus 8 : adc128d818 @ 0x1f */
495143b040fSPatrick Williams 
496143b040fSPatrick Williams     /*
497143b040fSPatrick Williams      * bus 13 : pca9548 @ 0x71
498143b040fSPatrick Williams      *      - channel 3:
499143b040fSPatrick Williams      *          - tmm421 @ 0x4c
500143b040fSPatrick Williams      *          - tmp421 @ 0x4e
501143b040fSPatrick Williams      *          - tmp421 @ 0x4f
502143b040fSPatrick Williams      */
503143b040fSPatrick Williams 
504143b040fSPatrick Williams }
505143b040fSPatrick Williams 
50662c2c2ebSCédric Le Goater static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
50762c2c2ebSCédric Le Goater {
50862c2c2ebSCédric Le Goater     AspeedSoCState *soc = &bmc->soc;
5093d165f12SCédric Le Goater     uint8_t *eeprom_buf = g_malloc0(8 * 1024);
51062c2c2ebSCédric Le Goater 
51163ceb818SCédric Le Goater     /* Bus 3: TODO bmp280@77 */
51263ceb818SCédric Le Goater     /* Bus 3: TODO max31785@52 */
51363ceb818SCédric Le Goater     /* Bus 3: TODO dps310@76 */
514044475f3SPhilippe Mathieu-Daudé     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), TYPE_PCA9552,
515044475f3SPhilippe Mathieu-Daudé                      0x60);
5168c9a61d7SCédric Le Goater 
51762c2c2ebSCédric Le Goater     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
51862c2c2ebSCédric Le Goater     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
51962c2c2ebSCédric Le Goater 
52062c2c2ebSCédric Le Goater     /* The Witherspoon expects a TMP275 but a TMP105 is compatible */
521044475f3SPhilippe Mathieu-Daudé     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), TYPE_TMP105,
522044475f3SPhilippe Mathieu-Daudé                      0x4a);
5236c4567c7SCédric Le Goater 
5246c4567c7SCédric Le Goater     /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
5256c4567c7SCédric Le Goater      * good enough */
5266c4567c7SCédric Le Goater     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
5273d165f12SCédric Le Goater 
5283d165f12SCédric Le Goater     smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,
5293d165f12SCédric Le Goater                           eeprom_buf);
530044475f3SPhilippe Mathieu-Daudé     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), TYPE_PCA9552,
5318c9a61d7SCédric Le Goater                      0x60);
53263ceb818SCédric Le Goater     /* Bus 11: TODO ucd90160@64 */
53362c2c2ebSCédric Le Goater }
53462c2c2ebSCédric Le Goater 
5351a15311aSCédric Le Goater static bool aspeed_get_mmio_exec(Object *obj, Error **errp)
5361a15311aSCédric Le Goater {
5371a15311aSCédric Le Goater     return ASPEED_MACHINE(obj)->mmio_exec;
5381a15311aSCédric Le Goater }
5391a15311aSCédric Le Goater 
5401a15311aSCédric Le Goater static void aspeed_set_mmio_exec(Object *obj, bool value, Error **errp)
5411a15311aSCédric Le Goater {
5421a15311aSCédric Le Goater     ASPEED_MACHINE(obj)->mmio_exec = value;
5431a15311aSCédric Le Goater }
5441a15311aSCédric Le Goater 
5451a15311aSCédric Le Goater static void aspeed_machine_instance_init(Object *obj)
5461a15311aSCédric Le Goater {
5471a15311aSCédric Le Goater     ASPEED_MACHINE(obj)->mmio_exec = false;
5481a15311aSCédric Le Goater }
5491a15311aSCédric Le Goater 
5501a15311aSCédric Le Goater static void aspeed_machine_class_props_init(ObjectClass *oc)
5511a15311aSCédric Le Goater {
5521a15311aSCédric Le Goater     object_class_property_add_bool(oc, "execute-in-place",
5531a15311aSCédric Le Goater                                    aspeed_get_mmio_exec,
554d2623129SMarkus Armbruster                                    aspeed_set_mmio_exec);
5551a15311aSCédric Le Goater     object_class_property_set_description(oc, "execute-in-place",
5567eecec7dSMarkus Armbruster                            "boot directly from CE0 flash device");
5571a15311aSCédric Le Goater }
5581a15311aSCédric Le Goater 
559b7f1a0cbSCédric Le Goater static int aspeed_soc_num_cpus(const char *soc_name)
560b7f1a0cbSCédric Le Goater {
561b7f1a0cbSCédric Le Goater    AspeedSoCClass *sc = ASPEED_SOC_CLASS(object_class_by_name(soc_name));
562b7f1a0cbSCédric Le Goater    return sc->num_cpus;
563b7f1a0cbSCédric Le Goater }
564b7f1a0cbSCédric Le Goater 
565fca9ca1bSCédric Le Goater static void aspeed_machine_class_init(ObjectClass *oc, void *data)
56662c2c2ebSCédric Le Goater {
56762c2c2ebSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
568*d3bad7e7SCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
56962c2c2ebSCédric Le Goater 
570fca9ca1bSCédric Le Goater     mc->init = aspeed_machine_init;
57162c2c2ebSCédric Le Goater     mc->no_floppy = 1;
57262c2c2ebSCédric Le Goater     mc->no_cdrom = 1;
57362c2c2ebSCédric Le Goater     mc->no_parallel = 1;
574afcbaed6SIgor Mammedov     mc->default_ram_id = "ram";
575*d3bad7e7SCédric Le Goater     amc->macs_mask = ASPEED_MAC0_ON;
5761a15311aSCédric Le Goater 
5771a15311aSCédric Le Goater     aspeed_machine_class_props_init(oc);
57862c2c2ebSCédric Le Goater }
57962c2c2ebSCédric Le Goater 
580baa4732bSCédric Le Goater static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data)
581baa4732bSCédric Le Goater {
582baa4732bSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
583baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
584baa4732bSCédric Le Goater 
585baa4732bSCédric Le Goater     mc->desc       = "OpenPOWER Palmetto BMC (ARM926EJ-S)";
586baa4732bSCédric Le Goater     amc->soc_name  = "ast2400-a1";
587baa4732bSCédric Le Goater     amc->hw_strap1 = PALMETTO_BMC_HW_STRAP1;
588baa4732bSCédric Le Goater     amc->fmc_model = "n25q256a";
589baa4732bSCédric Le Goater     amc->spi_model = "mx25l25635e";
590baa4732bSCédric Le Goater     amc->num_cs    = 1;
591baa4732bSCédric Le Goater     amc->i2c_init  = palmetto_bmc_i2c_init;
592baa4732bSCédric Le Goater     mc->default_ram_size       = 256 * MiB;
593b7f1a0cbSCédric Le Goater     mc->default_cpus = mc->min_cpus = mc->max_cpus =
594b7f1a0cbSCédric Le Goater         aspeed_soc_num_cpus(amc->soc_name);
595baa4732bSCédric Le Goater };
596baa4732bSCédric Le Goater 
597baa4732bSCédric Le Goater static void aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data)
598baa4732bSCédric Le Goater {
599baa4732bSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
600baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
601baa4732bSCédric Le Goater 
602baa4732bSCédric Le Goater     mc->desc       = "Aspeed AST2500 EVB (ARM1176)";
603baa4732bSCédric Le Goater     amc->soc_name  = "ast2500-a1";
604baa4732bSCédric Le Goater     amc->hw_strap1 = AST2500_EVB_HW_STRAP1;
605baa4732bSCédric Le Goater     amc->fmc_model = "w25q256";
606baa4732bSCédric Le Goater     amc->spi_model = "mx25l25635e";
607baa4732bSCédric Le Goater     amc->num_cs    = 1;
608baa4732bSCédric Le Goater     amc->i2c_init  = ast2500_evb_i2c_init;
609baa4732bSCédric Le Goater     mc->default_ram_size       = 512 * MiB;
610b7f1a0cbSCédric Le Goater     mc->default_cpus = mc->min_cpus = mc->max_cpus =
611b7f1a0cbSCédric Le Goater         aspeed_soc_num_cpus(amc->soc_name);
612baa4732bSCédric Le Goater };
613baa4732bSCédric Le Goater 
614baa4732bSCédric Le Goater static void aspeed_machine_romulus_class_init(ObjectClass *oc, void *data)
615baa4732bSCédric Le Goater {
616baa4732bSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
617baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
618baa4732bSCédric Le Goater 
619baa4732bSCédric Le Goater     mc->desc       = "OpenPOWER Romulus BMC (ARM1176)";
620baa4732bSCédric Le Goater     amc->soc_name  = "ast2500-a1";
621baa4732bSCédric Le Goater     amc->hw_strap1 = ROMULUS_BMC_HW_STRAP1;
622baa4732bSCédric Le Goater     amc->fmc_model = "n25q256a";
623baa4732bSCédric Le Goater     amc->spi_model = "mx66l1g45g";
624baa4732bSCédric Le Goater     amc->num_cs    = 2;
625baa4732bSCédric Le Goater     amc->i2c_init  = romulus_bmc_i2c_init;
626baa4732bSCédric Le Goater     mc->default_ram_size       = 512 * MiB;
627b7f1a0cbSCédric Le Goater     mc->default_cpus = mc->min_cpus = mc->max_cpus =
628b7f1a0cbSCédric Le Goater         aspeed_soc_num_cpus(amc->soc_name);
629baa4732bSCédric Le Goater };
630baa4732bSCédric Le Goater 
631143b040fSPatrick Williams static void aspeed_machine_sonorapass_class_init(ObjectClass *oc, void *data)
632143b040fSPatrick Williams {
633143b040fSPatrick Williams     MachineClass *mc = MACHINE_CLASS(oc);
634143b040fSPatrick Williams     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
635143b040fSPatrick Williams 
636143b040fSPatrick Williams     mc->desc       = "OCP SonoraPass BMC (ARM1176)";
637143b040fSPatrick Williams     amc->soc_name  = "ast2500-a1";
638143b040fSPatrick Williams     amc->hw_strap1 = SONORAPASS_BMC_HW_STRAP1;
639143b040fSPatrick Williams     amc->fmc_model = "mx66l1g45g";
640143b040fSPatrick Williams     amc->spi_model = "mx66l1g45g";
641143b040fSPatrick Williams     amc->num_cs    = 2;
642143b040fSPatrick Williams     amc->i2c_init  = sonorapass_bmc_i2c_init;
643143b040fSPatrick Williams     mc->default_ram_size       = 512 * MiB;
644b7f1a0cbSCédric Le Goater     mc->default_cpus = mc->min_cpus = mc->max_cpus =
645b7f1a0cbSCédric Le Goater         aspeed_soc_num_cpus(amc->soc_name);
646143b040fSPatrick Williams };
647143b040fSPatrick Williams 
648baa4732bSCédric Le Goater static void aspeed_machine_swift_class_init(ObjectClass *oc, void *data)
649baa4732bSCédric Le Goater {
650baa4732bSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
651baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
652baa4732bSCédric Le Goater 
653baa4732bSCédric Le Goater     mc->desc       = "OpenPOWER Swift BMC (ARM1176)";
654baa4732bSCédric Le Goater     amc->soc_name  = "ast2500-a1";
655baa4732bSCédric Le Goater     amc->hw_strap1 = SWIFT_BMC_HW_STRAP1;
656baa4732bSCédric Le Goater     amc->fmc_model = "mx66l1g45g";
657baa4732bSCédric Le Goater     amc->spi_model = "mx66l1g45g";
658baa4732bSCédric Le Goater     amc->num_cs    = 2;
659baa4732bSCédric Le Goater     amc->i2c_init  = swift_bmc_i2c_init;
660baa4732bSCédric Le Goater     mc->default_ram_size       = 512 * MiB;
661b7f1a0cbSCédric Le Goater     mc->default_cpus = mc->min_cpus = mc->max_cpus =
662b7f1a0cbSCédric Le Goater         aspeed_soc_num_cpus(amc->soc_name);
663baa4732bSCédric Le Goater };
664baa4732bSCédric Le Goater 
665baa4732bSCédric Le Goater static void aspeed_machine_witherspoon_class_init(ObjectClass *oc, void *data)
666baa4732bSCédric Le Goater {
667baa4732bSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
668baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
669baa4732bSCédric Le Goater 
670baa4732bSCédric Le Goater     mc->desc       = "OpenPOWER Witherspoon BMC (ARM1176)";
671baa4732bSCédric Le Goater     amc->soc_name  = "ast2500-a1";
672baa4732bSCédric Le Goater     amc->hw_strap1 = WITHERSPOON_BMC_HW_STRAP1;
673baa4732bSCédric Le Goater     amc->fmc_model = "mx25l25635e";
674baa4732bSCédric Le Goater     amc->spi_model = "mx66l1g45g";
675baa4732bSCédric Le Goater     amc->num_cs    = 2;
676baa4732bSCédric Le Goater     amc->i2c_init  = witherspoon_bmc_i2c_init;
677baa4732bSCédric Le Goater     mc->default_ram_size = 512 * MiB;
678b7f1a0cbSCédric Le Goater     mc->default_cpus = mc->min_cpus = mc->max_cpus =
679b7f1a0cbSCédric Le Goater         aspeed_soc_num_cpus(amc->soc_name);
680baa4732bSCédric Le Goater };
681baa4732bSCédric Le Goater 
682baa4732bSCédric Le Goater static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data)
683baa4732bSCédric Le Goater {
684baa4732bSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
685baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
686baa4732bSCédric Le Goater 
687baa4732bSCédric Le Goater     mc->desc       = "Aspeed AST2600 EVB (Cortex A7)";
6887582591aSJoel Stanley     amc->soc_name  = "ast2600-a1";
689baa4732bSCédric Le Goater     amc->hw_strap1 = AST2600_EVB_HW_STRAP1;
690baa4732bSCédric Le Goater     amc->hw_strap2 = AST2600_EVB_HW_STRAP2;
691baa4732bSCédric Le Goater     amc->fmc_model = "w25q512jv";
692baa4732bSCédric Le Goater     amc->spi_model = "mx66u51235f";
693baa4732bSCédric Le Goater     amc->num_cs    = 1;
694*d3bad7e7SCédric Le Goater     amc->macs_mask  = ASPEED_MAC1_ON | ASPEED_MAC2_ON | ASPEED_MAC3_ON;
695baa4732bSCédric Le Goater     amc->i2c_init  = ast2600_evb_i2c_init;
696baa4732bSCédric Le Goater     mc->default_ram_size = 1 * GiB;
697b7f1a0cbSCédric Le Goater     mc->default_cpus = mc->min_cpus = mc->max_cpus =
698b7f1a0cbSCédric Le Goater         aspeed_soc_num_cpus(amc->soc_name);
699baa4732bSCédric Le Goater };
700baa4732bSCédric Le Goater 
70163ceb818SCédric Le Goater static void aspeed_machine_tacoma_class_init(ObjectClass *oc, void *data)
70263ceb818SCédric Le Goater {
70363ceb818SCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
70463ceb818SCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
70563ceb818SCédric Le Goater 
7067582591aSJoel Stanley     mc->desc       = "OpenPOWER Tacoma BMC (Cortex A7)";
7077582591aSJoel Stanley     amc->soc_name  = "ast2600-a1";
70863ceb818SCédric Le Goater     amc->hw_strap1 = TACOMA_BMC_HW_STRAP1;
70963ceb818SCédric Le Goater     amc->hw_strap2 = TACOMA_BMC_HW_STRAP2;
71063ceb818SCédric Le Goater     amc->fmc_model = "mx66l1g45g";
71163ceb818SCédric Le Goater     amc->spi_model = "mx66l1g45g";
71263ceb818SCédric Le Goater     amc->num_cs    = 2;
713*d3bad7e7SCédric Le Goater     amc->macs_mask  = ASPEED_MAC2_ON;
71463ceb818SCédric Le Goater     amc->i2c_init  = witherspoon_bmc_i2c_init; /* Same board layout */
71563ceb818SCédric Le Goater     mc->default_ram_size = 1 * GiB;
716b7f1a0cbSCédric Le Goater     mc->default_cpus = mc->min_cpus = mc->max_cpus =
717b7f1a0cbSCédric Le Goater         aspeed_soc_num_cpus(amc->soc_name);
71863ceb818SCédric Le Goater };
71963ceb818SCédric Le Goater 
720baa4732bSCédric Le Goater static const TypeInfo aspeed_machine_types[] = {
721baa4732bSCédric Le Goater     {
722baa4732bSCédric Le Goater         .name          = MACHINE_TYPE_NAME("palmetto-bmc"),
723baa4732bSCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
724baa4732bSCédric Le Goater         .class_init    = aspeed_machine_palmetto_class_init,
725baa4732bSCédric Le Goater     }, {
726baa4732bSCédric Le Goater         .name          = MACHINE_TYPE_NAME("ast2500-evb"),
727baa4732bSCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
728baa4732bSCédric Le Goater         .class_init    = aspeed_machine_ast2500_evb_class_init,
729baa4732bSCédric Le Goater     }, {
730baa4732bSCédric Le Goater         .name          = MACHINE_TYPE_NAME("romulus-bmc"),
731baa4732bSCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
732baa4732bSCédric Le Goater         .class_init    = aspeed_machine_romulus_class_init,
733baa4732bSCédric Le Goater     }, {
734baa4732bSCédric Le Goater         .name          = MACHINE_TYPE_NAME("swift-bmc"),
735baa4732bSCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
736baa4732bSCédric Le Goater         .class_init    = aspeed_machine_swift_class_init,
737baa4732bSCédric Le Goater     }, {
738143b040fSPatrick Williams         .name          = MACHINE_TYPE_NAME("sonorapass-bmc"),
739143b040fSPatrick Williams         .parent        = TYPE_ASPEED_MACHINE,
740143b040fSPatrick Williams         .class_init    = aspeed_machine_sonorapass_class_init,
741143b040fSPatrick Williams     }, {
742baa4732bSCédric Le Goater         .name          = MACHINE_TYPE_NAME("witherspoon-bmc"),
743baa4732bSCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
744baa4732bSCédric Le Goater         .class_init    = aspeed_machine_witherspoon_class_init,
745baa4732bSCédric Le Goater     }, {
746baa4732bSCédric Le Goater         .name          = MACHINE_TYPE_NAME("ast2600-evb"),
747baa4732bSCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
748baa4732bSCédric Le Goater         .class_init    = aspeed_machine_ast2600_evb_class_init,
749baa4732bSCédric Le Goater     }, {
75063ceb818SCédric Le Goater         .name          = MACHINE_TYPE_NAME("tacoma-bmc"),
75163ceb818SCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
75263ceb818SCédric Le Goater         .class_init    = aspeed_machine_tacoma_class_init,
75363ceb818SCédric Le Goater     }, {
754fca9ca1bSCédric Le Goater         .name          = TYPE_ASPEED_MACHINE,
75562c2c2ebSCédric Le Goater         .parent        = TYPE_MACHINE,
756fca9ca1bSCédric Le Goater         .instance_size = sizeof(AspeedMachine),
7571a15311aSCédric Le Goater         .instance_init = aspeed_machine_instance_init,
758fca9ca1bSCédric Le Goater         .class_size    = sizeof(AspeedMachineClass),
759fca9ca1bSCédric Le Goater         .class_init    = aspeed_machine_class_init,
760baa4732bSCédric Le Goater         .abstract      = true,
761baa4732bSCédric Le Goater     }
762fca9ca1bSCédric Le Goater };
76374fb1f38SCédric Le Goater 
764baa4732bSCédric Le Goater DEFINE_TYPES(aspeed_machine_types)
765