[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH v5 12/31] sdhci: add the generic Arasan SDHCI 4.9a PHY
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-arm] [PATCH v5 12/31] sdhci: add the generic Arasan SDHCI 4.9a PHY controller |
Date: |
Mon, 8 Jan 2018 12:42:44 -0300 |
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/sd/arasan_sdhci.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/sd/Makefile.objs | 1 +
2 files changed, 73 insertions(+)
create mode 100644 hw/sd/arasan_sdhci.c
diff --git a/hw/sd/arasan_sdhci.c b/hw/sd/arasan_sdhci.c
new file mode 100644
index 0000000000..c6d96b2583
--- /dev/null
+++ b/hw/sd/arasan_sdhci.c
@@ -0,0 +1,72 @@
+/*
+ * Arasan SDHCI Controller emulation
+ *
+ * Copyright (C) 2018 Philippe Mathieu-Daudé <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * (at your option) any later version. See the COPYING file in the
+ * top-level directory.
+ */
+#include "qemu/osdep.h"
+#include "hw/sd/sdhci.h"
+#include "qapi/error.h"
+
+/* Compatible with:
+ * - SD Host Controller Specification Version 2.0 Part A2
+ * - SDIO Specification Version 2.0
+ * - MMC Specification Version 3.31
+ *
+ * - SDMA (single operation DMA)
+ * - ADMA1 (4 KB boundary limited DMA)
+ * - ADMA2
+ *
+ * - up to seven functions in SD1, SD4, but does not support SPI mode
+ * - SD high-speed (SDHS) card
+ * - SD High Capacity (SDHC) card
+ *
+ * - Low-speed, 1 KHz to 400 KHz
+ * - Full-speed, 1 MHz to 50 MHz (25 MB/sec)
+ */
+static void arasan4_9a_sdhci_realize(DeviceState *dev, Error **errp)
+{
+ SDHCICommonClass *cc = SYSBUS_SDHCI_COMMON_GET_CLASS(dev);
+ Object *obj = OBJECT(dev);
+ Error *local_err = NULL;
+
+ object_property_set_uint(obj, 2, "sd-spec-version", &local_err);
+ object_property_set_bool(obj, true, "adma1", &local_err);
+ object_property_set_bool(obj, true, "high-speed", &local_err);
+ object_property_set_uint(obj, 1024, "max-block-length", &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
+ cc->parent_realize(dev, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+}
+
+static void arasan4_9a_sdhci_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ SDHCICommonClass *cc = SYSBUS_SDHCI_COMMON_CLASS(klass);
+
+ cc->parent_realize = dc->realize;
+ dc->realize = arasan4_9a_sdhci_realize;
+}
+
+static const TypeInfo arasan4_9a_sdhci_info = {
+ .name = "arasan,sdhci-4.9a",
+ .parent = TYPE_SYSBUS_SDHCI,
+ .class_init = arasan4_9a_sdhci_class_init,
+};
+
+static void arasan_sdhci_register_types(void)
+{
+ type_register_static(&arasan4_9a_sdhci_info);
+}
+
+type_init(arasan_sdhci_register_types)
diff --git a/hw/sd/Makefile.objs b/hw/sd/Makefile.objs
index fd866d7f94..ef0fc3d3f7 100644
--- a/hw/sd/Makefile.objs
+++ b/hw/sd/Makefile.objs
@@ -3,6 +3,7 @@ common-obj-$(CONFIG_SD) += core.o
# SD/MMC host adapters
common-obj-$(CONFIG_PL181) += pl181.o
+common-obj-$(CONFIG_ZYNQ) += arasan_sdhci.o
common-obj-$(CONFIG_EXYNOS4) += dw-mshc.o
common-obj-$(CONFIG_SSI_SD) += ssi-sd.o
common-obj-$(CONFIG_SDHCI) += sdhci.o
--
2.15.1
- Re: [Qemu-arm] [Qemu-devel] [PATCH v5 05/31] sdhci: add DMA and 64-bit capabilities (Spec v2), (continued)
- [Qemu-arm] [PATCH v5 07/31] sdhci: Fix 64-bit ADMA2, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 08/31] hw/sd: clean/reorder the Makefile adding few comments, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 09/31] sdhci: add a common class, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 10/31] sdhci: add a Designware/Samsung host controller, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 11/31] hw/arm/exynos4210: use the "samsung, exynos4210-dw-mshc" device, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 12/31] sdhci: add the generic Arasan SDHCI 4.9a PHY controller,
Philippe Mathieu-Daudé <=
- [Qemu-arm] [PATCH v5 13/31] hw/arm/xilinx_zynq: use the "arasan, sdhci-4.9a" device, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 14/31] sdhci: add qtest to check the SD Spec version, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 15/31] sdhci: check Spec v2 capabilities qtest, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 16/31] sdhci: add v3 capabilities, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 17/31] sdhci: rename the hostctl1 register, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 18/31] sdhci: add the Broadcom BCM2835 SDHCI controller, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 19/31] hw/arm/bcm2835_peripherals: use the "brcm, bcm2835-sdhci" device, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 20/31] sdhci: add the Freescale controller for i.MX, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 21/31] hw/arm/fsl-imx6: use the "fsl, imx6q-usdhc" controller, Philippe Mathieu-Daudé, 2018/01/08