mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
hw/sd: Configure number of slots exposed by the ASPEED SDHCI model
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 <andrew@aj.id.au> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Cédric Le Goater <clg@kaod.org> Signed-off-by: Cédric Le Goater <clg@kaod.org> Message-id: 20200114103433.30534-2-clg@kaod.org [PMM: fixed up to use device_class_set_props()] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
16ab12a936
commit
0e2c24c626
5 changed files with 15 additions and 3 deletions
|
@ -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 = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue