Skip to content

Commit a7ddb48

Browse files
committed
Merge tag 'pull-aspeed-20240721' of https://github.com/legoater/qemu into staging
aspeed queue: * SMC model fix (Coverity) * AST2600 boot for eMMC support and test * AST2700 ADC model * I2C model changes preparing AST2700 I2C support # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmacwdQACgkQUaNDx8/7 # 7KFJGxAAyGLeAW8OJQgRMh0LygKyY6n4p+8LnImKwH19DkJy9KXsFmi2iCyg2Ufh # FvNU1NUNjJopYZv+9sMtNXDlFbv53FkxotpmRnPQZxncH7VNUqZ/FyfVBItU7fdB # pX4pU1x49InQDSL+ZwOYEDLirc8aTp/ZfyeayeFxmJvhtpVtAOGwH+R/Xx5o+Tfd # fHTkAkJ69LVxK37fk6Bz6X4s3RnOCUpC7g8MuwN4FOSs1IorCq37tH72npPQ+lR+ # rFAaTY8/EDvn+mhCk61rTDo7fNB+/Oaks336cqKVWX8cg+qc0qOfqnG9f8H77b/P # PLmCoXS+L83Ko6p8PMh2hzehYMW/NXJLHQm3YOFx20LicommM3Mg9wXd2FV4AcVi # VbsL4+gNi4fPb4z6qCKUV/ir9IoL3x4OLfazKvj9wo88AvOkw06cyhZCfIBIy1Pe # BQyI9Bg8ExjCsDX5MXhPOzHbqHSQDmGPpN7B4DkcCRSp61QoO4GR8XwsUMPOWt2H # jwa0qEicdetu4Rop6HIQMdGCvpQEB4RW9l9hoePlg5FSv66M+wQoO5DTmUmTP/Go # 5NNEdFK1oaf2xgvgiWsexFyeinKoyC12OwzhHWxeZp7OORo44M1eYosFQ8L7o+Pk # XKL+t9Om17/BKKEA4JQjjip8E4p7m9wNJ7HQNcb63lqh2sYH/rQ= # =r9I0 # -----END PGP SIGNATURE----- # gpg: Signature made Sun 21 Jul 2024 06:07:48 PM AEST # gpg: using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1 # gpg: Good signature from "Cédric Le Goater <[email protected]>" [undefined] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: A0F6 6548 F048 95EB FE6B 0B60 51A3 43C7 CFFB ECA1 * tag 'pull-aspeed-20240721' of https://github.com/legoater/qemu: aspeed: fix coding style hw/i2c/aspeed: rename the I2C class pool attribute to share_pool hw/i2c/aspeed: support to set the different memory size aspeed/soc: support ADC for AST2700 aspeed/adc: Add AST2700 support tests/avocado/machine_aspeed.py: Add eMMC boot tests aspeed: Introduce a 'boot-emmc' machine option aspeed: Introduce a 'hw_strap1' machine attribute aspeed: Add boot-from-eMMC HW strapping bit to rainier-bmc machine aspeed: Tune eMMC device properties to reflect HW strapping aspeed: Introduce a AspeedSoCClass 'boot_from_emmc' handler aspeed/scu: Add boot-from-eMMC HW strapping bit for AST2600 SoC aspeed: Load eMMC first boot area as a boot rom aspeed: Change type of eMMC device aspeed/smc: Fix possible integer overflow Signed-off-by: Richard Henderson <[email protected]>
2 parents a87a7c4 + 4db1c16 commit a7ddb48

File tree

13 files changed

+188
-39
lines changed

13 files changed

+188
-39
lines changed

docs/system/arm/aspeed.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ To boot the machine from the flash image, use an MTD drive :
123123
124124
Options specific to Aspeed machines are :
125125

126+
* ``boot-emmc`` to set or unset boot from eMMC (AST2600).
127+
126128
* ``execute-in-place`` which emulates the boot from the CE0 flash
127129
device by using the FMC controller to load the instructions, and
128130
not simply from RAM. This takes a little longer.

hw/adc/aspeed_adc.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,15 @@ static void aspeed_1030_adc_class_init(ObjectClass *klass, void *data)
398398
aac->nr_engines = 2;
399399
}
400400

401+
static void aspeed_2700_adc_class_init(ObjectClass *klass, void *data)
402+
{
403+
DeviceClass *dc = DEVICE_CLASS(klass);
404+
AspeedADCClass *aac = ASPEED_ADC_CLASS(klass);
405+
406+
dc->desc = "ASPEED 2700 ADC Controller";
407+
aac->nr_engines = 2;
408+
}
409+
401410
static const TypeInfo aspeed_adc_info = {
402411
.name = TYPE_ASPEED_ADC,
403412
.parent = TYPE_SYS_BUS_DEVICE,
@@ -430,6 +439,12 @@ static const TypeInfo aspeed_1030_adc_info = {
430439
.class_init = aspeed_1030_adc_class_init, /* No change since AST2600 */
431440
};
432441

442+
static const TypeInfo aspeed_2700_adc_info = {
443+
.name = TYPE_ASPEED_2700_ADC,
444+
.parent = TYPE_ASPEED_ADC,
445+
.class_init = aspeed_2700_adc_class_init,
446+
};
447+
433448
static void aspeed_adc_register_types(void)
434449
{
435450
type_register_static(&aspeed_adc_engine_info);
@@ -438,6 +453,7 @@ static void aspeed_adc_register_types(void)
438453
type_register_static(&aspeed_2500_adc_info);
439454
type_register_static(&aspeed_2600_adc_info);
440455
type_register_static(&aspeed_1030_adc_info);
456+
type_register_static(&aspeed_2700_adc_info);
441457
}
442458

443459
type_init(aspeed_adc_register_types);

hw/arm/aspeed.c

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct AspeedMachineState {
4646
uint32_t uart_chosen;
4747
char *fmc_model;
4848
char *spi_model;
49+
uint32_t hw_strap1;
4950
};
5051

5152
/* On 32-bit hosts, lower RAM to 1G because of the 2047 MB limit */
@@ -189,7 +190,7 @@ struct AspeedMachineState {
189190
#define TACOMA_BMC_HW_STRAP2 0x00000040
190191

191192
/* Rainier hardware value: (QEMU prototype) */
192-
#define RAINIER_BMC_HW_STRAP1 0x00422016
193+
#define RAINIER_BMC_HW_STRAP1 (0x00422016 | SCU_AST2600_HW_STRAP_BOOT_SRC_EMMC)
193194
#define RAINIER_BMC_HW_STRAP2 0x80000848
194195

195196
/* Fuji hardware value */
@@ -265,7 +266,8 @@ static void write_boot_rom(BlockBackend *blk, hwaddr addr, size_t rom_size,
265266
g_autofree void *storage = NULL;
266267
int64_t size;
267268

268-
/* The block backend size should have already been 'validated' by
269+
/*
270+
* The block backend size should have already been 'validated' by
269271
* the creation of the m25p80 object.
270272
*/
271273
size = blk_getlength(blk);
@@ -327,14 +329,20 @@ void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
327329
}
328330
}
329331

330-
static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo)
332+
static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo, bool emmc,
333+
bool boot_emmc)
331334
{
332335
DeviceState *card;
333336

334337
if (!dinfo) {
335338
return;
336339
}
337-
card = qdev_new(TYPE_SD_CARD);
340+
card = qdev_new(emmc ? TYPE_EMMC : TYPE_SD_CARD);
341+
if (emmc) {
342+
qdev_prop_set_uint64(card, "boot-partition-size", 1 * MiB);
343+
qdev_prop_set_uint8(card, "boot-config",
344+
boot_emmc ? 0x1 << 3 : 0x0);
345+
}
338346
qdev_prop_set_drive_err(card, "drive", blk_by_legacy_dinfo(dinfo),
339347
&error_fatal);
340348
qdev_realize_and_unref(card,
@@ -364,6 +372,8 @@ static void aspeed_machine_init(MachineState *machine)
364372
AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(machine);
365373
AspeedSoCClass *sc;
366374
int i;
375+
DriveInfo *emmc0 = NULL;
376+
bool boot_emmc;
367377

368378
bmc->soc = ASPEED_SOC(object_new(amc->soc_name));
369379
object_property_add_child(OBJECT(machine), "soc", OBJECT(bmc->soc));
@@ -385,7 +395,7 @@ static void aspeed_machine_init(MachineState *machine)
385395
}
386396
}
387397

388-
object_property_set_int(OBJECT(bmc->soc), "hw-strap1", amc->hw_strap1,
398+
object_property_set_int(OBJECT(bmc->soc), "hw-strap1", bmc->hw_strap1,
389399
&error_abort);
390400
object_property_set_int(OBJECT(bmc->soc), "hw-strap2", amc->hw_strap2,
391401
&error_abort);
@@ -436,21 +446,25 @@ static void aspeed_machine_init(MachineState *machine)
436446

437447
for (i = 0; i < bmc->soc->sdhci.num_slots; i++) {
438448
sdhci_attach_drive(&bmc->soc->sdhci.slots[i],
439-
drive_get(IF_SD, 0, i));
449+
drive_get(IF_SD, 0, i), false, false);
440450
}
441451

452+
boot_emmc = sc->boot_from_emmc(bmc->soc);
453+
442454
if (bmc->soc->emmc.num_slots) {
443-
sdhci_attach_drive(&bmc->soc->emmc.slots[0],
444-
drive_get(IF_SD, 0, bmc->soc->sdhci.num_slots));
455+
emmc0 = drive_get(IF_SD, 0, bmc->soc->sdhci.num_slots);
456+
sdhci_attach_drive(&bmc->soc->emmc.slots[0], emmc0, true, boot_emmc);
445457
}
446458

447459
if (!bmc->mmio_exec) {
448460
DeviceState *dev = ssi_get_cs(bmc->soc->fmc.spi, 0);
449461
BlockBackend *fmc0 = dev ? m25p80_get_blk(dev) : NULL;
450462

451-
if (fmc0) {
463+
if (fmc0 && !boot_emmc) {
452464
uint64_t rom_size = memory_region_size(&bmc->soc->spi_boot);
453465
aspeed_install_boot_rom(bmc, fmc0, rom_size);
466+
} else if (emmc0) {
467+
aspeed_install_boot_rom(bmc, blk_by_legacy_dinfo(emmc0), 64 * KiB);
454468
}
455469
}
456470

@@ -463,8 +477,10 @@ static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)
463477
DeviceState *dev;
464478
uint8_t *eeprom_buf = g_malloc0(32 * 1024);
465479

466-
/* The palmetto platform expects a ds3231 RTC but a ds1338 is
467-
* enough to provide basic RTC features. Alarms will be missing */
480+
/*
481+
* The palmetto platform expects a ds3231 RTC but a ds1338 is
482+
* enough to provide basic RTC features. Alarms will be missing
483+
*/
468484
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 0), "ds1338", 0x68);
469485

470486
smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 0), 0x50,
@@ -555,8 +571,10 @@ static void romulus_bmc_i2c_init(AspeedMachineState *bmc)
555571
{
556572
AspeedSoCState *soc = bmc->soc;
557573

558-
/* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is
559-
* good enough */
574+
/*
575+
* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is
576+
* good enough
577+
*/
560578
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32);
561579
}
562580

@@ -664,8 +682,10 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc)
664682
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), TYPE_TMP105,
665683
0x4a);
666684

667-
/* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
668-
* good enough */
685+
/*
686+
* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
687+
* good enough
688+
*/
669689
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32);
670690

671691
smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 11), 0x51,
@@ -1065,7 +1085,10 @@ static void aspeed_set_mmio_exec(Object *obj, bool value, Error **errp)
10651085

10661086
static void aspeed_machine_instance_init(Object *obj)
10671087
{
1088+
AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(obj);
1089+
10681090
ASPEED_MACHINE(obj)->mmio_exec = false;
1091+
ASPEED_MACHINE(obj)->hw_strap1 = amc->hw_strap1;
10691092
}
10701093

10711094
static char *aspeed_get_fmc_model(Object *obj, Error **errp)
@@ -1162,6 +1185,34 @@ static void aspeed_machine_class_init_cpus_defaults(MachineClass *mc)
11621185
mc->valid_cpu_types = sc->valid_cpu_types;
11631186
}
11641187

1188+
static bool aspeed_machine_ast2600_get_boot_from_emmc(Object *obj, Error **errp)
1189+
{
1190+
AspeedMachineState *bmc = ASPEED_MACHINE(obj);
1191+
1192+
return !!(bmc->hw_strap1 & SCU_AST2600_HW_STRAP_BOOT_SRC_EMMC);
1193+
}
1194+
1195+
static void aspeed_machine_ast2600_set_boot_from_emmc(Object *obj, bool value,
1196+
Error **errp)
1197+
{
1198+
AspeedMachineState *bmc = ASPEED_MACHINE(obj);
1199+
1200+
if (value) {
1201+
bmc->hw_strap1 |= SCU_AST2600_HW_STRAP_BOOT_SRC_EMMC;
1202+
} else {
1203+
bmc->hw_strap1 &= ~SCU_AST2600_HW_STRAP_BOOT_SRC_EMMC;
1204+
}
1205+
}
1206+
1207+
static void aspeed_machine_ast2600_class_emmc_init(ObjectClass *oc)
1208+
{
1209+
object_class_property_add_bool(oc, "boot-emmc",
1210+
aspeed_machine_ast2600_get_boot_from_emmc,
1211+
aspeed_machine_ast2600_set_boot_from_emmc);
1212+
object_class_property_set_description(oc, "boot-emmc",
1213+
"Set or unset boot from EMMC");
1214+
}
1215+
11651216
static void aspeed_machine_class_init(ObjectClass *oc, void *data)
11661217
{
11671218
MachineClass *mc = MACHINE_CLASS(oc);
@@ -1361,6 +1412,7 @@ static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data)
13611412
amc->i2c_init = ast2600_evb_i2c_init;
13621413
mc->default_ram_size = 1 * GiB;
13631414
aspeed_machine_class_init_cpus_defaults(mc);
1415+
aspeed_machine_ast2600_class_emmc_init(oc);
13641416
};
13651417

13661418
static void aspeed_machine_tacoma_class_init(ObjectClass *oc, void *data)
@@ -1433,6 +1485,7 @@ static void aspeed_machine_rainier_class_init(ObjectClass *oc, void *data)
14331485
amc->i2c_init = rainier_bmc_i2c_init;
14341486
mc->default_ram_size = 1 * GiB;
14351487
aspeed_machine_class_init_cpus_defaults(mc);
1488+
aspeed_machine_ast2600_class_emmc_init(oc);
14361489
};
14371490

14381491
#define FUJI_BMC_RAM_SIZE ASPEED_RAM_SIZE(2 * GiB)

hw/arm/aspeed_ast2600.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,13 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
646646
}
647647
}
648648

649+
static bool aspeed_soc_ast2600_boot_from_emmc(AspeedSoCState *s)
650+
{
651+
uint32_t hw_strap1 = object_property_get_uint(OBJECT(&s->scu),
652+
"hw-strap1", &error_abort);
653+
return !!(hw_strap1 & SCU_AST2600_HW_STRAP_BOOT_SRC_EMMC);
654+
}
655+
649656
static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
650657
{
651658
static const char * const valid_cpu_types[] = {
@@ -673,6 +680,7 @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
673680
sc->memmap = aspeed_soc_ast2600_memmap;
674681
sc->num_cpus = 2;
675682
sc->get_irq = aspeed_soc_ast2600_get_irq;
683+
sc->boot_from_emmc = aspeed_soc_ast2600_boot_from_emmc;
676684
}
677685

678686
static const TypeInfo aspeed_soc_ast2600_types[] = {

hw/arm/aspeed_ast27x0.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = {
6060
[ASPEED_DEV_SLIIO] = 0x14C1E000,
6161
[ASPEED_GIC_DIST] = 0x12200000,
6262
[ASPEED_GIC_REDIST] = 0x12280000,
63+
[ASPEED_DEV_ADC] = 0x14C00000,
6364
};
6465

6566
#define AST2700_MAX_IRQ 288
@@ -344,6 +345,9 @@ static void aspeed_soc_ast2700_init(Object *obj)
344345
object_initialize_child(obj, "sli", &s->sli, TYPE_ASPEED_2700_SLI);
345346
object_initialize_child(obj, "sliio", &s->sliio, TYPE_ASPEED_2700_SLIIO);
346347
object_initialize_child(obj, "intc", &a->intc, TYPE_ASPEED_2700_INTC);
348+
349+
snprintf(typename, sizeof(typename), "aspeed.adc-%s", socname);
350+
object_initialize_child(obj, "adc", &s->adc, typename);
347351
}
348352

349353
/*
@@ -601,6 +605,14 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
601605
aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sliio), 0,
602606
sc->memmap[ASPEED_DEV_SLIIO]);
603607

608+
/* ADC */
609+
if (!sysbus_realize(SYS_BUS_DEVICE(&s->adc), errp)) {
610+
return;
611+
}
612+
aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->adc), 0, sc->memmap[ASPEED_DEV_ADC]);
613+
sysbus_connect_irq(SYS_BUS_DEVICE(&s->adc), 0,
614+
aspeed_soc_get_irq(s, ASPEED_DEV_ADC));
615+
604616
create_unimplemented_device("ast2700.dpmcu", 0x11000000, 0x40000);
605617
create_unimplemented_device("ast2700.iomem0", 0x12000000, 0x01000000);
606618
create_unimplemented_device("ast2700.iomem1", 0x14000000, 0x01000000);

hw/arm/aspeed_soc_common.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
134134
}
135135
}
136136

137+
static bool aspeed_soc_boot_from_emmc(AspeedSoCState *s)
138+
{
139+
return false;
140+
}
141+
137142
static Property aspeed_soc_properties[] = {
138143
DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION,
139144
MemoryRegion *),
@@ -145,9 +150,11 @@ static Property aspeed_soc_properties[] = {
145150
static void aspeed_soc_class_init(ObjectClass *oc, void *data)
146151
{
147152
DeviceClass *dc = DEVICE_CLASS(oc);
153+
AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc);
148154

149155
dc->realize = aspeed_soc_realize;
150156
device_class_set_props(dc, aspeed_soc_properties);
157+
sc->boot_from_emmc = aspeed_soc_boot_from_emmc;
151158
}
152159

153160
static const TypeInfo aspeed_soc_types[] = {

0 commit comments

Comments
 (0)