qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Frédéric Basse" <contact@fredericb.info>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Evgeny Voevodin" <e.voevodin@samsung.com>,
	"Bartlomiej Zolnierkiewicz" <b.zolnierkie@samsung.com>,
	"Igor Mitsyanko" <i.mitsyanko@gmail.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Krzysztof Kozlowski" <krzk@kernel.org>,
	"Jean-Christophe Dubois" <jcd@tribudubois.net>,
	qemu-arm@nongnu.org, "Dmitry Solodkiy" <d.solodkiy@samsung.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Maksim Kozlov" <m.kozlov@samsung.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Guenter Roeck" <linux@roeck-us.net>
Subject: [PATCH 3/5] hw/sd/sdhci: Add dummy Samsung SDHCI controller
Date: Sat,  5 Oct 2019 17:47:46 +0200	[thread overview]
Message-ID: <20191005154748.21718-4-f4bug@amsat.org> (raw)
In-Reply-To: <20191005154748.21718-1-f4bug@amsat.org>

The Linux kernel access few S3C-specific registers [1] to set some
clock. We don't care about this part for device emulation [2]. Add
a dummy device to properly ignore these accesses, so we can focus
on the important registers missing.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/mmc/host/sdhci-s3c-regs.h?h=cc014f3
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/mmc/host/sdhci-s3c.c?h=v5.3#n263

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Eventually we should add the ADMA changes Igor sent in this patch:
https://patchwork.ozlabs.org/patch/181854/
They might solve the boot timing issues when using SD cards.
---
 hw/sd/sdhci.c         | 65 +++++++++++++++++++++++++++++++++++++++++++
 include/hw/sd/sdhci.h |  2 ++
 2 files changed, 67 insertions(+)

diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index 82ec5c1b4a..88404d0e9d 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1761,11 +1761,76 @@ static const TypeInfo imx_usdhc_info = {
     .instance_init = imx_usdhc_init,
 };
 
+/* --- qdev Samsung s3c --- */
+
+#define S3C_SDHCI_CONTROL2      0x80
+#define S3C_SDHCI_CONTROL3      0x84
+#define S3C_SDHCI_CONTROL4      0x8c
+
+static uint64_t sdhci_s3c_read(void *opaque, hwaddr offset, unsigned size)
+{
+    uint64_t ret;
+
+    switch (offset) {
+    case S3C_SDHCI_CONTROL2:
+    case S3C_SDHCI_CONTROL3:
+    case S3C_SDHCI_CONTROL4:
+        /* ignore */
+        ret = 0;
+        break;
+    default:
+        ret = sdhci_read(opaque, offset, size);
+        break;
+    }
+
+    return ret;
+}
+
+static void sdhci_s3c_write(void *opaque, hwaddr offset, uint64_t val,
+                            unsigned size)
+{
+    switch (offset) {
+    case S3C_SDHCI_CONTROL2:
+    case S3C_SDHCI_CONTROL3:
+    case S3C_SDHCI_CONTROL4:
+        /* ignore */
+        break;
+    default:
+        sdhci_write(opaque, offset, val, size);
+        break;
+    }
+}
+
+static const MemoryRegionOps sdhci_s3c_mmio_ops = {
+    .read = sdhci_s3c_read,
+    .write = sdhci_s3c_write,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 4,
+        .unaligned = false
+    },
+    .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
+static void sdhci_s3c_init(Object *obj)
+{
+    SDHCIState *s = SYSBUS_SDHCI(obj);
+
+    s->io_ops = &sdhci_s3c_mmio_ops;
+}
+
+static const TypeInfo sdhci_s3c_info = {
+    .name = TYPE_S3C_SDHCI  ,
+    .parent = TYPE_SYSBUS_SDHCI,
+    .instance_init = sdhci_s3c_init,
+};
+
 static void sdhci_register_types(void)
 {
     type_register_static(&sdhci_sysbus_info);
     type_register_static(&sdhci_bus_info);
     type_register_static(&imx_usdhc_info);
+    type_register_static(&sdhci_s3c_info);
 }
 
 type_init(sdhci_register_types)
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
index cbf415e43a..c6868c9699 100644
--- a/include/hw/sd/sdhci.h
+++ b/include/hw/sd/sdhci.h
@@ -116,4 +116,6 @@ typedef struct SDHCIState {
 
 #define TYPE_IMX_USDHC "imx-usdhc"
 
+#define TYPE_S3C_SDHCI "s3c-sdhci"
+
 #endif /* SDHCI_H */
-- 
2.20.1



  parent reply	other threads:[~2019-10-05 15:50 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-05 15:47 [PATCH 0/5] hw/arm/exynos4210: Add acceptance tests to the SMDKC210 board Philippe Mathieu-Daudé
2019-10-05 15:47 ` [PATCH 1/5] tests/boot_linux_console: Add initrd test for the Exynos4210 Philippe Mathieu-Daudé
2019-10-07 16:28   ` Peter Maydell
2019-10-08 21:49     ` Cleber Rosa
2019-10-08 23:01       ` Guenter Roeck
2019-10-09 13:38       ` Peter Maydell
2019-10-09 19:07         ` Cleber Rosa
2019-10-10 13:43           ` Philippe Mathieu-Daudé
2019-10-21 12:11             ` Philippe Mathieu-Daudé
2019-10-08 21:35   ` Cleber Rosa
2019-10-05 15:47 ` [PATCH 2/5] hw/sd/sdhci: Add a comment to distinct the i.MX eSDHC functions Philippe Mathieu-Daudé
2019-10-08 21:58   ` Cleber Rosa
2019-10-05 15:47 ` Philippe Mathieu-Daudé [this message]
2019-10-07  8:59   ` [PATCH 3/5] hw/sd/sdhci: Add dummy Samsung SDHCI controller Krzysztof Kozlowski
2019-10-05 15:47 ` [PATCH 4/5] hw/arm/exynos4210: Use the Samsung s3c " Philippe Mathieu-Daudé
2019-10-07  9:00   ` Krzysztof Kozlowski
2019-10-05 15:47 ` [PATCH 5/5] tests/boot_linux_console: Add sdcard test for the Exynos4210 Philippe Mathieu-Daudé
2019-10-08 23:12   ` Cleber Rosa
2019-10-07  9:10 ` [PATCH 0/5] hw/arm/exynos4210: Add acceptance tests to the SMDKC210 board Krzysztof Kozlowski
2019-10-07 17:42   ` Krzysztof Kozlowski
2019-10-18 14:48 ` Philippe Mathieu-Daudé
2019-10-22 12:54   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191005154748.21718-4-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=contact@fredericb.info \
    --cc=crosa@redhat.com \
    --cc=d.solodkiy@samsung.com \
    --cc=e.voevodin@samsung.com \
    --cc=ehabkost@redhat.com \
    --cc=i.mitsyanko@gmail.com \
    --cc=jcd@tribudubois.net \
    --cc=krzk@kernel.org \
    --cc=linux@roeck-us.net \
    --cc=m.kozlov@samsung.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).