summaryrefslogtreecommitdiff
path: root/hw/arm
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2020-01-30 16:02:02 +0000
committerPeter Maydell <peter.maydell@linaro.org>2020-01-30 16:02:02 +0000
commita29e3e127077709c6b733475a3a031bc49adf293 (patch)
treeffe7aee0d114ca43cf669bd22e6062d2311e6bfe /hw/arm
parent0e2c24c6267c1874daee71ecd98d1f2108ea7c66 (diff)
downloadqemu-a29e3e127077709c6b733475a3a031bc49adf293.zip
hw/arm: ast2600: Wire up the eMMC controller
Initialise another SDHCI model instance for the AST2600's eMMC controller and use the SDHCI's num_slots value introduced previously to determine whether we should create an SD card instance for the new slot. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Reviewed-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Cédric Le Goater <clg@kaod.org> Message-id: 20200114103433.30534-3-clg@kaod.org [ clg : - removed ternary operator from sdhci_attach_drive() - renamed SDHCI objects with a '-controller' prefix ] Signed-off-by: Cédric Le Goater <clg@kaod.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/arm')
-rw-r--r--hw/arm/aspeed.c26
-rw-r--r--hw/arm/aspeed_ast2600.c29
2 files changed, 43 insertions, 12 deletions
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 4174e313ca..8702256af1 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -171,6 +171,19 @@ static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
}
}
+static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo)
+{
+ DeviceState *card;
+
+ card = qdev_create(qdev_get_child_bus(DEVICE(sdhci), "sd-bus"),
+ TYPE_SD_CARD);
+ if (dinfo) {
+ qdev_prop_set_drive(card, "drive", blk_by_legacy_dinfo(dinfo),
+ &error_fatal);
+ }
+ object_property_set_bool(OBJECT(card), true, "realized", &error_fatal);
+}
+
static void aspeed_machine_init(MachineState *machine)
{
AspeedBoardState *bmc;
@@ -264,16 +277,11 @@ static void aspeed_machine_init(MachineState *machine)
}
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;
- DeviceState *card;
+ sdhci_attach_drive(&bmc->soc.sdhci.slots[i], drive_get_next(IF_SD));
+ }
- blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL;
- card = qdev_create(qdev_get_child_bus(DEVICE(sdhci), "sd-bus"),
- TYPE_SD_CARD);
- qdev_prop_set_drive(card, "drive", blk, &error_fatal);
- object_property_set_bool(OBJECT(card), true, "realized", &error_fatal);
+ if (bmc->soc.emmc.num_slots) {
+ sdhci_attach_drive(&bmc->soc.emmc.slots[0], drive_get_next(IF_SD));
}
arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo);
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
index fb73c4043e..90cf1c755d 100644
--- a/hw/arm/aspeed_ast2600.c
+++ b/hw/arm/aspeed_ast2600.c
@@ -46,6 +46,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
[ASPEED_ADC] = 0x1E6E9000,
[ASPEED_VIDEO] = 0x1E700000,
[ASPEED_SDHCI] = 0x1E740000,
+ [ASPEED_EMMC] = 0x1E750000,
[ASPEED_GPIO] = 0x1E780000,
[ASPEED_GPIO_1_8V] = 0x1E780800,
[ASPEED_RTC] = 0x1E781000,
@@ -64,6 +65,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
#define ASPEED_SOC_AST2600_MAX_IRQ 128
+/* Shared Peripheral Interrupt values below are offset by -32 from datasheet */
static const int aspeed_soc_ast2600_irqmap[] = {
[ASPEED_UART1] = 47,
[ASPEED_UART2] = 48,
@@ -77,6 +79,7 @@ static const int aspeed_soc_ast2600_irqmap[] = {
[ASPEED_ADC] = 78,
[ASPEED_XDMA] = 6,
[ASPEED_SDHCI] = 43,
+ [ASPEED_EMMC] = 15,
[ASPEED_GPIO] = 40,
[ASPEED_GPIO_1_8V] = 11,
[ASPEED_RTC] = 13,
@@ -196,16 +199,26 @@ static void aspeed_soc_ast2600_init(Object *obj)
sysbus_init_child_obj(obj, "gpio_1_8v", OBJECT(&s->gpio_1_8v),
sizeof(s->gpio_1_8v), typename);
- sysbus_init_child_obj(obj, "sdc", OBJECT(&s->sdhci), sizeof(s->sdhci),
- TYPE_ASPEED_SDHCI);
+ sysbus_init_child_obj(obj, "sd-controller", 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]),
+ sysbus_init_child_obj(obj, "sd-controller.sdhci[*]",
+ OBJECT(&s->sdhci.slots[i]),
sizeof(s->sdhci.slots[i]), TYPE_SYSBUS_SDHCI);
}
+
+ sysbus_init_child_obj(obj, "emmc-controller", OBJECT(&s->emmc),
+ sizeof(s->emmc), TYPE_ASPEED_SDHCI);
+
+ object_property_set_int(OBJECT(&s->emmc), 1, "num-slots", &error_abort);
+
+ sysbus_init_child_obj(obj, "emmc-controller.sdhci",
+ OBJECT(&s->emmc.slots[0]), sizeof(s->emmc.slots[0]),
+ TYPE_SYSBUS_SDHCI);
}
/*
@@ -497,6 +510,16 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
sc->memmap[ASPEED_SDHCI]);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0,
aspeed_soc_get_irq(s, ASPEED_SDHCI));
+
+ /* eMMC */
+ object_property_set_bool(OBJECT(&s->emmc), true, "realized", &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
+ }
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->emmc), 0, sc->memmap[ASPEED_EMMC]);
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->emmc), 0,
+ aspeed_soc_get_irq(s, ASPEED_EMMC));
}
static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)