public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu@linaro.org>
To: u-boot@lists.denx.de
Subject: [PATCH v2 07/13] mmc: synquacer: Add SynQuacer F_SDH30 SDHCI driver
Date: Sat, 17 Apr 2021 08:38:26 +0900	[thread overview]
Message-ID: <161861630583.298230.7570622190142671460.stgit@localhost> (raw)
In-Reply-To: <161861622792.298230.15803163505976731363.stgit@localhost>

From: Jassi Brar <jaswinder.singh@linaro.org>

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
---
 drivers/mmc/Kconfig   |   10 ++++++
 drivers/mmc/Makefile  |    1 +
 drivers/mmc/f_sdh30.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mmc/sdhci.c   |    9 +++++
 4 files changed, 101 insertions(+)
 create mode 100644 drivers/mmc/f_sdh30.c

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index f8ca52efb6..a9ae419e41 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -549,6 +549,16 @@ config MMC_SDHCI_IPROC
 
 	  If unsure, say N.
 
+config F_SDH30_SDHCI
+	bool "SDHCI support for Fujitsu Semiconductor F_SDH30"
+	depends on BLK && DM_MMC
+	depends on MMC_SDHCI
+	help
+	  This selects the Secure Digital Host Controller Interface (SDHCI)
+	  Needed by some Fujitsu SoC for MMC / SD / SDIO support.
+	  If you have a controller with this interface, say Y or M here.
+	  If unsure, say N.
+
 config MMC_SDHCI_KONA
 	bool "SDHCI support on Broadcom KONA platform"
 	depends on MMC_SDHCI
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 89d6af3db3..b48a76ba94 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -76,3 +76,4 @@ obj-$(CONFIG_MMC_UNIPHIER)		+= tmio-common.o uniphier-sd.o
 obj-$(CONFIG_RENESAS_SDHI)		+= tmio-common.o renesas-sdhi.o
 obj-$(CONFIG_MMC_BCM2835)		+= bcm2835_sdhost.o
 obj-$(CONFIG_MMC_MTK)			+= mtk-sd.o
+obj-$(CONFIG_F_SDH30_SDHCI)		+= f_sdh30.o
diff --git a/drivers/mmc/f_sdh30.c b/drivers/mmc/f_sdh30.c
new file mode 100644
index 0000000000..44c6521bfe
--- /dev/null
+++ b/drivers/mmc/f_sdh30.c
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Socionext F_SDH30 eMMC driver
+ * Copyright 2021 Linaro Ltd.
+ * Copyright 2021 Socionext, Inc.
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <malloc.h>
+#include <sdhci.h>
+
+struct f_sdh30_plat {
+	struct mmc_config cfg;
+	struct mmc mmc;
+};
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int f_sdh30_probe(struct udevice *dev)
+{
+	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+	struct f_sdh30_plat *plat = dev_get_plat(dev);
+	struct sdhci_host *host = dev_get_priv(dev);
+	int ret;
+
+	ret = mmc_of_parse(dev, &plat->cfg);
+	if (ret)
+		return ret;
+
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
+	host->mmc->priv = host;
+
+	ret = sdhci_setup_cfg(&plat->cfg, host, 200000000, 400000);
+	if (ret)
+		return ret;
+
+	upriv->mmc = host->mmc;
+
+	mmc_set_clock(host->mmc, host->mmc->cfg->f_min, MMC_CLK_ENABLE);
+
+	return sdhci_probe(dev);
+}
+
+static int f_sdh30_of_to_plat(struct udevice *dev)
+{
+	struct sdhci_host *host = dev_get_priv(dev);
+
+	host->name = strdup(dev->name);
+	host->ioaddr = dev_read_addr_ptr(dev);
+	host->bus_width = dev_read_u32_default(dev, "bus-width", 4);
+	host->index = dev_read_u32_default(dev, "index", 0);
+
+	return 0;
+}
+
+static int f_sdh30_bind(struct udevice *dev)
+{
+	struct f_sdh30_plat *plat = dev_get_plat(dev);
+
+	return sdhci_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+static const struct udevice_id f_sdh30_mmc_ids[] = {
+	{ .compatible = "fujitsu,mb86s70-sdhci-3.0" },
+	{ }
+};
+
+U_BOOT_DRIVER(f_sdh30_drv) = {
+	.name		= "f_sdh30_sdhci",
+	.id		= UCLASS_MMC,
+	.of_match	= f_sdh30_mmc_ids,
+	.of_to_plat	= f_sdh30_of_to_plat,
+	.ops		= &sdhci_ops,
+	.bind		= f_sdh30_bind,
+	.probe		= f_sdh30_probe,
+	.priv_auto	= sizeof(struct sdhci_host),
+	.plat_auto	= sizeof(struct f_sdh30_plat),
+};
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index d9ab6a0a83..f038debc6c 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -708,6 +708,15 @@ static int sdhci_init(struct mmc *mmc)
 
 	sdhci_set_power(host, fls(mmc->cfg->voltages) - 1);
 
+	if (IS_ENABLED(CONFIG_F_SDH30_SDHCI)) {
+		/*
+		 * Reference to Part1 Physical Layer Simplified Specification
+		 * Ver 3.01, 6.4.1 Power Up
+		 * This delay must be at least 74 clock sizes, or 1 ms.
+		 */
+		udelay(1000);
+	}
+
 	if (host->ops && host->ops->get_cd)
 		host->ops->get_cd(host);
 

  parent reply	other threads:[~2021-04-16 23:38 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 23:37 [PATCH v2 00/13] arm64: synquacer: Add SynQuacer/DeveloperBox support Masami Hiramatsu
2021-04-16 23:37 ` [PATCH v2 01/13] ata: ahci-pci: Use scsi_ops to initialize ops Masami Hiramatsu
2021-04-16 23:37 ` [PATCH v2 02/13] dm: pci: Skip setting VGA bridge bits if parent device is the host bus Masami Hiramatsu
2021-04-16 23:37 ` [PATCH v2 03/13] efi: Fix to use null handle to create new handle for efi_fmp_raw Masami Hiramatsu
2021-04-16 23:37 ` [PATCH v2 04/13] gpio: Introduce CONFIG_ONLY_GENERIC_GPIO to cleanup #ifdefs Masami Hiramatsu
2021-04-29 16:09   ` Simon Glass
2021-04-30  2:03     ` Masami Hiramatsu
2021-04-30 18:13       ` Simon Glass
2021-05-03 11:51         ` Tom Rini
2021-05-06  2:28           ` Masami Hiramatsu
2021-04-16 23:38 ` [PATCH v2 05/13] mtd: spi-nor-ids: add support for Macronix mx25u51245g and mx66u1g45g flash Masami Hiramatsu
2021-04-19  8:41   ` Pratyush Yadav
2021-04-21  2:39     ` Masami Hiramatsu
2021-04-21 11:15       ` Pratyush Yadav
2021-04-16 23:38 ` [PATCH v2 06/13] pci: synquacer: Add SynQuacer ECAM based PCIe driver Masami Hiramatsu
2021-04-16 23:38 ` Masami Hiramatsu [this message]
2021-04-19 22:05   ` [PATCH v2 07/13] mmc: synquacer: Add SynQuacer F_SDH30 SDHCI driver Jaehoon Chung
2021-04-20  0:59     ` Masami Hiramatsu
2021-04-20  5:35       ` Jaehoon Chung
2021-04-25 22:05     ` Jassi Brar
2021-04-25 23:06       ` Jaehoon Chung
2021-04-16 23:38 ` [PATCH v2 08/13] spi: synquacer: Add HSSPI SPI controller driver for SynQuacer Masami Hiramatsu
2021-04-16 23:38 ` [PATCH v2 09/13] net: synquacer: Add netsec driver Masami Hiramatsu
2021-04-23  0:16   ` Ramon Fried
2021-04-16 23:38 ` [PATCH v2 10/13] ARM: dts: synquacer: Add device trees for DeveloperBox Masami Hiramatsu
2021-04-16 23:39 ` [PATCH v2 11/13] board: synquacer: Add DeveloperBox 96boards EE support Masami Hiramatsu
2021-04-21  2:40   ` Masami Hiramatsu
2021-04-16 23:39 ` [PATCH v2 12/13] doc: qemu: arm64: Fix the documentation of capsule update Masami Hiramatsu
2021-04-17 18:21   ` Heinrich Schuchardt
2021-04-18  8:07     ` Sughosh Ganu
2021-04-19  0:37       ` Takahiro Akashi
2021-04-19  2:24         ` Masami Hiramatsu
2021-04-19  2:35           ` Heinrich Schuchardt
2021-04-20  6:16             ` Takahiro Akashi
2021-04-16 23:39 ` [PATCH v2 13/13] configs: synquacer: Enable EFI capsule update support Masami Hiramatsu

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=161861630583.298230.7570622190142671460.stgit@localhost \
    --to=masami.hiramatsu@linaro.org \
    --cc=u-boot@lists.denx.de \
    /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