From: Joel Stanley <j...@jms.id.au> This value is taken from a running Rainier machine. It sets bit 3 (select boot0) and bit 6 (enable).
Signed-off-by: Joel Stanley <j...@jms.id.au> [ clg: Check HW strapping to choose the boot device ] Signed-off-by: Cédric Le Goater <c...@kaod.org> --- include/hw/arm/aspeed_soc.h | 1 + hw/arm/aspeed.c | 14 ++++++++++---- hw/arm/aspeed_ast2600.c | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h index 8adff7007286..17ded3e1fd18 100644 --- a/include/hw/arm/aspeed_soc.h +++ b/include/hw/arm/aspeed_soc.h @@ -118,6 +118,7 @@ struct AspeedSoCClass { const hwaddr *memmap; uint32_t num_cpus; qemu_irq (*get_irq)(AspeedSoCState *s, int dev); + bool boot_emmc; }; diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 00fd3c2e4e8a..6631552358d1 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -319,7 +319,8 @@ void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, } } -static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo, bool emmc) +static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo, bool emmc, + bool boot_emmc) { DeviceState *card; @@ -329,6 +330,7 @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo, bool emmc) card = qdev_new(emmc ? TYPE_EMMC : TYPE_SD_CARD); if (emmc) { qdev_prop_set_uint8(card, "spec_version", SD_PHY_SPECv3_01_VERS); + qdev_prop_set_uint8(card, "boot-config", boot_emmc ? 0x48 : 0x0); } qdev_prop_set_drive_err(card, "drive", blk_by_legacy_dinfo(dinfo), &error_fatal); @@ -361,11 +363,15 @@ static void aspeed_machine_init(MachineState *machine) int i; NICInfo *nd = &nd_table[0]; DriveInfo *emmc0 = NULL; + bool boot_emmc; object_initialize_child(OBJECT(machine), "soc", &bmc->soc, amc->soc_name); sc = ASPEED_SOC_GET_CLASS(&bmc->soc); + boot_emmc = sc->boot_emmc && + !!(amc->hw_strap1 & AST26500_HW_STRAP_BOOT_SRC_EMMC); + /* * This will error out if the RAM size is not supported by the * memory controller of the SoC. @@ -432,19 +438,19 @@ static void aspeed_machine_init(MachineState *machine) for (i = 0; i < bmc->soc.sdhci.num_slots; i++) { sdhci_attach_drive(&bmc->soc.sdhci.slots[i], - drive_get(IF_SD, 0, i), false); + drive_get(IF_SD, 0, i), false, false); } if (bmc->soc.emmc.num_slots) { emmc0 = drive_get(IF_SD, 0, bmc->soc.sdhci.num_slots); - sdhci_attach_drive(&bmc->soc.emmc.slots[0], emmc0, true); + sdhci_attach_drive(&bmc->soc.emmc.slots[0], emmc0, true, boot_emmc); } if (!bmc->mmio_exec) { DeviceState *dev = ssi_get_cs(bmc->soc.fmc.spi, 0); BlockBackend *fmc0 = dev ? m25p80_get_blk(dev) : NULL; - if (fmc0) { + if (fmc0 && !boot_emmc) { uint64_t rom_size = memory_region_size(&bmc->soc.spi_boot); aspeed_install_boot_rom(bmc, fmc0, rom_size); } else if (emmc0) { diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index a8b3a8065a11..9d7551b109df 100644 --- a/hw/arm/aspeed_ast2600.c +++ b/hw/arm/aspeed_ast2600.c @@ -644,6 +644,7 @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) sc->memmap = aspeed_soc_ast2600_memmap; sc->num_cpus = 2; sc->get_irq = aspeed_soc_ast2600_get_irq; + sc->boot_emmc = true; } static const TypeInfo aspeed_soc_ast2600_type_info = { -- 2.41.0