xref: /qemu/hw/arm/aspeed.c (revision d2623129a7dec1d3041ad1221dda1ca49c667532)
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;
261327d8e4eSAndrew Jeffery 
26274fb1f38SCédric Le Goater     bmc = g_new0(AspeedBoardState, 1);
263ad1a9782SCédric Le Goater 
264ad1a9782SCédric Le Goater     memory_region_init(&bmc->ram_container, NULL, "aspeed-ram-container",
265ad1a9782SCédric Le Goater                        UINT32_MAX);
266afcbaed6SIgor Mammedov     memory_region_add_subregion(&bmc->ram_container, 0, machine->ram);
267ad1a9782SCédric Le Goater 
2681b0ad567SPhilippe Mathieu-Daudé     object_initialize_child(OBJECT(machine), "soc", &bmc->soc,
269baa4732bSCédric Le Goater                             (sizeof(bmc->soc)), amc->soc_name, &error_abort,
2701b0ad567SPhilippe Mathieu-Daudé                             NULL);
271327d8e4eSAndrew Jeffery 
272b033271fSCédric Le Goater     sc = ASPEED_SOC_GET_CLASS(&bmc->soc);
273b033271fSCédric Le Goater 
274533eb415SIgor Mammedov     /*
275533eb415SIgor Mammedov      * This will error out if isize is not supported by memory controller.
276533eb415SIgor Mammedov      */
27719e9cdf0SMarc-André Lureau     object_property_set_uint(OBJECT(&bmc->soc), ram_size, "ram-size",
278533eb415SIgor Mammedov                              &error_fatal);
279533eb415SIgor Mammedov 
280baa4732bSCédric Le Goater     object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap1, "hw-strap1",
28187e79af0SAndrew Jeffery                             &error_abort);
282baa4732bSCédric Le Goater     object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap2, "hw-strap2",
283ccc2c418SCédric Le Goater                             &error_abort);
284baa4732bSCédric Le Goater     object_property_set_int(OBJECT(&bmc->soc), amc->num_cs, "num-cs",
28526d5df95SCédric Le Goater                             &error_abort);
286cc7d44c2SLike Xu     object_property_set_int(OBJECT(&bmc->soc), machine->smp.cpus, "num-cpus",
287ece09beeSCédric Le Goater                             &error_abort);
288c4e1f0b4SCédric Le Goater     object_property_set_link(OBJECT(&bmc->soc), OBJECT(&bmc->ram_container),
289c4e1f0b4SCédric Le Goater                              "dram", &error_abort);
290b6e70d1dSJoel Stanley     if (machine->kernel_filename) {
291b6e70d1dSJoel Stanley         /*
292b6e70d1dSJoel Stanley          * When booting with a -kernel command line there is no u-boot
293b6e70d1dSJoel Stanley          * that runs to unlock the SCU. In this case set the default to
294b6e70d1dSJoel Stanley          * be unlocked as the kernel expects
295b6e70d1dSJoel Stanley          */
296b6e70d1dSJoel Stanley         object_property_set_int(OBJECT(&bmc->soc), ASPEED_SCU_PROT_KEY,
297b6e70d1dSJoel Stanley                                 "hw-prot-key", &error_abort);
298b6e70d1dSJoel Stanley     }
299327d8e4eSAndrew Jeffery     object_property_set_bool(OBJECT(&bmc->soc), true, "realized",
300327d8e4eSAndrew Jeffery                              &error_abort);
301327d8e4eSAndrew Jeffery 
302d783d1feSCédric Le Goater     memory_region_add_subregion(get_system_memory(),
30354ecafb7SCédric Le Goater                                 sc->memmap[ASPEED_SDRAM],
304ad1a9782SCédric Le Goater                                 &bmc->ram_container);
305de46f5f4SCédric Le Goater 
306ebe31c0aSCédric Le Goater     max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size",
307ebe31c0aSCédric Le Goater                                             &error_abort);
308ebe31c0aSCédric Le Goater     memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL,
309ebe31c0aSCédric Le Goater                           "max_ram", max_ram_size  - ram_size);
310ad1a9782SCédric Le Goater     memory_region_add_subregion(&bmc->ram_container, ram_size, &bmc->max_ram);
311ebe31c0aSCédric Le Goater 
312baa4732bSCédric Le Goater     aspeed_board_init_flashes(&bmc->soc.fmc, amc->fmc_model, &error_abort);
313baa4732bSCédric Le Goater     aspeed_board_init_flashes(&bmc->soc.spi[0], amc->spi_model, &error_abort);
314e1ad9bc4SCédric Le Goater 
315d769a1daSCédric Le Goater     /* Install first FMC flash content as a boot rom. */
316d769a1daSCédric Le Goater     if (drive0) {
317d769a1daSCédric Le Goater         AspeedSMCFlash *fl = &bmc->soc.fmc.flashes[0];
318d769a1daSCédric Le Goater         MemoryRegion *boot_rom = g_new(MemoryRegion, 1);
319d769a1daSCédric Le Goater 
320d769a1daSCédric Le Goater         /*
321d769a1daSCédric Le Goater          * create a ROM region using the default mapping window size of
32293bf276dSCédric Le Goater          * the flash module. The window size is 64MB for the AST2400
32393bf276dSCédric Le Goater          * SoC and 128MB for the AST2500 SoC, which is twice as big as
32493bf276dSCédric Le Goater          * needed by the flash modules of the Aspeed machines.
325d769a1daSCédric Le Goater          */
3261a15311aSCédric Le Goater         if (ASPEED_MACHINE(machine)->mmio_exec) {
3271a15311aSCédric Le Goater             memory_region_init_alias(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
3281a15311aSCédric Le Goater                                      &fl->mmio, 0, fl->size);
3291a15311aSCédric Le Goater             memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
3301a15311aSCédric Le Goater                                         boot_rom);
3311a15311aSCédric Le Goater         } else {
33244cf837dSPeter Maydell             memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
333d769a1daSCédric Le Goater                                    fl->size, &error_abort);
334d769a1daSCédric Le Goater             memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
335d769a1daSCédric Le Goater                                         boot_rom);
336d769a1daSCédric Le Goater             write_boot_rom(drive0, FIRMWARE_ADDR, fl->size, &error_abort);
337d769a1daSCédric Le Goater         }
3381a15311aSCédric Le Goater     }
339d769a1daSCédric Le Goater 
3409bb6d140SJoel Stanley     if (machine->kernel_filename && bmc->soc.num_cpus > 1) {
3419bb6d140SJoel Stanley         /* With no u-boot we must set up a boot stub for the secondary CPU */
3429bb6d140SJoel Stanley         MemoryRegion *smpboot = g_new(MemoryRegion, 1);
3439bb6d140SJoel Stanley         memory_region_init_ram(smpboot, OBJECT(bmc), "aspeed.smpboot",
3449bb6d140SJoel Stanley                                0x80, &error_abort);
3459bb6d140SJoel Stanley         memory_region_add_subregion(get_system_memory(),
3469bb6d140SJoel Stanley                                     AST_SMP_MAILBOX_BASE, smpboot);
3479bb6d140SJoel Stanley 
3489bb6d140SJoel Stanley         aspeed_board_binfo.write_secondary_boot = aspeed_write_smpboot;
3499bb6d140SJoel Stanley         aspeed_board_binfo.secondary_cpu_reset_hook = aspeed_reset_secondary;
3509bb6d140SJoel Stanley         aspeed_board_binfo.smp_loader_start = AST_SMP_MBOX_CODE;
3519bb6d140SJoel Stanley     }
3529bb6d140SJoel Stanley 
35374fb1f38SCédric Le Goater     aspeed_board_binfo.ram_size = ram_size;
35454ecafb7SCédric Le Goater     aspeed_board_binfo.loader_start = sc->memmap[ASPEED_SDRAM];
355ece09beeSCédric Le Goater     aspeed_board_binfo.nb_cpus = bmc->soc.num_cpus;
356b033271fSCédric Le Goater 
357baa4732bSCédric Le Goater     if (amc->i2c_init) {
358baa4732bSCédric Le Goater         amc->i2c_init(bmc);
3592cf6cb50SCédric Le Goater     }
3602cf6cb50SCédric Le Goater 
3610e2c24c6SAndrew Jeffery     for (i = 0; i < bmc->soc.sdhci.num_slots; i++) {
362a29e3e12SAndrew Jeffery         sdhci_attach_drive(&bmc->soc.sdhci.slots[i], drive_get_next(IF_SD));
363a29e3e12SAndrew Jeffery     }
3642bea128cSEddie James 
365a29e3e12SAndrew Jeffery     if (bmc->soc.emmc.num_slots) {
366a29e3e12SAndrew Jeffery         sdhci_attach_drive(&bmc->soc.emmc.slots[0], drive_get_next(IF_SD));
3672bea128cSEddie James     }
3682bea128cSEddie James 
3692744ece8STao Xu     arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo);
370327d8e4eSAndrew Jeffery }
371327d8e4eSAndrew Jeffery 
3722cf6cb50SCédric Le Goater static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)
3732cf6cb50SCédric Le Goater {
3742cf6cb50SCédric Le Goater     AspeedSoCState *soc = &bmc->soc;
375a87e81b9SCédric Le Goater     DeviceState *dev;
3763d165f12SCédric Le Goater     uint8_t *eeprom_buf = g_malloc0(32 * 1024);
3772cf6cb50SCédric Le Goater 
3782cf6cb50SCédric Le Goater     /* The palmetto platform expects a ds3231 RTC but a ds1338 is
3792cf6cb50SCédric Le Goater      * enough to provide basic RTC features. Alarms will be missing */
3802cf6cb50SCédric Le Goater     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68);
381a87e81b9SCédric Le Goater 
3823d165f12SCédric Le Goater     smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50,
3833d165f12SCédric Le Goater                           eeprom_buf);
3843d165f12SCédric Le Goater 
385a87e81b9SCédric Le Goater     /* add a TMP423 temperature sensor */
386a87e81b9SCédric Le Goater     dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2),
387a87e81b9SCédric Le Goater                            "tmp423", 0x4c);
388a87e81b9SCédric Le Goater     object_property_set_int(OBJECT(dev), 31000, "temperature0", &error_abort);
389a87e81b9SCédric Le Goater     object_property_set_int(OBJECT(dev), 28000, "temperature1", &error_abort);
390a87e81b9SCédric Le Goater     object_property_set_int(OBJECT(dev), 20000, "temperature2", &error_abort);
391a87e81b9SCédric Le Goater     object_property_set_int(OBJECT(dev), 110000, "temperature3", &error_abort);
3922cf6cb50SCédric Le Goater }
3932cf6cb50SCédric Le Goater 
3942cf6cb50SCédric Le Goater static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
3952cf6cb50SCédric Le Goater {
3962cf6cb50SCédric Le Goater     AspeedSoCState *soc = &bmc->soc;
3973d165f12SCédric Le Goater     uint8_t *eeprom_buf = g_malloc0(8 * 1024);
3983d165f12SCédric Le Goater 
3993d165f12SCédric Le Goater     smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50,
4003d165f12SCédric Le Goater                           eeprom_buf);
4012cf6cb50SCédric Le Goater 
4022cf6cb50SCédric Le Goater     /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
403044475f3SPhilippe Mathieu-Daudé     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7),
404044475f3SPhilippe Mathieu-Daudé                      TYPE_TMP105, 0x4d);
4056c4567c7SCédric Le Goater 
4066c4567c7SCédric Le Goater     /* The AST2500 EVB does not have an RTC. Let's pretend that one is
4076c4567c7SCédric Le Goater      * plugged on the I2C bus header */
4086c4567c7SCédric Le Goater     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
4092cf6cb50SCédric Le Goater }
4102cf6cb50SCédric Le Goater 
411ccc2c418SCédric Le Goater static void ast2600_evb_i2c_init(AspeedBoardState *bmc)
412ccc2c418SCédric Le Goater {
413ccc2c418SCédric Le Goater     /* Start with some devices on our I2C busses */
414ccc2c418SCédric Le Goater     ast2500_evb_i2c_init(bmc);
415ccc2c418SCédric Le Goater }
416ccc2c418SCédric Le Goater 
4176c4567c7SCédric Le Goater static void romulus_bmc_i2c_init(AspeedBoardState *bmc)
4186c4567c7SCédric Le Goater {
4196c4567c7SCédric Le Goater     AspeedSoCState *soc = &bmc->soc;
4206c4567c7SCédric Le Goater 
4216c4567c7SCédric Le Goater     /* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is
4226c4567c7SCédric Le Goater      * good enough */
4236c4567c7SCédric Le Goater     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
4246c4567c7SCédric Le Goater }
4256c4567c7SCédric Le Goater 
426aae7a18dSAdriana Kobylak static void swift_bmc_i2c_init(AspeedBoardState *bmc)
427aae7a18dSAdriana Kobylak {
428aae7a18dSAdriana Kobylak     AspeedSoCState *soc = &bmc->soc;
429aae7a18dSAdriana Kobylak 
430aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60);
431aae7a18dSAdriana Kobylak 
432aae7a18dSAdriana Kobylak     /* The swift board expects a TMP275 but a TMP105 is compatible */
433aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x48);
434aae7a18dSAdriana Kobylak     /* The swift board expects a pca9551 but a pca9552 is compatible */
435aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "pca9552", 0x60);
436aae7a18dSAdriana Kobylak 
437aae7a18dSAdriana Kobylak     /* The swift board expects an Epson RX8900 RTC but a ds1338 is compatible */
438aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "ds1338", 0x32);
439aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60);
440aae7a18dSAdriana Kobylak 
441aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp423", 0x4c);
442aae7a18dSAdriana Kobylak     /* The swift board expects a pca9539 but a pca9552 is compatible */
443aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "pca9552", 0x74);
444aae7a18dSAdriana Kobylak 
445aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "tmp423", 0x4c);
446aae7a18dSAdriana Kobylak     /* The swift board expects a pca9539 but a pca9552 is compatible */
447aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "pca9552",
448aae7a18dSAdriana Kobylak                      0x74);
449aae7a18dSAdriana Kobylak 
450aae7a18dSAdriana Kobylak     /* The swift board expects a TMP275 but a TMP105 is compatible */
451aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x48);
452aae7a18dSAdriana Kobylak     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x4a);
453aae7a18dSAdriana Kobylak }
454aae7a18dSAdriana Kobylak 
455143b040fSPatrick Williams static void sonorapass_bmc_i2c_init(AspeedBoardState *bmc)
456143b040fSPatrick Williams {
457143b040fSPatrick Williams     AspeedSoCState *soc = &bmc->soc;
458143b040fSPatrick Williams 
459143b040fSPatrick Williams     /* bus 2 : */
460143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), "tmp105", 0x48);
461143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), "tmp105", 0x49);
462143b040fSPatrick Williams     /* bus 2 : pca9546 @ 0x73 */
463143b040fSPatrick Williams 
464143b040fSPatrick Williams     /* bus 3 : pca9548 @ 0x70 */
465143b040fSPatrick Williams 
466143b040fSPatrick Williams     /* bus 4 : */
467143b040fSPatrick Williams     uint8_t *eeprom4_54 = g_malloc0(8 * 1024);
468143b040fSPatrick Williams     smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), 0x54,
469143b040fSPatrick Williams                           eeprom4_54);
470143b040fSPatrick Williams     /* PCA9539 @ 0x76, but PCA9552 is compatible */
471143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "pca9552", 0x76);
472143b040fSPatrick Williams     /* PCA9539 @ 0x77, but PCA9552 is compatible */
473143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "pca9552", 0x77);
474143b040fSPatrick Williams 
475143b040fSPatrick Williams     /* bus 6 : */
476143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 6), "tmp105", 0x48);
477143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 6), "tmp105", 0x49);
478143b040fSPatrick Williams     /* bus 6 : pca9546 @ 0x73 */
479143b040fSPatrick Williams 
480143b040fSPatrick Williams     /* bus 8 : */
481143b040fSPatrick Williams     uint8_t *eeprom8_56 = g_malloc0(8 * 1024);
482143b040fSPatrick Williams     smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), 0x56,
483143b040fSPatrick Williams                           eeprom8_56);
484143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60);
485143b040fSPatrick Williams     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x61);
486143b040fSPatrick Williams     /* bus 8 : adc128d818 @ 0x1d */
487143b040fSPatrick Williams     /* bus 8 : adc128d818 @ 0x1f */
488143b040fSPatrick Williams 
489143b040fSPatrick Williams     /*
490143b040fSPatrick Williams      * bus 13 : pca9548 @ 0x71
491143b040fSPatrick Williams      *      - channel 3:
492143b040fSPatrick Williams      *          - tmm421 @ 0x4c
493143b040fSPatrick Williams      *          - tmp421 @ 0x4e
494143b040fSPatrick Williams      *          - tmp421 @ 0x4f
495143b040fSPatrick Williams      */
496143b040fSPatrick Williams 
497143b040fSPatrick Williams }
498143b040fSPatrick Williams 
49962c2c2ebSCédric Le Goater static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
50062c2c2ebSCédric Le Goater {
50162c2c2ebSCédric Le Goater     AspeedSoCState *soc = &bmc->soc;
5023d165f12SCédric Le Goater     uint8_t *eeprom_buf = g_malloc0(8 * 1024);
50362c2c2ebSCédric Le Goater 
50463ceb818SCédric Le Goater     /* Bus 3: TODO bmp280@77 */
50563ceb818SCédric Le Goater     /* Bus 3: TODO max31785@52 */
50663ceb818SCédric Le Goater     /* Bus 3: TODO dps310@76 */
507044475f3SPhilippe Mathieu-Daudé     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), TYPE_PCA9552,
508044475f3SPhilippe Mathieu-Daudé                      0x60);
5098c9a61d7SCédric Le Goater 
51062c2c2ebSCédric Le Goater     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
51162c2c2ebSCédric Le Goater     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
51262c2c2ebSCédric Le Goater 
51362c2c2ebSCédric Le Goater     /* The Witherspoon expects a TMP275 but a TMP105 is compatible */
514044475f3SPhilippe Mathieu-Daudé     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), TYPE_TMP105,
515044475f3SPhilippe Mathieu-Daudé                      0x4a);
5166c4567c7SCédric Le Goater 
5176c4567c7SCédric Le Goater     /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
5186c4567c7SCédric Le Goater      * good enough */
5196c4567c7SCédric Le Goater     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
5203d165f12SCédric Le Goater 
5213d165f12SCédric Le Goater     smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,
5223d165f12SCédric Le Goater                           eeprom_buf);
523044475f3SPhilippe Mathieu-Daudé     i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), TYPE_PCA9552,
5248c9a61d7SCédric Le Goater                      0x60);
52563ceb818SCédric Le Goater     /* Bus 11: TODO ucd90160@64 */
52662c2c2ebSCédric Le Goater }
52762c2c2ebSCédric Le Goater 
5281a15311aSCédric Le Goater static bool aspeed_get_mmio_exec(Object *obj, Error **errp)
5291a15311aSCédric Le Goater {
5301a15311aSCédric Le Goater     return ASPEED_MACHINE(obj)->mmio_exec;
5311a15311aSCédric Le Goater }
5321a15311aSCédric Le Goater 
5331a15311aSCédric Le Goater static void aspeed_set_mmio_exec(Object *obj, bool value, Error **errp)
5341a15311aSCédric Le Goater {
5351a15311aSCédric Le Goater     ASPEED_MACHINE(obj)->mmio_exec = value;
5361a15311aSCédric Le Goater }
5371a15311aSCédric Le Goater 
5381a15311aSCédric Le Goater static void aspeed_machine_instance_init(Object *obj)
5391a15311aSCédric Le Goater {
5401a15311aSCédric Le Goater     ASPEED_MACHINE(obj)->mmio_exec = false;
5411a15311aSCédric Le Goater }
5421a15311aSCédric Le Goater 
5431a15311aSCédric Le Goater static void aspeed_machine_class_props_init(ObjectClass *oc)
5441a15311aSCédric Le Goater {
5451a15311aSCédric Le Goater     object_class_property_add_bool(oc, "execute-in-place",
5461a15311aSCédric Le Goater                                    aspeed_get_mmio_exec,
547*d2623129SMarkus Armbruster                                    aspeed_set_mmio_exec);
5481a15311aSCédric Le Goater     object_class_property_set_description(oc, "execute-in-place",
5497eecec7dSMarkus Armbruster                            "boot directly from CE0 flash device");
5501a15311aSCédric Le Goater }
5511a15311aSCédric Le Goater 
552fca9ca1bSCédric Le Goater static void aspeed_machine_class_init(ObjectClass *oc, void *data)
55362c2c2ebSCédric Le Goater {
55462c2c2ebSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
55562c2c2ebSCédric Le Goater 
556fca9ca1bSCédric Le Goater     mc->init = aspeed_machine_init;
557ece09beeSCédric Le Goater     mc->max_cpus = ASPEED_CPUS_NUM;
55862c2c2ebSCédric Le Goater     mc->no_floppy = 1;
55962c2c2ebSCédric Le Goater     mc->no_cdrom = 1;
56062c2c2ebSCédric Le Goater     mc->no_parallel = 1;
561afcbaed6SIgor Mammedov     mc->default_ram_id = "ram";
5621a15311aSCédric Le Goater 
5631a15311aSCédric Le Goater     aspeed_machine_class_props_init(oc);
56462c2c2ebSCédric Le Goater }
56562c2c2ebSCédric Le Goater 
566baa4732bSCédric Le Goater static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data)
567baa4732bSCédric Le Goater {
568baa4732bSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
569baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
570baa4732bSCédric Le Goater 
571baa4732bSCédric Le Goater     mc->desc       = "OpenPOWER Palmetto BMC (ARM926EJ-S)";
572baa4732bSCédric Le Goater     amc->soc_name  = "ast2400-a1";
573baa4732bSCédric Le Goater     amc->hw_strap1 = PALMETTO_BMC_HW_STRAP1;
574baa4732bSCédric Le Goater     amc->fmc_model = "n25q256a";
575baa4732bSCédric Le Goater     amc->spi_model = "mx25l25635e";
576baa4732bSCédric Le Goater     amc->num_cs    = 1;
577baa4732bSCédric Le Goater     amc->i2c_init  = palmetto_bmc_i2c_init;
578baa4732bSCédric Le Goater     mc->default_ram_size       = 256 * MiB;
579baa4732bSCédric Le Goater };
580baa4732bSCédric Le Goater 
581baa4732bSCédric Le Goater static void aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data)
582baa4732bSCédric Le Goater {
583baa4732bSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
584baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
585baa4732bSCédric Le Goater 
586baa4732bSCédric Le Goater     mc->desc       = "Aspeed AST2500 EVB (ARM1176)";
587baa4732bSCédric Le Goater     amc->soc_name  = "ast2500-a1";
588baa4732bSCédric Le Goater     amc->hw_strap1 = AST2500_EVB_HW_STRAP1;
589baa4732bSCédric Le Goater     amc->fmc_model = "w25q256";
590baa4732bSCédric Le Goater     amc->spi_model = "mx25l25635e";
591baa4732bSCédric Le Goater     amc->num_cs    = 1;
592baa4732bSCédric Le Goater     amc->i2c_init  = ast2500_evb_i2c_init;
593baa4732bSCédric Le Goater     mc->default_ram_size       = 512 * MiB;
594baa4732bSCédric Le Goater };
595baa4732bSCédric Le Goater 
596baa4732bSCédric Le Goater static void aspeed_machine_romulus_class_init(ObjectClass *oc, void *data)
597baa4732bSCédric Le Goater {
598baa4732bSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
599baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
600baa4732bSCédric Le Goater 
601baa4732bSCédric Le Goater     mc->desc       = "OpenPOWER Romulus BMC (ARM1176)";
602baa4732bSCédric Le Goater     amc->soc_name  = "ast2500-a1";
603baa4732bSCédric Le Goater     amc->hw_strap1 = ROMULUS_BMC_HW_STRAP1;
604baa4732bSCédric Le Goater     amc->fmc_model = "n25q256a";
605baa4732bSCédric Le Goater     amc->spi_model = "mx66l1g45g";
606baa4732bSCédric Le Goater     amc->num_cs    = 2;
607baa4732bSCédric Le Goater     amc->i2c_init  = romulus_bmc_i2c_init;
608baa4732bSCédric Le Goater     mc->default_ram_size       = 512 * MiB;
609baa4732bSCédric Le Goater };
610baa4732bSCédric Le Goater 
611143b040fSPatrick Williams static void aspeed_machine_sonorapass_class_init(ObjectClass *oc, void *data)
612143b040fSPatrick Williams {
613143b040fSPatrick Williams     MachineClass *mc = MACHINE_CLASS(oc);
614143b040fSPatrick Williams     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
615143b040fSPatrick Williams 
616143b040fSPatrick Williams     mc->desc       = "OCP SonoraPass BMC (ARM1176)";
617143b040fSPatrick Williams     amc->soc_name  = "ast2500-a1";
618143b040fSPatrick Williams     amc->hw_strap1 = SONORAPASS_BMC_HW_STRAP1;
619143b040fSPatrick Williams     amc->fmc_model = "mx66l1g45g";
620143b040fSPatrick Williams     amc->spi_model = "mx66l1g45g";
621143b040fSPatrick Williams     amc->num_cs    = 2;
622143b040fSPatrick Williams     amc->i2c_init  = sonorapass_bmc_i2c_init;
623143b040fSPatrick Williams     mc->default_ram_size       = 512 * MiB;
624143b040fSPatrick Williams };
625143b040fSPatrick Williams 
626baa4732bSCédric Le Goater static void aspeed_machine_swift_class_init(ObjectClass *oc, void *data)
627baa4732bSCédric Le Goater {
628baa4732bSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
629baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
630baa4732bSCédric Le Goater 
631baa4732bSCédric Le Goater     mc->desc       = "OpenPOWER Swift BMC (ARM1176)";
632baa4732bSCédric Le Goater     amc->soc_name  = "ast2500-a1";
633baa4732bSCédric Le Goater     amc->hw_strap1 = SWIFT_BMC_HW_STRAP1;
634baa4732bSCédric Le Goater     amc->fmc_model = "mx66l1g45g";
635baa4732bSCédric Le Goater     amc->spi_model = "mx66l1g45g";
636baa4732bSCédric Le Goater     amc->num_cs    = 2;
637baa4732bSCédric Le Goater     amc->i2c_init  = swift_bmc_i2c_init;
638baa4732bSCédric Le Goater     mc->default_ram_size       = 512 * MiB;
639baa4732bSCédric Le Goater };
640baa4732bSCédric Le Goater 
641baa4732bSCédric Le Goater static void aspeed_machine_witherspoon_class_init(ObjectClass *oc, void *data)
642baa4732bSCédric Le Goater {
643baa4732bSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
644baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
645baa4732bSCédric Le Goater 
646baa4732bSCédric Le Goater     mc->desc       = "OpenPOWER Witherspoon BMC (ARM1176)";
647baa4732bSCédric Le Goater     amc->soc_name  = "ast2500-a1";
648baa4732bSCédric Le Goater     amc->hw_strap1 = WITHERSPOON_BMC_HW_STRAP1;
649baa4732bSCédric Le Goater     amc->fmc_model = "mx25l25635e";
650baa4732bSCédric Le Goater     amc->spi_model = "mx66l1g45g";
651baa4732bSCédric Le Goater     amc->num_cs    = 2;
652baa4732bSCédric Le Goater     amc->i2c_init  = witherspoon_bmc_i2c_init;
653baa4732bSCédric Le Goater     mc->default_ram_size = 512 * MiB;
654baa4732bSCédric Le Goater };
655baa4732bSCédric Le Goater 
656baa4732bSCédric Le Goater static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data)
657baa4732bSCédric Le Goater {
658baa4732bSCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
659baa4732bSCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
660baa4732bSCédric Le Goater 
661baa4732bSCédric Le Goater     mc->desc       = "Aspeed AST2600 EVB (Cortex A7)";
6627582591aSJoel Stanley     amc->soc_name  = "ast2600-a1";
663baa4732bSCédric Le Goater     amc->hw_strap1 = AST2600_EVB_HW_STRAP1;
664baa4732bSCédric Le Goater     amc->hw_strap2 = AST2600_EVB_HW_STRAP2;
665baa4732bSCédric Le Goater     amc->fmc_model = "w25q512jv";
666baa4732bSCédric Le Goater     amc->spi_model = "mx66u51235f";
667baa4732bSCédric Le Goater     amc->num_cs    = 1;
668baa4732bSCédric Le Goater     amc->i2c_init  = ast2600_evb_i2c_init;
669baa4732bSCédric Le Goater     mc->default_ram_size = 1 * GiB;
670baa4732bSCédric Le Goater };
671baa4732bSCédric Le Goater 
67263ceb818SCédric Le Goater static void aspeed_machine_tacoma_class_init(ObjectClass *oc, void *data)
67363ceb818SCédric Le Goater {
67463ceb818SCédric Le Goater     MachineClass *mc = MACHINE_CLASS(oc);
67563ceb818SCédric Le Goater     AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
67663ceb818SCédric Le Goater 
6777582591aSJoel Stanley     mc->desc       = "OpenPOWER Tacoma BMC (Cortex A7)";
6787582591aSJoel Stanley     amc->soc_name  = "ast2600-a1";
67963ceb818SCédric Le Goater     amc->hw_strap1 = TACOMA_BMC_HW_STRAP1;
68063ceb818SCédric Le Goater     amc->hw_strap2 = TACOMA_BMC_HW_STRAP2;
68163ceb818SCédric Le Goater     amc->fmc_model = "mx66l1g45g";
68263ceb818SCédric Le Goater     amc->spi_model = "mx66l1g45g";
68363ceb818SCédric Le Goater     amc->num_cs    = 2;
68463ceb818SCédric Le Goater     amc->i2c_init  = witherspoon_bmc_i2c_init; /* Same board layout */
68563ceb818SCédric Le Goater     mc->default_ram_size = 1 * GiB;
68663ceb818SCédric Le Goater };
68763ceb818SCédric Le Goater 
688baa4732bSCédric Le Goater static const TypeInfo aspeed_machine_types[] = {
689baa4732bSCédric Le Goater     {
690baa4732bSCédric Le Goater         .name          = MACHINE_TYPE_NAME("palmetto-bmc"),
691baa4732bSCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
692baa4732bSCédric Le Goater         .class_init    = aspeed_machine_palmetto_class_init,
693baa4732bSCédric Le Goater     }, {
694baa4732bSCédric Le Goater         .name          = MACHINE_TYPE_NAME("ast2500-evb"),
695baa4732bSCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
696baa4732bSCédric Le Goater         .class_init    = aspeed_machine_ast2500_evb_class_init,
697baa4732bSCédric Le Goater     }, {
698baa4732bSCédric Le Goater         .name          = MACHINE_TYPE_NAME("romulus-bmc"),
699baa4732bSCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
700baa4732bSCédric Le Goater         .class_init    = aspeed_machine_romulus_class_init,
701baa4732bSCédric Le Goater     }, {
702baa4732bSCédric Le Goater         .name          = MACHINE_TYPE_NAME("swift-bmc"),
703baa4732bSCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
704baa4732bSCédric Le Goater         .class_init    = aspeed_machine_swift_class_init,
705baa4732bSCédric Le Goater     }, {
706143b040fSPatrick Williams         .name          = MACHINE_TYPE_NAME("sonorapass-bmc"),
707143b040fSPatrick Williams         .parent        = TYPE_ASPEED_MACHINE,
708143b040fSPatrick Williams         .class_init    = aspeed_machine_sonorapass_class_init,
709143b040fSPatrick Williams     }, {
710baa4732bSCédric Le Goater         .name          = MACHINE_TYPE_NAME("witherspoon-bmc"),
711baa4732bSCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
712baa4732bSCédric Le Goater         .class_init    = aspeed_machine_witherspoon_class_init,
713baa4732bSCédric Le Goater     }, {
714baa4732bSCédric Le Goater         .name          = MACHINE_TYPE_NAME("ast2600-evb"),
715baa4732bSCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
716baa4732bSCédric Le Goater         .class_init    = aspeed_machine_ast2600_evb_class_init,
717baa4732bSCédric Le Goater     }, {
71863ceb818SCédric Le Goater         .name          = MACHINE_TYPE_NAME("tacoma-bmc"),
71963ceb818SCédric Le Goater         .parent        = TYPE_ASPEED_MACHINE,
72063ceb818SCédric Le Goater         .class_init    = aspeed_machine_tacoma_class_init,
72163ceb818SCédric Le Goater     }, {
722fca9ca1bSCédric Le Goater         .name          = TYPE_ASPEED_MACHINE,
72362c2c2ebSCédric Le Goater         .parent        = TYPE_MACHINE,
724fca9ca1bSCédric Le Goater         .instance_size = sizeof(AspeedMachine),
7251a15311aSCédric Le Goater         .instance_init = aspeed_machine_instance_init,
726fca9ca1bSCédric Le Goater         .class_size    = sizeof(AspeedMachineClass),
727fca9ca1bSCédric Le Goater         .class_init    = aspeed_machine_class_init,
728baa4732bSCédric Le Goater         .abstract      = true,
729baa4732bSCédric Le Goater     }
730fca9ca1bSCédric Le Goater };
73174fb1f38SCédric Le Goater 
732baa4732bSCédric Le Goater DEFINE_TYPES(aspeed_machine_types)
733