[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/26] hw/sd: Configure number of slots exposed by the ASPEED SDHC
From: |
Peter Maydell |
Subject: |
[PULL 03/26] hw/sd: Configure number of slots exposed by the ASPEED SDHCI model |
Date: |
Thu, 30 Jan 2020 16:15:10 +0000 |
From: Andrew Jeffery <address@hidden>
The AST2600 includes a second cut-down version of the SD/MMC controller
found in the AST2500, named the eMMC controller. It's cut down in the
sense that it only supports one slot rather than two, but it brings the
total number of slots supported by the AST2600 to three.
The existing code assumed that the SD controller always provided two
slots. Rework the SDHCI object to expose the number of slots as a
property to be set by the SoC configuration.
Signed-off-by: Andrew Jeffery <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Cédric Le Goater <address@hidden>
Signed-off-by: Cédric Le Goater <address@hidden>
Message-id: address@hidden
[PMM: fixed up to use device_class_set_props()]
Signed-off-by: Peter Maydell <address@hidden>
---
include/hw/sd/aspeed_sdhci.h | 1 +
hw/arm/aspeed.c | 2 +-
hw/arm/aspeed_ast2600.c | 2 ++
hw/arm/aspeed_soc.c | 2 ++
hw/sd/aspeed_sdhci.c | 11 +++++++++--
5 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/include/hw/sd/aspeed_sdhci.h b/include/hw/sd/aspeed_sdhci.h
index dfdab437902..dffbb46946b 100644
--- a/include/hw/sd/aspeed_sdhci.h
+++ b/include/hw/sd/aspeed_sdhci.h
@@ -24,6 +24,7 @@ typedef struct AspeedSDHCIState {
SysBusDevice parent;
SDHCIState slots[ASPEED_SDHCI_NUM_SLOTS];
+ uint8_t num_slots;
MemoryRegion iomem;
qemu_irq irq;
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index cc06af4fbb3..4174e313cae 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -263,7 +263,7 @@ static void aspeed_machine_init(MachineState *machine)
amc->i2c_init(bmc);
}
- for (i = 0; i < ARRAY_SIZE(bmc->soc.sdhci.slots); i++) {
+ for (i = 0; i < bmc->soc.sdhci.num_slots; i++) {
SDHCIState *sdhci = &bmc->soc.sdhci.slots[i];
DriveInfo *dinfo = drive_get_next(IF_SD);
BlockBackend *blk;
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
index 89e4b009504..fb73c4043ea 100644
--- a/hw/arm/aspeed_ast2600.c
+++ b/hw/arm/aspeed_ast2600.c
@@ -199,6 +199,8 @@ static void aspeed_soc_ast2600_init(Object *obj)
sysbus_init_child_obj(obj, "sdc", OBJECT(&s->sdhci), sizeof(s->sdhci),
TYPE_ASPEED_SDHCI);
+ object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
+
/* Init sd card slot class here so that they're under the correct parent */
for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
sysbus_init_child_obj(obj, "sdhci[*]", OBJECT(&s->sdhci.slots[i]),
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
index 99892cbae67..b5e809a1d3f 100644
--- a/hw/arm/aspeed_soc.c
+++ b/hw/arm/aspeed_soc.c
@@ -209,6 +209,8 @@ static void aspeed_soc_init(Object *obj)
sysbus_init_child_obj(obj, "sdc", OBJECT(&s->sdhci), sizeof(s->sdhci),
TYPE_ASPEED_SDHCI);
+ object_property_set_int(OBJECT(&s->sdhci), 2, "num-slots", &error_abort);
+
/* Init sd card slot class here so that they're under the correct parent */
for (i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
sysbus_init_child_obj(obj, "sdhci[*]", OBJECT(&s->sdhci.slots[i]),
diff --git a/hw/sd/aspeed_sdhci.c b/hw/sd/aspeed_sdhci.c
index cff3eb7dd21..6a039a1d2f1 100644
--- a/hw/sd/aspeed_sdhci.c
+++ b/hw/sd/aspeed_sdhci.c
@@ -13,6 +13,7 @@
#include "qapi/error.h"
#include "hw/irq.h"
#include "migration/vmstate.h"
+#include "hw/qdev-properties.h"
#define ASPEED_SDHCI_INFO 0x00
#define ASPEED_SDHCI_INFO_RESET 0x00030000
@@ -120,14 +121,14 @@ static void aspeed_sdhci_realize(DeviceState *dev, Error
**errp)
/* Create input irqs for the slots */
qdev_init_gpio_in_named_with_opaque(DEVICE(sbd), aspeed_sdhci_set_irq,
- sdhci, NULL, ASPEED_SDHCI_NUM_SLOTS);
+ sdhci, NULL, sdhci->num_slots);
sysbus_init_irq(sbd, &sdhci->irq);
memory_region_init_io(&sdhci->iomem, OBJECT(sdhci), &aspeed_sdhci_ops,
sdhci, TYPE_ASPEED_SDHCI, 0x1000);
sysbus_init_mmio(sbd, &sdhci->iomem);
- for (int i = 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) {
+ for (int i = 0; i < sdhci->num_slots; ++i) {
Object *sdhci_slot = OBJECT(&sdhci->slots[i]);
SysBusDevice *sbd_slot = SYS_BUS_DEVICE(&sdhci->slots[i]);
@@ -174,6 +175,11 @@ static const VMStateDescription vmstate_aspeed_sdhci = {
},
};
+static Property aspeed_sdhci_properties[] = {
+ DEFINE_PROP_UINT8("num-slots", AspeedSDHCIState, num_slots, 0),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static void aspeed_sdhci_class_init(ObjectClass *classp, void *data)
{
DeviceClass *dc = DEVICE_CLASS(classp);
@@ -181,6 +187,7 @@ static void aspeed_sdhci_class_init(ObjectClass *classp,
void *data)
dc->realize = aspeed_sdhci_realize;
dc->reset = aspeed_sdhci_reset;
dc->vmsd = &vmstate_aspeed_sdhci;
+ device_class_set_props(dc, aspeed_sdhci_properties);
}
static TypeInfo aspeed_sdhci_info = {
--
2.20.1
- [PULL 00/26] target-arm queue, Peter Maydell, 2020/01/30
- [PULL 01/26] hw/core/or-irq: Fix incorrect assert forbidding num-lines == MAX_OR_LINES, Peter Maydell, 2020/01/30
- [PULL 02/26] target/arm/arm-semi: Don't let the guest close stdin/stdout/stderr, Peter Maydell, 2020/01/30
- [PULL 04/26] hw/arm: ast2600: Wire up the eMMC controller, Peter Maydell, 2020/01/30
- [PULL 03/26] hw/sd: Configure number of slots exposed by the ASPEED SDHCI model,
Peter Maydell <=
- [PULL 05/26] ftgmac100: check RX and TX buffer alignment, Peter Maydell, 2020/01/30
- [PULL 06/26] hw/arm/aspeed: add a 'execute-in-place' property to boot directly from CE0, Peter Maydell, 2020/01/30
- [PULL 07/26] misc/pca9552: Add qom set and get, Peter Maydell, 2020/01/30
- [PULL 09/26] add device_legacy_reset function to prepare for reset api change, Peter Maydell, 2020/01/30
- [PULL 08/26] hw/arm/raspi: Remove obsolete use of -smp to set the soc 'enabled-cpus', Peter Maydell, 2020/01/30
- [PULL 10/26] hw/core/qdev: add trace events to help with resettable transition, Peter Maydell, 2020/01/30
- [PULL 12/26] hw/core: add Resettable support to BusClass and DeviceClass, Peter Maydell, 2020/01/30
- [PULL 14/26] hw/core/qdev: handle parent bus change regarding resettable, Peter Maydell, 2020/01/30
- [PULL 13/26] hw/core/resettable: add support for changing parent, Peter Maydell, 2020/01/30
- [PULL 16/26] hw/core: deprecate old reset functions and introduce new ones, Peter Maydell, 2020/01/30