[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [Qemu-devel] [PATCH v9 16/16] hw/arm/xilinx_zynq: fix the
From: |
Alistair Francis |
Subject: |
Re: [Qemu-arm] [Qemu-devel] [PATCH v9 16/16] hw/arm/xilinx_zynq: fix the capabilities register to match the datasheet |
Date: |
Tue, 23 Jan 2018 16:36:36 -0800 |
On Mon, Jan 22, 2018 at 6:08 PM, Philippe Mathieu-Daudé <address@hidden> wrote:
> checking Xilinx datasheet "UG585" (v1.12.1)
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Alistair Francis <address@hidden>
Alistair
> ---
> hw/arm/xilinx_zynq.c | 53
> ++++++++++++++++++++++++++++------------------------
> tests/sdhci-test.c | 5 +++++
> 2 files changed, 34 insertions(+), 24 deletions(-)
>
> diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
> index 1836a4ed45..0f76333770 100644
> --- a/hw/arm/xilinx_zynq.c
> +++ b/hw/arm/xilinx_zynq.c
> @@ -61,6 +61,8 @@ static const int dma_irqs[8] = {
> #define SLCR_XILINX_UNLOCK_KEY 0xdf0d
> #define SLCR_XILINX_LOCK_KEY 0x767b
>
> +#define ZYNQ_SDHCI_CAPABILITIES 0x69ec0080 /* Datasheet: UG585 (v1.12.1) */
> +
> #define ARMV7_IMM16(x) (extract32((x), 0, 12) | \
> extract32((x), 12, 4) << 16)
>
> @@ -165,10 +167,8 @@ static void zynq_init(MachineState *machine)
> MemoryRegion *address_space_mem = get_system_memory();
> MemoryRegion *ext_ram = g_new(MemoryRegion, 1);
> MemoryRegion *ocm_ram = g_new(MemoryRegion, 1);
> - DeviceState *dev, *carddev;
> + DeviceState *dev;
> SysBusDevice *busdev;
> - DriveInfo *di;
> - BlockBackend *blk;
> qemu_irq pic[64];
> int n;
>
> @@ -247,27 +247,32 @@ static void zynq_init(MachineState *machine)
> gem_init(&nd_table[0], 0xE000B000, pic[54-IRQ_OFFSET]);
> gem_init(&nd_table[1], 0xE000C000, pic[77-IRQ_OFFSET]);
>
> - dev = qdev_create(NULL, TYPE_SYSBUS_SDHCI);
> - qdev_init_nofail(dev);
> - sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0100000);
> - sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[56-IRQ_OFFSET]);
> -
> - di = drive_get_next(IF_SD);
> - blk = di ? blk_by_legacy_dinfo(di) : NULL;
> - carddev = qdev_create(qdev_get_child_bus(dev, "sd-bus"), TYPE_SD_CARD);
> - qdev_prop_set_drive(carddev, "drive", blk, &error_fatal);
> - object_property_set_bool(OBJECT(carddev), true, "realized",
> &error_fatal);
> -
> - dev = qdev_create(NULL, TYPE_SYSBUS_SDHCI);
> - qdev_init_nofail(dev);
> - sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000);
> - sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]);
> -
> - di = drive_get_next(IF_SD);
> - blk = di ? blk_by_legacy_dinfo(di) : NULL;
> - carddev = qdev_create(qdev_get_child_bus(dev, "sd-bus"), TYPE_SD_CARD);
> - qdev_prop_set_drive(carddev, "drive", blk, &error_fatal);
> - object_property_set_bool(OBJECT(carddev), true, "realized",
> &error_fatal);
> + for (n = 0; n < 2; n++) {
> + int hci_irq = n ? 79 : 56;
> + hwaddr hci_addr = n ? 0xE0101000 : 0xE0100000;
> + DriveInfo *di;
> + BlockBackend *blk;
> + DeviceState *carddev;
> +
> + /* Compatible with:
> + * - SD Host Controller Specification Version 2.0 Part A2
> + * - SDIO Specification Version 2.0
> + * - MMC Specification Version 3.31
> + */
> + dev = qdev_create(NULL, TYPE_SYSBUS_SDHCI);
> + qdev_prop_set_uint8(dev, "sd-spec-version", 2);
> + qdev_prop_set_uint64(dev, "capareg", ZYNQ_SDHCI_CAPABILITIES);
> + qdev_init_nofail(dev);
> + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, hci_addr);
> + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[hci_irq -
> IRQ_OFFSET]);
> +
> + di = drive_get_next(IF_SD);
> + blk = di ? blk_by_legacy_dinfo(di) : NULL;
> + carddev = qdev_create(qdev_get_child_bus(dev, "sd-bus"),
> TYPE_SD_CARD);
> + qdev_prop_set_drive(carddev, "drive", blk, &error_fatal);
> + object_property_set_bool(OBJECT(carddev), true, "realized",
> + &error_fatal);
> + }
>
> dev = qdev_create(NULL, TYPE_ZYNQ_XADC);
> qdev_init_nofail(dev);
> diff --git a/tests/sdhci-test.c b/tests/sdhci-test.c
> index 094e0570e1..aae2cfc1b5 100644
> --- a/tests/sdhci-test.c
> +++ b/tests/sdhci-test.c
> @@ -41,6 +41,11 @@ static const struct sdhci_t {
> /* Exynos4210 */
> { "arm", "smdkc210",
> {0x12510000, 2, 0, {1, 0x5e80080} } },
> +
> + /* Zynq-7000 */
> + { "arm", "xilinx-zynq-a9", /* Datasheet: UG585 (v1.12.1) */
> + {0xe0100000, 2, 0, {1, 0x69ec0080} } },
> +
> };
>
> static struct {
> --
> 2.15.1
>
>