mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-24 12:09:58 +00:00
hw/arm: versal-virt: Add support for SD
Add support for SD. Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Luc Michel <luc.michel@greensocs.com> Message-id: 20200427181649.26851-11-edgar.iglesias@gmail.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
eb1221c52d
commit
3afec85c2e
@ -20,6 +20,7 @@
|
||||
#include "hw/arm/sysbus-fdt.h"
|
||||
#include "hw/arm/fdt.h"
|
||||
#include "cpu.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "hw/arm/xlnx-versal.h"
|
||||
|
||||
#define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("xlnx-versal-virt")
|
||||
@ -256,6 +257,32 @@ static void fdt_add_zdma_nodes(VersalVirt *s)
|
||||
}
|
||||
}
|
||||
|
||||
static void fdt_add_sd_nodes(VersalVirt *s)
|
||||
{
|
||||
const char clocknames[] = "clk_xin\0clk_ahb";
|
||||
const char compat[] = "arasan,sdhci-8.9a";
|
||||
int i;
|
||||
|
||||
for (i = ARRAY_SIZE(s->soc.pmc.iou.sd) - 1; i >= 0; i--) {
|
||||
uint64_t addr = MM_PMC_SD0 + MM_PMC_SD0_SIZE * i;
|
||||
char *name = g_strdup_printf("/sdhci@%" PRIx64, addr);
|
||||
|
||||
qemu_fdt_add_subnode(s->fdt, name);
|
||||
|
||||
qemu_fdt_setprop_cells(s->fdt, name, "clocks",
|
||||
s->phandle.clk_25Mhz, s->phandle.clk_25Mhz);
|
||||
qemu_fdt_setprop(s->fdt, name, "clock-names",
|
||||
clocknames, sizeof(clocknames));
|
||||
qemu_fdt_setprop_cells(s->fdt, name, "interrupts",
|
||||
GIC_FDT_IRQ_TYPE_SPI, VERSAL_SD0_IRQ_0 + i * 2,
|
||||
GIC_FDT_IRQ_FLAGS_LEVEL_HI);
|
||||
qemu_fdt_setprop_sized_cells(s->fdt, name, "reg",
|
||||
2, addr, 2, MM_PMC_SD0_SIZE);
|
||||
qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat));
|
||||
g_free(name);
|
||||
}
|
||||
}
|
||||
|
||||
static void fdt_nop_memory_nodes(void *fdt, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
@ -411,10 +438,23 @@ static void create_virtio_regions(VersalVirt *s)
|
||||
}
|
||||
}
|
||||
|
||||
static void sd_plugin_card(SDHCIState *sd, DriveInfo *di)
|
||||
{
|
||||
BlockBackend *blk = di ? blk_by_legacy_dinfo(di) : NULL;
|
||||
DeviceState *card;
|
||||
|
||||
card = qdev_create(qdev_get_child_bus(DEVICE(sd), "sd-bus"), TYPE_SD_CARD);
|
||||
object_property_add_child(OBJECT(sd), "card[*]", OBJECT(card),
|
||||
&error_fatal);
|
||||
qdev_prop_set_drive(card, "drive", blk, &error_fatal);
|
||||
object_property_set_bool(OBJECT(card), true, "realized", &error_fatal);
|
||||
}
|
||||
|
||||
static void versal_virt_init(MachineState *machine)
|
||||
{
|
||||
VersalVirt *s = XLNX_VERSAL_VIRT_MACHINE(machine);
|
||||
int psci_conduit = QEMU_PSCI_CONDUIT_DISABLED;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* If the user provides an Operating System to be loaded, we expect them
|
||||
@ -455,6 +495,7 @@ static void versal_virt_init(MachineState *machine)
|
||||
fdt_add_gic_nodes(s);
|
||||
fdt_add_timer_nodes(s);
|
||||
fdt_add_zdma_nodes(s);
|
||||
fdt_add_sd_nodes(s);
|
||||
fdt_add_cpu_nodes(s, psci_conduit);
|
||||
fdt_add_clk_node(s, "/clk125", 125000000, s->phandle.clk_125Mhz);
|
||||
fdt_add_clk_node(s, "/clk25", 25000000, s->phandle.clk_25Mhz);
|
||||
@ -464,6 +505,11 @@ static void versal_virt_init(MachineState *machine)
|
||||
memory_region_add_subregion_overlap(get_system_memory(),
|
||||
0, &s->soc.fpd.apu.mr, 0);
|
||||
|
||||
/* Plugin SD cards. */
|
||||
for (i = 0; i < ARRAY_SIZE(s->soc.pmc.iou.sd); i++) {
|
||||
sd_plugin_card(&s->soc.pmc.iou.sd[i], drive_get_next(IF_SD));
|
||||
}
|
||||
|
||||
s->binfo.ram_size = machine->ram_size;
|
||||
s->binfo.loader_start = 0x0;
|
||||
s->binfo.get_dtb = versal_virt_get_dtb;
|
||||
|
Loading…
Reference in New Issue
Block a user